GDB Administrator [Tue, 4 Jun 2019 00:00:13 +0000 (00:00 +0000)]
Automatic date update in version.in
Philippe Waroquiers [Mon, 3 Jun 2019 19:51:56 +0000 (21:51 +0200)]
Document in NEWS and gdb.texinfo the "help", "apropos" and "show style" changes.
Philippe Waroquiers [Mon, 3 Jun 2019 19:50:22 +0000 (21:50 +0200)]
Update tests following changes to "help" and "apropos"
Factorizes the testing of the help output, by having a single place
that defines the common help trailer and/or prefix messages.
Philippe Waroquiers [Fri, 31 May 2019 12:00:47 +0000 (14:00 +0200)]
Improve usability and/or readibility of help and apropos output.
The "help" command can output long list of command names or classes.
Use the title style to style the command names or classes to make
the output more readable.
Similarly, change "apropos" command to also style the command names.
It is sometimes unclear why "apropos REGEXP" lists some commands,
and then the user has to manually do 'help command' for all commands
listed by "apropos" to see more details about the matching commands.
=> Add an optional flag -v so that "apropos -v REGEXP":
* outputs the full documentation of matching commands.
* highlights the documentation parts matching REGEXP.
Philippe Waroquiers [Fri, 31 May 2019 11:47:37 +0000 (13:47 +0200)]
Add highlight style, title style, fputs_highlighted. Improve 'show style'
Have 'show style' and its subcommands using a style to style its output.
This allows the GDB user or developer to use 'show style' to visually see
with one command how all the current styles look like.
Add 2 new styles highlight style, title style and fputs_highlighted function.
Highlight style is used by fputs_highlighted to highlight the parts of
its char *STR argument that match a HIGHLIGHT regexp.
This (and the title style) will be used in a following patch.
Nick Clifton [Mon, 3 Jun 2019 15:28:15 +0000 (16:28 +0100)]
Revert patch that disables building libctf for non-ELF based targets.
Revert:
binutls 2019-05-29 Nick Clifton <nickc@redhat.com>
* configure.ac (LIBCTF): Export. Set to empty for non-ELF based
targets.
(HAVE_LIBCTF): Define if libctf support is available.
* Makefile.am (LIBCTF): Set value to @LIBCTF@.
* objdump.c: Make CTF code conditional upon HAVE_LIBCTF being
defined.
* readelf.c: Likewise.
* configure: Regenerate.
* Makefile.in: Regenerate.
* config.in: Regenerate.
top 2019-05-29 Nick Clifton <nickc@redhat.com>
* configure.ac (noconfigdirs): Add libctf if the target does not use
the ELF file format.
* configure: Regenerate.
Alan Modra [Mon, 3 Jun 2019 02:16:04 +0000 (11:46 +0930)]
Don't waste space in prefix_opcd_indices
* ppc-dis.c (prefix_opcd_indices): Correct size.
GDB Administrator [Mon, 3 Jun 2019 00:00:54 +0000 (00:00 +0000)]
Automatic date update in version.in
Tom Tromey [Sat, 1 Jun 2019 15:16:04 +0000 (09:16 -0600)]
Remove fromhex implementation from gdbreplay
gdbreplay had its own implementation of fromhex. This patch changes
it to use the one in common/.
gdb/gdbserver/ChangeLog
2019-06-02 Tom Tromey <tom@tromey.com>
* gdbreplay.c (fromhex): Remove.
* Makefile.in (GDBREPLAY_OBS): Add rsp-low.o.
GDB Administrator [Sun, 2 Jun 2019 00:01:00 +0000 (00:01 +0000)]
Automatic date update in version.in
GDB Administrator [Sat, 1 Jun 2019 00:00:23 +0000 (00:00 +0000)]
Automatic date update in version.in
Philippe Waroquiers [Sat, 4 May 2019 13:39:27 +0000 (15:39 +0200)]
NEWS and documentation for | (pipe) command.
gdb/ChangeLog
* NEWS: Mention new pipe command and new convenience variables.
gdb/doc/ChangeLog
* gdb.texinfo (Shell Commands): Document pipe command.
(Logging Output): Add a reference to pipe command.
(Convenience Variables): Document $_shell_exitcode and
$_shell_exitstatus.
Philippe Waroquiers [Sat, 20 Apr 2019 20:17:17 +0000 (22:17 +0200)]
Test the | (pipe) command.
gdb/testsuite/ChangeLog
2019-05-31 Philippe Waroquiers <philippe.waroquiers@skynet.be>
* gdb.base/shell.exp: Test pipe command, $_shell_exitcode,
$_shell_exitsignal.
* gdb.base/default.exp: Update for new convenience variables.
Philippe Waroquiers [Sat, 20 Apr 2019 12:14:23 +0000 (14:14 +0200)]
Implement | (pipe) command.
The pipe command allows to run a GDB command, and pipe its output
to a shell command:
(gdb) help pipe
Send the output of a gdb command to a shell command.
Usage: | [COMMAND] | SHELL_COMMAND
Usage: | -d DELIM COMMAND DELIM SHELL_COMMAND
Usage: pipe [COMMAND] | SHELL_COMMAND
Usage: pipe -d DELIM COMMAND DELIM SHELL_COMMAND
Executes COMMAND and sends its output to SHELL_COMMAND.
The -d option indicates to use the string DELIM to separate COMMAND
from SHELL_COMMAND, in alternative to |. This is useful in
case COMMAND contains a | character.
With no COMMAND, repeat the last executed command
and send its output to SHELL_COMMAND.
(gdb)
For example:
(gdb) pipe print some_data_structure | grep -B3 -A3 something
The pipe character is defined as an alias for pipe command, so that
the above can be typed as:
(gdb) | print some_data_structure | grep -B3 -A3 something
If no GDB COMMAND is given, then the previous command is relaunched,
and its output is sent to the given SHELL_COMMAND.
This also defines convenience vars $_shell_exitcode and $_shell_exitsignal
to record the exit code and exit signal of the last shell command
launched by GDB e.g. by "shell", "pipe", ...
gdb/ChangeLog
2019-05-31 Philippe Waroquiers <philippe.waroquiers@skynet.be>
* cli/cli-cmds.c (pipe_command): New function.
(_initialize_cli_cmds): Call add_com for pipe_command.
Define | as an alias for pipe.
(exit_status_set_internal_vars): New function.
(shell_escape): Call exit_status_set_internal_vars.
cli/cli-decode.c (find_command_name_length): Recognize | as
a single character command.
Philippe Waroquiers [Fri, 26 Apr 2019 18:52:16 +0000 (20:52 +0200)]
Add function execute_command_to_ui_file
2019-05-31 Philippe Waroquiers <philippe.waroquiers@skynet.be>
* gdbcmd.h (execute_command_to_ui_file): New declaration.
top.c (execute_command_to_ui_file): New function, mostly a copy
of execute_command_to_string.
(execute_command_to_string): Implement by calling
execute_command_to_ui_file.
Philippe Waroquiers [Sat, 20 Apr 2019 12:02:29 +0000 (14:02 +0200)]
Add previous_saved_command_line to allow a command to repeat a previous command.
Currently, a previous command can be repeated when the user types an
empty line. This is implemented in handle_line_of_input by
returning saved_command_line in case an empty line has been input.
If we want a command to repeat the previous command, we need to save
the previous saved_command_line, as when a command runs, the saved_command_line
already contains the current command line of the command being executed.
As suggested by Tom, the previous_saved_command_line is made static.
At the same time, saved_command_line is also made static.
The support functions/variables for the repeat command logic are now all
located inside top.c.
gdb/ChangeLog
2019-05-31 Philippe Waroquiers <philippe.waroquiers@skynet.be>
* top.h (saved_command_line): Remove declaration.
* top.c (previous_saved_command_line, previous_repeat_arguments):
New variables.
(saved_command_line): Make static, define together with other
'repeat variables'.
(dont_repeat): Clear repeat_arguments.
(repeat_previous, get_saved_command_line, save_command_line):
New functions.
(gdb_init): Initialize saved_command_line
and previous_saved_command_line.
* main.c (captured_main_1): Remove saved_command_line initialization.
* event-top.c (handle_line_of_input): Update to use
the new 'repeat' related functions instead of direct access to
saved_command_line.
* command.h (repeat_previous, get_saved_command_line,
save_command_line): New declarations.
(dont_repeat): Add comment.
Jose E. Marchesi [Fri, 31 May 2019 09:10:51 +0000 (11:10 +0200)]
libctf: fix a number of build problems found on Solaris and NetBSD
- Use of nonportable <endian.h>
- Use of qsort_r
- Use of zlib without appropriate magic to pull in the binutils zlib
- Use of off64_t without checking (fixed by dropping the unused fields
that need off64_t entirely)
- signedness problems due to long being too short a type on 32-bit
platforms: ctf_id_t is now 'unsigned long', and CTF_ERR must be
used only for functions that return ctf_id_t
- One lingering use of bzero() and of <sys/errno.h>
All fixed, using code from gnulib where possible.
Relatedly, set cts_size in a couple of places it was missed
(string table and symbol table loading upon ctf_bfdopen()).
binutils/
* objdump.c (make_ctfsect): Drop cts_type, cts_flags, and
cts_offset.
* readelf.c (shdr_to_ctf_sect): Likewise.
include/
* ctf-api.h (ctf_sect_t): Drop cts_type, cts_flags, and cts_offset.
(ctf_id_t): This is now an unsigned type.
(CTF_ERR): Cast it to ctf_id_t. Note that it should only be used
for ctf_id_t-returning functions.
libctf/
* Makefile.am (ZLIB): New.
(ZLIBINC): Likewise.
(AM_CFLAGS): Use them.
(libctf_a_LIBADD): New, for LIBOBJS.
* configure.ac: Check for zlib, endian.h, and qsort_r.
* ctf-endian.h: New, providing htole64 and le64toh.
* swap.h: Code style fixes.
(bswap_identity_64): New.
* qsort_r.c: New, from gnulib (with one added #include).
* ctf-decls.h: New, providing a conditional qsort_r declaration,
and unconditional definitions of MIN and MAX.
* ctf-impl.h: Use it. Do not use <sys/errno.h>.
(ctf_set_errno): Now returns unsigned long.
* ctf-util.c (ctf_set_errno): Adjust here too.
* ctf-archive.c: Use ctf-endian.h.
(ctf_arc_open_by_offset): Use memset, not bzero. Drop cts_type,
cts_flags and cts_offset.
(ctf_arc_write): Drop debugging dependent on the size of off_t.
* ctf-create.c: Provide a definition of roundup if not defined.
(ctf_create): Drop cts_type, cts_flags and cts_offset.
(ctf_add_reftype): Do not check if type IDs are below zero.
(ctf_add_slice): Likewise.
(ctf_add_typedef): Likewise.
(ctf_add_member_offset): Cast error-returning ssize_t's to size_t
when known error-free. Drop CTF_ERR usage for functions returning
int.
(ctf_add_member_encoded): Drop CTF_ERR usage for functions returning
int.
(ctf_add_variable): Likewise.
(enumcmp): Likewise.
(enumadd): Likewise.
(membcmp): Likewise.
(ctf_add_type): Likewise. Cast error-returning ssize_t's to size_t
when known error-free.
* ctf-dump.c (ctf_is_slice): Drop CTF_ERR usage for functions
returning int: use CTF_ERR for functions returning ctf_type_id.
(ctf_dump_label): Likewise.
(ctf_dump_objts): Likewise.
* ctf-labels.c (ctf_label_topmost): Likewise.
(ctf_label_iter): Likewise.
(ctf_label_info): Likewise.
* ctf-lookup.c (ctf_func_args): Likewise.
* ctf-open.c (upgrade_types): Cast to size_t where appropriate.
(ctf_bufopen): Likewise. Use zlib types as needed.
* ctf-types.c (ctf_member_iter): Drop CTF_ERR usage for functions
returning int.
(ctf_enum_iter): Likewise.
(ctf_type_size): Likewise.
(ctf_type_align): Likewise. Cast to size_t where appropriate.
(ctf_type_kind_unsliced): Likewise.
(ctf_type_kind): Likewise.
(ctf_type_encoding): Likewise.
(ctf_member_info): Likewise.
(ctf_array_info): Likewise.
(ctf_enum_value): Likewise.
(ctf_type_rvisit): Likewise.
* ctf-open-bfd.c (ctf_bfdopen): Drop cts_type, cts_flags and
cts_offset.
(ctf_simple_open): Likewise.
(ctf_bfdopen_ctfsect): Likewise. Set cts_size properly.
* Makefile.in: Regenerate.
* aclocal.m4: Likewise.
* config.h: Likewise.
* configure: Likewise.
GDB Administrator [Fri, 31 May 2019 00:00:14 +0000 (00:00 +0000)]
Automatic date update in version.in
Jim Wilson [Thu, 30 May 2019 22:23:10 +0000 (15:23 -0700)]
RISC-V: Fix lui argument parsing.
This fixes a bug reported on the riscv.org sw-dev mailing list. This
rejects "lui x1,symbol", as a symbol should only be accepted here when
used inside %hi(). Without the fix, this gets assembled as "lui x1,0"
with no relocation which is clearly wrong.
gas/
* config/tc-riscv.c (riscv_ip) <'u'>: Move O_constant check inside if
statement. Delete O_symbol and O_constant check after if statement.
* testsuite/gas/riscv/auipc-parsing.s: Test lui with missing %hi.
* testsuite/gas/riscv/auipc-parsing.l: Update.
Tom Tromey [Thu, 30 May 2019 14:50:22 +0000 (08:50 -0600)]
Two comment fixes in gdbtypes.h
This fixes a couple of comments in gdbtypes.h. One comment had a
typo; and another comment referred to "Moto", which is presumably some
long-gone Motorola-related project.
Tested by rebuilding.
gdb/ChangeLog
2019-05-30 Tom Tromey <tromey@adacore.com>
* gdbtypes.h (struct range_bounds) <flag_upper_bound_is_count>:
Fix comment.
(TYPE_ARRAY_UPPER_BOUND_IS_UNDEFINED): Rewrite comment.
Jan Vrany [Thu, 30 May 2019 12:04:26 +0000 (13:04 +0100)]
Initialize variable word in complete
The complete function should set parameter word to the end of the
word to complete. However, completion_find_completion_word may fail,
leaving word uninitialized.
To make sure word is always set, initialize it to the completion point
which is the end of the line parameter.
gdb/Changelog
PR cli/24587
* completer.c (complete): Initialize variable word.
Nick Clifton [Thu, 30 May 2019 10:17:19 +0000 (11:17 +0100)]
Revert "Sync top level files with versions from gcc."
This reverts commit
f948b2de97884bfb4e5fc11d40a6bea9e0b096ae.
Nick Clifton [Thu, 30 May 2019 09:17:29 +0000 (10:17 +0100)]
Harmonize readelf's output for version sections.
PR 24627
binutils * readelf.c (process_version_sections): Add 0x prefix to address
display. Correct indentation.
ld * testsuite/ld-elf/ver_def.vd: Update expected output.
GDB Administrator [Thu, 30 May 2019 00:00:14 +0000 (00:00 +0000)]
Automatic date update in version.in
Sergio Durigan Junior [Wed, 29 May 2019 14:36:57 +0000 (10:36 -0400)]
Don't crash is dwarf_decode_macro_bytes's 'body' is NULL, even when '!is_define'
Ref.: https://bugzilla.redhat.com/show_bug.cgi?id=1715008
On commit
7bede82892a06e6c26989803e70f53697392dcf9 ("Don't crash if
dwarf_decode_macro_bytes's 'body' is NULL"), I was too strict when
checking if 'body' is NULL: the check only comprised the case when
'is_define' is true. However, the corruption of .debug_macro by
rpmbuild's "debugedit" also affects the case when 'is_define' is
false, i.e., when the macro is being undefined.
This commit improves the check and covers both cases now. This has
been tested on Fedora 30 with a problematic debuginfo, and I don't see
a segfault anymore.
OK to push?
gdb/ChangeLog:
2019-05-29 Sergio Durigan Junior <sergiodj@redhat.com>
Ref.: https://bugzilla.redhat.com/show_bug.cgi?id=1708192
Ref.: https://bugzilla.redhat.com/show_bug.cgi?id=1715008
* dwarf2read.c (dwarf_decode_macro_bytes): Move check to see if
'body' is NULL to the outter 'if', protecting the '!is_define'
situation as well.
Tom Tromey [Tue, 28 May 2019 16:55:59 +0000 (10:55 -0600)]
Fix failure in gdb.ada/complete.exp
I noticed a failure in gdb.ada/complete.exp when testing locally:
FAIL: gdb.ada/complete.exp: complete break ada
This failed due to this output:
[...]
break ada/generated/gnatvsn.ads
break ada/libgnat/s-excmac.ads
break ada/sdefault.adb
break ada/snames.adb
break ada/snames.ads
This patch updates the regexp to allow "/" and "-" to appear.
gdb/testsuite/ChangeLog
2019-05-29 Tom Tromey <tromey@adacore.com>
* gdb.ada/complete.exp (test_gdb_no_completion): Add "/" and "-"
to "break complete ada" test case's regexp.
Tom Tromey [Wed, 22 May 2019 13:08:49 +0000 (09:08 -0400)]
Make some DWARF complaints clearer
I noticed that the complaint in partial_die_parent_scope was not using
dwarf_tag_name, so I changed that. Then I noticed that dwarf_tag_name
does not show the numeric value for an unrecognized tag, so I changed
that function and all the related functions to do so.
gdb/ChangeLog
2019-05-29 Tom Tromey <tromey@adacore.com>
* dwarf2read.c (partial_die_parent_scope): Call dwarf_tag_name.
(dwarf_unknown): New function.
(dwarf_tag_name, dwarf_attr_name, dwarf_form_name)
(dwarf_type_encoding_name): Use dwarf_unknown.
Tom Tromey [Wed, 29 May 2019 15:34:50 +0000 (09:34 -0600)]
Fix crash in cp_print_value_fields
PR c++/20020 concerns a crash in cp_print_value_fields. The immediate
cause is that cp_print_value_fields does not handle the case where
value_static_field fails. This is fixed in this patch by calling
cp_print_static_field from the "try" block.
Digging a bit deeper, the error occurs because GCC does not emit a
DW_AT_const_value for a static constexpr member appearing in a
template class. I've filed a GCC bug for this.
Tested on x86-64 Fedora 29.
gdb/ChangeLog
2019-05-29 Tom Tromey <tromey@adacore.com>
PR c++/20020:
* cp-valprint.c (cp_print_value_fields): Call
cp_print_static_field inside "try".
gdb/testsuite/ChangeLog
2019-05-29 Tom Tromey <tromey@adacore.com>
PR c++/20020:
* gdb.cp/constexpr-field.exp: New file.
* gdb.cp/constexpr-field.cc: New file.
Alan Modra [Wed, 29 May 2019 13:26:30 +0000 (22:56 +0930)]
s12z genelf.em
This changes s12z to use generic.em and genelf.em, which is more
suited to targets that use the generic linker hash table. A tweak or
two to some testsuite predicates then gives a clean testsuite result
on the target.
PR 24596
binutils/
* testsuite/lib/binutils-common.exp (supports_gnu_unique): Add
s12z to targets not supporting this feature.
ld/
* emulparams/m9s12zelf.sh (TEMPLATE_NAME): Set to generic.
(EXTRA_EM_FILE): Define to genelf.
* testsuite/lib/ld-lib.exp (uses_genelf): Add s12z.
Alan Modra [Wed, 29 May 2019 13:24:37 +0000 (22:54 +0930)]
Support tcl procedure calls in run_dump_test xfail
Also support tcl procedure calls in the run_ld_link_tests and
run_ld_link_exec_tests optional "xfail" args. Implements "is_generic"
and renames "is_generic_elf" to "uses_genelf", then uses these procs
in lots of ld tests.
moxie-elf -FAIL: ld-elf/orphan3
mt-elf -FAIL: ld-elf/merge
s12z-elf -FAIL: ld-discard/extern
s12z-elf -FAIL: ld-discard/start
s12z-elf -FAIL: ld-discard/static
s12z-elf -FAIL: PR ld/21703
s12z-elf -FAIL: PR ld/21703 -r
s12z-elf -FAIL: Symbol flags copy
s12z-elf -FAIL: ld-elf/group1
s12z-elf -FAIL: ld-elf/group3b
s12z-elf -FAIL: ld-elf/group8a
s12z-elf -FAIL: ld-elf/group8b
s12z-elf -FAIL: ld-elf/group9a
s12z-elf -FAIL: ld-elf/group9b
s12z-elf -FAIL: ld-elf/linkonce2
s12z-elf -FAIL: ld-elf/merge2
s12z-elf -FAIL: ld-elf/merge3
s12z-elf -FAIL: ld-elf/pr12851
s12z-elf -FAIL: ld-elf/pr17550c
s12z-elf -FAIL: ld-elf/pr17550d
s12z-elf -FAIL: ld-elf/pr22677
s12z-elf -FAIL: ld-elf/pr22836-1a
s12z-elf -FAIL: ld-elf/pr22836-1b
s12z-elf -FAIL: ld-elf/warn1
s12z-elf -FAIL: ld-elf/warn3
binutils/
* testsuite/lib/binutils-common.exp (run_dump_test): Support
tcl procedures for xfail args.
ld/
* testsuite/lib/ld-lib.exp (run_ld_link_tests): Support procedure
calls in optional "xfail" args.
(run_ld_link_exec_tests): Likewise.
(is_generic): New.
(uses_genelf): Rename from is_generic_elf. Delete bogus semicolons.
* testsuite/ld-scripts/align.exp: Rename is_generic_elf call.
* testsuite/ld-elf/elf.exp: Use is_generic and uses_genelf. Delete
xfail_implib var.
* testsuite/ld-elf/sec64k.exp: Use is_generic.
* testsuite/ld-elf/shared.exp: Likewise.
* testsuite/ld-discard/extern.d: Use is_generic in xfail.
* testsuite/ld-discard/start.d: Likewise.
* testsuite/ld-discard/static.d: Likewise.
* testsuite/ld-elf/attributes.d: Likewise.
* testsuite/ld-elf/group1.d: Likewise.
* testsuite/ld-elf/group3b.d: Likewise.
* testsuite/ld-elf/group8a.d: Likewise.
* testsuite/ld-elf/group8b.d: Likewise.
* testsuite/ld-elf/group9a.d: Likewise.
* testsuite/ld-elf/group9b.d: Likewise.
* testsuite/ld-elf/linkonce2.d: Likewise.
* testsuite/ld-elf/merge2.d: Likewise.
* testsuite/ld-elf/merge3.d: Likewise.
* testsuite/ld-elf/pr12851.d: Likewise.
* testsuite/ld-elf/pr12975.d: Likewise.
* testsuite/ld-elf/pr13177.d: Likewise.
* testsuite/ld-elf/pr13195.d: Likewise.
* testsuite/ld-elf/pr17550c.d: Likewise.
* testsuite/ld-elf/pr17550d.d: Likewise.
* testsuite/ld-elf/pr17615.d: Likewise.
* testsuite/ld-elf/pr21562a.d: Likewise.
* testsuite/ld-elf/pr21562b.d: Likewise.
* testsuite/ld-elf/pr21562c.d: Likewise.
* testsuite/ld-elf/pr21562d.d: Likewise.
* testsuite/ld-elf/pr21562i.d: Likewise.
* testsuite/ld-elf/pr21562j.d: Likewise.
* testsuite/ld-elf/pr21562k.d: Likewise.
* testsuite/ld-elf/pr21562l.d: Likewise.
* testsuite/ld-elf/pr21562m.d: Likewise.
* testsuite/ld-elf/pr21562n.d: Likewise.
* testsuite/ld-elf/pr22677.d: Likewise.
* testsuite/ld-elf/pr22836-1a.d: Likewise.
* testsuite/ld-elf/pr22836-1b.d: Likewise.
* testsuite/ld-elf/warn3.d: Likewise.
* testsuite/ld-elf/warn1.d: Likewise and xfail sparc solaris
targets rather than notarget.
* testsuite/ld-elf/compressed1d.d: Use uses_genelf in xfail.
* testsuite/ld-elf/orphan-10.d: Likewise.
* testsuite/ld-elf/orphan-9.d: Likewise.
* testsuite/ld-elf/orphan-region.d: Likewise.
* testsuite/ld-elf/orphan.d: Likewise.
* testsuite/ld-elf/orphan3.d: Likewise.
* testsuite/ld-elf/pr20528a.d: Likewise.
* testsuite/ld-elf/pr20528b.d: Likewise.
* testsuite/ld-elf/pr23658-1a.d: Likewise.
* testsuite/ld-elf/pr23658-1b.d: Likewise.
* testsuite/ld-elf/pr349.d: Likewise.
* testsuite/ld-elf/warn2.d: Likewise and xfail sparc solaris
targets rather than notarget.
* testsuite/ld-elf/merge.d: Correct ms1-*-* to mt-*-*.
Tom Tromey [Fri, 10 May 2019 15:25:19 +0000 (09:25 -0600)]
Add new GCC 9 warnings to warnings.m4
GCC 9 has a few new warnings that aren't enabled in the gdb build by
default: -Wdeprecated-copy, -Wdeprecated-copy-dtor, and
-Wredundant-move. This patch enables them all.
Tested by rebuilding with a new GCC (git master) on x86-64 Fedora 29.
gdb/ChangeLog
2019-05-29 Tom Tromey <tromey@adacore.com>
* inflow.c (struct terminal_info): Add default operator=.
* configure: Rebuild.
* warning.m4 (AM_GDB_WARNINGS): Add -Wdeprecated-copy,
-Wdeprecated-copy-dtor, -Wredundant-move.
gdb/gdbserver/ChangeLog
2019-05-29 Tom Tromey <tromey@adacore.com>
* configure: Rebuild.
Tom Tromey [Wed, 15 May 2019 19:06:59 +0000 (13:06 -0600)]
Add "set print finish"
A user wanted to be able to disable the display of the value when
using "finish" -- but still have the value entered into the value
history in case it was useful later on. Part of the rationale here is
that sometimes the value might be quite large, or expensive to display
(in their case this was compounded by a rogue pretty-printer).
This patch implements this idea.
gdb/ChangeLog
2019-05-29 Tom Tromey <tromey@adacore.com>
* NEWS: Add entry.
* infcmd.c (print_return_value_1): Handle finish_print
option.
(show_print_finish): New function.
(_initialize_infcmd): Add "set/show print finish" commands.
* valprint.c (user_print_options): Initialize new member.
* valprint.h (struct value_print_options) <finish_print>: New
member.
gdb/doc/ChangeLog
2019-05-29 Tom Tromey <tromey@adacore.com>
* gdb.texinfo (Continuing and Stepping): Document new
commands.
gdb/testsuite/ChangeLog
2019-05-29 Tom Tromey <tromey@adacore.com>
* gdb.base/finish.exp (finish_no_print): New proc.
(finish_tests): Call it.
Nick Clifton [Wed, 29 May 2019 11:49:13 +0000 (12:49 +0100)]
Update release tools with libctf support.
top * src-release.sh (do_proto_toplev): Add libctf to list of
directories that can be disabled.
binutils* README-how-to-make-a-release: Add libctf to list of directories
that need updates in their ChangeLogs.
Nick Clifton [Wed, 29 May 2019 11:43:42 +0000 (12:43 +0100)]
Sync top level files with versions from gcc.
top * Makefile.def (target_modules): Add libphobos.
(flags_to_pass): Add GDC, GDCFLAGS, GDC_FOR_TARGET and
GDCFLAGS_FOR_TARGET.
(dependencies): Make libphobos depend on libatomic, libbacktrace
configure, and zlib configure.
(language): Add language d.
* Makefile.in: Rebuild.
* Makefile.tpl (BUILD_EXPORTS): Add GDC and GDCFLAGS.
(HOST_EXPORTS): Add GDC.
(POSTSTAGE1_HOST_EXPORTS): Add GDC and GDC_FOR_BUILD.
(BASE_TARGET_EXPORTS): Add GDC.
(GDC_FOR_BUILD, GDC, GDCFLAGS): New variables.
(GDC_FOR_TARGET, GDC_FLAGS_FOR_TARGET): New variables.
(EXTRA_HOST_FLAGS): Add GDC.
(STAGE1_FLAGS_TO_PASS): Add GDC.
(EXTRA_TARGET_FLAGS): Add GDC and GDCFLAGS.
* config-ml.in: Treat GDC and GDCFLAGS like other compiler/flag
environment variables.
* configure: Rebuild.
* configure.ac: Add target-libphobos to target_libraries. Set and
substitute GDC_FOR_BUILD and GDC_FOR_TARGET.
Nick Clifton [Wed, 29 May 2019 10:31:16 +0000 (11:31 +0100)]
Do not build libctf for targets that do not use the ELF file format.
top * configure.ac (noconfigdirs): Add libctf if the target does not use
the ELF file format.
* configure: Regenerate.
binutils* configure.ac (LIBCTF): Export. Set to empty for non-ELF based
targets.
(HAVE_LIBCTF): Define if libctf support is available.
* Makefile.am (LIBCTF): Set value to @LIBCTF@.
* objdump.c: Make CTF code conditional upon HAVE_LIBCTF being
defined.
* readelf.c: Likewise.
* configure: Regenerate.
* Makefile.in: Regenerate.
* config.in: Regenerate.
Nick Alcock [Wed, 29 May 2019 09:11:37 +0000 (11:11 +0200)]
Fix libctf build on non-ELF targets.
All machinery works as on ELF, except for automatic loading of ELF
string and symbol tables in the BFD-style open machinery.
* Makefile.def (dependencies): configure-libctf depends on all-bfd
and all its deps.
* Makefile.in: Regenerated.
libctf/
* configure.in: Check for bfd_section_from_elf_index.
* configure: Regenerate.
* config.h.in [HAVE_BFD_ELF]: Likewise.
* libctf/ctf_open_bfd (ctf_bfdopen_ctfsect): Use it.
abfd is potentially unused now.
GDB Administrator [Wed, 29 May 2019 00:00:28 +0000 (00:00 +0000)]
Automatic date update in version.in
Faraz Shahbazker [Fri, 24 May 2019 01:16:08 +0000 (18:16 -0700)]
MIPS/LD: Skip overflow check for %pcrel_hi relocations
Overflow checks were removed for all hi16 relocations except PC-relative
high relocations per PR ld/16720. Remove overflow checks from %pcrel_hi
relocations so that we can correctly handle negative offsets from PC.
bfd/
* elfxx-mips.c (mips_elf_calculate_relocation) <R_MIPS_PCHI16>:
Remove overflow check.
ld/
* testsuite/ld-mips-elf/undefweak-overflow.s: Remove test case
for pcrel_hi/pcrel_lo.
* testsuite/ld-mips-elf/undefweak-overflow.d: Update to match.
* testsuite/ld-mips-elf/reloc-pcrel-r6.s: New test source.
* testsuite/ld-mips-elf/reloc-pcrel-r6.d: New test linker script.
* testsuite/ld-mips-elf/reloc-pcrel-r6.ld: New test.
* testsuite/ld-mips-elf/mips-elf.exp: Run the new test.
H.J. Lu [Tue, 28 May 2019 17:05:28 +0000 (10:05 -0700)]
x86: Add CheckRegSize to AVX512_BF16 instructions with Disp8ShiftVL
For AVX512 instructions with Disp8ShiftVL and Broadcast, we may need to
add CheckRegSize to check if broadcast matches the destination register
size.
gas/
PR gas/24625
* testsuite/gas/i386/inval-avx512f.s: Add tests for AVX512_BF16
instructions with invalid broadcast.
* testsuite/gas/i386/x86-64-inval-avx512f.s: Likewise.
* testsuite/gas/i386/inval-avx512f.l: Updated.
* testsuite/gas/i386/x86-64-inval-avx512f.l: Likewise.
opcodes/
PR gas/24625
* i386-opc.tbl: Add CheckRegSize to AVX512_BF16 instructions with
Disp8ShiftVL.
* i386-tbl.h: Regenerated.
Tom Tromey [Thu, 23 May 2019 14:40:27 +0000 (10:40 -0400)]
Remove find_old_style_renaming_symbol
We found a case where a "bt" was very slow with Ada code. Profiling
with callgrind showed this to be primarily due to calls to
find_old_style_renaming_symbol. Because new-style renaming symbols
were implemented in 2007, it seems safe enough to remove this old
code.
A "-batch -ex bt" test on a large Ada program improves from:
13.23user 0.57system 0:13.82elapsed 99%CPU (0avgtext+0avgdata 571408maxresident)k
to
4.25user 0.48system 0:04.74elapsed 99%CPU (0avgtext+0avgdata 559844maxresident)k
with this patch.
Tested on x86-64 Fedora 29. Joel reviewed this internally; and as it
is Ada-specific, I am checking it in.
gdb/ChangeLog
2019-05-28 Tom Tromey <tromey@adacore.com>
* ada-lang.c (ada_remove_Xbn_suffix)
(find_old_style_renaming_symbol)
(parse_old_style_renaming): Remove.
(ada_find_renaming_symbol): Don't call
find_old_style_renaming_symbol.
(ada_is_renaming_symbol): Rename from
ada_find_renaming_symbol. Remove "block" parameter. Return
bool. Now static.
(ada_read_var_value): Update and simplify.
* ada-exp.y (write_var_or_type): Remove old code.
Nick Alcock [Tue, 28 May 2019 16:01:32 +0000 (17:01 +0100)]
Add libctf to top-level MAINTAINERS; add myself as CTF maintainer.
Nick Alcock [Wed, 24 Apr 2019 11:04:33 +0000 (12:04 +0100)]
binutils: CTF support for objdump and readelf
This introduces CTF support for objdump and readelf. objdump has the
following new arguments:
--ctf=SECTION: display CTF in the given SECTION
--ctf-parent=SECTION: name of CTF section that is the parent of this section
readelf has the above, and these two as well:
--ctf-symbols=SECTION: name of symbol table section (optional)
--ctf-strings=SECTION: name of string table section (optional)
(objdump can always use BFD machinery to determine the applicable string
and symbol tables automatically, so these arguments are unnecessary.)
Nearly all the work is done by the ctf_dump machinery in libctf: most of
the remaining work is option-processing and section-reading, and thus is
different for objdump and readelf: the minimal amount of similar code
remaining is, in my view, too small to share, particularly given that
objdump uses ctf_bfdopen() and readelf uses ctf_simple_open() since it
doesn't have a bfd.
I am not particularly satisfied with the way resources are freed in
either of these (I was forced to do it at the top level, for lack of
anywhere else to free resources allocated during option processing), but
I can't see any better way to do it without introducing new
infrastructure for no other purpose.
There are essentially arbitrary ordering changes to the Makefile.in's
order of libtool-related stuff that I can't get rid of, but they have no
semantic effect. (It is possible that some hunks of these changes could
be dropped, but that seems a bit risky to me.)
binutils/
* objdump.c (ctf-api.h): New include.
(dump_ctf_section_info): New variable.
(dump_ctf_section_name): Likewise.
(usage): Describe new options.
(enum option_values): Add OPTION_CTF and OPTION_CTF_PARENT.
(main): Use them to add --ctf and --ctf-parent.
(read_section_stabs): Add new parameter, entsize_ptr.
(find_stabs_section): Adjust accordingly.
(make_ctfsect): New.
(dump_ctf_indent_lines): New.
(dump_ctf_archive_member): New.
(dump_ctf): New.
(dump_bfd): Call it. Free resources afterwards.
* readelf.c (ctf-api.h): New include.
(CTF_DUMP): New.
(static bfd_boolean do_ctf): Likewise.
(dump_ctf_parent_name): Likewise.
(dump_ctf_symtab_name): Likewise.
(dump_ctf_strtab_name): Likewise.
(OPTION_CTF_DUMP): Likewise.
(OPTION_CTF_PARENT): Likewise.
(OPTION_CTF_SYMBOLS): Likewise.
(OPTION_CTF_STRINGS): Likewise.
(options): Add them.
(usage): Likewise.
(parse_args): Handle the new options, requesting CTF_DUMP.
(process_section_contents): Handle CTF_DUMP.
(shdr_to_ctf_sect): New.
(dump_ctf_indent_lines): New.
(dump_section_as_ctf): New.
(main): Free resources.
* Makefile.am (LIBCTF): New variable.
(objdump_DEPENDENCIES): Use it.
(readelf_DEPENDENCIES): Likewise.
(objdump_LDADD): Likewise.
(readelf_LDADD): Likewise.
* aclocal.m4: Regenerated.
* Makefile.in: Likewise.
* doc/binutils.texi (objdump): Document the new options.
(readelf): Likewise.
* doc/ctf.options.texi: New.
* doc/Makefile.in: Regenerated.
* NEWS: Mention the new feature.
Nick Alcock [Wed, 24 Apr 2019 10:49:48 +0000 (11:49 +0100)]
libctf: build system
This ties libctf into the build system, and makes binutils depend on it
(used by the next commits).
* Makefile.def (host_modules): Add libctf.
* Makefile.def (dependencies): Likewise.
libctf depends on zlib, libiberty, and bfd.
* Makefile.in: Regenerated.
* configure.ac (host_libs): Add libctf.
* configure: Regenerated.
libctf/
* Makefile.am: New.
* Makefile.in: Regenerated.
* config.h.in: Likewise.
* aclocal.m4: Likewise.
* configure: Likewise.
Nick Alcock [Wed, 24 Apr 2019 10:41:00 +0000 (11:41 +0100)]
libctf: debug dumping
This introduces ctf_dump(), an iterator which returns a series of
strings, each representing a debugging dump of one item from a given
section in the CTF file. The items may be multiline: a callback is
provided to allow the caller to decorate each line as they desire before
the line is returned.
libctf/
* ctf-dump.c: New.
include/
* ctf-api.h (ctf_dump_decorate_f): New.
(ctf_dump_state_t): new.
(ctf_dump): New.
Nick Alcock [Wed, 24 Apr 2019 10:35:37 +0000 (11:35 +0100)]
libctf: labels
This facility allows you to associate regions of type IDs with *labels*,
a labelled tiling of the type ID space. You can use these to define
CTF containers with distinct parents for distinct ranges of the ID
space, or to assist with parallelization of CTF processing, or for any
other purpose you can think of.
Notably absent from here (though declared in the API header) is any way
to define new labels: this will probably be introduced soon, as part of
the linker deduplication work. (One existed in the past, but was deeply
tied to the Solaris CTF file generator and had to be torn out.)
libctf/
* ctf-labels.c: New.
include/
* ctf-api.h (ctf_label_f): New.
(ctf_label_set): New.
(ctf_label_get): New.
(ctf_label_topmost): New.
(ctf_label_info): New.
(ctf_label_iter): New.
Nick Alcock [Wed, 24 Apr 2019 10:26:42 +0000 (11:26 +0100)]
libctf: library version enforcement
This old Solaris standard allows callers to specify that they are
expecting one particular API and/or CTF file format from the library.
libctf/
* ctf-impl.h (_libctf_version): New declaration.
* ctf-subr.c (_libctf_version): Define it.
(ctf_version): New.
include/
* ctf-api.h (ctf_version): New.
Nick Alcock [Wed, 24 Apr 2019 10:22:03 +0000 (11:22 +0100)]
libctf: type copying
ctf_add_type() allows you to copy types, and all the types they depend
on, from one container to another (writable) container. This lets a
program maintaining multiple distinct containers (not in a parent-child
relationship) introduce types that depend on types in one container in
another writable one, by copying the necessary types.
libctf/
* ctf-create.c (enumcmp): New.
(enumadd): Likewise.
(membcmp): Likewise.
(membadd): Likewise.
(ctf_add_type): Likewise.
Nick Alcock [Wed, 24 Apr 2019 10:15:33 +0000 (11:15 +0100)]
libctf: lookups by name and symbol
These functions allow you to look up types given a name in a simple
subset of C declarator syntax (no function pointers), to look up the
types of variables given a name, and to look up the types of data
objects and the type signatures of functions given symbol table offsets.
(Despite its name, one function in this commit, ctf_lookup_symbol_name(),
is for the internal use of libctf only, and does not appear in any
public header files.)
libctf/
* ctf-lookup.c (isqualifier): New.
(ctf_lookup_by_name): Likewise.
(struct ctf_lookup_var_key): Likewise.
(ctf_lookup_var): Likewise.
(ctf_lookup_variable): Likewise.
(ctf_lookup_symbol_name): Likewise.
(ctf_lookup_by_symbol): Likewise.
(ctf_func_info): Likewise.
(ctf_func_args): Likewise.
include/
* ctf-api.h (ctf_func_info): New.
(ctf_func_args): Likewise.
(ctf_lookup_by_symbol): Likewise.
(ctf_lookup_by_symbol): Likewise.
(ctf_lookup_variable): Likewise.
Nick Alcock [Wed, 24 Apr 2019 10:03:37 +0000 (11:03 +0100)]
libctf: core type lookup
Finally we get to the functions used to actually look up and enumerate
properties of types in a container (names, sizes, members, what type a
pointer or cv-qual references, determination of whether two types are
assignment-compatible, etc).
With a very few exceptions these do not work for types newly added via
ctf_add_*(): they only work on types in read-only containers, or types
added before the most recent call to ctf_update().
This also adds support for lookup of "variables" (string -> type ID
mappings) and for generation of C type names corresponding to a type ID.
libctf/
* ctf-decl.c: New file.
* ctf-types.c: Likewise.
* ctf-impl.h: New declarations.
include/
* ctf-api.h (ctf_visit_f): New definition.
(ctf_member_f): Likewise.
(ctf_enum_f): Likewise.
(ctf_variable_f): Likewise.
(ctf_type_f): Likewise.
(ctf_type_isparent): Likewise.
(ctf_type_ischild): Likewise.
(ctf_type_resolve): Likewise.
(ctf_type_aname): Likewise.
(ctf_type_lname): Likewise.
(ctf_type_name): Likewise.
(ctf_type_sizee): Likewise.
(ctf_type_align): Likewise.
(ctf_type_kind): Likewise.
(ctf_type_reference): Likewise.
(ctf_type_pointer): Likewise.
(ctf_type_encoding): Likewise.
(ctf_type_visit): Likewise.
(ctf_type_cmp): Likewise.
(ctf_type_compat): Likewise.
(ctf_member_info): Likewise.
(ctf_array_info): Likewise.
(ctf_enum_name): Likewise.
(ctf_enum_value): Likewise.
(ctf_member_iter): Likewise.
(ctf_enum_iter): Likewise.
(ctf_type_iter): Likewise.
(ctf_variable_iter): Likewise.
Nick Alcock [Wed, 24 Apr 2019 09:46:39 +0000 (10:46 +0100)]
libctf: ELF file opening via BFD
These functions let you open an ELF file with a customarily-named CTF
section in it, automatically opening the CTF file or archive and
associating the symbol and string tables in the ELF file with the CTF
container, so that you can look up the types of symbols in the ELF file
via ctf_lookup_by_symbol(), and so that strings can be shared between
the ELF file and CTF container, to save space.
It uses BFD machinery to do so. This has now been lightly tested and
seems to work. In particular, if you already have a bfd you can pass
it in to ctf_bfdopen(), and if you want a bfd made for you you can
call ctf_open() or ctf_fdopen(), optionally specifying a target (or
try once without a target and then again with one if you get
ECTF_BFD_AMBIGUOUS back).
We use a forward declaration for the struct bfd in ctf-api.h, so that
ctf-api.h users are not required to pull in <bfd.h>. (This is mostly
for the sake of readelf.)
libctf/
* ctf-open-bfd.c: New file.
* ctf-open.c (ctf_close): New.
* ctf-impl.h: Include bfd.h.
(ctf_file): New members ctf_data_mmapped, ctf_data_mmapped_len.
(ctf_archive_internal): New members ctfi_abfd, ctfi_data,
ctfi_bfd_close.
(ctf_bfdopen_ctfsect): New declaration.
(_CTF_SECTION): likewise.
include/
* ctf-api.h (struct bfd): New forward.
(ctf_fdopen): New.
(ctf_bfdopen): Likewise.
(ctf_open): Likewise.
(ctf_arc_open): Likewise.
Nick Alcock [Wed, 24 Apr 2019 10:30:17 +0000 (11:30 +0100)]
libctf: mmappable archives
If you need to store a large number of CTF containers somewhere, this
provides a dedicated facility for doing so: an mmappable archive format
like a very simple tar or ar without all the system-dependent format
horrors or need for heavy file copying, with built-in compression of
files above a particular size threshold.
libctf automatically mmap()s uncompressed elements of these archives, or
uncompresses them, as needed. (If the platform does not support mmap(),
copying into dynamically-allocated buffers is used.)
Archive iteration operations are partitioned into raw and non-raw
forms. Raw operations pass thhe raw archive contents to the callback:
non-raw forms open each member with ctf_bufopen() and pass the resulting
ctf_file_t to the iterator instead. This lets you manipulate the raw
data in the archive, or the contents interpreted as a CTF file, as
needed.
It is not yet known whether we will store CTF archives in a linked ELF
object in one of these (akin to debugdata) or whether they'll get one
section per TU plus one parent container for types shared between them.
(In the case of ELF objects with very large numbers of TUs, an archive
of all of them would seem preferable, so we might just use an archive,
and add lzma support so you can assume that .gnu_debugdata and .ctf are
compressed using the same algorithm if both are present.)
To make usage easier, the ctf_archive_t is not the on-disk
representation but an abstraction over both ctf_file_t's and archives of
many ctf_file_t's: users see both CTF archives and raw CTF files as
ctf_archive_t's upon opening, the only difference being that a raw CTF
file has only a single "archive member", named ".ctf" (the default if a
null pointer is passed in as the name). The next commit will make use
of this facility, in addition to providing the public interface to
actually open archives. (In the future, it should be possible to have
all CTF sections in an ELF file appear as an "archive" in the same
fashion.)
This machinery is also used to allow library-internal creators of
ctf_archive_t's (such as the next commit) to stash away an ELF string
and symbol table, so that all opens of members in a given archive will
use them. This lets CTF archives exploit the ELF string and symbol
table just like raw CTF files can.
(All this leads to somewhat confusing type naming. The ctf_archive_t is
a typedef for the opaque internal type, struct ctf_archive_internal: the
non-internal "struct ctf_archive" is the on-disk structure meant for
other libraries manipulating CTF files. It is probably clearest to use
the struct name for struct ctf_archive_internal inside the program, and
the typedef names outside.)
libctf/
* ctf-archive.c: New.
* ctf-impl.h (ctf_archive_internal): New type.
(ctf_arc_open_internal): New declaration.
(ctf_arc_bufopen): Likewise.
(ctf_arc_close_internal): Likewise.
include/
* ctf.h (CTFA_MAGIC): New.
(struct ctf_archive): New.
(struct ctf_archive_modent): Likewise.
* ctf-api.h (ctf_archive_member_f): New.
(ctf_archive_raw_member_f): Likewise.
(ctf_arc_write): Likewise.
(ctf_arc_close): Likewise.
(ctf_arc_open_by_name): Likewise.
(ctf_archive_iter): Likewise.
(ctf_archive_raw_iter): Likewise.
(ctf_get_arc): Likewise.
Nick Alcock [Wed, 24 Apr 2019 09:17:13 +0000 (10:17 +0100)]
libctf: opening
This fills in the other half of the opening/creation puzzle: opening of
already-existing CTF files. Such files are always read-only: if you
want to add to a CTF file opened with one of the opening functions in
this file, use ctf_add_type(), in a later commit, to copy appropriate
types into a newly ctf_create()d, writable container.
The lowest-level opening functions are in here: ctf_bufopen(), which
takes ctf_sect_t structures akin to ELF section headers, and
ctf_simple_open(), which can be used if you don't have an entire ELF
section header to work from. Both will malloc() new space for the
buffers only if necessary, will mmap() directly from the file if
requested, and will mprotect() it afterwards to prevent accidental
corruption of the types. These functions are also used by ctf_update()
when converting types in a writable container into read-only types that
can be looked up using the lookup functions (in later commits).
The files are always of the native endianness of the system that created
them: at read time, the endianness of the header magic number is used to
determine whether or not the file needs byte-swapping, and the entire
thing is aggressively byte-swapped.
The agggressive nature of this swapping avoids complicating the rest of
the code with endianness conversions, while the native endianness
introduces no byte-swapping overhead in the common case. (The
endianness-independence code is also much newer than everything else in
this file, and deserves closer scrutiny.)
The accessors at the top of the file are there to transparently support
older versions of the CTF file format, allowing translation from older
formats that have different sizes for the structures in ctf.h:
currently, these older formats are intermingled with the newer ones in
ctf.h: they will probably migrate to a compatibility header in time, to
ease readability. The ctf_set_base() function is split out for the same
reason: when conversion code to a newer format is written, it would need
to malloc() new storage for the entire ctf_file_t if a file format
change causes it to grow, and for that we need ctf_set_base() to be a
separate function.
One pair of linked data structures supported by this file has no
creation code in libctf yet: the data and function object sections read
by init_symtab(). These will probably arrive soon, when the linker comes
to need them. (init_symtab() has hardly been changed since 2009, but if
any code in libctf has rotted over time, this will.)
A few simple accessors are also present that can even be called on
read-only containers because they don't actually modify them, since the
relevant things are not stored in the container but merely change its
operation: ctf_setmodel(), which lets you specify whether a container is
LP64 or not (used to statically determine the sizes of a few types),
ctf_import(), which is the only way to associate a parent container with
a child container, and ctf_setspecific(), which lets the caller
associate an arbitrary pointer with the CTF container for any use. If
the user doesn't call these functions correctly, libctf will misbehave:
this is particularly important for ctf_import(), since a container built
against a given parent container will not be able to resolve types that
depend on types in the parent unless it is ctf_import()ed with a parent
container with the same set of types at the same IDs, or a superset.
Possible future extensions (also noted in the ctf-hash.c file) include
storing a count of things so that we don't need to do one pass over the
CTF file counting everything, and computing a perfect hash at CTF
creation time in some compact form, storing it in the CTF file, and
using it to hash things so we don't need to do a second pass over the
entire CTF file to set up the hashes used to go from names to type IDs.
(There are multiple such hashes, one for each C type namespace: types,
enums, structs, and unions.)
libctf/
* ctf-open.c: New file.
* swap.h: Likewise.
include/
* ctf-api.h (ctf_file_close): New declaration.
(ctf_getdatasect): Likewise.
(ctf_parent_file): Likewise.
(ctf_parent_name): Likewise.
(ctf_parent_name_set): Likewise.
(ctf_import): Likewise.
(ctf_setmodel): Likewise.
(ctf_getmodel): Likewise.
(ctf_setspecific): Likewise.
(ctf_getspecific): Likewise.
Nick Alcock [Tue, 23 Apr 2019 21:45:46 +0000 (22:45 +0100)]
libctf: creation functions
The CTF creation process looks roughly like (error handling elided):
int err;
ctf_file_t *foo = ctf_create (&err);
ctf_id_t type = ctf_add_THING (foo, ...);
ctf_update (foo);
ctf_*write (...);
Some ctf_add_THING functions accept other type IDs as arguments,
depending on the type: cv-quals, pointers, and structure and union
members all take other types as arguments. So do 'slices', which
let you take an existing integral type and recast it as a type
with a different bitness or offset within a byte, for bitfields.
One class of THING is not a type: "variables", which are mappings
of names (in the internal string table) to types. These are mostly
useful when encoding variables that do not appear in a symbol table
but which some external user has some other way to figure out the
address of at runtime (dynamic symbol lookup or querying a VM
interpreter or something).
You can snapshot the creation process at any point: rolling back to a
snapshot deletes all types and variables added since that point.
You can make arbitrary type queries on the CTF container during the
creation process, but you must call ctf_update() first, which
translates the growing dynamic container into a static one (this uses
the CTF opening machinery, added in a later commit), which is quite
expensive. This function must also be called after adding types
and before writing the container out.
Because addition of types involves looking up existing types, we add a
little of the type lookup machinery here, as well: only enough to
look up types in dynamic containers under construction.
libctf/
* ctf-create.c: New file.
* ctf-lookup.c: New file.
include/
* ctf-api.h (zlib.h): New include.
(ctf_sect_t): New.
(ctf_sect_names_t): Likewise.
(ctf_encoding_t): Likewise.
(ctf_membinfo_t): Likewise.
(ctf_arinfo_t): Likewise.
(ctf_funcinfo_t): Likewise.
(ctf_lblinfo_t): Likewise.
(ctf_snapshot_id_t): Likewise.
(CTF_FUNC_VARARG): Likewise.
(ctf_simple_open): Likewise.
(ctf_bufopen): Likewise.
(ctf_create): Likewise.
(ctf_add_array): Likewise.
(ctf_add_const): Likewise.
(ctf_add_enum_encoded): Likewise.
(ctf_add_enum): Likewise.
(ctf_add_float): Likewise.
(ctf_add_forward): Likewise.
(ctf_add_function): Likewise.
(ctf_add_integer): Likewise.
(ctf_add_slice): Likewise.
(ctf_add_pointer): Likewise.
(ctf_add_type): Likewise.
(ctf_add_typedef): Likewise.
(ctf_add_restrict): Likewise.
(ctf_add_struct): Likewise.
(ctf_add_union): Likewise.
(ctf_add_struct_sized): Likewise.
(ctf_add_union_sized): Likewise.
(ctf_add_volatile): Likewise.
(ctf_add_enumerator): Likewise.
(ctf_add_member): Likewise.
(ctf_add_member_offset): Likewise.
(ctf_add_member_encoded): Likewise.
(ctf_add_variable): Likewise.
(ctf_set_array): Likewise.
(ctf_update): Likewise.
(ctf_snapshot): Likewise.
(ctf_rollback): Likewise.
(ctf_discard): Likewise.
(ctf_write): Likewise.
(ctf_gzwrite): Likewise.
(ctf_compress_write): Likewise.
Nick Alcock [Tue, 23 Apr 2019 21:24:13 +0000 (22:24 +0100)]
libctf: implementation definitions related to file creation
We now enter a series of commits that are sufficiently tangled that
avoiding forward definitions is almost impossible: no attempt is made to
make individual commits compilable (which is why the build system does
not reference any of them yet): the only important thing is that they
should form something like conceptual groups.
But first, some definitions, including the core ctf_file_t itself. Uses
of these definitions will be introduced in later commits.
libctf/
* ctf-impl.h: New definitions and declarations for type creation
and lookup.
Nick Alcock [Tue, 23 Apr 2019 21:12:16 +0000 (22:12 +0100)]
libctf: hashing
libctf maintains two distinct hash ADTs, one (ctf_dynhash) for wrapping
dynamically-generated unknown-sized hashes during CTF file construction,
one (ctf_hash) for wrapping unchanging hashes whose size is known at
creation time for reading CTF files that were previously created.
In the binutils implementation, these are both fairly thin wrappers
around libiberty hashtab.
Unusually, this code is not kept synchronized with libdtrace-ctf,
due to its dependence on libiberty hashtab.
libctf/
* ctf-hash.c: New file.
* ctf-impl.h: New declarations.
Nick Alcock [Tue, 23 Apr 2019 21:05:52 +0000 (22:05 +0100)]
libctf: error handling
CTF functions return zero on success or an extended errno value which
can be translated into a string via the functions in this commit.
The errno numbers start at -CTF_BASE.
libctf/
* ctf-error.c: New file.
include/
* ctf-api.h (ctf_errno): New declaration.
(ctf_errmsg): Likewise.
Nick Alcock [Tue, 23 Apr 2019 20:45:30 +0000 (21:45 +0100)]
libctf: low-level list manipulation and helper utilities
These utilities are a bit of a ragbag of small things needed by more
than one TU: list manipulation, ELF32->64 translators, routines to look
up strings in string tables, dynamically-allocated string appenders, and
routines to set the specialized errno values previously committed in
<ctf-api.h>.
We do still need to dig around in raw ELF symbol tables in places,
because libctf allows the caller to pass in the contents of string and
symbol sections without telling it where they come from, so we cannot
use BFD to get the symbols (BFD reasonably demands the entire file). So
extract minimal ELF definitions from glibc into a private header named
libctf/elf.h: later, we use those to get symbols. (The start-of-
copyright range on elf.h reflects this glibc heritage.)
libctf/
* ctf-util.c: New file.
* elf.h: Likewise.
* ctf-impl.h: Include it, and add declarations.
Nick Alcock [Tue, 23 Apr 2019 17:55:27 +0000 (18:55 +0100)]
libctf: lowest-level memory allocation and debug-dumping wrappers
The memory-allocation wrappers are simple things to allow malloc
interposition: they are only used inconsistently at present, usually
where malloc debugging was required in the past.
These provide a default implementation that is environment-variable
triggered (initialized on the first call to the libctf creation and
file-opening functions, the first functions people will use), and
a ctf_setdebug()/ctf_getdebug() pair that allows the caller to
explicitly turn debugging off and on. If ctf_setdebug() is called,
the automatic setting from an environment variable is skipped.
libctf/
* ctf-impl.h: New file.
* ctf-subr.c: New file.
include/
* ctf-api.h (ctf_setdebug): New.
(ctf_getdebug): Likewise.
Nick Alcock [Tue, 23 Apr 2019 17:42:34 +0000 (18:42 +0100)]
include: new header ctf-api.h
This non-installed header is the means by which libctf consumers
communicate with libctf.
This header will be extended in subsequent commits.
include/
* ctf-api.h: New file.
Nick Alcock [Tue, 23 Apr 2019 17:02:25 +0000 (18:02 +0100)]
include: new header ctf.h: file format description
The data structures and macros in this header can be used, if desired,
to access or create CTF files directly, without going through libctf,
though this should rarely be necessary in practice.
libctf relies on this header as its description of the CTF file format.
include/
* ctf.h: New file.
Alan Modra [Tue, 28 May 2019 10:42:32 +0000 (20:12 +0930)]
PE linker segmentation fault with MALLOC_PERTURB_=1
PR 24596
* emultempl/pe.em (gld_${EMULATION_NAME}_after_open): Check that
the output is coff before accessing coff tdata.
* emultempl/pep.em (gld_${EMULATION_NAME}_after_open): Likewise.
Szabolcs Nagy [Tue, 28 May 2019 10:48:08 +0000 (11:48 +0100)]
aarch64: fix variant_pcs ld tests
Force sysv hash style for reliable symbol table layout.
ld/ChangeLog:
* testsuite/ld-aarch64/variant_pcs-now.d: Use --hash-style=sysv.
* testsuite/ld-aarch64/variant_pcs-shared.d: Likewise.
Alan Hayward [Tue, 28 May 2019 09:07:54 +0000 (10:07 +0100)]
Suppress SIGTTOU when handling errors
Calls to error () can cause SIGTTOU to send gdb to the background.
For example, on an Arm build:
(gdb) b main
Breakpoint 1 at 0x10774: file /build/gdb/testsuite/../../../src/binutils-gdb/gdb/testsuite/gdb.base/watchpoint.c, line 174.
(gdb) r
Starting program: /build/gdb/testsuite/outputs/gdb.base/watchpoint/watchpoint
[1]+ Stopped ../gdb ./outputs/gdb.base/watchpoint/watchpoint
localhost$ fg
../gdb ./outputs/gdb.base/watchpoint/watchpoint
Cannot parse expression `.L1199 4@r4'.
warning: Probes-based dynamic linker interface failed.
Reverting to original interface.
The SIGTTOU is raised whilst inside a syscall during the call to tcdrain.
Fix is to use scoped_ignore_sigttou to ensure SIGTTOU is blocked.
In addition fix include comments - job_control is not included via terminal.h
gdb/ChangeLog:
* event-top.c: Remove include comment.
* inflow.c (class scoped_ignore_sigttou): Move from here...
* inflow.h (class scoped_ignore_sigttou): ...to here.
* ser-unix.c (hardwire_drain_output): Block SIGTTOU during drain.
* top.c: Remove include comment.
Alan Modra [Tue, 28 May 2019 08:22:42 +0000 (17:52 +0930)]
COFF linker segmentation faults
A plugin can change the element, so call the generic
bfd_link_add_symbols.
PR 24596
* cofflink.c (coff_link_check_archive_element): Don't assume
element is a coff object file after calling add_archive_element.
Alan Modra [Tue, 28 May 2019 06:24:15 +0000 (15:54 +0930)]
Microblaze linker segmentation fault
PR 24596
* elf32-microblaze.c (microblaze_elf_finish_dynamic_sections): Don't
attempt to set sh_entsize for excluded PLT section.
Alan Modra [Tue, 28 May 2019 05:36:47 +0000 (15:06 +0930)]
Alpha-linux linker segmentation fault
This patch cures a linker segfault, and "FAIL: Build pr22263-1".
PR 24596
* elf64-alpha.c (elf64_alpha_relocate_section): Don't attempt
to emit R_ALPHA_GOTTPREL in PIEs, for which no space is
allocated in alpha_dynamic_entries_for_reloc.
Alan Modra [Tue, 28 May 2019 05:04:37 +0000 (14:34 +0930)]
LM32 linker segmentation faults
PR 24596
* elf32-lm32.c (lm32_elf_finish_dynamic_sections): Don't segfault
on NULL output_section.
* elflink.c (elf_final_link_free): Don't free -1 symshndxbuf.
Alan Modra [Tue, 28 May 2019 02:19:30 +0000 (11:49 +0930)]
m68k linker segmentation faults
This doesn't fix the underlying bug, but an abort is better than a
segfault.
PR 24596
* elf32-m68k.c (elf_m68k_get_got_entry): Don't create a new
entry when MUST_FIND. Abort when MUST_FIND not found.
(elf_m68k_get_bfd2got_entry): Likewise.
(elf_m68k_relocate_section): Remove now useless assert.
Alan Modra [Mon, 27 May 2019 23:11:56 +0000 (08:41 +0930)]
HPPA64 linker segmentation faults
One of the ld tests produces:
failed with: <Segmentation fault>, no expected output
FAIL: Discarded dynamic relocation section
This patch cures the segv. (The test still fails with ld producing
a really messed up output, DT_RELA at address 0!)
PR 24596
* elf64-hppa.c (elf64_hppa_finalize_dynreloc): Get the output bfd
from bfd_link_info, not an output section owner.
(elf64_hppa_finish_dynamic_symbol, elf64_hppa_finalize_opd): Likewise.
(elf_hppa_final_link_relocate): Likewise.
Alan Modra [Mon, 27 May 2019 10:30:11 +0000 (20:00 +0930)]
Obsolete tic30-aout, and linker segmentation faults
See also the FIXME. tic30-aout linker support is so bad (and has been
that way since the initial tic30-aout commit) that I'm obsoleting the
target. This patch fixes numerous linker testsuite segmentation faults.
PR 24596
* aout-tic30.c (MY_bfd_final_link): Don't segfault on missing
create_object_symbols_section, obj_textsec, obj_datasec or
obj_bsssec. Fix other errors in placement.
* config.bfd: Obsolete tic30-aout.
Alan Modra [Mon, 27 May 2019 06:08:55 +0000 (15:38 +0930)]
XCOFF linker segmentation fault
The XCOFF linker temporarily trims the output bfd section list,
without adjusting section_count to suit. This is a little rude, but
the dwarf line number code can easily cope with this situation. So
check for a NULL end of list as well as limiting the saved section
VMAs to the first section_count list entries.
Also fixes
-FAIL: Weak test 3 (main, static) (32-bit)
-FAIL: Weak test 3 (main, static) (64-bit)
PR 24596
* dwarf2.c (save_section_vma, section_vma_same): Check for NULL
end of section list as well as section_count.
* xcofflink.c (xcoff_link_add_symbols): Fix temporarily changed
section list before returning error.
GDB Administrator [Tue, 28 May 2019 00:00:15 +0000 (00:00 +0000)]
Automatic date update in version.in
Tom Tromey [Mon, 27 May 2019 20:53:12 +0000 (14:53 -0600)]
Fix typo in gdb/NEWS
I noticed a typo in gdb/NEWS. This fixes it.
gdb/ChangeLog
2019-05-27 Tom Tromey <tom@tromey.com>
* NEWS: Fix typo.
Alan Modra [Mon, 27 May 2019 02:07:51 +0000 (11:37 +0930)]
Fix failure on powerpc 32-bit only targets
Targets that lack ppc64 support were failing the new prefix-reloc
test. This patch adds some test infrastructure to deal with that, and
changes the powerpc gas usage info so that "-a64" is omitted when
unsupported.
I've been meaning to break up the usage message for a long time;
While doing so causes translators some work now, it should make it
easier next time a new powerpc option is added.
* config/tc-ppc.c (is_ppc64_target): New function.
(md_show_usage): Split up usage message. Don't show -a64 when
unsupported.
testsuite/gas/ppc/ppc.exp (supports_ppc64): New.
(prefix-reloc): Only run for ppc64.
Alan Modra [Mon, 27 May 2019 01:07:37 +0000 (10:37 +0930)]
readelf group errors/warnings
I noticed that one of the readelf errors stopped processing of further
group sections. This patch makes readelf continue on to other groups,
like it does with the other errors.
* readelf.c (process_section_groups): Continue processing groups
when sh_entsize exceeds group size.
Alan Modra [Mon, 27 May 2019 00:59:22 +0000 (10:29 +0930)]
Another generic ELF target assertion failure
After fixing the ld-elf/pr22836-1a segmentation fault we run into an
assertion failure due to the generic ELF target not removing empty
SHT_GROUP sections. Avoid that.
* elf.c (bfd_elf_set_group_contents): Exit on zero size section.
Alan Modra [Mon, 27 May 2019 00:08:42 +0000 (09:38 +0930)]
Generic ELF target group signature symbol
Even though the generic ELF target doesn't handle groups correctly,
this helps avoid a segfault in bfd_elf_set_group_contents seen on
d30v-elf, dlx-elf, pj-elf, and xgate-elf when linking the pr22836
testcase.
PR 24596
bfd/
* linker.c (_bfd_generic_link_output_symbols): Heed BSF_KEEP.
ld/
* emultempl/genelf.em (gld${EMULATION_NAME}_after_open): Set
BFS_KEEP on group signature symbol.
GDB Administrator [Mon, 27 May 2019 00:00:12 +0000 (00:00 +0000)]
Automatic date update in version.in
GDB Administrator [Sun, 26 May 2019 00:01:00 +0000 (00:01 +0000)]
Automatic date update in version.in
GDB Administrator [Sat, 25 May 2019 00:00:20 +0000 (00:00 +0000)]
Automatic date update in version.in
Szabolcs Nagy [Thu, 25 Apr 2019 14:07:14 +0000 (15:07 +0100)]
aarch64: handle STO_AARCH64_VARIANT_PCS in bfd
Propagate STO_AARCH64_VARIANT_PCS st_other attribute to the output and
add DT_AARCH64_VARIANT_PCS dynamic tag if necessary.
Mismatching attributes are not diagnosed.
bfd/ChangeLog:
* elfnn-aarch64.c (elfNN_aarch64_merge_symbol_attribute): New function.
(struct elf_aarch64_link_hash_table): Add variant_pcs member.
(elfNN_aarch64_allocate_dynrelocs): Update variant_pcs.
(elfNN_aarch64_size_dynamic_sections): Add DT_AARCH64_VARIANT_PCS.
(elf_backend_merge_symbol_attribute): Define.
ld/ChangeLog:
* testsuite/ld-aarch64/aarch64-elf.exp: Add new tests.
* testsuite/ld-aarch64/variant_pcs-1.s: New asm for tests.
* testsuite/ld-aarch64/variant_pcs-2.s: New asm for tests.
* testsuite/ld-aarch64/variant_pcs-now.d: New test.
* testsuite/ld-aarch64/variant_pcs-r.d: New test.
* testsuite/ld-aarch64/variant_pcs-shared.d: New test.
* testsuite/ld-aarch64/variant_pcs.ld: New linker script for tests.
Szabolcs Nagy [Thu, 25 Apr 2019 14:07:10 +0000 (15:07 +0100)]
aarch64: override default elf .set handling in gas
Allow st_other values such as STO_AARCH64_VARIANT_PCS to be set for alias
symbols independently. This is needed for ifunc symbols which are
aliased to the resolver using .set and don't expect resolver attributes
to override the ifunc symbol attributes. This means .variant_pcs must be
added explicitly to aliases.
gas/ChangeLog:
* config/tc-aarch64.c (aarch64_elf_copy_symbol_attributes): Define.
* config/tc-aarch64.h (aarch64_elf_copy_symbol_attributes): Declare.
(OBJ_COPY_SYMBOL_ATTRIBUTES): Define.
* testsuite/gas/aarch64/symbol-variant_pcs-3.d: New test.
* testsuite/gas/aarch64/symbol-variant_pcs-3.s: New test.
Szabolcs Nagy [Thu, 25 Apr 2019 14:06:53 +0000 (15:06 +0100)]
aarch64: handle .variant_pcs directive in gas
In ELF objects the specified symbol is marked with STO_AARCH64_VARIANT_PCS.
gas/ChangeLog:
* config/tc-aarch64.c (s_variant_pcs): New function.
* doc/c-aarch64.texi: Document .variant_pcs.
* testsuite/gas/aarch64/symbol-variant_pcs-1.d: New test.
* testsuite/gas/aarch64/symbol-variant_pcs-1.s: New test.
* testsuite/gas/aarch64/symbol-variant_pcs-2.d: New test.
* testsuite/gas/aarch64/symbol-variant_pcs-2.s: New test.
Szabolcs Nagy [Thu, 25 Apr 2019 12:46:01 +0000 (13:46 +0100)]
aarch64: add STO_AARCH64_VARIANT_PCS and DT_AARCH64_VARIANT_PCS
The bottom 2 bits of st_other are used for visibility, the top 6 bits are
de facto reserved for processor specific use. This patch defines a
bits to mark function symbols that follow a variant procedure call standard
with different register usage convention.
A dynamic tag is also defined that marks modules with R_<CLS>_JUMP_SLOT
relocations referencing symbols marked with STO_AARCH64_VARIANT_PCS.
This can be used by dynamic linkers that support lazy binding to decide
what registers need to be preserved during symbol resolution.
binutils/ChangeLog:
* readelf.c (get_aarch64_dynamic_type): Handle DT_AARCH64_VARIANT_PCS.
(get_aarch64_symbol_other): New, handles STO_AARCH64_VARIANT_PCS.
(get_symbol_other): Call get_aarch64_symbol_other.
include/ChangeLog:
* elf/aarch64.h (DT_AARCH64_VARIANT_PCS): Define.
(STO_AARCH64_VARIANT_PCS): Define.
Alan Modra [Fri, 24 May 2019 13:39:56 +0000 (23:09 +0930)]
Regen POTFILES for bpf
bfd/
* po/SRC-POTFILES.in: Regenerate.
gas/
* po/POTFILES.in: Regenerate.
ld/
* po/BLD-POTFILES.in: Regenerate.
opcodes/
* po/POTFILES.in: Regenerate.
Tom de Vries [Fri, 24 May 2019 12:25:33 +0000 (14:25 +0200)]
[gdb/testsuite] Add test-case for gdb-add-index.sh
Add a test-case gdb.dwarf2/gdb-add-index.exp to test
gdb/contrib/gdb-add-index.sh.
Tested with x86_64-linux.
gdb/testsuite/ChangeLog:
2019-05-24 Tom de Vries <tdevries@suse.de>
* gdb.dwarf2/gdb-add-index.exp: New file.
Alan Modra [Thu, 9 Aug 2018 13:23:00 +0000 (22:53 +0930)]
PowerPC notoc linkage stubs
Use pcrel addressing instructions in linkage stubs.
bfd/
* elf64-ppc.c: Comment on powerxx _notoc stub variants.
(LI_R11_0, LIS_R11, ORI_R11_R11_0, SLDI_R11_R11_34): Define.
(PADDI_R12_PC, PLD_R12_PC, D34, HA34): Define.
(struct ppc_link_hash_table): Add powerxx_stubs.
(ppc64_elf_check_relocs): Set powerxx_stubs.
(build_powerxx_offset, size_powerxx_offset),
(num_relocs_for_powerxx_offset),
(emit_relocs_for_powerxx_offset): New functions.
(plt_stub_size): Size powerxx stubs.
(ppc_build_one_stub): Emit powerxx stubs.
(ppc_size_one_stub): Size powerxx stubs. Omit .eh_frame for
powerxx stubs.
ld/
* testsuite/ld-powerpc/notoc2.d,
* testsuite/ld-powerpc/notoc2.s: New test.
* testsuite/ld-powerpc/powerpc.exp: Run it.
Alan Modra [Tue, 30 Apr 2019 07:03:25 +0000 (16:33 +0930)]
PowerPC GOT_PCREL34 optimisation
bfd/
* elf64-ppc.c (ppc64_elf_check_relocs): Set has_gotrel for
R_PPC64_GOT_PCREL34.
(xlate_pcrel_opt): New function.
(ppc64_elf_edit_toc): Handle R_PPC64_GOT_PCREL34.
(ppc64_elf_relocate_section): Edit GOT indirect to GOT relative
for R_PPC64_GOT_PCREL34. Implement R_PPC64_PCREL_OPT optimisation.
ld/
* testsuite/ld-powerpc/pcrelopt.s,
* testsuite/ld-powerpc/pcrelopt.d,
* testsuite/ld-powerpc/pcrelopt.sec: New test.
* testsuite/ld-powerpc/powerpc.exp: Run it.
Alan Modra [Wed, 29 Aug 2018 04:52:34 +0000 (14:22 +0930)]
PowerPC relocations for prefix insns
include/
* elf/ppc64.h (R_PPC64_PLTSEQ_NOTOC, R_PPC64_PLTCALL_NOTOC),
(R_PPC64_PCREL_OPT, R_PPC64_D34, R_PPC64_D34_LO, R_PPC64_D34_HI30),
(R_PPC64_D34_HA30, R_PPC64_PCREL34, R_PPC64_GOT_PCREL34),
(R_PPC64_PLT_PCREL34, R_PPC64_PLT_PCREL34_NOTOC),
(R_PPC64_ADDR16_HIGHER34, R_PPC64_ADDR16_HIGHERA34),
(R_PPC64_ADDR16_HIGHEST34, R_PPC64_ADDR16_HIGHESTA34),
(R_PPC64_REL16_HIGHER34, R_PPC64_REL16_HIGHERA34),
(R_PPC64_REL16_HIGHEST34, R_PPC64_REL16_HIGHESTA34),
(R_PPC64_D28, R_PPC64_PCREL28): Define.
bfd/
* reloc.c (BFD_RELOC_PPC64_D34, BFD_RELOC_PPC64_D34_LO),
(BFD_RELOC_PPC64_D34_HI30, BFD_RELOC_PPC64_D34_HA30),
(BFD_RELOC_PPC64_PCREL34, BFD_RELOC_PPC64_GOT_PCREL34),
(BFD_RELOC_PPC64_PLT_PCREL34),
(BFD_RELOC_PPC64_ADDR16_HIGHER34, BFD_RELOC_PPC64_ADDR16_HIGHERA34),
(BFD_RELOC_PPC64_ADDR16_HIGHEST34, BFD_RELOC_PPC64_ADDR16_HIGHESTA34),
(BFD_RELOC_PPC64_REL16_HIGHER34, BFD_RELOC_PPC64_REL16_HIGHERA34),
(BFD_RELOC_PPC64_REL16_HIGHEST34, BFD_RELOC_PPC64_REL16_HIGHESTA34),
(BFD_RELOC_PPC64_D28, BFD_RELOC_PPC64_PCREL28): New reloc enums.
* elf64-ppc.c (PNOP): Define.
(ppc64_elf_howto_raw): Add reloc howtos for new relocations.
(ppc64_elf_reloc_type_lookup): Translate new bfd reloc numbers.
(ppc64_elf_ha_reloc): Adjust addend for highera34 and highesta34
relocs.
(ppc64_elf_prefix_reloc): New function.
(struct ppc_link_hash_table): Add notoc_plt.
(is_branch_reloc): Add R_PPC64_PLTCALL_NOTOC.
(is_plt_seq_reloc): Add R_PPC64_PLT_PCREL34,
R_PPC64_PLT_PCREL34_NOTOC, and R_PPC64_PLTSEQ_NOTOC.
(ppc64_elf_check_relocs): Handle pcrel got and plt relocs. Set
has_pltcall for section on seeing R_PPC64_PLTCALL_NOTOC. Handle
possible need for dynamic relocs on non-pcrel powerxx relocs.
(dec_dynrel_count): Handle non-pcrel powerxx relocs.
(ppc64_elf_inline_plt): Handle R_PPC64_PLTCALL_NOTOC.
(toc_adjusting_stub_needed): Likewise.
(ppc64_elf_tls_optimize): Handle R_PPC64_PLTSEQ_NOTOC.
(ppc64_elf_relocate_section): Handle new powerxx relocs.
* bfd-in2.h: Regenerate.
* libbfd.h: Regenerate.
gas/
* config/tc-ppc.c (ppc_elf_suffix): Support @pcrel, @got@pcrel,
@plt@pcrel, @higher34, @highera34, @highest34, and @highesta34.
(fixup_size): Handle new powerxx relocs.
(md_assemble): Warn for @pcrel on non-prefix insns.
Accept @l, @h and @ha on prefix insns, and infer reloc without
any @ suffix. Translate powerxx relocs to suit DQ and DS field
instructions. Include operand tests as well as opcode test to
translate BFD_RELOC_HI16_S to BFD_RELOC_PPC_16DX_HA.
(ppc_fix_adjustable): Return false for pcrel GOT and PLT relocs.
(md_apply_fix): Handle new powerxx relocs.
* config/tc-ppc.h (TC_FORCE_RELOCATION_SUB_LOCAL): Accept
BFD_RELOC_PPC64_ADDR16_HIGHER34, BFD_RELOC_PPC64_ADDR16_HIGHERA34,
BFD_RELOC_PPC64_ADDR16_HIGHEST34, BFD_RELOC_PPC64_ADDR16_HIGHESTA34,
BFD_RELOC_PPC64_D34, and BFD_RELOC_PPC64_D28.
* testsuite/gas/ppc/prefix-reloc.d,
* testsuite/gas/ppc/prefix-reloc.s: New test.
* testsuite/gas/ppc/ppc.exp: Run it.
Peter Bergner [Sat, 28 Jul 2018 03:21:43 +0000 (22:21 -0500)]
PowerPC D-form prefixed loads and stores
opcodes/
* ppc-opc.c (insert_d34, extract_d34, insert_nsi34, extract_nsi34),
(insert_pcrel, extract_pcrel, extract_pcrel0): New functions.
(extract_esync, extract_raq, extract_tbr, extract_sxl): Comment.
(powerpc_operands <D34, SI34, NSI34, PRA0, PRAQ, PCREL, PCREL0,
XTOP>): Define and add entries.
(P8LS, PMLS, P_D_MASK, P_DRAPCREL_MASK): Define.
(prefix_opcodes): Add pli, paddi, pla, psubi, plwz, plbz, pstw,
pstb, plhz, plha, psth, plfs, plfd, pstfs, pstfd, plq, plxsd,
plxssp, pld, plwa, pstxsd, pstxssp, pstxv, pstd, and pstq.
gas/
* config/tc-ppc.c (ppc_insert_operand): Only sign extend fields that
are 32-bits or smaller.
* messages.c (as_internal_value_out_of_range): Do not truncate
variables and use BFD_VMA_FMT to print them.
* testsuite/gas/ppc/prefix-pcrel.s,
* testsuite/gas/ppc/prefix-pcrel.d: New test.
* testsuite/gas/ppc/ppc.exp: Run it.
Peter Bergner [Tue, 15 May 2018 21:48:14 +0000 (16:48 -0500)]
PowerPC add initial -mfuture instruction support
This patch adds initial 64-bit insn assembler/disassembler support.
The only instruction added is "pnop" along with the automatic aligning
of prefix instruction so they do not cross 64-byte boundaries.
include/
* dis-asm.h (WIDE_OUTPUT): Define.
* opcode/ppc.h (prefix_opcodes, prefix_num_opcodes): Declare.
(PPC_OPCODE_POWERXX, PPC_GET_PREFIX, PPC_GET_SUFFIX),
(PPC_PREFIX_P, PPC_PREFIX_SEG): Define.
opcodes/
* ppc-dis.c (ppc_opts): Add "future" entry.
(PREFIX_OPCD_SEGS): Define.
(prefix_opcd_indices): New array.
(disassemble_init_powerpc): Initialize prefix_opcd_indices.
(lookup_prefix): New function.
(print_insn_powerpc): Handle 64-bit prefix instructions.
* ppc-opc.c (PREFIX_OP, PREFIX_FORM, SUFFIX_MASK, PREFIX_MASK),
(PMRR, POWERXX): Define.
(prefix_opcodes): New instruction table.
(prefix_num_opcodes): New constant.
binutils/
* objdump.c (disassemble_bytes): Set WIDE_OUTPUT in flags.
gas/
* config/tc-ppc.c (ppc_setup_opcodes): Handle prefix_opcodes.
(struct insn_label_list): New.
(insn_labels, free_insn_labels): New variables.
(ppc_record_label, ppc_clear_labels, ppc_start_line_hook): New funcs.
(ppc_frob_label, ppc_new_dot_label): Move functions earlier in file
and call ppc_record_label.
(md_assemble): Handle 64-bit prefix instructions. Align labels
that are on the same line as a prefix instruction.
* config/tc-ppc.h (tc_frob_label, ppc_frob_label): Move to
later in the file.
(md_start_line_hook): Define.
(ppc_start_line_hook): Declare.
* testsuite/gas/ppc/prefix-align.d,
* testsuite/gas/ppc/prefix-align.s: New test.
* testsuite/gas/ppc/ppc.exp: Run new test.
GDB Administrator [Fri, 24 May 2019 00:00:23 +0000 (00:00 +0000)]
Automatic date update in version.in
Jose E. Marchesi [Thu, 23 May 2019 21:17:39 +0000 (23:17 +0200)]
bfd: fix build with --enable-targets=all in 32-bit hosts
This patch avoids for bpf_elf64_le_vec to be referenced in targmatch.h
when building a BFD without BFD64, resulting in an undefined symbol.
This was a regression introduced along with the BPF target.
bfd/ChangeLog:
2019-05-23 Jose E. Marchesi <jose.marchesi@oracle.com>
* config.bfd (targ_cpu): Process bpf-*-none only if BFD64.
* configure.ac: Set target_size=64 for bpf_elf64_le_vec and
bpf_elf64_be_vec.
* configure: Regenerate.
Jose E. Marchesi [Thu, 23 May 2019 17:07:07 +0000 (19:07 +0200)]
binutils: add myself as the maintainer for BPF
binutils/ChangeLog:
2019-05-23 Jose E. Marchesi <jose.marchesi@oracle.com>
* MAINTAINERS: Add myself as the maintainer for BPF.
Jose E. Marchesi [Thu, 23 May 2019 17:06:17 +0000 (19:06 +0200)]
binutils: add support for eBPF
This patch adds support for ELF64 eBPF to readelf, and fixes a `nm'
test to run properly in bpf-*-* targets.
binutils/ChangeLog:
2019-05-23 Jose E. Marchesi <jose.marchesi@oracle.com>
* readelf.c: Include elf/bpf.h.
(guess_is_rela): Hanle EM_BPF.
(dump_relocations): Likewise.
(is_32bit_abs_reloc): Likewise.
* testsuite/binutils-all/nm.exp: Add bpf-*-* to the list of
ELF targets.
Jose E. Marchesi [Thu, 23 May 2019 17:05:42 +0000 (19:05 +0200)]
ld: add support for eBPF
This patch adds support to the linker for the Linux eBPF architecture.
A minimal testsuite is included.
ld/ChangeLog:
2019-05-23 Jose E. Marchesi <jose.marchesi@oracle.com>
* Makefile.am (ALL_64_EMULATION_SOURCES): Add eelf64bpf.c.
* Makefile.in (prefix): Regenerate.
* configure.tgt (targ_extra_ofiles): Add case for bpf-*-* targets.
* emulparams/elf64bpf.sh: New file.
* testsuite/lib/ld-lib.exp (check_gc_sections_available): Add
bpf-*-* to the list of targets not supporting gc-sections.
* testsuite/ld-bpf/bar.s: New file.
* testsuite/ld-bpf/jump-1.d: Likewise.
* testsuite/ld-bpf/foo.s: Likewise.
* testsuite/ld-bpf/call-1.d: Likewise.
* testsuite/ld-bpf/bpf.exp: Likewise.
* testsuite/ld-bpf/baz.s: Likewise.
Jose E. Marchesi [Thu, 23 May 2019 17:05:12 +0000 (19:05 +0200)]
gas: add support for eBPF
This patch adds a port for the Linux kernel eBPF to the GNU assembler.
A testsuite and documentation updates are included.
gas/ChangeLog:
2019-05-23 Jose E. Marchesi <jose.marchesi@oracle.com>
* configure.ac: Handle bpf-*-* targets.
* configure.tgt (generic_target): Likewise.
* configure: Regenerate.
* Makefile.am (TARGET_CPU_CFILES): Add tc-bpf.c.
(TARGET_CPU_HFILES): Add tc-bpf.h.
* Makefile.in: Regenerated.
* config/tc-bpf.c: New file.
* config/tc-bpf.h: Likewise.
* doc/Makefile.am (CPU_DOCS): Add c-bpf.texi.
* doc/Makefile.in: Regenerated.
* doc/all.texi: set BPF.
* doc/as.texi: Add eBPF contents.
* doc/c-bpf.texi: New file.
* testsuite/gas/bpf/alu.d: New file.
* testsuite/gas/bpf/mem-be.d: Likewise.
* testsuite/gas/bpf/mem.s: Likewise.
* testsuite/gas/bpf/mem.d: Likewise.
* testsuite/gas/bpf/lddw-be.d: Likewise.
* testsuite/gas/bpf/lddw.s: Likewise.
* testsuite/gas/bpf/lddw.d: Likewise.
* testsuite/gas/bpf/jump-be.d: Likewise.
* testsuite/gas/bpf/jump.s: Likewise.
* testsuite/gas/bpf/jump.d: Likewise.
* testsuite/gas/bpf/exit-be.d: Likewise.
* testsuite/gas/bpf/exit.s: Likewise.
* testsuite/gas/bpf/exit.d: Likewise.
* testsuite/gas/bpf/call-be.d: Likewise.
* testsuite/gas/bpf/call.s: Likewise.
* testsuite/gas/bpf/call.d: Likewise.
* testsuite/gas/bpf/bpf.exp: Likewise.
* testsuite/gas/bpf/atomic-be.d: Likewise.
* testsuite/gas/bpf/atomic.s: Likewise.
* testsuite/gas/bpf/atomic.d: Likewise.
* testsuite/gas/bpf/alu-be.d: Likewise.
* testsuite/gas/bpf/alu32-be.d: Likewise.
* testsuite/gas/bpf/alu32.s: Likewise.
* testsuite/gas/bpf/alu32.d: Likewise.
* testsuite/gas/bpf/alu.s: Likewise.
* testsuite/gas/all/gas.exp: Introduce a nop_type for eBPF.
* testsuite/gas/all/org-1.s: Support nop_type 6.
* testsuite/gas/all/org-1.l: Updated to reflect changes in
org-1.s.
Jose E. Marchesi [Thu, 23 May 2019 17:04:36 +0000 (19:04 +0200)]
opcodes: add support for eBPF
This patch adds support for the Linux kernel eBPF architecture to the
opcodes. The port is based on CGEN.
opcodes/ChangeLog:
2019-05-23 Jose E. Marchesi <jose.marchesi@oracle.com>
* configure.ac (SHARED_DEPENDENCIES): Add case for bfd_bpf_arch.
* configure: Regenerated.
* Makefile.am: Add rules for the files generated from cpu/bpf.cpu
and cpu/bpf.opc.
(HFILES): Add bpf-desc.h and bpf-opc.h.
(TARGET_LIBOPCODES_CFILES): Add bpf-asm.c, bpf-desc.c, bpf-dis.c,
bpf-ibld.c and bpf-opc.c.
(BPF_DEPS): Define.
* Makefile.in: Regenerated.
* disassemble.c (ARCH_bpf): Define.
(disassembler): Add case for bfd_arch_bpf.
(disassemble_init_for_target): Likewise.
(enum epbf_isa_attr): Define.
* disassemble.h: extern print_insn_bpf.
* bpf-asm.c: Generated.
* bpf-opc.h: Likewise.
* bpf-opc.c: Likewise.
* bpf-ibld.c: Likewise.
* bpf-dis.c: Likewise.
* bpf-desc.h: Likewise.
* bpf-desc.c: Likewise.
Jose E. Marchesi [Thu, 23 May 2019 17:03:59 +0000 (19:03 +0200)]
cpu: add eBPF cpu description
This patch adds a CPU description for the Linux kernel eBPF virtual
machine, plus supporting code for disassembler and assembler.
cpu/ChangeLog:
2019-05-23 Jose E. Marchesi <jose.marchesi@oracle.com>
* bpf.cpu: New file.
* bpf.opc: Likewise.
Jose E. Marchesi [Thu, 23 May 2019 17:33:41 +0000 (19:33 +0200)]
bfd: add support for eBPF
This patch adds support to BFD for elf64-bpf, in both little-endian
and big-endian variants.
bfd/ChangeLog:
2019-05-23 Jose E. Marchesi <jose.marchesi@oracle.com>
* configure.ac: Add bpf_elf64_le_vec and bpf_elf64_be_vec.
* configure: Regenerated.
* Makefile.am (ALL_MACHINES): Add cpu-bpf.lo.
(ALL_MACHINES_CFILES): Add cpu-bpf.c.
(BFD64_BACKENDS): Add elf64-bpf.lo.
(BFD64_BACKENDS_CFILES): Add elf64-bpf.c.
* Makefile.in (SOURCE_HFILES): Regenerate.
* config.bfd (targ_cpu): Handle bpf-*-* targets.
* cpu-bpf.c: New file.
* elf64-bpf.c: Likewise.
* targets.c (_bfd_target_vector): Add bpf_elf64_be_vec and
bpf_elf64_le_vec.
* archures.c: Define architecture bfd_arch_bpf and machine
bfd_arch_bpf.
* reloc.c: Define BFD relocations used by the BPF target.
* bfd-in2.h: Regenerated.
* libbfd.h: Likewise.