external/binutils.git
7 years agoIntroduce class completion_tracker & rewrite completion<->readline interaction
Pedro Alves [Mon, 17 Jul 2017 13:45:59 +0000 (14:45 +0100)]
Introduce class completion_tracker & rewrite completion<->readline interaction

This patch reworks the whole completion machinery, and prepares it
for later enhancements.

Adds a new "completion_tracker" class that is meant to hold everything
about the state of the current completion operation.

This class now has the responsibility of tracking the list of
completion matches, and checking whether the max completions limit has
been reached.  You can look at this as this patch starting out by
C++fying the existing "completion_tracker" in symtab.c (it's just an
htab_t typedef currently), moving it to completer.h/c, and then making
it a class/generalizing/enhancing it.

Unlike with the current tracking, completion_tracker now checks
whether the limit has been reached on each completion match list
insertion.  This both simplifies the max-completions handling code
(maybe_add_completion_enum is gone, for example), and is a
prerequisite for follow up patches.

The current completion_tracker is only used for symbol completions,
and the symbol code gets at the current instance via globals.  This
patch cleans that up by adding a completion_tracker reference to the
signature of the completion functions, and passing the tracker around
everywhere necessary.

Then, the patch changes how the completion match list is handed over
to readline.  Currently, we're using the rl_completion_entry_function
readline entry point, and the patch switches to
rl_attempted_completion_function.  A following patch will want to let
GDB itself decide the common completion prefix between all matches
(what readline calls the "lowest common denominator"), instead of
having readline compute it, and that's not possible with the
rl_completion_entry_function entry point.  Also,
rl_attempted_completion_function lets GDB hand over the match list to
readline as an array in one go instead of passing down matches one by
one, so from that angle it's a nicer entry point anyway.

Lastly, the patch catches exceptions around the readline entry points,
because we can't let C++ exceptions cross readline.  We handle that in
the readline input entry point, but the completion entry point isn't
guarded, so GDB can abort if completion throws.  E.g., in current
master:

 (gdb) b -function "fun<tab>
 terminate called after throwing an instance of 'gdb_exception_RETURN_MASK_ERROR'
 Aborted (core dumped)

This patch fixes that.  This will be exercised in the new tests added
later on in the series.

gdb/ChangeLog:
2017-07-17  Pedro Alves  <palves@redhat.com>

* ada-lang.c (symbol_completion_match): Adjust comments.
(symbol_completion_add): Replace vector parameter with
completion_tracker parameter.  Use it.
(ada_make_symbol_completion_list): Rename to...
(ada_collect_symbol_completion_matches): ... this.  Add
completion_tracker parameter and use it.
(ada_language_defn): Adjust.
* break-catch-syscall.c (catch_syscall_completer): Adjust
prototype and work with completion_tracker instead of VEC.
* breakpoint.c (condition_completer): Adjust prototype and work
with completion_tracker instead of VEC.
* c-lang.c (c_language_defn, cplus_language_defn)
(asm_language_defn, minimal_language_defn): Adjust to renames.
* cli/cli-cmds.c (complete_command): Rework using
completion_tracker.  Catch exceptions when completing.
* cli/cli-decode.c (integer_unlimited_completer)
(complete_on_cmdlist, complete_on_enum): Adjust prototype and work
with completion_tracker instead of VEC.
* command.h (struct completion_tracker): Forward declare.
(completer_ftype, completer_handle_brkchars_ftype): Change
types.
(complete_on_cmdlist, complete_on_enum): Adjust.
* completer.c: Include <algorithm>.
(struct gdb_completer_state): New.
(current_completion): New global.
(readline_line_completion_function): Delete.
(noop_completer, filename_completer)
(filename_completer_handle_brkchars, complete_files_symbols)
(linespec_location_completer): Adjust to work with a
completion_tracker instead of a VEC.
(string_or_empty): New.
(collect_explicit_location_matches): Adjust to work with a
completion_tracker instead of a VEC.
(explicit_location_completer): Rename to ...
(complete_explicit_location): ... this and adjust to work with a
completion_tracker instead of a VEC.
(location_completer): Adjust to work with a completion_tracker
instead of a VEC.
(add_struct_fields): Adjust to work with a completion_list instead
of VEC.
(expression_completer): Rename to ...
(complete_expression): ... this and adjust to work with a
completion_tracker instead of a VEC.  Use complete_files_symbols.
(expression_completer): Reimplement on top of complete_expression.
(symbol_completer): Adjust to work with a completion_tracker
instead of a VEC.
(enum complete_line_internal_reason): Add describing comments.
(complete_line_internal_normal_command): Adjust to work with a
completion_tracker instead of a VEC.
(complete_line_internal): Rename to ...
(complete_line_internal_1): ... this and adjust to work with a
completion_tracker instead of a VEC.  Assert TEXT is NULL in the
handle_brkchars phase.
(new_completion_tracker): Delete.
(complete_line_internal): Reimplement as TRY/CATCH wrapper around
complete_line_internal_1.
(free_completion_tracker): Delete.
(INITIAL_COMPLETION_HTAB_SIZE): New.
(completion_tracker::completion_tracker)
(completion_tracker::~completion_tracker): New.
(maybe_add_completion): Delete.
(completion_tracker::maybe_add_completion)
(completion_tracker::add_completion)
(completion_tracker::add_completions): New.
(throw_max_completions_reached_error): Delete.
(complete_line): Adjust to work with a completion_tracker instead
of a VEC.  Don't create a completion_tracker_t or check for max
completions here.
(command_completer, command_completer_handle_brkchars)
(signal_completer, reg_or_group_completer_1)
(reg_or_group_completer, default_completer_handle_brkchars):
Adjust to work with a completion_tracker.
(gdb_completion_word_break_characters_throw): New.
(gdb_completion_word_break_characters): Reimplement.
(line_completion_function): Delete.
(completion_tracker::recompute_lowest_common_denominator)
(expand_preserving_ws)
(completion_tracker::build_completion_result)
(completion_result::completion_result)
(completion_result::completion_result)
(completion_result::~completion_result)
(completion_result::completion_result)
(completion_result::release_match_list, compare_cstrings)
(completion_result::sort_match_list)
(completion_result::reset_match_list)
(gdb_rl_attempted_completion_function_throw)
(gdb_rl_attempted_completion_function): New.
* completer.h (completion_list, struct completion_result)
(class completion_tracker): New.
(complete_line): Add completion_tracker parameter.
(readline_line_completion_function): Delete.
(gdb_rl_attempted_completion_function): New.
(noop_completer, filename_completer, expression_completer)
(location_completer, symbol_completer, command_completer)
(signal_completer, reg_or_group_completer): Update prototypes.
(completion_tracker_t, new_completion_tracker)
(make_cleanup_free_completion_tracker): Delete.
(enum maybe_add_completion_enum): Delete.
(maybe_add_completion): Delete.
(throw_max_completions_reached_error): Delete.
* corefile.c (complete_set_gnutarget): Adjust to work with a
completion_tracker instead of a VEC.
* cp-abi.c (cp_abi_completer): Adjust to work with a
completion_tracker instead of a VEC.
* d-lang.c (d_language_defn): Adjust.
* disasm.c (disassembler_options_completer): Adjust to work with a
completion_tracker instead of a VEC.
* f-lang.c (f_make_symbol_completion_list): Rename to ...
(f_collect_symbol_completion_matches): ... this.  Adjust to work
with a completion_tracker instead of a VEC.
(f_language_defn): Adjust.
* go-lang.c (go_language_defn): Adjust.
* guile/scm-cmd.c (cmdscm_add_completion, cmdscm_completer):
Adjust to work with a completion_tracker instead of a VEC.
* infrun.c (handle_completer): Likewise.
* interps.c (interpreter_completer): Likewise.
* interps.h (interpreter_completer): Likewise.
* language.c (unknown_language_defn, auto_language_defn)
(local_language_defn): Adjust.
* language.h (language_defn::la_make_symbol_completion_list):
Rename to ...
(language_defn::la_collect_symbol_completion_matches): ... this
and adjust to work with a completion_tracker instead of a VEC.
* m2-lang.c (m2_language_defn): Adjust.
* objc-lang.c (objc_language_defn): Adjust.
* opencl-lang.c (opencl_language_defn): Adjust.
* p-lang.c (pascal_language_defn): Adjust.
* python/py-cmd.c (cmdpy_completer_helper): Handle NULL word.
(cmdpy_completer_handle_brkchars, cmdpy_completer): Adjust to work
with a completion_tracker.
* rust-lang.c (rust_language_defn): Adjust.
* symtab.c (free_completion_list, do_free_completion_list)
(return_val, completion_tracker): Delete.
(completion_list_add_name, completion_list_add_symbol)
(completion_list_add_msymbol, completion_list_objc_symbol)
(completion_list_add_fields, add_symtab_completions): Add
completion_tracker parameter and use it.
(default_make_symbol_completion_list_break_on_1): Rename to...
(default_collect_symbol_completion_matches_break_on): ... this.
Add completion_tracker parameter and use it instead of allocating
a completion tracker here.
(default_make_symbol_completion_list_break_on): Delete old
implementation.
(default_make_symbol_completion_list): Delete.
(default_collect_symbol_completion_matches): New.
(make_symbol_completion_list): Delete.
(collect_symbol_completion_matches): New.
(make_symbol_completion_type): Rename to ...
(collect_symbol_completion_matches_type): ... this.  Add
completion_tracker parameter and use it instead of VEC.
(make_file_symbol_completion_list_1): Rename to...
(collect_file_symbol_completion_matches): ... this.  Add
completion_tracker parameter and use it instead of VEC.
(make_file_symbol_completion_list): Delete.
(add_filename_to_list): Use completion_list instead of a VEC.
(add_partial_filename_data::list): Now a completion_list.
(make_source_files_completion_list): Work with a completion_list
instead of a VEC.
* symtab.h: Include "completer.h".
(default_make_symbol_completion_list_break_on)
(default_make_symbol_completion_list, make_symbol_completion_list)
(make_symbol_completion_type, make_file_symbol_completion_list)
(make_source_files_completion_list): Delete.
(default_collect_symbol_completion_matches_break_on)
(default_collect_symbol_completion_matches)
(collect_symbol_completion_matches)
(collect_symbol_completion_matches_type)
(collect_file_symbol_completion_matches)
(make_source_files_completion_list): New.
* top.c (init_main): Don't install a rl_completion_entry_function
hook.  Install a rl_attempted_completion_function hook instead.
* tui/tui-layout.c (layout_completer): Adjust to work with a
completion_tracker.
* tui/tui-regs.c (tui_reggroup_completer):
* tui/tui-win.c (window_name_completer, focus_completer)
(winheight_completer): Adjust to work with a completion_tracker.
* value.c: Include "completer.h".
(complete_internalvar): Adjust to work with a completion_tracker.
* value.h (complete_internalvar): Likewise.

7 years agoClean up "completer_handle_brkchars" callback handling
Pedro Alves [Mon, 17 Jul 2017 11:05:03 +0000 (12:05 +0100)]
Clean up "completer_handle_brkchars" callback handling

This patch cleans up "completer_handle_brkchars" callback handling:

- Renames the function typedef to better match its intent:
  completer_ftype_void ->  completer_handle_brkchars_ftype

- Factors out common code in complete_line_internal handling the
  "handle_brkchars" callback to a separate function.

- Centralizes all the "completer method" to "handle_brkchars method"
  mapping in a single function.

gdb/ChangeLog:
2017-07-17  Pedro Alves  <palves@redhat.com>

* cli/cli-decode.c (set_cmd_completer_handle_brkchars): Adjust to
renames.
* cli/cli-decode.h (struct cmd_list_element) <completer>: Move
comments to completer_ftype's declaration.
<completer_handle_brkchars>: Change type to
completer_handle_brkchars_ftype.
* command.h (completer_ftype): Add describing comment and give
names to parameters.
(completer_ftype_void): Rename to ...
(completer_handle_brkchars_ftype) ... this.  Add describing comment.
(set_cmd_completer_handle_brkchars): Adjust.
* completer.c (filename_completer_handle_brkchars): New function.
(complete_line_internal_normal_command): New function, factored
out from ...
(complete_line_internal): ... here.
(command_completer_handle_brkchars)
(default_completer_handle_brkchars)
(completer_handle_brkchars_func_for_completer): New functions.
* completer.h (set_gdb_completion_word_break_characters): Delete
declaration.
(completer_handle_brkchars_func_for_completer): New declaration.
* python/py-cmd.c (cmdpy_completer_handle_brkchars): Adjust to use
completer_handle_brkchars_func_for_completer.

7 years agoRename make_symbol_completion_list_fn -> symbol_completer
Pedro Alves [Mon, 17 Jul 2017 10:55:42 +0000 (11:55 +0100)]
Rename make_symbol_completion_list_fn -> symbol_completer

"make_symbol_completion_list_fn" is odly named when you look at a list
of "standard" completers, like the Python/Guile completer lists
adjusted by this patch.  Rename / move it to completers.h/c, for
consistency.

gdb/ChangeLog:
2017-07-17  Pedro Alves  <palves@redhat.com>

* completer.c (symbol_completer): New function, based on
make_symbol_completion_list_fn.
* completer.h (symbol_completer): New declaration.
* guile/scm-cmd.c (cmdscm_completers): Adjust.
* python/py-cmd.c (completers): Adjust.
* symtab.c (make_symbol_completion_list_fn): Delete.
* symtab.h (make_symbol_completion_list_fn): Delete.
* cli/cli-decode.c (add_cmd): Adjust.

7 years agoFix TAB-completion + .gdb_index slowness (generalize filename_seen_cache)
Pedro Alves [Mon, 17 Jul 2017 10:28:33 +0000 (11:28 +0100)]
Fix TAB-completion + .gdb_index slowness (generalize filename_seen_cache)

Tab completion when debugging a program binary that uses GDB index is
surprisingly much slower than when GDB uses psymtabs instead.  Around
1.5x/3x slower.  That's surprising, because the whole point of GDB
index is to speed things up...

For example, with:

 set pagination off
 set $count = 0
 while $count < 400
   complete b string_prin         # matches gdb's string_printf
   printf "count = %d\n", $count
   set $count = $count + 1
 end

 $ time ./gdb --batch -q  ./gdb-with-index -ex "source script.cmd"
 real    0m11.042s
 user    0m10.920s
 sys     0m0.042s

 $ time ./gdb --batch -q  ./gdb-without-index -ex "source script.cmd"
 real    0m4.635s
 user    0m4.590s
 sys     0m0.037s

Same but with:
 -   complete b string_prin
 +   complete b zzzzzz
to exercise the no-matches worst case, master currently gets you
something like:

 with index           without index
 real    0m11.971s    0m8.413s
 user    0m11.912s    0m8.355s
 sys     0m0.035s     0m0.035s

Running gdb under perf shows 80% spent inside
maybe_add_partial_symtab_filename, and 20% spent in the lbasename
inside that.

The problem that tab completion walks over all compunit symtabs, and
for each, walks the contained file symtabs.  And there a huge number
of file symtabs (each included system header, etc.) that appear in
each compunit symtab's file symtab list.  As in, when debugging GDB, I
have 367381 symtabs iterated, when of those only 5371 filenames are
unique...

This was a regression from the earlier (nice) split of symtabs in
compunit symtabs + file symtabs.

The fix here is to add a cache of unique filenames per objfile so that
the walk / uniquing is only done once.  There's already a abstraction
for this in symtab.c; this patch moves that code out to a separate
file and C++ifies it bit.

This makes the worst-case scenario above consistently drop to ~2.5s
(1.5s for the "string_prin" hit case), making it over 3.3x times
faster than psymtabs in this use case (7x in the "string_prin" hit
case).

gdb/ChangeLog:
2017-07-17  Pedro Alves  <palves@redhat.com>

* Makefile.in (COMMON_OBS): Add filename-seen-cache.o.
* dwarf2read.c: Include "filename-seen-cache.h".
* dwarf2read.c (dwarf2_per_objfile) <filenames_cache>: New field.
(dw2_map_symbol_filenames): Build and use a filenames_seen_cache.
* filename-seen-cache.c: New file.
* filename-seen-cache.h: New file.
* symtab.c: Include "filename-seen-cache.h".
(struct filename_seen_cache, INITIAL_FILENAME_SEEN_CACHE_SIZE)
(create_filename_seen_cache, clear_filename_seen_cache)
(delete_filename_seen_cache, filename_seen): Delete, parts moved
to filename-seen-cache.h/filename-seen-cache.c.
(output_source_filename, sources_info)
(maybe_add_partial_symtab_filename)
(make_source_files_completion_list): Adjust to use
filename_seen_cache.

7 years agoC++ify dwarf2_per_objfile
Pedro Alves [Mon, 17 Jul 2017 10:31:20 +0000 (11:31 +0100)]
C++ify dwarf2_per_objfile

This makes dwarf2_per_objfile a class with cdtors.

A following patch will add a non-trivial field to struct
dwarf2_per_objfile, making dwarf2_per_objfile itself non-trivial.
Since dwarf2_per_objfile is allocated in an obstack, we need to run
its cdtors manually.

Tested on x86-64 GNU/Linux.

gdb/ChangeLog:
2017-07-17  Pedro Alves  <palves@redhat.com>

* dwarf2read.c (dwarf2_per_objfile): In-class initialize all
fields.
(dwarf2_per_objfile::dwarf2_per_objfile(objfile*, const
dwarf2_debug_sections*)): New.
(dwarf2_per_objfile::dwarf2_per_objfile(const
dwarf2_per_objfile&)): Declare as deleted.
(dwarf2_per_objfile::operator=): Declare as deleted.
(dwarf2_per_objfile::dwarf2_per_objfile)
(dwarf2_per_objfile::~dwarf2_per_objfile)
(dwarf2_per_objfile::free_cached_comp_units): New.
(dwarf2_has_info): dwarf2_per_objfile initialization code moved to
ctor.  Call dwarf2_per_objfile's ctor manually.
(dwarf2_locate_sections): Deleted/refactored as ...
(dwarf2_per_objfile::locate_sections): ... this new method.
(free_cached_comp_units): Defer to
dwarf2_per_objfile::free_cached_comp_units.
(dwarf2_free_objfile): Call dwarf2_per_objfile's dtor manually.

7 years agoCorrect previous fix for an absence of input files on the ar command line, so that...
Nick Clifton [Mon, 17 Jul 2017 09:51:45 +0000 (10:51 +0100)]
Correct previous fix for an absence of input files on the ar command line, so that a complaint is not issued in MRI mode.

PR 21433
* ar.c (main): Skip check for no files on the command line when
running in MRI mode.

7 years agoUpdate assembler documentation on some AVR cores.
Georg-Johann Lay [Mon, 17 Jul 2017 09:23:10 +0000 (10:23 +0100)]
Update assembler documentation on some AVR cores.

PR 21472
* config/tc-avr.c (mcu_types): Add entries for: attiny212,
attiny214, attiny412, attiny414, attiny814, attiny1614,
attiny1616, attiny1617, attiny3214, attiny3216, attiny3217.
(md_show_usage): Adjust doc for "avrxmega3".
* doc/c-avr.texi (AVR options) [-mmcu=]: Adjust doc for avrxmega3.
Add MCUs: attiny212, attiny214, attiny412, attiny414, attiny416,
attiny417, attiny814, attiny816, attiny817, attiny1614,
attiny1616, attiny1617, attiny3214, attiny3216, attiny3217.

7 years agoAutomatic date update in version.in
GDB Administrator [Mon, 17 Jul 2017 00:00:58 +0000 (00:00 +0000)]
Automatic date update in version.in

7 years ago__tls_get_addr_opt GOT entries
Alan Modra [Sun, 16 Jul 2017 02:20:52 +0000 (11:50 +0930)]
__tls_get_addr_opt GOT entries

My 2017-01-24 patch (commit f0158f44) wrongly applied an optimization
of GOT entries for the __tls_get_addr_opt stub, to shared libraries.

When the TLS segment layout is known, as it is for the executable and
shared libraries loaded at initial program start, powerpc supports a
__tls_get_addr optimization.  On the first call to __tls_get_addr for
a given __tls_index GOT entry, the DTPMOD word is set to zero and the
DTPREL word to the thread pointer offset to the thread variable.  This
allows the __tls_get_addr_opt stub to return that value immediately
without making a call into glibc for any subsequent __tls_get_addr
calls using that __tls_index GOT entry.

That's all fine, but I thought I'd be clever and when the thread
variable is local, set up the GOT entry as if __tls_get_addr had
already been called.  Which is good only for the executable, since ld
cannot know the TLS layout for shared libraries.

Of course, if this only applies to executables there isn't much point
to the optimization.  Normally, GD and LD code in an executable will
be converted to IE or LE, losing the __tls_get_addr call.  So the only
time it will trigger is with --no-tls-optimize.  Thus, revert all
support.

* elf64-ppc.c (ppc64_elf_relocate_section): Don't optimize
__tls_index GOT entries when using __tls_get_addr_opt stub.
* elf32-ppc.c (ppc_elf_relocate_section): Likewise.

7 years agoAutomatic date update in version.in
GDB Administrator [Sun, 16 Jul 2017 00:00:55 +0000 (00:00 +0000)]
Automatic date update in version.in

7 years agogdb: Make some test names unique
Andrew Burgess [Wed, 14 Jun 2017 18:52:32 +0000 (19:52 +0100)]
gdb: Make some test names unique

Make sure all of the tests have unique names in
gdb.mi/mi-vla-fortran.exp.

gdb/testsuite/ChangeLog:

* gdb.mi/mi-vla-fortran.exp: Make test names unique.

7 years agoAutomatic date update in version.in
GDB Administrator [Sat, 15 Jul 2017 00:00:42 +0000 (00:00 +0000)]
Automatic date update in version.in

7 years agoHandle sizeof(type) in Rust
Tom Tromey [Fri, 14 Jul 2017 14:10:39 +0000 (08:10 -0600)]
Handle sizeof(type) in Rust

PR rust/21764 notes that "sizeof" does not work correctly for all types
in Rust.  The bug turns out to be an error in the conversion of the AST
to gdb expressions.  This patch fixes the bug and also avoids generating
incorrect expressions in another case.

Tested on the buildbot.  I'm checking this in.

2017-07-14  Tom Tromey  <tom@tromey.com>

PR rust/21764:
* rust-exp.y (convert_ast_to_expression): Add "want_type"
parameter.
<UNOP_SIZEOF>: Split into separate case.
<UNOP_VAR_VALUE>: Handle want_type.  Add error case.

2017-07-14  Tom Tromey  <tom@tromey.com>

PR rust/21764:
* gdb.rust/simple.exp: Add tests.

7 years agoMake gdb.lookup_typename work for Rust types
Tom Tromey [Thu, 13 Jul 2017 21:03:27 +0000 (15:03 -0600)]
Make gdb.lookup_typename work for Rust types

PR rust/21763 points out that gdb.lookup_typename does not work properly
for (some) Rust types.  I tracked this down to a missing case in
symbol_matches_domain.

Tested by the buildbot.

2017-07-14  Tom Tromey  <tom@tromey.com>

PR rust/21763:
* symtab.c (symbol_matches_domain): Add language_rust to special
case.
* rust-exp.y (convert_ast_to_expression) <OP_VAR_VALUE>: Don't
treat LOC_TYPEDEF symbols as variables.

2017-07-14  Tom Tromey  <tom@tromey.com>

* gdb.rust/simple.exp: Add regression test for PR rust/21763.

7 years agoFix gdb.base/completion.exp with --target_board=dwarf4-gdb-index
Pedro Alves [Fri, 14 Jul 2017 15:50:35 +0000 (16:50 +0100)]
Fix gdb.base/completion.exp with --target_board=dwarf4-gdb-index

This is the same patch as posted at
<https://sourceware.org/ml/gdb-patches/2017-02/msg00644.html>, with
the test at
<https://sourceware.org/ml/gdb-patches/2017-02/msg00687.html> squashed
in.

This patch fixes:

 -FAIL: gdb.base/completion.exp: tab complete break break.c:ma (timeout)
 -FAIL: gdb.base/completion.exp: complete break break.c:ma
 +PASS: gdb.base/completion.exp: tab complete break break.c:ma
 +PASS: gdb.base/completion.exp: delete breakpoint for tab complete break break.c:ma
 +PASS: gdb.base/completion.exp: complete break break.c:ma

When run with --target_board=dwarf4-gdb-index.

The issue here is that make_file_symbol_completion_list_1, used when
completing a symbol restricted to a given source file, uses
lookup_symtab to look up the symtab with the given name, and search
for matching symbols inside.  This assumes that there's only one
symtab for the given source file.  This is an incorrect assumption
with (for example) -fdebug-types-section, where we'll have an extra
extra symtab containing the types.  lookup_symtab finds that symtab,
and inside that symtab there are no functions...

gdb/ChangeLog:
2017-07-14  Pedro Alves  <palves@redhat.com>

* symtab.c (make_file_symbol_completion_list_1): Iterate over
symtabs matching all symtabs with SRCFILE as file name instead of
only considering the first hit, with lookup_symtab.

gdb/testsuite/ChangeLog:
2017-07-14  Pedro Alves  <palves@redhat.com>

* gdb.linespec/base/one/thefile.cc (z1): New function.
* gdb.linespec/base/two/thefile.cc (z2): New function.
* gdb.linespec/linespec.exp: Add tests.

7 years agobinutils/objdump: Fix disassemble for huge elf sections
Ravi Bangoria [Fri, 14 Jul 2017 07:56:27 +0000 (13:26 +0530)]
binutils/objdump: Fix disassemble for huge elf sections

When elf section size is beyond unsigned int max value, objdump fails
to disassemble from that section. Ex on PowerPC,

  $ objdump -h /proc/kcore
    Idx  Name   Size       VMA
      4  load2  100000000  c000000000000000

Here, size of load2 section is 0x100000000. Also note that, 0xc00....
address range is kernel space for PowerPC. Now let's try to disassemble
do_sys_open() using /proc/kcore.

  $ cat /proc/kallsyms | grep -A1 -w do_sys_open
    c00000000036c000 T do_sys_open
    c00000000036c2d0 T SyS_open

Before patch:

  $ objdump -d --start-address=0xc00000000036c000 --stop-address=0xc00000000036c2d0 /proc/kcore
    /proc/kcore:    file format elf64-powerpcle

    Disassembly of section load2:

    c00000000036c000 <load2+0x36c000>:
    c00000000036c000:    Address 0xc00000000036c000 is out of bounds.

Fix this by changing type of 'buffer_length' from unsigned int to
size_t. After patch:

  $ objdump -d --start-address=0xc00000000036c000 --stop-address=0xc00000000036c2d0 /proc/kcore
    /proc/kcore:    file format elf64-powerpcle

    Disassembly of section load2:

    c00000000036c000 <load2+0x36c000>:
    c00000000036c000: fc 00 4c 3c     addis   r2,r12,252
    c00000000036c004: 00 53 42 38     addi    r2,r2,21248
    c00000000036c008: a6 02 08 7c     mflr    r0

include/
* dis-asm.h (struct disassemble_info): Change type of buffer_length
field to size_t.
opcodes/
* dis-buf.c (buffer_read_memory): Change type of end_addr_offset,
max_addr_offset and octets variables to size_t.

7 years agoppc32 tlsopt tests
Alan Modra [Fri, 14 Jul 2017 09:07:26 +0000 (18:37 +0930)]
ppc32 tlsopt tests

These all were odd in that they used r13 as the GOT pointer.  That
didn't matter for the purpose of testing, but would never occur in
practice.  Also, the tlsopt5 tests could have their global dynamic
sequences optimized to initial exec, so link with -shared.

* testsuite/ld-powerpc/powerpc.exp: Add -shared to tlsop5 tests.
* testsuite/ld-powerpc/tlsopt5.d: Adjust.
* testsuite/ld-powerpc/tlsopt1_32.s: Use r30 as GOT pointer.
* testsuite/ld-powerpc/tlsopt2_32.s: Likewise.
* testsuite/ld-powerpc/tlsopt3_32.s: Likewise.
* testsuite/ld-powerpc/tlsopt4_32.s: Likewise.
* testsuite/ld-powerpc/tlsopt5_32.s: Rewrite.
* testsuite/ld-powerpc/tlsopt1_32.d: Adjust.
* testsuite/ld-powerpc/tlsopt2_32.d: Adjust.
* testsuite/ld-powerpc/tlsopt3_32.d: Adjust.
* testsuite/ld-powerpc/tlsopt5_32.d: Adjust.

7 years agoPR ld/21529: Use a linker script to limit output with the test case
Maciej W. Rozycki [Fri, 14 Jul 2017 10:53:08 +0000 (11:53 +0100)]
PR ld/21529: Use a linker script to limit output with the test case

Complement commit d9409498813c ("Add a testcase for PR ld/21529") and
use a linker script to prevent an inter-segment gap arranged by the
default linker script associated with some targets such as `rx-elf':

$ ld -e main -o tmpdir/dump-elf tmpdir/pr21529.o
$ readelf -l tmpdir/dump-elf
Elf file type is EXEC (Executable file)
Entry point 0x10000004
There are 2 program headers, starting at offset 52

Program Headers:
  Type           Offset   VirtAddr   PhysAddr   FileSiz MemSiz  Flg Align
  LOAD           0x001000 0x10000000 0x10000000 0x00008 0x00008 R E 0x1000
  LOAD           0x001ffc 0xbffffffc 0xbffffffc 0x00004 0x00004 RW  0x1000

 Section to Segment mapping:
  Segment Sections...
   00     .text
   01     .stack
$

and converted to padding with the use of the binary BFD for output from
producing unreasonably large files.

ld/
* testsuite/ld-unique/pr21529.ld: New test linker script.
* testsuite/ld-unique/pr21529.d: Use it.

7 years agoax-gdb: Remove more unused arguments
Simon Marchi [Fri, 14 Jul 2017 10:47:40 +0000 (12:47 +0200)]
ax-gdb: Remove more unused arguments

gdb/ChangeLog:

* ax-gdb.c (gen_aggregate_elt_ref): Remove operand_name and
operator_name parameters.
(gen_expr): Update function call.

7 years agoax-gdb: Remove unnecessary gdbarch parameters
Simon Marchi [Fri, 14 Jul 2017 10:47:40 +0000 (12:47 +0200)]
ax-gdb: Remove unnecessary gdbarch parameters

In multiple places, we pass the gdbarch as an argument to some
functions, even though it's available in the agent_expr structure also
passed to the same functions.  Remove these arguments and replace their
usage with accesses to agent_expr::gdbarch.

gdb/ChangeLog:

* dwarf2loc.h (dwarf2_compile_expr_to_ax): Remove gdbarch
parameter.
* symtab.h (struct symbol_computed_ops::tracepoint_var_ref):
Likewise.
* dwarf2loc.c (dwarf2_compile_expr_to_ax): Remove gdbarch
parameter, use agent_expr::gdbarch instead, update function
calls.
(locexpr_tracepoint_var_ref): Likewise.
(loclist_tracepoint_var_ref): Likewise.
* ax-gdb.c (gen_trace_static_fields): Likewise.
(gen_traced_pop): Likewise.
(gen_frame_args_address): Likewise.
(gen_frame_locals_address): Likewise.
(gen_var_ref): Likewise.
(gen_struct_ref_recursive): Likewise.
(gen_static_field): Likewise.
(gen_maybe_namespace_elt): Likewise.
(gen_expr): Likewise.
(gen_trace_for_var): Likewise.
(gen_trace_for_expr): Likewise.
(gen_trace_for_return_address): Likewise.

7 years agoax-gdb: Remove two unused agent_expr *ax parameters
Simon Marchi [Fri, 14 Jul 2017 10:47:39 +0000 (12:47 +0200)]
ax-gdb: Remove two unused agent_expr *ax parameters

gdb/ChangeLog:

* ax-gdb.c (gen_deref, gen_address_of): Remove unused ax
parameter.
(gen_struct_ref, gen_expr, gen_expr_binop_rest): Update call.

7 years agoax-gdb: Use ax->gdbarch instead of exp->gdbarch, remove unused parameters
Simon Marchi [Fri, 14 Jul 2017 10:47:39 +0000 (12:47 +0200)]
ax-gdb: Use ax->gdbarch instead of exp->gdbarch, remove unused parameters

In many ax generation functions, the "expression *exp" parameter is only
used to access the gdbarch.  The same value can be found in the
"agent_expr *ax" parameter, which needs to be passed in any case.  By
using ax->gdbarch instead of exp->gdbarch, we can avoid passing exp in
many of these functions.

gdb/ChangeLog:

* ax-gdb.c (gen_usual_unary): Remove exp parameter, get gdbarch
from ax, update calls.
(gen_usual_arithmetic): Likewise.
(gen_integral_promotions): Likewise.
(gen_bitfield_ref): Likewise.
(gen_primitive_field): Likewise.
(gen_struct_ref_recursive): Likewise.
(gen_struct_ref): Likewise.
(gen_maybe_namespace_elt): Likewise.
(gen_struct_elt_for_reference): Likewise.
(gen_namespace_elt): Likewise.
(gen_aggregate_elt_ref): Likewise.
(gen_expr): Get gdbarch from ax, update calls.
(gen_expr_binop_rest): Likewise.

7 years agoAutomatic date update in version.in
GDB Administrator [Fri, 14 Jul 2017 00:00:47 +0000 (00:00 +0000)]
Automatic date update in version.in

7 years agoAdd RDMA support for falkot/qdf24xx.
Jim Wilson [Thu, 13 Jul 2017 21:40:22 +0000 (14:40 -0700)]
Add RDMA support for falkot/qdf24xx.

gas/
* config/tc-arch64.c (aarch64_cpus): Add AARCH64_FEATURE_RDMA to
falkor and qdf24xx entries.

7 years agogdb: Fix more parameter passing to mi_create_breakpoint
Andrew Burgess [Thu, 13 Jul 2017 19:55:11 +0000 (20:55 +0100)]
gdb: Fix more parameter passing to mi_create_breakpoint

In the test gdb.mi/mi-vla-fortran.exp the parameters passed to
mi_create_breakpoint are passed in the wrong order.  By good luck the
tests still passes, however the wrong test name is used.  All fixed in
this commit.

A previous commit fixed most of these, but I missed this last one.

gdb/testsuite/ChangeLog:

* gdb.mi/mi-vla-fortran.exp: Correct even more parameter passing
to mi_create_breakpoint.

7 years agoFix x86-64 GNU/Linux crashes
Pedro Alves [Thu, 13 Jul 2017 19:56:42 +0000 (20:56 +0100)]
Fix x86-64 GNU/Linux crashes

Ref: https://sourceware.org/ml/gdb-patches/2017-07/msg00162.html

Debugging x86-64 GNU/Linux programs currently crashes GDB in
tdesc_use_registers during gdbarch initialization:

  Program received signal SIGSEGV, Segmentation fault.
  0x0000000001093eaf in htab_remove_elt_with_hash (htab=0x2ef9fa0, element=0x26af960, hash=557151073) at src/libiberty/hashtab.c:728
  728       if (*slot == HTAB_EMPTY_ENTRY)
  (top-gdb) p slot
  $1 = (void **) 0x0
  (top-gdb) bt
  #0  0x0000000001093eaf in htab_remove_elt_with_hash (htab=0x2ef9fa0, element=0x26af960, hash=557151073) at src/libiberty/hashtab.c:728
  #1  0x0000000001093e79 in htab_remove_elt (htab=0x2ef9fa0, element=0x26af960) at src/libiberty/hashtab.c:714
  #2  0x00000000009121b0 in tdesc_use_registers (gdbarch=0x3001240, target_desc=0x2659cb0, early_data=0x2881cb0)
      at src/gdb/target-descriptions.c:1328
  #3  0x000000000047c93e in i386_gdbarch_init (info=..., arches=0x0) at src/gdb/i386-tdep.c:8634
  #4  0x0000000000818d5f in gdbarch_find_by_info (info=...) at src/gdb/gdbarch.c:5394
  #5  0x00000000007198a8 in set_gdbarch_from_file (abfd=0x2f48250) at src/gdb/arch-utils.c:618
  #6  0x00000000007f21cb in exec_file_attach (filename=0x7fffffffddb0 "/home/pedro/gdb/tests/threads", from_tty=1) at src/gdb/exec.c:380
  #7  0x0000000000865c18 in catch_command_errors_const (command=0x7f1d83 <exec_file_attach(char const*, int)>, arg=0x7fffffffddb0 "/home/pedro/gdb/tests/threads",
      from_tty=1) at src/gdb/main.c:403
  #8  0x00000000008669cf in captured_main_1 (context=0x7fffffffd860) at src/gdb/main.c:1035
  #9  0x0000000000866de2 in captured_main (data=0x7fffffffd860) at src/gdb/main.c:1142
  #10 0x0000000000866e24 in gdb_main (args=0x7fffffffd860) at src/gdb/main.c:1160
  #11 0x000000000041312d in main (argc=3, argv=0x7fffffffd968) at src/gdb/gdb.c:32

The direct cause of the crash is that we tried to remove an element
from the hash which supposedly exists, but does not.  (htab_remove_elt
shouldn't really crash in this case, but that's secondary.)

The real problem is that early_data passed to tdesc_use_registers
includes regs from a target description that is not the target_desc,
which violates its assumptions.  The registers in question are the
fs_base/gs_base registers, added by amd64_init_abi:

      tdesc_numbered_register (feature, tdesc_data_segments,
       AMD64_FSBASE_REGNUM, "fs_base");
      tdesc_numbered_register (feature, tdesc_data_segments,
       AMD64_GSBASE_REGNUM, "gs_base");

and that happens because amd64_linux_init_abi uses amd64_init_abi as
helper, but they don't coordinate on which fallback tdesc to use.

amd64_init_abi does:

  if (! tdesc_has_registers (tdesc))
    tdesc = tdesc_amd64;

and then adds the fs_base/gs_base registers of the "tdesc_amd64" tdesc
to the tdesc_arch_data.

After amd64_init_abi returns, amd64_linux_init_abi does:

  if (! tdesc_has_registers (tdesc))
    tdesc = tdesc_amd64_linux;
  tdep->tdesc = tdesc;

and we end up tdesc_amd64_linux installed in tdep->tdesc.

The fix is to make sure that amd64_linux_init_abi and amd64_init_abi
agree on default tdesc, by adding a "default tdesc" parameter to
amd64_init_abi, instead of having amd64_init_abi hardcode a default.
With this, amd64_init_abi creates the fs_base/gs_base registers using
the tdesc_amd64_linux tdesc.

Tested on x86-64 GNU/Linux, -m64.  I don't have an x32 setup handy.

Thanks to John Baldwin, Yao Qi and Simon Marchi for the investigation.

gdb/ChangeLog:
2017-07-13  Pedro Alves  <palves@redhat.com>

* amd64-darwin-tdep.c (x86_darwin_init_abi_64): Pass tdesc_amd64
as default tdesc.
* amd64-dicos-tdep.c (amd64_dicos_init_abi):
* amd64-fbsd-tdep.c (amd64fbsd_init_abi):
* amd64-linux-tdep.c (amd64_linux_init_abi): Pass
tdesc_amd64_linux as default tdesc.  Get final tdesc from the
tdep.
(amd64_x32_linux_init_abi): Pass tdesc_x32_linux as default tdesc.
Get final tdesc from the tdep.
* amd64-nbsd-tdep.c (amd64nbsd_init_abi): Pass tdesc_amd64 as
default tdesc.
* amd64-obsd-tdep.c (amd64obsd_init_abi): Likewise.
* amd64-sol2-tdep.c (amd64_sol2_init_abi): Likewise.
* amd64-tdep.c (amd64_init_abi): Add 'default_tdesc' parameter.
Use it as default tdesc.
(amd64_x32_init_abi): Add 'default_tdesc' parameter, and pass it
down to amd_init_abi.  No longer handle fallback tdesc here.
* amd64-tdep.h (tdesc_x32): Declare.
(amd64_init_abi, amd64_x32_init_abi): Add 'default_tdesc'
parameter.
* amd64-windows-tdep.c (amd64_windows_init_abi): Pass tdesc_amd64
as default tdesc.

7 years agogdb: Fix parameter passing to mi_create_breakpoint
Andrew Burgess [Wed, 14 Jun 2017 18:47:52 +0000 (19:47 +0100)]
gdb: Fix parameter passing to mi_create_breakpoint

In the test gdb.mi/mi-vla-fortran.exp the parameters passed to
mi_create_breakpoint are passed in the wrong order.  By good luck the
tests still passes, however the wrong test name is used.  All fixed in
this commit.

gdb/testsuite/ChangeLog:

* gdb.mi/mi-vla-fortran.exp: Correct parameter passing to
mi_create_breakpoint.

7 years agoS390: Add record/replay support for arch12 instructions
Andreas Arnez [Thu, 13 Jul 2017 18:17:03 +0000 (20:17 +0200)]
S390: Add record/replay support for arch12 instructions

Support record/replay of the z/Architecture instructions that were
introduced with arch12.

gdb/ChangeLog:

* s390-linux-tdep.c (s390_process_record): Add support for
instructions new in arch12.

7 years agoAlways delete $testarchive first
H.J. Lu [Thu, 13 Jul 2017 15:10:57 +0000 (08:10 -0700)]
Always delete $testarchive first

Always delete $testarchive first so that it exists only when it is
supported,

* testsuite/binutils-all/objdump.exp: Always delete $testarchive
first.

7 years agoAutomatic date update in version.in
GDB Administrator [Thu, 13 Jul 2017 00:00:50 +0000 (00:00 +0000)]
Automatic date update in version.in

7 years agoAdd missing gold/ChangeLog entry.
Cary Coutant [Wed, 12 Jul 2017 14:24:37 +0000 (07:24 -0700)]
Add missing gold/ChangeLog entry.

7 years agoUpdate PO files
Alan Modra [Wed, 12 Jul 2017 12:49:58 +0000 (22:19 +0930)]
Update PO files

bfd/
* po/es.po: Update from translationproject.org/latest/bfd/.
* po/fi.po: Likewise.
* po/fr.po: Likewise.
* po/id.po: Likewise.
* po/ja.po: Likewise.
* po/ro.po: Likewise.
* po/ru.po: Likewise.
* po/sr.po: Likewise.
* po/sv.po: Likewise.
* po/tr.po: Likewise.
* po/uk.po: Likewise.
* po/vi.po: Likewise.
* po/zh_CN.po: Likewise.
* po/hr.po: New file from translationproject.org.
* configure.ac (ALL_LINGUAS): Add hr.  Sort.
* configure: Regenerate.

binutils/
* po/bg.po: Update from translationproject.org/latest/binutils/.
* po/ca.po: Likewise.
* po/da.po: Likewise.
* po/es.po: Likewise.
* po/fi.po: Likewise.
* po/fr.po: Likewise.
* po/hr.po: Likewise.
* po/id.po: Likewise.
* po/it.po: Likewise.
* po/ja.po: Likewise.
* po/ro.po: Likewise.
* po/ru.po: Likewise.
* po/sk.po: Likewise.
* po/sr.po: Likewise.
* po/sv.po: Likewise.
* po/tr.po: Likewise.
* po/uk.po: Likewise.
* po/vi.po: Likewise.
* po/zh_CN.po: Likewise.
* po/zh_TW.po: Likewise.

gas/
* po/es.po: Update from translationproject.org/latest/gas/.
* po/fi.po: Likewise.
* po/fr.po: Likewise.
* po/id.po: Likewise.
* po/ja.po: Likewise.
* po/ru.po: Likewise.
* po/sv.po: Likewise.
* po/tr.po: Likewise.
* po/uk.po: Likewise.
* po/zh_CN.po: Likewise.

gold/
* po/es.po: Update from translationproject.org/latest/gold/.
* po/fi.po: Likewise.
* po/fr.po: Likewise.
* po/id.po: Likewise.
* po/it.po: Likewise.
* po/vi.po: Likewise.
* po/zh_CN.po: Likewise.
* po/ja.po: New file from translationproject.org.
* po/sv.po: Likewise.
* po/uk.po: Likewise.

gprof/
* po/bg.po: Update from translationproject.org/latest/gprof/.
* po/da.po: Likewise.
* po/de.po: Likewise.
* po/eo.po: Likewise.
* po/es.po: Likewise.
* po/fi.po: Likewise.
* po/fr.po: Likewise.
* po/ga.po: Likewise.
* po/hu.po: Likewise.
* po/id.po: Likewise.
* po/it.po: Likewise.
* po/ja.po: Likewise.
* po/ms.po: Likewise.
* po/nl.po: Likewise.
* po/pt_BR.po: Likewise.
* po/ro.po: Likewise.
* po/ru.po: Likewise.
* po/sr.po: Likewise.
* po/sv.po: Likewise.
* po/tr.po: Likewise.
* po/uk.po: Likewise.
* po/vi.po: Likewise.

ld/
* po/bg.po: Update from translationproject.org/latest/ld/.
* po/da.po: Likewise.
* po/es.po: Likewise.
* po/fi.po: Likewise.
* po/fr.po: Likewise.
* po/id.po: Likewise.
* po/it.po: Likewise.
* po/ja.po: Likewise.
* po/tr.po: Likewise.
* po/uk.po: Likewise.
* po/vi.po: Likewise.
* po/zh_CN.po: Likewise.
* po/zh_TW.po: Likewise.
* po/de.po: New file from translationproject.org.
* po/ru.po: Likewise.
* configure.ac (ALL_LINGUAS): Add de, ru.  Sort.
* configure: Regenerate.

opcodes/
* po/da.po: Update from translationproject.org/latest/opcodes/.
* po/de.po: Likewise.
* po/es.po: Likewise.
* po/fi.po: Likewise.
* po/fr.po: Likewise.
* po/id.po: Likewise.
* po/it.po: Likewise.
* po/nl.po: Likewise.
* po/pt_BR.po: Likewise.
* po/ro.po: Likewise.
* po/sv.po: Likewise.
* po/tr.po: Likewise.
* po/uk.po: Likewise.
* po/vi.po: Likewise.
* po/zh_CN.po: Likewise.

7 years agoFix compile time warnings building the binutils with gcc 7.1.1.
Nick Clifton [Wed, 12 Jul 2017 11:17:02 +0000 (12:17 +0100)]
Fix compile time warnings building the binutils with gcc 7.1.1.

bfd * elf32-xtensa.c (elf_xtensa_get_plt_section): Increase length of
plt_name buffer.
(elf_xtensa_get_gotplt_section): Increase length of got_name
buffer.
* mach-o-arm.c (bfd_mach_o_arm_canonicalize_one_reloc): Add a
default return of FALSE.
* mach-o-i386.c (bfd_mach_o_i386_canonicalize_one_reloc): Add a
default return of FALSE.

binutils * dwarf.c (dwarf_vmatoa_1): Do not pass a NULL string pointer to
sprintf.
* srconv.c (walk_tree_type): Initialise the spare field of the
IT_dty structure.

gas * config/tc-pru.c (md_assemble): Add continue statement after
handling 'E' operand character.
* config/tc-v850.c (md_assemble): Initialise the 'insn' variable.

7 years agors6000 testsuite update
Alan Modra [Wed, 12 Jul 2017 09:52:30 +0000 (19:22 +0930)]
rs6000 testsuite update

* testsuite/ld-scripts/align.exp: Exclude powerpc*-*-aix*.
* testsuite/ld-scripts/assign-loc.d: Likewise.
* testsuite/ld-scripts/defined3.d: Likewise.
* testsuite/ld-scripts/defined4.d: Likewise.
* testsuite/ld-scripts/defined5.d: Likewise.
* testsuite/ld-scripts/expr2.d: Likewise.
* testsuite/ld-scripts/provide.exp: Likewise.
* testsuite/ld-scripts/sane1.d: Likewise.
* testsuite/ld-scripts/size.exp: Likewise.
* testsuite/ld-scripts/defined2.d: Don't xfail rs6000-*-aix*.

7 years agobfd_error_handler bfd_vma and bfd_size_type args
Alan Modra [Sun, 9 Jul 2017 13:41:32 +0000 (23:11 +0930)]
bfd_error_handler bfd_vma and bfd_size_type args

This patch uses the new %L _bfd_error_handler support for printing
bfd_vma arguments, and fixes a many other format and/or argument
errors in error messages.

bfd/
* binary.c (binary_set_section_contents): Don't print filepos in
error message.
(coff_write_object_contents): Cast size_t for error message.
(coff_slurp_line_table): Don't use bfd_vma symndx.
(coff_slurp_reloc_table): Remove unneeded cast.
* dwarf2.c (read_section): Cast bfd_int64_t to long long for
error message.
(find_abstract_instance_name): Likewise.
* elf32-arm.c (arm_type_of_stub): Correct error arg order.
(bfd_elf32_arm_stm32l4xx_erratum_scan): Don't cast error arg.
(elf32_arm_check_relocs): Make r_symndx an int.
* elf32-cris.c (cris_elf_check_relocs): Delete extraneous %s in
format string.
* elf32-metag.c (elf_metag_relocate_section): Delete extra error
message arg.
* elf32-nds32.c (nds32_elf_ex9_build_hash_table): Rewrite bogus
error message.
* elf32-i386.c (elf_i386_check_relocs): Make r_symndx an int.
* elf32-s390.c (elf_s390_check_relocs): Likewise.
* elf32-tic6x.c (elf32_tic6x_check_relocs): Likewise.
* elf32-tilepro.c (tilepro_elf_check_relocs): Likewise.
* elf32-xtensa.c (elf_xtensa_check_relocs): Likewise.
* elf64-s390.c (elf_s390_check_relocs): Likewise.
* elf64-x86-64.c (elf_x86_64_check_relocs): Likewise.
* elfnn-aarch64.c (elfNN_aarch64_check_relocs): Likewise.
* elfnn-riscv.c (riscv_elf_check_relocs): Likewise.
* elfxx-sparc.c (_bfd_sparc_elf_check_relocs): Likewise.
* elfxx-tilegx.c (tilegx_elf_check_relocs): Likewise.
* elf64-mmix.c (_bfd_mmix_after_linker_allocation): Cast size_t args
and use %lu for error message.
* elflink.c (elf_link_adjust_relocs): Delete extra error message arg.
* mmo.c (mmo_scan): Make stab_loc a file_ptr.  Cast expression for
error message.

* elf32-arm.c (elf32_arm_tls_relax): Correct format string and args
in error message.
(elf32_arm_final_link_relocate): Likewise.
* coff-arm.c (bfd_arm_process_before_allocation): Likewise.
* coffcode.h (styp_to_sec_flags): Likewise.
* cofflink.c (_bfd_coff_write_global_sym): Likewise.
* ecoff.c (_bfd_ecoff_slurp_symbol_table): Likewise.
* elf32-arc.c (arc_elf_merge_private_bfd_data): Likewise.
* elf32-bfin.c (bfinfdpic_check_relocs): Likewise.
(elf32_bfin_merge_private_bfd_data): Likewise.
* elf32-cris.c (cris_elf_relocate_section): Likewise.
* elf32-frv.c (frv_elf_merge_private_bfd_data): Likewise.
* elf32-i370.c (i370_elf_merge_private_bfd_data): Likewise.
(i370_elf_relocate_section): Likewise.
* elf32-iq2000.c (iq2000_elf_merge_private_bfd_data): Likewise.
* elf32-m32c.c (m32c_elf_merge_private_bfd_data): Likewise.
* elf32-m68hc1x.c (_bfd_m68hc11_elf_merge_private_bfd_data): Likewise.
* elf32-mcore.c (mcore_elf_relocate_section): Likewise.
* elf32-mep.c (mep_elf_merge_private_bfd_data): Likewise.
* elf32-mt.c (mt_elf_merge_private_bfd_data): Likewise.
* elf64-sparc.c (elf64_sparc_merge_private_bfd_data): Likewise.
* elfxx-mips.c (mips_elf_merge_obj_e_flags): Likewise.
(_bfd_mips_elf_merge_private_bfd_data): Likewise.
* ieee.c (ieee_write_id, read_id): Likewise.
* mach-o.c (bfd_mach_o_write_contents): Likewise.
(bfd_mach_o_layout_commands, bfd_mach_o_read_section_32): Likewise.
(bfd_mach_o_read_section_64, bfd_mach_o_read_symtab_symbol): Likewise.
(bfd_mach_o_read_command, bfd_mach_o_header_p): Likewise.
* peXXigen.c (_bfd_XXi_swap_aouthdr_in): Likewise.
* stabs.c (_bfd_link_section_stabs): Likewise.

* coff-arm.c (coff_arm_relocate_section): Use L modifier in error
format.
* coff-mcore.c (coff_mcore_relocate_section): Likewise.
* coff-ppc.c (coff_ppc_relocate_section): Likewise.
* coff-rs6000.c (xcoff_reloc_type_toc): Likewise.
* coff-sh.c (sh_relax_section): Likewise.
(sh_relax_delete_bytes, sh_swap_insns): Likewise.
* coff-tic80.c (coff_tic80_relocate_section): Likewise.
* coffcode.h (coff_slurp_reloc_table): Likewise.
* coffgen.c (_bfd_coff_get_external_symbols): Likewise.
(_bfd_coff_read_string_table): Likewise.
* cofflink.c (_bfd_coff_generic_relocate_section): Likewise.
* compress.c (bfd_get_full_section_contents): Likewise.
* dwarf2.c (read_formatted_entries, decode_line_info): Likewise.
* elf-m10300.c (mn10300_elf_relocate_section): Likewise.
* elf.c (bfd_elf_string_from_elf_section): Likewise.
* elf32-arc.c (arc_special_overflow_checks): Likewise.
* elf32-arm.c (elf32_arm_tls_relax): Likewise.
(elf32_arm_final_link_relocate, elf32_arm_relocate_section): Likewise.
(elf32_arm_write_section): Likewise.
* elf32-bfin.c (bfin_relocate_section): Likewise.
(bfinfdpic_relocate_section): Likewise.
* elf32-hppa.c (hppa_build_one_stub): Likewise.
(final_link_relocate, elf32_hppa_relocate_section): Likewise.
* elf32-i386.c (elf_i386_tls_transition): Likewise.
(elf_i386_relocate_section): Likewise.
* elf32-ip2k.c (ip2k_final_link_relocate): Likewise.
* elf32-lm32.c (lm32_elf_finish_dynamic_sections): Likewise.
* elf32-m32r.c (m32r_elf_relocate_section): Likewise.
* elf32-m68k.c (elf_m68k_relocate_section): Likewise.
* elf32-metag.c (elf_metag_relocate_section): Likewise.
* elf32-nds32.c (unrecognized_reloc_msg): Likewise.
(nds32_elf_relax_longcall1, nds32_elf_relax_longcall2): Likewise.
(nds32_elf_relax_longcall3, nds32_elf_relax_longjump1): Likewise.
(nds32_elf_relax_longjump2, nds32_elf_relax_longjump3): Likewise.
(nds32_elf_relax_longcall4, nds32_elf_relax_longcall5): Likewise.
(nds32_elf_relax_longcall6, nds32_elf_relax_longjump4): Likewise.
(nds32_elf_relax_longjump5, nds32_elf_relax_longjump6): Likewise.
(nds32_elf_relax_longjump7, nds32_elf_relax_loadstore): Likewise.
(nds32_elf_relax_ptr, nds32_elf_ex9_build_hash_table): Likewise.
* elf32-nios2.c (nios2_elf32_relocate_section): Likewise.
* elf32-rx.c (UNSAFE_FOR_PID): Likewise.
* elf32-s390.c (invalid_tls_insn, elf_s390_relocate_section): Likewise.
* elf32-score.c (s3_bfd_score_elf_check_relocs): Likewise.
* elf32-score7.c (s7_bfd_score_elf_check_relocs): Likewise.
* elf32-sh.c (sh_elf_relax_section): Likewise.
(sh_elf_relax_delete_bytes, sh_elf_swap_insns): Likewise.
(sh_elf_relocate_section): Likewise.
* elf32-sh64.c (shmedia_prepare_reloc): Likewise.
* elf32-spu.c (spu_elf_relocate_section): Likewise.
* elf32-tic6x.c (elf32_tic6x_relocate_section): Likewise.
* elf32-tilepro.c (tilepro_elf_relocate_section): Likewise.
* elf32-v850.c (v850_elf_relax_section): Likewise.
* elf32-vax.c (elf_vax_check_relocs): Likewise.
(elf_vax_relocate_section): Likewise.
* elf32-xtensa.c (elf_xtensa_relocate_section): Likewise.
(extend_ebb_bounds_forward, extend_ebb_bounds_backward): Likewise.
(compute_text_actions, compute_ebb_proposed_actions): Likewise.
(do_fix_for_relocatable_link): Likewise.
* elf64-alpha.c (elf64_alpha_relax_got_load): Likewise.
(elf64_alpha_relax_with_lituse): Likewise.
* elf64-hppa.c (elf64_hppa_finish_dynamic_symbol): Likewise.
(elf_hppa_final_link_relocate): Likewise.
* elf64-ia64-vms.c (elf64_ia64_relax_section): Likewise.
(elf64_ia64_choose_gp, elf64_ia64_relocate_section): Likewise.
(elf64_vms_link_add_object_symbols): Likewise.
* elf64-mmix.c (mmix_elf_perform_relocation): Likewise.
(mmix_final_link_relocate): Likewise.
* elf64-s390.c (invalid_tls_insn): Likewise.
(elf_s390_relocate_section): Likewise.
* elf64-sh64.c (sh_elf64_relocate_section): Likewise.
* elf64-x86-64.c (elf_x86_64_tls_transition): Likewise.
(elf_x86_64_relocate_section): Likewise.
* elfcode.h (elf_slurp_symbol_table): Likewise.
* elfcore.h (elf_core_file_p): Likewise.
* elflink.c (elf_link_read_relocs_from_section): Likewise.
* elfnn-aarch64.c (elfNN_aarch64_final_link_relocate): Likewise.
(elfNN_aarch64_relocate_section): Likewise.
* elfnn-ia64.c (elfNN_ia64_relax_section): Likewise.
(elfNN_ia64_choose_gp, elfNN_ia64_relocate_section): Likewise.
* elfnn-riscv.c (riscv_elf_relocate_section): Likewise.
* elfxx-mips.c (_bfd_mips_elf_check_relocs): Likewise.
(_bfd_mips_elf_relocate_section): Likewise.
(_bfd_mips_elf_finish_dynamic_symbol, mips_finish_exec_plt): Likewise.
* elfxx-sparc.c (_bfd_sparc_elf_relocate_section): Likewise.
* elfxx-tilegx.c (tilegx_elf_relocate_section): Likewise.
* ieee.c (ieee_slurp_external_symbols): Likewise.
* ihex.c (ihex_write_object_content): Likewise.
* mach-o.c (bfd_mach_o_build_exec_seg_command): Likewise.
* merge.c (_bfd_merged_section_offset): Likewise.
* mmo.c (mmo_write_loc_chunk): Likewise.
(mmo_write_object_contents): Likewise.
* peXXigen.c (_bfd_XX_bfd_copy_private_bfd_data_common): Likewise.
* stabs.c (_bfd_link_section_stabs): Likewise.
* xcofflink.c (xcoff_link_add_symbols, xcoff_find_tc0): Likewise.
ld/
* testsuite/ld-arc/nps-1b.err: Update.
* testsuite/ld-x86-64/ilp32-11.d: Update.

7 years agoAutomatic date update in version.in
GDB Administrator [Wed, 12 Jul 2017 00:00:47 +0000 (00:00 +0000)]
Automatic date update in version.in

7 years agoFixing for PR gold/21491 - Errata workaround can produce broken images.
Han Shen [Mon, 10 Jul 2017 22:23:05 +0000 (15:23 -0700)]
Fixing for PR gold/21491 - Errata workaround can produce broken images.

The problem is caused by the fact that gold is relocating the stubs
for an entire output section when it processes the relocations for a
particular input section that happened to be designated as the stub
table "owner". The Relocate_task for that input section may or may not
run before the Relocate_task for another input section that contains
the code that needs the erratum fix, but doesn't "own" the stub
table. If it runs before (or might even race with) that other task, it
ends up with a copy of the unrelocated original instruction.

In other words - when calling fix_errata() from
do_relocate_sections(), gold is going through the list of errata stubs
that are associated only with that object. This routine updates the
stored original instruction and replaces it in the output view with a
branch to the stub. Later, as gold is going through the object file's
input sections, it then checks for stub tables "owned" by each input
section, and writes out all the stubs from that stub table, regardless
of what object file each stub is associated with.

Fixed by relocating the erratum stub only after the corresponding
errata spot is fixed. That is to have fix_errata() call
Stub_table::relocate_erratum_stub() for each stub.

gold/ChangeLog
2017-07-06  Han Shen  <shenhan@google.com>

PR gold/21491

* aarch64.cc (Erratum_stub::invalidate_erratum_stub): New method.
(Erratum_stub::is_invalidated_erratum_stub): New method.
(Stub_table::relocate_reloc_stub): Renamed from "relocate_stub".
(Stub_table::relocate_reloc_stubs): Renamed from "relocate_stubs".
(Stub_table::relocate_erratum_stub): New method.
(AArch64_relobj::fix_errata_and_relocate_erratum_stubs): Renamed from
"fix_errata".
(Target_aarch64::relocate_reloc_stub): Renamed from "relocate_stub".

7 years agoSupport the fs_base and gs_base registers on FreeBSD/amd64 native processes.
John Baldwin [Tue, 27 Jun 2017 01:18:19 +0000 (18:18 -0700)]
Support the fs_base and gs_base registers on FreeBSD/amd64 native processes.

Use ptrace operations to fetch and store the fs_base and gs_base registers
for FreeBSD/amd64 processes.  Note that FreeBSD does not currently store the
value of these registers in core dumps, so these registers are only
available when inspecting a running process.

gdb/ChangeLog:

* amd64-bsd-nat.c (amd64bsd_fetch_inferior_registers): Use
PT_GETFSBASE and PT_GETGSBASE.
(amd64bsd_store_inferior_registers): Use PT_SETFSBASE and
PT_SETGSBASE.

7 years agoInclude the fs_base and gs_base registers in amd64 target descriptions.
John Baldwin [Tue, 27 Jun 2017 01:14:43 +0000 (18:14 -0700)]
Include the fs_base and gs_base registers in amd64 target descriptions.

This permits these registers to be used with non-Linux targets.

gdb/ChangeLog:

* features/Makefile (amd64.dat, amd64-avx.dat, amd64-mpx.dat)
(amd64-avx-mpx.dat, amd64-avx-avx512.dat)
(amd64-avx-mpx-avx512-pku.dat): Add i386/64bit-segments.xml in
those rules.
* features/i386/amd64-avx-avx512.xml: Add 64bit-segments.xml.
        * features/i386/amd64-avx-mpx-avx512-pku.xml: Add 64bit-segments.xml.
* features/i386/amd64-avx-mpx.xml: Add 64bit-segments.xml.
* features/i386/amd64-avx.xml: Add 64bit-segments.xml.
* features/i386/amd64-mpx.xml: Add 64bit-segments.xml.
* features/i386/amd64.xml: Add 64bit-segments.xml.
* features/i386/amd64-avx-avx512.c: Regenerated.
* features/i386/amd64-avx-mpx-avx512-pku.c: Regenerated.
* features/i386/amd64-avx-mpx.c: Regenerated.
* features/i386/amd64-avx.c: Regenerated.
* features/i386/amd64-mpx.c: Regenerated.
* features/i386/amd64.c: Regenerated.
* regformats/i386/amd64-avx-avx512.dat: Regenerated.
* regformats/i386/amd64-avx-mpx-avx512-pku.dat: Regenerated.
* regformats/i386/amd64-avx-mpx.dat: Regenerated.
* regformats/i386/amd64-avx.dat: Regenerated.
* regformats/i386/amd64-mpx.dat: Regenerated.
* regformats/i386/amd64.dat: Regenerated.

7 years agoSupport single digit GCC version
H.J. Lu [Tue, 11 Jul 2017 15:37:48 +0000 (08:37 -0700)]
Support single digit GCC version

On Fedora 26, "g++ -dumpversion" displays "7", instead of "7.1.1".
Update selective.exp to support single digit GCC version.  Also
remove duplicated [4-9] version check.

* testsuite/ld-selective/selective.exp: Support single digit
GCC version.

7 years agoAdd missing newlines in readelf -n output
Andreas Schwab [Tue, 11 Jul 2017 15:36:35 +0000 (17:36 +0200)]
Add missing newlines in readelf -n output

* readelf.c (process_note): Print newline after description data
in narrow mode.
(print_core_note): Print newline if nothing was printed in wide
mode.

7 years agoppc32 use of %x in einfo format, typo fix
Alan Modra [Tue, 11 Jul 2017 13:08:54 +0000 (22:38 +0930)]
ppc32 use of %x in einfo format, typo fix

* elf32-ppc.c (ppc_elf_relocate_section): Fix typo.

7 years ago[AArch64] Use "#pass" instead of "#..." to filter multiple lines
Jiong Wang [Tue, 11 Jul 2017 10:11:09 +0000 (11:11 +0100)]
[AArch64] Use "#pass" instead of "#..." to filter multiple lines

ld/
* testsuite/ld-aarch64/dt_textrel.d: Use "#pass" instead of ".*" to
filter out remaining lines.

7 years agoppc32 use of %x in einfo format
Alan Modra [Tue, 11 Jul 2017 09:48:47 +0000 (19:18 +0930)]
ppc32 use of %x in einfo format

einfo doesn't support %x.

* elf32-ppc.c (ppc_elf_relocate_section): Emit "unexpected
instruction" error using _bfd_error_handler, not einfo.

7 years agoMark generated cgen files read-only
Alan Modra [Tue, 11 Jul 2017 09:43:08 +0000 (19:13 +0930)]
Mark generated cgen files read-only

* cgen.sh: Mark generated files read-only.
* epiphany-asm.c: Regenerate.
* epiphany-desc.c: Regenerate.
* epiphany-desc.h: Regenerate.
* epiphany-dis.c: Regenerate.
* epiphany-ibld.c: Regenerate.
* epiphany-opc.c: Regenerate.
* epiphany-opc.h: Regenerate.
* fr30-asm.c: Regenerate.
* fr30-desc.c: Regenerate.
* fr30-desc.h: Regenerate.
* fr30-dis.c: Regenerate.
* fr30-ibld.c: Regenerate.
* fr30-opc.c: Regenerate.
* fr30-opc.h: Regenerate.
* frv-asm.c: Regenerate.
* frv-desc.c: Regenerate.
* frv-desc.h: Regenerate.
* frv-dis.c: Regenerate.
* frv-ibld.c: Regenerate.
* frv-opc.c: Regenerate.
* frv-opc.h: Regenerate.
* ip2k-asm.c: Regenerate.
* ip2k-desc.c: Regenerate.
* ip2k-desc.h: Regenerate.
* ip2k-dis.c: Regenerate.
* ip2k-ibld.c: Regenerate.
* ip2k-opc.c: Regenerate.
* ip2k-opc.h: Regenerate.
* iq2000-asm.c: Regenerate.
* iq2000-desc.c: Regenerate.
* iq2000-desc.h: Regenerate.
* iq2000-dis.c: Regenerate.
* iq2000-ibld.c: Regenerate.
* iq2000-opc.c: Regenerate.
* iq2000-opc.h: Regenerate.
* lm32-asm.c: Regenerate.
* lm32-desc.c: Regenerate.
* lm32-desc.h: Regenerate.
* lm32-dis.c: Regenerate.
* lm32-ibld.c: Regenerate.
* lm32-opc.c: Regenerate.
* lm32-opc.h: Regenerate.
* lm32-opinst.c: Regenerate.
* m32c-asm.c: Regenerate.
* m32c-desc.c: Regenerate.
* m32c-desc.h: Regenerate.
* m32c-dis.c: Regenerate.
* m32c-ibld.c: Regenerate.
* m32c-opc.c: Regenerate.
* m32c-opc.h: Regenerate.
* m32r-asm.c: Regenerate.
* m32r-desc.c: Regenerate.
* m32r-desc.h: Regenerate.
* m32r-dis.c: Regenerate.
* m32r-ibld.c: Regenerate.
* m32r-opc.c: Regenerate.
* m32r-opc.h: Regenerate.
* m32r-opinst.c: Regenerate.
* mep-asm.c: Regenerate.
* mep-desc.c: Regenerate.
* mep-desc.h: Regenerate.
* mep-dis.c: Regenerate.
* mep-ibld.c: Regenerate.
* mep-opc.c: Regenerate.
* mep-opc.h: Regenerate.
* mt-asm.c: Regenerate.
* mt-desc.c: Regenerate.
* mt-desc.h: Regenerate.
* mt-dis.c: Regenerate.
* mt-ibld.c: Regenerate.
* mt-opc.c: Regenerate.
* mt-opc.h: Regenerate.
* or1k-asm.c: Regenerate.
* or1k-desc.c: Regenerate.
* or1k-desc.h: Regenerate.
* or1k-dis.c: Regenerate.
* or1k-ibld.c: Regenerate.
* or1k-opc.c: Regenerate.
* or1k-opc.h: Regenerate.
* or1k-opinst.c: Regenerate.
* xc16x-asm.c: Regenerate.
* xc16x-desc.c: Regenerate.
* xc16x-desc.h: Regenerate.
* xc16x-dis.c: Regenerate.
* xc16x-ibld.c: Regenerate.
* xc16x-opc.c: Regenerate.
* xc16x-opc.h: Regenerate.
* xstormy16-asm.c: Regenerate.
* xstormy16-desc.c: Regenerate.
* xstormy16-desc.h: Regenerate.
* xstormy16-dis.c: Regenerate.
* xstormy16-ibld.c: Regenerate.
* xstormy16-opc.c: Regenerate.
* xstormy16-opc.h: Regenerate.

7 years agoSync dlang demangling tests from upstream libiberty testsuite.
Iain Buclaw [Tue, 11 Jul 2017 07:51:03 +0000 (09:51 +0200)]
Sync dlang demangling tests from upstream libiberty testsuite.

Rationale behind the change instead of adding a `.init$' postfix being
that "initializer for symbol" is much more informative when inspecting D
runtime type information in gdb, which is the only place where you would
encounter references to this compiler-generated symbol.

gdb/testsuite/ChangeLog:

* gdb.dlang/demangle.exp: Update for demangling changes.

7 years agoAutomatic date update in version.in
GDB Administrator [Tue, 11 Jul 2017 00:00:41 +0000 (00:00 +0000)]
Automatic date update in version.in

7 years agoAdd missing ChangeLog etries
Anton Kolesov [Mon, 10 Jul 2017 17:48:30 +0000 (20:48 +0300)]
Add missing ChangeLog etries

This adds the missing ChangeLog entries for my previous patch

3d99e81 Import setenv and unsetenv from gnulib

7 years agoFix compile time warning about duplicate case values for powerpc-aix target.
Nick Clifton [Mon, 10 Jul 2017 12:18:05 +0000 (13:18 +0100)]
Fix compile time warning about duplicate case values for powerpc-aix target.

* coffcode.h (coff_slurp_symbol_table): Do not include an entry
for C_AIX_WEAKEXT if it has the same value as C_WEAKEXT.

7 years agoRe-generate i386/amd64-avx-avx512-linux.c and i386/amd64-avx-mpx-avx512-pku-linux.c
Yao Qi [Mon, 10 Jul 2017 11:00:35 +0000 (12:00 +0100)]
Re-generate i386/amd64-avx-avx512-linux.c and i386/amd64-avx-mpx-avx512-pku-linux.c

gdb:

2017-07-10  Yao Qi  <yao.qi@linaro.org>

* features/i386/amd64-avx-avx512-linux.c: Re-generated.
* features/i386/amd64-avx-mpx-avx512-pku-linux.c: Re-generated.

7 years agoRe-indent the code
Yao Qi [Mon, 10 Jul 2017 10:53:44 +0000 (11:53 +0100)]
Re-indent the code

gdb/gdbserver:

2017-07-10  Yao Qi  <yao.qi@linaro.org>

* linux-x86-low.c (x86_linux_read_description): Re-indent the code.

7 years agoImport setenv and unsetenv from gnulib
Anton Kolesov [Mon, 3 Jul 2017 16:17:29 +0000 (19:17 +0300)]
Import setenv and unsetenv from gnulib

This patch supersedes
https://sourceware.org/ml/gdb-patches/2017-07/msg00009.html

---

Patch [1] broke a build on MinGW hosts, because MinGW doesn't provide POSIX
functions setenv () and unsetenv ().  This can be fixed by using
implementations from gnulib.

[1] https://sourceware.org/git/?p=binutils-gdb.git;a=commit;h=9a6c7d9c0

gdb/ChangeLog
yyyy-mm-dd  Anton Kolesov  <Anton.Kolesov@synopsys.com>

* gnulib/update-gnulib.sh (IMPORTED_GNULIB_MODULES): Add setenv and
unsetenv.
* gnulib/aclocal.m4: Regenerate.
* gnulib/config.in: Regenerate.
* gnulib/configure: Regenerate.
* gnulib/import/Makefile.am: Regenerate.
* gnulib/import/Makefile.in: Regenerate.
* gnulib/import/m4/gnulib-cache.m4: Regenerate.
* gnulib/import/m4/gnulib-comp.m4: Regenerate.
* gnulib/import/m4/environ.m4: New file.
* gnulib/import/m4/setenv.m4: New file.
* gnulib/import/setenv.c: New file.
* gnulib/import/unsetenv.c: New file.

7 years agoAutomatic date update in version.in
GDB Administrator [Mon, 10 Jul 2017 00:00:41 +0000 (00:00 +0000)]
Automatic date update in version.in

7 years agoDWARF-5: Fix error message typo.
Jan Kratochvil [Sun, 9 Jul 2017 18:52:18 +0000 (20:52 +0200)]
DWARF-5: Fix error message typo.

binutils/
2017-07-09  Rafael Fontenelle <rafaelff@gnome.org>

* dwarf.c (display_formatted_table): Fix error message typo.

7 years agocompile-loc2c: Fix uninitialized variable error
Simon Marchi [Sun, 9 Jul 2017 18:25:38 +0000 (20:25 +0200)]
compile-loc2c: Fix uninitialized variable error

Compiling with clang gives this warning/error:

  /home/emaisin/src/binutils-gdb/gdb/compile/compile-loc2c.c:731:6: error: variable 'uoffset' is uninitialized when used here [-Werror,-Wuninitialized]
              uoffset += dwarf2_per_cu_text_offset (per_cu);
              ^~~~~~~
  /home/emaisin/src/binutils-gdb/gdb/compile/compile-loc2c.c:669:23: note: initialize the variable 'uoffset' to silence this warning
        uint64_t uoffset, reg;
                        ^
                         = 0

I am really not sure if what this patch does is good, but it is my best
guess.  DW_OP_addr means that there's an constant address provided by
the DWARF bytecode that should be pushed on the stack.  That address is
considered skipped by the "op_ptr += addr_size", but it is never read.
uoffset is indeed read just after, without having been assigned first.

So I think the intent is to read the address, it was just omitted.

gdb/ChangeLog:

* compile/compile-loc2c.c (do_compile_dwarf_expr_to_c): Read
address when op is DW_OP_addr.

7 years agoFix size check in dwarf2_evaluate_loc_desc_full
Tom Tromey [Sun, 28 May 2017 14:06:54 +0000 (08:06 -0600)]
Fix size check in dwarf2_evaluate_loc_desc_full

This Rust bug report:

https://github.com/rust-lang/rust/issues/41970

noted an error from gdb.  What is happening here (for me, the original
report had a different error) is that a pieced DWARF expression is not
writing to every byte in the resulting value.  GDB errors in this
case.  However, it seems to me that it is always valid to write fewer
bytes; the issue comes from writing too many -- that is, the test is
reversed.  The test was also checking the sub-object, but this also
seems incorrect, as it's expected for the expression to write the
entirety of the enclosing object.  So, this patch reverses the test
and applies it to the outer type, not the subobject type.

Regtested on the buildbot.

gdb/ChangeLog
2017-07-09  Tom Tromey  <tom@tromey.com>

* dwarf2loc.c (dwarf2_evaluate_loc_desc_full): Reverse size
check and apply to outer type.

gdb/testsuite/ChangeLog
2017-07-09  Tom Tromey  <tom@tromey.com>

* gdb.dwarf2/shortpiece.exp: New file.

7 years agoAutomatic date update in version.in
GDB Administrator [Sun, 9 Jul 2017 00:00:41 +0000 (00:00 +0000)]
Automatic date update in version.in

7 years agoAutomatic date update in version.in
GDB Administrator [Sat, 8 Jul 2017 00:00:40 +0000 (00:00 +0000)]
Automatic date update in version.in

7 years agoRead signal information from FreeBSD core dumps.
John Baldwin [Wed, 28 Jun 2017 19:50:56 +0000 (12:50 -0700)]
Read signal information from FreeBSD core dumps.

FreeBSD recently added a new ELF core note which dumps the entire LWP
info structure (the same structure returned by the ptrace PT_LWPINFO
operation) for each thread.  The plan is for this note to eventually
supplant the older "thrmisc" ELF core note as it contains more
information and it permits new information to be exported via both
ptrace() and core dumps using the same structure.

For signal information, the implementation is similar to the native
implementation for FreeBSD processes.  The PL_FLAG_SI flag must be
checked to determine if the embedded siginfo_t structure is valid, and
if so it is transferred into the caller's buffer.

gdb/ChangeLog:

* fbsd-tdep.c (LWPINFO_OFFSET, LWPINFO_PL_FLAGS)
(LWPINFO64_PL_SIGINFO, LWPINFO32_PL_SIGINFO, PL_FLAG_SI)
(SIZE64_SIGINFO_T, SIZE32_SIGINFO_T, fbsd_core_xfer_siginfo): New.
(fbsd_init_abi): Install gdbarch "core_xfer_siginfo" method.

7 years agoCreate pseudo sections for FreeBSD NT_PTLWPINFO core notes.
John Baldwin [Wed, 28 Jun 2017 19:47:14 +0000 (12:47 -0700)]
Create pseudo sections for FreeBSD NT_PTLWPINFO core notes.

bfd/ChangeLog:

* elf.c (elfcore_grok_freebsd_note): Handle NT_FREEBSD_PTLWPINFO.

7 years agoRecognize the recently-added FreeBSD core dump note for LWP info.
John Baldwin [Wed, 28 Jun 2017 18:41:41 +0000 (11:41 -0700)]
Recognize the recently-added FreeBSD core dump note for LWP info.

This core dump note contains the same information returned by the
ptrace PT_LWPINFO operation for each LWP belonging to a process.

binutils/ChangeLog:

* readelf.c (get_freebsd_elfcore_note_type): Handle
NT_FREEBSD_PTLWPINFO.

include/ChangeLog:

* elf/common.h (NT_FREEBSD_PTLWPINFO): Define.

7 years agoUse the thread_section_name helper class in fbsd_core_thread_name.
John Baldwin [Wed, 28 Jun 2017 18:21:10 +0000 (11:21 -0700)]
Use the thread_section_name helper class in fbsd_core_thread_name.

gdb/ChangeLog:

* fbsd-tdep.c (fbsd_core_thread_name): Use thread_section_name.

7 years agoAdd a new gdbarch method to fetch signal information from core files.
John Baldwin [Wed, 28 Jun 2017 18:11:20 +0000 (11:11 -0700)]
Add a new gdbarch method to fetch signal information from core files.

Previously the core_xfer_partial method used core_get_siginfo to handle
TARGET_OBJECT_SIGNAL_INFO requests.  However, core_get_siginfo looked for
Linux-specific sections in the core file.  To support fetching siginfo
from cores on other systems, add a new gdbarch method (`core_xfer_siginfo`)
and move the body of the existing core_get_siginfo into a
linux_core_xfer_siginfo implementation of this method in linux-tdep.c.

gdb/ChangeLog:

* corelow.c (get_core_siginfo): Remove.
(core_xfer_partial): Use the gdbarch "core_xfer_siginfo" method
instead of get_core_siginfo.
* gdbarch.sh (core_xfer_siginfo): New gdbarch callback.
* gdbarch.h: Re-generate.
* gdbarch.c: Re-generate.
* linux-tdep.c (linux_core_xfer_siginfo): New.
(linux_init_abi): Install gdbarch "core_xfer_siginfo" method.

7 years agoMove the thread_section_name class to gdbcore.h.
John Baldwin [Wed, 28 Jun 2017 17:41:57 +0000 (10:41 -0700)]
Move the thread_section_name class to gdbcore.h.

This allows it to be used outside of corelow.c.

7 years agoFetch signal information for native FreeBSD processes.
John Baldwin [Wed, 28 Jun 2017 16:53:06 +0000 (09:53 -0700)]
Fetch signal information for native FreeBSD processes.

Use the `pl_siginfo' field in the `struct ptrace_lwpinfo' object returned
by the PT_LWPINFO ptrace() request to supply the current contents of
$_siginfo for each thread.  Note that FreeBSD does not supply a way to
modify the signal information for a thread, so $_siginfo is read-only for
FreeBSD.

To handle 32-bit processes on a 64-bit host, define types for 32-bit
compatible siginfo_t and convert the 64-bit siginfo_t to the 32-bit
equivalent when supplying information for a 32-bit process.

gdb/ChangeLog:

* fbsd-nat.c [PT_LWPINFO && __LP64__] (union sigval32)
(struct siginfo32): New.
[PT_LWPINFO] (fbsd_siginfo_size, fbsd_convert_siginfo): New.
(fbsd_xfer_partial) [PT_LWPINFO]: Handle TARGET_OBJECT_SIGNAL_INFO
via ptrace(PT_LWPINFO).

7 years agoImplement the "get_siginfo_type" gdbarch method for FreeBSD architectures.
John Baldwin [Wed, 28 Jun 2017 15:14:06 +0000 (08:14 -0700)]
Implement the "get_siginfo_type" gdbarch method for FreeBSD architectures.

As with Linux architectures, cache the created type in the gdbarch when it
is first created.  Currently FreeBSD uses an identical siginfo type on
all architectures, so there is no support for architecture-specific fields.

gdb/ChangeLog:

* fbsd-tdep.c (fbsd_gdbarch_data_handle, struct fbsd_gdbarch_data)
(init_fbsd_gdbarch_data, get_fbsd_gdbarch_data)
(fbsd_get_siginfo_type): New.
(fbsd_init_abi): Install gdbarch "get_siginfo_type" method.
(_initialize_fbsd_tdep): New.

7 years agoMIPS/LD: Fix a segfault from ELF `e_flags' access with non-ELF output BFD
Maciej W. Rozycki [Fri, 7 Jul 2017 16:58:03 +0000 (17:58 +0100)]
MIPS/LD: Fix a segfault from ELF `e_flags' access with non-ELF output BFD

Fix a commit 861fb55ab50a ("Defer allocation of R_MIPS_REL32 GOT
slots"), <https://sourceware.org/ml/binutils/2008-08/msg00096.html>,
regression and a more recent:

FAIL: ld-unique/pr21529

new LD test case failure, observed with all the relevant MIPS targets
whenever the linker is invoked with one or more ELF inputs and the
output format set to `binary'.

The culprit is a segmentation fault caused in `mips_before_allocation'
by a null pointer dereference, where an attempt is made to access the
ELF file header's `e_flags' member, for the purpose of determining
whether to produce a PLT and copy relocations, without first checking
that the output BFD is ELF.  The `e_flags' member is stored in BFD's
private data pointed to by `tdep', which in the case of the `binary' BFD
is null, causing the segmentation fault.  With other non-ELF BFDs such
as SREC `tdep' is not null and consequently no crash may happen and in
that case random data will be interpreted as it was `e_flags'.

Disable the access to `e_flags' then and all the associated checks and
consequently never produce a PLT and copy relocations if output is not a
MIPS ELF BFD, matching `_bfd_mips_elf_merge_private_bfd_data' that does
not process `e_flags' in that case either and therefore does not let us
decide here anyway if all the input objects included in the link are
suitable for use with a PLT and copy relocations.

ld/
* emultempl/mipself.em (mips_before_allocation): Avoid ELF
processing if not MIPS ELF.
* testsuite/ld-mips-elf/binary.d: New test.
* testsuite/ld-mips-elf/binary.ld: New test linker script.
* testsuite/ld-mips-elf/binary.s: New test source.
* testsuite/ld-mips-elf/mips-elf.exp: Run the new test.

7 years agoMake ppc476 testcases more robust
Alan Modra [Fri, 7 Jul 2017 14:19:42 +0000 (23:49 +0930)]
Make ppc476 testcases more robust

* testsuite/ld-powerpc/ppc476-shared.lnk: Align .bss.
* testsuite/ld-powerpc/ppc476-shared.d: Adjust.
* testsuite/ld-powerpc/ppc476-shared2.d: Adjust.

7 years agoMove print_insn_XXX to an opcodes internal header, again
Alan Modra [Fri, 7 Jul 2017 02:44:53 +0000 (12:14 +0930)]
Move print_insn_XXX to an opcodes internal header, again

88c1242dc0a changed some generated files rather than the source.

* cgen-dis.in: Include disassemble.h, not dis-asm.h.
* m32c-dis.c: Regenerate.
* mep-dis.c: Regenerate.

7 years agoAdd some missing xcoff support
Alan Modra [Fri, 7 Jul 2017 01:01:27 +0000 (10:31 +0930)]
Add some missing xcoff support

* coffcode.h (coff_slurp_symbol_table): Handle C_AIX_WEAKEXT.

7 years agoApply ld/Makefile.in patch to the correct file
Alan Modra [Fri, 7 Jul 2017 01:00:53 +0000 (10:30 +0930)]
Apply ld/Makefile.in patch to the correct file

Makefile.in is generated.

* Makefile.am (eelf64_s390.c): Depend on emultempl/s390.em.

7 years agoAnother _doprnt fix for %L handling
Alan Modra [Fri, 7 Jul 2017 00:49:08 +0000 (10:19 +0930)]
Another _doprnt fix for %L handling

* bfd.c (_doprnt): Replace "L" with "ll" when printing bfd_vma
as long long.  Move code replacing "ll" with "I64", and simplify.

7 years agoAutomatic date update in version.in
GDB Administrator [Fri, 7 Jul 2017 00:00:35 +0000 (00:00 +0000)]
Automatic date update in version.in

7 years agoFission support for multiple CUs per DWO file
David Blaikie [Thu, 6 Jul 2017 18:17:52 +0000 (11:17 -0700)]
Fission support for multiple CUs per DWO file

In some cases a compiler may produce a single object file (& thus single
DWO file) representing multiple source files. The most common example of
this is in whole program optimization (such as LLVM's LTO). Fission may
still be a beneficial feature to use here - to avoid the need to
read/link the debug info with system libraries and the like.

This change adds basic support for multiple CUs in a single DWO file to
support LLVM's output in this situation.

There is still outstanding work to design and implement a solution for
cross-CU references (usually using DW_FORM_ref_addr) in this scenario.
For now LLVM works around this by duplicating DIEs rather than making
cross-CU references in DWO files. This degrades debugger
behavior/quality especially for file-local entities.

2017-07-06  David Blaikie  <dblaikie@gmail.com>

* dwarf2read.c (struct dwo_file): Use a htab of dwo_unit* (rather than
a singular dwo_unit*) to support multiple CUs in the same way that
multiple TUs are supported.
(create_cus_hash_table): Replace create_dwo_cu with a function for
parsing multiple CUs from a DWO file.
(open_and_init_dwo_file): Use create_cus_hash_table rather than
create_dwo_cu.
(lookup_dwo_cutu): Lookup CU in the hash table in the dwo_file with
htab_find, rather than comparing the signature to a singleton CU in
the dwo_file.

2017-07-06  David Blaikie  <dblaikie@gmail.com>

* gdb.dwarf2/fission-multi-cu.S: Test containing multiple CUs in a DWO,
built from fissiont-multi-cu{1,2}.c.
* gdb.dwarf2/fission-multi-cu.exp: Test similar to fission-base.exp,
except putting 'main' and 'func' in separate CUs in the same DWO file.
* gdb.dwarf2/fission-multi-cu1.c: First CU for the multi-CU-single-DWO
test.
* gdb.dwarf2/fission-multi-cu2.c: Second CU in the multi-CU-single-DWO
test.

7 years agoConvert 'L' to 'l' when setting wide_width to 1
H.J. Lu [Thu, 6 Jul 2017 13:52:13 +0000 (06:52 -0700)]
Convert 'L' to 'l' when setting wide_width to 1

When setting wide_width to 1, convert 'L' to 'l'.  Otherwise, %Lx/%Lu/%Ld
will be passed to fprintf which will treat the argument as long long.

* bfd.c (_doprnt): Convert 'L' to 'l' when setting wide_width
to 1.

7 years agoAutomatic date update in version.in
GDB Administrator [Thu, 6 Jul 2017 00:00:56 +0000 (00:00 +0000)]
Automatic date update in version.in

7 years agoFix Python unwinder frames regression
Pedro Alves [Wed, 5 Jul 2017 23:19:24 +0000 (00:19 +0100)]
Fix Python unwinder frames regression

The gdb.python/py-unwind.exp test is crashing GDB / leaving core dumps
in the test dir, even though it all passes cleanly.  The crash is not
visible in gdb.sum/gdb.log because it happens as side effect of the
"quit" command, while flushing the frame cache.

The problem is simply a typo in a 'for' loop's condition, introduced
by a recent change [4fa847d78edd ("Remove MAX_REGISTER_SIZE from
py-unwind.c")], resulting in infinite loop / double-free.

The new test exposes the crash, like:

 Running src/gdb/testsuite/gdb.python/py-unwind.exp ...
 ERROR: Process no longer exists

gdb/ChangeLog:
2017-07-06  Pedro Alves  <palves@redhat.com>

* python/py-unwind.c (pyuw_dealloc_cache): Fix for loop condition.

gdb/testsuite/ChangeLog:
2017-07-06  Pedro Alves  <palves@redhat.com>

* gdb.python/py-unwind.exp: Test flushregs.

7 years agoFix build with GCC 4.2
H.J. Lu [Wed, 5 Jul 2017 16:04:51 +0000 (09:04 -0700)]
Fix build with GCC 4.2

Fix GCC 4.2 warnings like:

cc1: warnings being treated as errors
binutils-gdb/bfd/dwarf2.c:1844: warning: declaration of ‘time’ shadows a global declaration
/usr/include/time.h:187: warning: shadowed declaration is here
binutils-gdb/bfd/dwarf2.c: In function ‘line_info_add_file_name’:
binutils-gdb/bfd/dwarf2.c:1854: warning: declaration of ‘time’ shadows a global declaration
/usr/include/time.h:187: warning: shadowed declaration is here

bfd/

* dwarf2.c (line_info_add_include_dir_stub): Replace time with
xtime.
(line_info_add_file_name): Likewise.
(decode_line_info): Likewise.

binutils/

* dwarf.c (display_debug_names): Replace index with xindex.

7 years ago[ARM] Add support for Cortex-A55 and Cortex-A75.
James Greenhalgh [Wed, 5 Jul 2017 11:04:37 +0000 (12:04 +0100)]
[ARM] Add support for Cortex-A55 and Cortex-A75.

This patch adds support for the ARM Cortex-A55 and
Cortex-A75 processors.

The ARM Cortex-A55 and Cortex-A75 procsessors implement the ARMv8-A
architecture, with support for the ARMv8.1-A and ARMv8.2-A extensions,
including support for the 16-bit floating point extensions.

The 16-bit floating-point extensions are optional, and we haven't defined
an option mapping straight to them thus far, so this patch first needs to
add one of those in include/opcode/arm.h, then we can simply add the CPU names
as usual in config/tc-arm.c .

Tested on arm-none-eabi.

2017-07-05  James Greenhalgh  <james.greenhalgh@arm.com>

* config/tc-arm.c (arm_cpus): Add Cortex-A55 and Cortex-A75.
* doc/c-arm.texi (-mcpu): Document Cortex-A55 and Cortex-A75.

7 years agoX86: Disassemble primary opcode map's group 2 ModRM.reg == 6 aliases correctly
Borislav Petkov [Wed, 5 Jul 2017 09:27:49 +0000 (11:27 +0200)]
X86: Disassemble primary opcode map's group 2 ModRM.reg == 6 aliases correctly

The instructions are not documented in the Intel SDM but are documented
in the AMD APM as an alias to the group 2, ModRM.reg == 4 variant.

Both AMD and Intel CPUs execute the C[0-1] and D[0-3] instructions as
expected, i.e., like the /4 aliases:

  #include <stdio.h>

  int main(void)
  {
          int a = 2;

          printf ("a before: %d\n", a);

          asm volatile(".byte 0xd0,0xf0"          /* SHL %al */
                       : "+a" (a));

          printf("a after : %d\n", a);

          return 0;
  }

  $ ./a.out
  a before: 2
  a after : 4

7 years agoFixup changelog entries for previous commit
Ramana Radhakrishnan [Wed, 5 Jul 2017 09:21:07 +0000 (10:21 +0100)]
Fixup changelog entries for previous commit

40c7d50720e04c3d1ef1695a8097f735bafbe54f

7 years agoAutomatic date update in version.in
GDB Administrator [Wed, 5 Jul 2017 00:00:31 +0000 (00:00 +0000)]
Automatic date update in version.in

7 years agoGarbage collect TYPE_STATIC and several TYPE_FN_FIELD_x
Pedro Alves [Tue, 4 Jul 2017 17:40:26 +0000 (18:40 +0100)]
Garbage collect TYPE_STATIC and several TYPE_FN_FIELD_x

Nothing uses these.  Most of the TYPE_FN_FIELD_ ones were probably
used by the gcj support.

gdb/ChangeLog:
2017-07-04  Pedro Alves  <palves@redhat.com>

* gdbtypes.c (recursive_dump_type): Don't reference TYPE_STATIC.
* gdbtypes.h (TYPE_STATIC): Delete.
(struct fn_field) <is_public, is_abstract, is_static, is_final,
is_synchronized, is_native>: Delete.
<dummy>: Bump.
(TYPE_FN_FIELD_PUBLIC, TYPE_FN_FIELD_STATIC, TYPE_FN_FIELD_FINAL)
(TYPE_FN_FIELD_SYNCHRONIZED, TYPE_FN_FIELD_NATIVE)
(TYPE_FN_FIELD_ABSTRACT): Delete.

7 years ago[Patch ARM] Support MVFR2 VFP Coprocessor register for ARMv8-A
Ramana Radhakrishnan [Tue, 4 Jul 2017 15:18:47 +0000 (16:18 +0100)]
[Patch ARM] Support MVFR2 VFP Coprocessor register for ARMv8-A

This patch adds support mvfr2 control registers for armv8-a as
this was missed from the original port to armv8-a (documented
at G6.2.109 in (Issue B.a) of the ARM-ARM. This was discovered
by an internal user of the GNU toolchain.

I'd like to backport this to the binutils 2.28 and binutils 2.29
release branch if possible (with suitable testing and basically
checking removing the armv8-r parts).

Tristan - are you ok with the backports ?

Applied to trunk.

regards Ramana

2017-07-04  Ramana Radhakrishnan  <ramana.radhakrishnan@arm.com>

        * gas/config/tc-arm.c (arm_regs): Add MVFR2.
        (do_vmrs): Constraint for MVFR2 and armv8.
        (do_vmsr): Likewise.
        * gas/testsuite/gas/arm/armv8-a+fp.d: Update.
        * gas/testsuite/gas/arm/armv8-ar+fp.s: Likewise.
        * gas/testsuite/gas/arm/armv8-r+fp.d: Likewise.
        * gas/testsuite/gas/arm/vfp-bad.s: Likewise.
        * gas/testsuite/gas/arm/vfp-bad.l: Likewise.
        * opcodes/arm-dis.c: Support MVFR2 in disassembly
        with vmrs and vmsr.

7 years agoRegenerate configure.
Tristan Gingold [Tue, 4 Jul 2017 09:15:33 +0000 (11:15 +0200)]
Regenerate configure.

bfd/
2017-07-04  Tristan Gingold  <gingold@adacore.com>

* version.m4: Bump version to 2.29.51
* configure: Regenerate.

binutils/
2017-07-04  Tristan Gingold  <gingold@adacore.com>

* configure: Regenerate.

gas/
2017-07-04  Tristan Gingold  <gingold@adacore.com>

* configure: Regenerate.

gprof/
2017-07-04  Tristan Gingold  <gingold@adacore.com>

* configure: Regenerate.

ld/
2017-07-04  Tristan Gingold  <gingold@adacore.com>

* configure: Regenerate.

opcodes/
2017-07-04  Tristan Gingold  <gingold@adacore.com>

* configure: Regenerate.

7 years agoAdd markers.
Tristan Gingold [Tue, 4 Jul 2017 09:06:02 +0000 (11:06 +0200)]
Add markers.

binutils/
2017-07-04  Tristan Gingold  <gingold@adacore.com>

* NEWS: Add marker for 2.29.

gas/
2017-07-04  Tristan Gingold  <gingold@adacore.com>

* NEWS: Add marker for 2.29.

ld/
2017-07-04  Tristan Gingold  <gingold@adacore.com>

* NEWS: Add marker for 2.29.

7 years ago[AArch64] Remove useless and incorrect assertion
Jiong Wang [Mon, 3 Jul 2017 16:15:26 +0000 (17:15 +0100)]
[AArch64] Remove useless and incorrect assertion

The outer caller elf_link_output_extsym in elflink.c is a traverse function on
all external symbol, and it will only call *finish_dynamic_symbol if some
conditions is meet.  It is executed conditionally.

If the condition to trigger that assertion is satisified, it then won't satify
the outer check in finish_dynamic_symbol, so *finish_dynamic_symbol won't be
called that the assertion is expected to be dead code.

If elf_link_output_extsym is a traverse function that unconditionally called
on external symbols decided to be exported, then an assertion to make sure these
symbols are in sane status might make sense.

bfd/
        * elfnn-aarch64.c (elfNN_aarch64_finish_dynamic_symbol): Remove the
        sanity check at the head of this function.

7 years ago[binutils patch] DWARF-5: Extend bfd/dwarf2.c parse_comp_unit()
Jan Kratochvil [Tue, 4 Jul 2017 08:09:27 +0000 (10:09 +0200)]
[binutils patch] DWARF-5: Extend bfd/dwarf2.c parse_comp_unit()

bfd/
2017-07-04  Jan Kratochvil  <jan.kratochvil@redhat.com>

* dwarf2.c (struct dwarf2_debug): Add fields dwarf_line_str_buffer and
dwarf_line_str_size.
(struct attr_abbrev): Add field implicit_const.
(dwarf_debug_sections): Add .debug_line_str.
(enum dwarf_debug_section_enum): Add debug_line_str and debug_max.
(dwarf_debug_section_assert): Add static assertion.
(read_indirect_line_string): New.
(read_abbrevs): Support DW_FORM_implicit_const.
(is_str_attr): Support DW_FORM_line_strp.
(read_attribute_value): Support DW_FORM_line_strp and
DW_FORM_implicit_const.
(read_attribute): Support DW_FORM_implicit_const.
(line_info_add_include_dir, line_info_add_include_dir_stub):
(line_info_add_file_name, read_formatted_entries): New.
(decode_line_info, parse_comp_unit): Support DWARF 5.
(_bfd_dwarf2_cleanup_debug_info): Free dwarf_line_str_buffer.

7 years agoAutomatic date update in version.in
GDB Administrator [Tue, 4 Jul 2017 00:00:43 +0000 (00:00 +0000)]
Automatic date update in version.in

7 years agobfd: partial revert commit EC1ACAB (prevent all but undef weak symbols to become...
Egeyar Bagcioglu [Mon, 3 Jul 2017 18:06:35 +0000 (20:06 +0200)]
bfd: partial revert commit EC1ACAB (prevent all but undef weak symbols to become dynamic in sparc).

bfd/ChangeLog:

2017-07-03  Egeyar Bagcioglu  <egeyar.bagcioglu@oracle.com>

        * elfxx-sparc.c (_bfd_sparc_elf_finish_dynamic_symbol): Remove the
        abort statement that was put for symbols that are not dynamic.

7 years agoRegenerate pot files.
Tristan Gingold [Mon, 3 Jul 2017 15:02:01 +0000 (17:02 +0200)]
Regenerate pot files.

7 years agostrings: remove section/file size check
Alan Modra [Mon, 3 Jul 2017 12:30:32 +0000 (22:00 +0930)]
strings: remove section/file size check

This reverts most of 06803313754, 2005-07-05 Dmitry V. Levin change
adding a check that section size doesn't exceed file size.  As we've
seen recently with mmo tests, decoded section size can easily exceed
file size with formats that encode section data.

I've also changed "strings" to use bfd_malloc_and_get_section, so that
"strings" won't die on a malloc failure.  I think it's better to
continue on looking at other sections after failing to dump a section
with fuzzed size.

The testcases at https://bugzilla.altlinux.org/show_bug.cgi?id=5871
on a 32-bit host now produce
$ strings -d --target=a.out-i386 /tmp/bfdkiller.dat
strings: error: /tmp/bfdkiller.dat(.text) is too large (0xffffffff bytes)
strings: /tmp/bfdkiller.dat: Reading section .text failed: Memory exhausted
strings: /tmp/bfdkiller.dat: Reading section .data failed: File truncated
org.ec
$ strings -d --target=a.out-i386 /tmp/eclipse-state
strings: /tmp/eclipse-state: Reading section .text failed: File truncated
org.eclipse.osgi
System Bundle
[snip]

* strings.c (filename_and_size_t): Delete.
(strings_a_section): Don't check section size against file size.
Use bdf_malloc_and_get_section.  Report an error on failures.
Replace arg param with filename and got_a_section param.
(got_a_section): Move to..
(strings_object_file): ..an auto var here.  Iterate over sections
rather than calling bfd_map_over_sections.  Adjust strings_a_section
call.

7 years agoSupport %Lx, %Lu, %Ld in _bfd_error_handler format
Alan Modra [Mon, 3 Jul 2017 12:29:45 +0000 (21:59 +0930)]
Support %Lx, %Lu, %Ld in _bfd_error_handler format

One way to print 64-bit bfd_vma or bfd_size_type values on 32-bit
hosts is to cast the value to long long and use the 'll' modifier in
printf format strings.  However, that's awkward because we also
support the Microsoft C library printf that uses 'I64' as a modifier
instead, and having variants of translated strings would not endear us
to the translation project.  So, rewrite the 'll' modifier in
_doprint for Microsoft.  Even with that capability it's not so nice
for 32-bit code to need casts to long long, so this patch makes 'L' a
modifier for bfd_vma rather than an alias for 'll'.

I've then used the new 'L' modifier to fix selected format strings.

* bfd.c (_doprnt): Rewrite "ll" and "L" modifiers to "I64" for
__MSVCRT__.  Support "L" modifier for bfd_vma.  Formatting.
* elf.c (setup_group): Use "Lx" to print sh_size.
(_bfd_elf_setup_sections): Remove unnecessary cast and print
unknown section type in hex.
(copy_special_section_fields): Style fix.
(bfd_section_from_shdr): Correct format for sh_link.  Use a
common error message for all the variants of unrecognized
section types.
(assign_file_positions_for_load_sections): Use "Lx" for lma
adjust error message.
(assign_file_positions_for_non_load_sections): Formatting.
(rewrite_elf_program_header): Formatting.  Use "Lx" for
bfd_vma values in error messages.
* elfcode.h (elf_slurp_reloc_table_from_section): Cast
ELF_R_SYM value to type expected by format.
* elflink.c (elf_link_read_relocs_from_section): Use "Lx"
in error messages.
(elf_link_add_object_symbols): Use "Lu" for symbol sizes.
(elf_link_input_bfd): Use "Lx" for r_info.
(bfd_elf_gc_record_vtinherit): Use "Lx" for offset.

7 years agoBFD long long cleanup
Alan Modra [Mon, 3 Jul 2017 12:29:30 +0000 (21:59 +0930)]
BFD long long cleanup

long long isn't supposed to be used without a configure test, to
support ancient compilers.  Probably not terribly important nowadays.

* bfd.c (bfd_scan_vma): Don't use long long unless HAVE_LONG_LONG.
* coff-rs6000.c (FMT20): Handle hosts with 64-bit long and
Microsoft C library variant of long long format specifier.
(PRINT20): Cast value to bfd_uint64_t not long long.
* coffcode.h (coff_print_aux): Use BFD_VMA_FMT.
* coff-x86_64.c (coff_amd64_reloc): Use bfd_uint64_t rather than
long long.  Don't cast to bfd_vma.
* elf32-score.c (score3_bfd_getl48): Likewise.
* vms-alpha.c (_bfd_vms_slurp_eisd): Likewise.

7 years agoMiscellaneous format string fixes
Alan Modra [Mon, 3 Jul 2017 12:26:29 +0000 (21:56 +0930)]
Miscellaneous format string fixes

* elf.c (_bfd_elf_print_private_bfd_data): Use BFD_VMA_FMT to
print d_tag.
(bfd_elf_print_symbol): Don't cast symbol->flags.
(_bfd_elf_symbol_from_bfd_symbol): Likewise.
* elf32-ppc.c (ppc_elf_begin_write_processing): Correct
_bfd_error_handler argument order.
(ppc_elf_merge_private_bfd_data): Don't cast flags.

7 years agoMissing config for bfd.c:_doprnt
Alan Modra [Mon, 3 Jul 2017 12:25:57 +0000 (21:55 +0930)]
Missing config for bfd.c:_doprnt

This function uses HAVE_LONG_LONG and HAVE_LONG_DOUBLE

* configure.ac: Invoke AC_CHECK_TYPES for long long.  Invoke
AC_TYPE_LONG_DOUBLE.
* configure: Regenerate.
* config.in: Regenerate.

7 years agoDisable symver test on hppa64-hpux
Alan Modra [Mon, 3 Jul 2017 12:25:21 +0000 (21:55 +0930)]
Disable symver test on hppa64-hpux

The syntax for common symbols is different on that target.

* testsuite/gas/elf/symver.d: Don't run on hppa64-hpux.

7 years ago[GOLD] undef after using DW_IDX and friends
Alan Modra [Mon, 3 Jul 2017 12:16:59 +0000 (21:46 +0930)]
[GOLD] undef after using DW_IDX and friends

* dwarf.h (DW_FIRST_IDX, DW_IDX, DW_IDX_DUP, DW_END_IDX): Undef
after using.

7 years agoRepair include/dwarf2.def breakage
Alan Modra [Mon, 3 Jul 2017 10:00:24 +0000 (19:30 +0930)]
Repair include/dwarf2.def breakage

* dwarf.h (DW_FIRST_IDX, DW_IDX, DW_IDX_DUP, DW_END_IDX): Define.

7 years agobuffer.h: Fix spelling mistakes
Simon Marchi [Mon, 3 Jul 2017 11:59:00 +0000 (13:59 +0200)]
buffer.h: Fix spelling mistakes

gdb/ChangeLog:

* buffer.h (buffer_finish): Fix spelling mistakes.