deliverable/binutils-gdb.git
6 years agoFix PR gdb/21954: make 'unset environment' work again
Sergio Durigan Junior [Tue, 15 Aug 2017 17:49:18 +0000 (13:49 -0400)] 
Fix PR gdb/21954: make 'unset environment' work again

When I made commit 9a6c7d9c021cfeb290d76584db7a01e57e7c3d4e, which
C++-fied gdb/common/environ.[ch], I mistakenly altered the behaviour
of the 'unset environment' command.  This command, which should delete
all environment variables, is now resetting the list of variables to
the state they were when GDB was started.

This commit fixes this regression, and also adds a test on
gdb.base/environ.exp which really checks if 'unset environment'
worked.

gdb/ChangeLog:
2017-08-15  Sergio Durigan Junior  <sergiodj@redhat.com>

PR gdb/21954
* infcmd.c (unset_environment_command): Use the 'clear' method on
the environment instead of resetting it.

gdb/testsuite/ChangeLog:
2017-08-15  Sergio Durigan Junior  <sergiodj@redhat.com>

PR gdb/21954
* gdb.base/environ.exp: Add test to check if 'unset environment'
works.

6 years agoFix compile on big-endian platforms in siginfo_t converter.
John Baldwin [Tue, 15 Aug 2017 15:04:23 +0000 (08:04 -0700)] 
Fix compile on big-endian platforms in siginfo_t converter.

gdb/ChangeLog:

* fbsd-nat.c (fbsd_convert_siginfo): Fix compile on big-endian
platforms.

6 years ago[Patch AArch64] Turn lr, fp, ip0 and ip1 into proper aliases
Ramana Radhakrishnan [Tue, 15 Aug 2017 12:58:01 +0000 (13:58 +0100)] 
[Patch AArch64] Turn lr, fp, ip0 and ip1 into proper aliases

We got a report from the linux-arm-kernel folks about getting spurious
warnings when building the kernel with binutils 2.29. See
https://www.spinics.net/lists/arm-kernel/msg599929.html

which boils down to this testcase.

$> cat /tmp/tst.s
    lr .req x30
    /tmp/tst.s: Assembler messages:
    /tmp/tst.s:1: Warning: ignoring attempt to redefine built-in register 'lr'

Instead let's treat this as a proper alias at startup time thus
avoiding the problem and treating these as proper aliases
rather than new registers. This means that attempts to redefine
the alias with the same "name" will provoke no warning and attempts
to redefine the alias to something else will provoke the above mentioned
warning.

Tested make check-gas and no regressions.

Ok to apply to trunk (and backport to 2.29 branch)?

Regards
Ramana

6 years agoGDB testsuite: Suppress GCC's colored output
Andreas Arnez [Mon, 14 Aug 2017 18:31:09 +0000 (20:31 +0200)] 
GDB testsuite: Suppress GCC's colored output

Newer GCC versions yield colored diagnostic messages by default, which may
be useful when executing GDB interactively from a terminal.  But when run
from a GDB test case, the compiler output is written into gdb.log, where
such escape sequences are usually more inhibiting than helpful to the
evaluation of test results.  So this patch suppresses that.

gdb/testsuite/ChangeLog:

* lib/gdb.exp (universal_compile_options): New caching proc.
(gdb_compile): Suppress GCC's coloring of messages.

6 years agoRemove BITS_IN_BYTES define
Tom Tromey [Tue, 11 Jul 2017 12:44:36 +0000 (06:44 -0600)] 
Remove BITS_IN_BYTES define

While working on the previous patch, I noticed that BITS_IN_BYTES can be
replaced by HOST_CHAR_BIT, which is used more widely in gdb.

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

* valprint.c (print_octal_chars): Use HOST_CHAR_BIT.
(print_binary_chars): Likewise.
(BITS_IN_BYTES): Remove.

6 years agoFix two regressions in scalar printing
Tom Tromey [Tue, 11 Jul 2017 12:40:40 +0000 (06:40 -0600)] 
Fix two regressions in scalar printing

PR gdb/21675 points out a few regressions in scalar printing.

One type of regression is due to not carrying over the old handling of
floating point printing -- where a format like "/d" causes a floating
point number to first be cast to a signed integer.  This patch restores
this behavior.

The other regression is a longstanding bug in print_octal_chars: one of
the constants was wrong.  This patch fixes the constant and adds static
asserts to help catch this sort of error.

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

PR gdb/21675
* valprint.c (LOW_ZERO): Change value to 034.
(print_octal_chars): Add static_asserts for octal constants.
* printcmd.c (print_scalar_formatted): Add 'd' case.

testsuite/ChangeLog
2017-08-14  Tom Tromey  <tom@tromey.com>

PR gdb/21675:
* gdb.base/printcmds.exp (test_radices): New function.
* gdb.dwarf2/var-access.exp: Use p/u, not p/d.
* gdb.base/sizeof.exp (check_valueof): Use p/d.
* lib/gdb.exp (get_integer_valueof): Use p/d.

6 years agoFix memory leak in add_symbol_file_command
Tom Tromey [Thu, 3 Aug 2017 23:07:06 +0000 (17:07 -0600)] 
Fix memory leak in add_symbol_file_command

I happened to notice that add_symbol_file_command leaks "sect_opts".
This patch fixes the leak by changing sect_opts to be a std::vector.

I had to change the logic in the loop a little bit.  Previously, it
was incrementing section_index after completing an entry; but this
changes it to push a new entry when the name is seen.

I believe the argument parsing here is mildly incorrect, in that
nothing checks whether the -s option actually had any arguments.
Maybe gdb can crash if "-s NAME" is given without an argument.  I
didn't try to fix this in this patch, but I do have another patch I
can send later that fixes it up.

Regression tested on the buildbot.

ChangeLog
2017-08-11  Tom Tromey  <tom@tromey.com>

* symfile.c (add_symbol_file_command): Use std::vector.

6 years agoUse std::move in a few places
Tom Tromey [Fri, 11 Aug 2017 16:14:16 +0000 (10:14 -0600)] 
Use std::move in a few places

This patch adds std::move to few spots where it seems to be missing.

Regression tested by the buildbot.

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

* break-catch-throw.c (handle_gnu_v3_exceptions): Use std::move.
* break-catch-syscall.c (create_syscall_event_catchpoint): Use
std::move.
* break-catch-sig.c (create_signal_catchpoint): Use std::move.

6 years agoFix null pointer dereference when parsing a corrupt ELF binary.
Nick Clifton [Mon, 14 Aug 2017 11:09:36 +0000 (12:09 +0100)] 
Fix null pointer dereference when parsing a corrupt ELF binary.

PR 21957
* elf.c (setup_group): Check for an empty or very small group
section.
* po/bfd.pot: Regenerate.

6 years agoAutomatic date update in version.in
GDB Administrator [Mon, 14 Aug 2017 00:01:33 +0000 (00:01 +0000)] 
Automatic date update in version.in

6 years agoPR21441, Unnecessary padding of .eh_frame section
Alan Modra [Sun, 13 Aug 2017 23:55:17 +0000 (09:25 +0930)] 
PR21441, Unnecessary padding of .eh_frame section

Until all .eh_frame sections have been edited we don't know their
sizes.  So it isn't possible to properly decide whether a non-empty
.eh_frame section follows a given section until editing is complete.

bfd/
PR 21441
* elf-eh-frame.c (_bfd_elf_discard_section_eh_frame): Don't add
alignment padding here.
* elflink.c (bfd_elf_discard_info): Add .eh_frame padding here
in a reverse pass over sections.
ld/
PR 21441
* testsuite/ld-x86-64/pr21038a.d: Adjust.
* testsuite/ld-x86-64/pr21038a-now.d: Adjust.

6 years agold: Restore linker scripts in PR ld/21884 tests
H.J. Lu [Sun, 13 Aug 2017 12:41:37 +0000 (05:41 -0700)] 
ld: Restore linker scripts in PR ld/21884 tests

OUTPUT_FORMAT in linker script of PR ld/21884 tests is needed to trigger
PR ld/21884.  Restore linker scripts and add nacl versions of the same
tests.

* testsuite/ld-i386/i386.exp: Run pr21884-nacl.
* testsuite/ld-x86-64/x86-64.exp: Likewise.
* testsuite/ld-i386/pr21884.d: Don't run on nacl targets.
* testsuite/ld-x86-64/pr21884.d: Likewise.
* testsuite/ld-i386/pr21884.t: Revert the last change.
* testsuite/ld-x86-64/pr21884.t: Likewise.
* testsuite/ld-i386/pr21884-nacl.d: New file.
* testsuite/ld-i386/pr21884-nacl.t: Likewise.
* testsuite/ld-x86-64/pr21884-nacl.d: Likewise.
* testsuite/ld-x86-64/pr21884-nacl.t: Likewise.

6 years agoFix i686-nacl and x86_64-nacl pr21884 failures
Alan Modra [Sun, 13 Aug 2017 00:04:04 +0000 (09:34 +0930)] 
Fix i686-nacl and x86_64-nacl pr21884 failures

OUTPUT_FORMAT in the script results in "./ld-new: target elf32-i386
not found" and similarly for the x86_64 test.

* testsuite/ld-i386/pr21884.t: Remove unneeded format, arch and entry.
* testsuite/ld-x86-64/pr21884.t: Likewise.

6 years agoAutomatic date update in version.in
GDB Administrator [Sun, 13 Aug 2017 00:00:56 +0000 (00:00 +0000)] 
Automatic date update in version.in

6 years agoFix typo on documentation ("show set startup-with-shell")
Sergio Durigan Junior [Sat, 12 Aug 2017 16:46:03 +0000 (12:46 -0400)] 
Fix typo on documentation ("show set startup-with-shell")

The documentation was erroneously saying that there is a command named
"show set startup-with-shell", while the correct version is "show
startup-with-shell".  This commit fixes obvious mistake.

gdb/doc/ChangeLog:
2017-08-12  Sergio Durigan Junior  <sergiodj@redhat.com>

PR gdb/21925
* gdb.texinfo (Starting) <startup-with-shell>: Fix typo ("show
set...").

6 years agotestsuite: Exclude end-of-line characters from get_valueof result
Simon Marchi [Sat, 12 Aug 2017 08:33:00 +0000 (10:33 +0200)] 
testsuite: Exclude end-of-line characters from get_valueof result

The get_valueof procedure allows tests to conveniently make gdb evaluate
an expression an return the value as a string.  However, it includes an
end-of-line character in its result.  I stumbled on this when trying to
use that result as part of a regex further in a test.

You can see this for example by adding a puts in
gdb.dwarf2/implref-struct.exp:get_members:

    set members [get_valueof "" ${var} ""]
    puts "<$members>"

The output is

    <{a = 0, b = 1, c = 2}
    >

This is because the regex in get_valueof is too greedy, the captured
portion matches anything up to the gdb_prompt, including the end of line
characters.  This patch changes it to capture everything but end of line
characters.

The output of the puts becomes:

    <{a = 0, b = 1, c = 2}>

I tested this by running gdb.dwarf2/implref-array.exp and
gdb.dwarf2/implref-struct.exp, the two only current users of that
procedure.

gdb/testsuite/ChangeLog:

* lib/gdb.exp (get_valueof): Don't capture end-of-line
characters.

6 years agoCollision between NT_GNU_BUILD_ATTRIBUTE_OPEN and NT_PPC_VMX
Alan Modra [Sat, 12 Aug 2017 06:57:29 +0000 (16:27 +0930)] 
Collision between NT_GNU_BUILD_ATTRIBUTE_OPEN and NT_PPC_VMX

* readelf.c (process_note): Qualify NT_GNU_BUILD_ATTRIBUTE notes
by name data.

6 years agoAutomatic date update in version.in
GDB Administrator [Sat, 12 Aug 2017 00:00:57 +0000 (00:00 +0000)] 
Automatic date update in version.in

6 years agox86: Allocate space for symbol names with symbol table
H.J. Lu [Fri, 11 Aug 2017 16:32:44 +0000 (09:32 -0700)] 
x86: Allocate space for symbol names with symbol table

When synthesizing symbols for PLT entries, allocate space for symbol
names with @plt suffixes together with symbol table so that all memory
is returned when symbol table is freed.

PR binutils/21943
* elf32-i386.c (elf_i386_get_synthetic_symtab): Allocate space
for @plt suffixes first.
* elf64-x86-64.c (elf_x86_64_get_synthetic_symtab): Likewise.

6 years agoAdd -z globalaudit linker command line option to set the DF_GLOBALAUDIT flag bit...
Nick Clifton [Fri, 11 Aug 2017 15:36:28 +0000 (16:36 +0100)] 
Add -z globalaudit linker command line option to set the DF_GLOBALAUDIT flag bit in the dynamic tags.

* emultempl/elf32.em (handle_option): Accept the -z globalaudit
command line option.
* lexsup.c (elf_static_list_options): Add -z globalaudit.
* ld.texinfo: Document the support for the new command line
option.
* NEWS: Mention the new feature.
* testsuite/ld-elf/audit.exp: Add a test of the -z globalaudit
command line option.
* testsuite/ld-elf/globalaudit.rd: New file: Expected output from
readelf.

6 years agoAdd 2 more tests for PR ld/21884
H.J. Lu [Fri, 11 Aug 2017 15:05:00 +0000 (08:05 -0700)] 
Add 2 more tests for PR ld/21884

PR ld/21884
* testsuite/ld-i386/i386.exp: Run pr21884.
* testsuite/ld-x86-64/x86-64.exp: Likewise.
* testsuite/ld-i386/pr21884.d: New file.
* testsuite/ld-i386/pr21884.t: Likewise.
* testsuite/ld-x86-64/pr21884.d: Likewise.
* testsuite/ld-x86-64/pr21884.t: Likewise.

6 years agoAlso disallow global alias of common symbol
H.J. Lu [Fri, 11 Aug 2017 14:41:51 +0000 (07:41 -0700)] 
Also disallow global alias of common symbol

We can't create alias of common symbol.  Local alias of common symbol has
been disallowed.  But global alias of common symbol is disallowed when the
common symbol is seen first and silently dropped otherwise.  This patch
disallows alias of common symbol in all cases.

gas/

PR gas/21667
* read.c (pseudo_set): Update error message for alias of common
symbol.
* write.c (write_object_file): Disallow both local and global
aliases of common symbol.
* testsuite/gas/elf/common5a.d: New file.
* testsuite/gas/elf/common5a.l: Likewise.
* testsuite/gas/elf/common5a.s: Likewise.
* testsuite/gas/elf/common5b.d: Likewise.
* testsuite/gas/elf/common5b.l: Likewise.
* testsuite/gas/elf/common5b.s: Likewise.
* testsuite/gas/elf/common5c.d: Likewise.
* testsuite/gas/elf/common5c.s: Likewise.
* testsuite/gas/elf/common5d.d: Likewise.
* testsuite/gas/elf/common5d.s: Likewise.
* testsuite/gas/elf/elf.exp: Run common5a, common5b, common5c
and common5d.

6 years agoMore gdb/skip.c C++ification
Pedro Alves [Fri, 11 Aug 2017 11:11:28 +0000 (12:11 +0100)] 
More gdb/skip.c C++ification

- Make skiplist_entry a class with private data members.
- Move all construction logic to the ctor.
- Make skip_file_p etc be methods of skiplist_entry.
- Use std::list for the skip entries chain.  Make the list own its
  elements.
- Get rid of the ALL_SKIPLIST_ENTRIES/ALL_SKIPLIST_ENTRIES_SAFE
  macros, use range-for / iterators instead.
- function_name_is_marked_for_skip 'function_sal' argument must be
  non-NULL, so make it a reference instead.

All skiplist_entry invariants are now controlled by skiplist_entry
methods/internals.  Some gdb_asserts disappear for being redundant.

gdb/ChangeLog:
2017-08-11  Pedro Alves  <palves@redhat.com>

* infrun.c (process_event_stop_test): Adjust
function_name_is_marked_for_skip call.
* skip.c: Include <list>.
(skiplist_entry): Make it a class with private fields, and
getters/setters.
(skiplist_entry_chain): Delete.
(skiplist_entries): New.
(skiplist_entry_count): Delete.
(highest_skiplist_entry_num): New.
(ALL_SKIPLIST_ENTRIES, ALL_SKIPLIST_ENTRIES_SAFE): Delete.
(add_skiplist_entry): Delete.
(skiplist_entry::skiplist_entry): New.
(skiplist_entry::add_entry): New.
(skip_file_command, skip_function): Adjust.
(compile_skip_regexp): Delete.
(skip_command): Don't compile regexp here.  Adjust to use
skiplist_entry::add_entry.
(skip_info): Adjust to use range-for and getters.
(skip_enable_command, skip_disable_command): Adjust to use
range-for and setters.
(skip_delete_command): Adjust to use std::list.
(add_skiplist_entry): Delete.
(skip_file_p): Delete, refactored as ...
(skiplist_entry::do_skip_file_p): ... this new method.
(skip_gfile_p): Delete, refactored as ...
(skiplist_entry::do_gskip_file_p): ... this new method.
(skip_function_p, skip_rfunction_p): Delete, refactored as ...
(skiplist_entry::skip_function_p): ... this new method.
(function_name_is_marked_for_skip): Now returns bool, and takes
the function sal by const reference.  Adjust to use range-for and
skiplist_entry methods.
(_initialize_step_skip): Remove references to
skiplist_entry_chain, skiplist_entry_count.
* skip.h (function_name_is_marked_for_skip): Now returns bool, and
takes the function sal by const reference.

6 years agoReset *THIS_CACHE in frame_unwind_try_unwinder in case of exception
Yao Qi [Fri, 11 Aug 2017 08:30:02 +0000 (09:30 +0100)] 
Reset *THIS_CACHE in frame_unwind_try_unwinder in case of exception

It is required that unwinder->sniffer should set *this_cache to NULL if
the unwinder is not applicable or exception is thrown, so
78ac5f831692f70b841044961069e50d4ba6a76f adds clear_pointer_cleanup to set
*this_cache to NULL in case of exception in order to fix PR 14100.
https://sourceware.org/ml/gdb-patches/2012-08/msg00075.html

This patch removes that clear_pointer_cleanup, and catch all exception in
the caller of unwinder->sniffer.  In case of exception, reset *this_case.

gdb:

2017-08-11  Yao Qi  <yao.qi@linaro.org>

* dwarf2-frame.c (clear_pointer_cleanup): Remove.
(dwarf2_frame_cache): Remove reset_cache_cleanup.
(dwarf2_frame_cache):
* frame-unwind.c (frame_unwind_try_unwinder): Catch
RETURN_MASK_ALL and set *this_case to NULL.
* frame-unwind.h: Update comments.

6 years agoClass-fy dwarf2_frame_state_reg_info
Yao Qi [Fri, 11 Aug 2017 08:30:02 +0000 (09:30 +0100)] 
Class-fy dwarf2_frame_state_reg_info

This patch adds dwarf2_frame_state_reg_info ctor, dtor, copy ctor,
assignment operator, and move assignment.  This patch also adds unit test
to execute_cfa_program to cover the changes.

gdb:

2017-08-11  Yao Qi  <yao.qi@linaro.org>

* dwarf2-frame.c (dwarf2_frame_state_alloc_regs): Remove.
(dwarf2_frame_state_copy_regs): Remove.
(dwarf2_frame_state_free_regs): Remove.
(dwarf2_frame_state::~dwarf2_frame_state): Remove.
(dwarf2_restore_rule): Call method .alloc_regs instead of
dwarf2_frame_state_alloc_regs.
(execute_cfa_program): Likewise.  Call dwarf2_frame_state_reg_info
constructor.  Call std::move.
(dwarf2_fetch_cfa_info): Don't call dwarf2_frame_state_copy_regs.
(dwarf2_frame_cache): Likewise.

[GDB_SELF_TEST]: Include selftest.h and
selftest-arch.h.
[GDB_SELF_TEST] (execute_cfa_program_test): New function.
(_initialize_dwarf2_frame) [GDB_SELF_TEST]: Register
execute_cfa_program_test.

* dwarf2-frame.h (dwarf2_frame_state_reg_info): Add ctor, dtor,
copy ctor, assignment operator, move assignment.
<alloc_regs>: New method.
<swap>: New method.
(struct dwarf2_frame_state): Delete dtor.
(dwarf2_frame_state_alloc_regs): Remove declaration.
* sparc-tdep.c (sparc_execute_dwarf_cfa_vendor_op): Don't call
dwarf2_frame_state_alloc_regs, use .alloc_regs instead.

6 years agoClass-fy dwarf2_frame_state
Yao Qi [Fri, 11 Aug 2017 08:30:02 +0000 (09:30 +0100)] 
Class-fy dwarf2_frame_state

This patch adds ctor and dtor to dwarf2_frame_state, so that we can
remove one cleanup "old_chain".

gdb:

2017-08-11  Yao Qi  <yao.qi@linaro.org>

* dwarf2-frame.c (dwarf2_frame_state_free): Remove.
(dwarf2_frame_state::dwarf2_frame_state): New.
(dwarf2_frame_state::~dwarf2_frame_state): New.
(dwarf2_fetch_cfa_info): Update.
(dwarf2_frame_cache): Remove old_chain.  Change 'fs' to an object
rather than a pointer.  Update code.
* dwarf2-frame.h (struct dwarf2_frame_state): Declare ctor and
dtor.
<data_align, code_align, retaddr_column>: Change them to const.
<armcc_cfa_offsets_sf, armcc_cfa_offsets_reversed>: Change them
to bool.

6 years agoMove dwarf2_frame_state_reg.exp_len to union .loc
Yao Qi [Fri, 11 Aug 2017 08:30:02 +0000 (09:30 +0100)] 
Move dwarf2_frame_state_reg.exp_len to union .loc

dwarf2_frame_state_reg.exp_len is only used together with .loc.exp, so
it makes more sense to exp_len to the union as well.

gdb:

2017-08-11  Yao Qi  <yao.qi@linaro.org>

* dwarf2-frame.h (struct dwarf2_frame_state_reg) <exp_len>: Remove.
<loc.exp>: New field.
* dwarf2-frame.c (execute_cfa_program): Update.
(dwarf2_frame_prev_register): Update.

6 years agoAutomatic date update in version.in
GDB Administrator [Fri, 11 Aug 2017 00:01:26 +0000 (00:01 +0000)] 
Automatic date update in version.in

6 years agoAllow gdb::unique_xmalloc_ptr<T[]>
Pedro Alves [Thu, 10 Aug 2017 13:18:02 +0000 (14:18 +0100)] 
Allow gdb::unique_xmalloc_ptr<T[]>

Currently, if you try to use the array version of
gdb::unique_xmalloc_ptr (i.e., std::unique_ptr) in order to have
access to operator[], like:

  gdb::unique_xmalloc_ptr<char[]> buf ((char *) xmalloc (10));
  return buf[0];

then the build fails, like:

  /usr/include/c++/5.3.1/bits/unique_ptr.h: In instantiation of ‘std::unique_ptr<_Tp [], _Dp>::~unique_ptr() [with _Tp = char; _Dp = gdb::xfree_deleter<char []>]’:
  main.c:30:61:   required from here
  /usr/include/c++/5.3.1/bits/unique_ptr.h:484:17: error: no match for call to ‘(std::unique_ptr<char [], gdb::xfree_deleter<char []> >::deleter_type {aka gdb::xfree_deleter<char []>}) (char*&)’
      get_deleter()(__ptr);
   ^
  In file included from src/gdb/common/common-defs.h:92:0,
   from src/gdb/defs.h:28,
   from src/gdb/main.c:20:
  src/gdb/common/gdb_unique_ptr.h:34:8: note: candidate: void gdb::xfree_deleter<T>::operator()(T*) const [with T = char []]
     void operator() (T *ptr) const { xfree (ptr); }
  ^
  src/gdb/common/gdb_unique_ptr.h:34:8: note:   no known conversion for argument 1 from ‘char*’ to ‘char (*)[]’
  Makefile:1911: recipe for target 'main.o' failed
  make: *** [main.o] Error 1

The problem is that we're missing an xfree_deleter specialization for
arrays.

gdb/ChangeLog:
2017-08-10  Pedro Alves  <palves@redhat.com>

* common/gdb_unique_ptr.h (xfree_deleter<T[]>): Define.

6 years agoAdd support for PE startup files that want to define their own constructor and desctr...
Nick Clifton [Thu, 10 Aug 2017 12:17:12 +0000 (13:17 +0100)] 
Add support for PE startup files that want to define their own constructor and desctructor sequencing.

* scripttempl/pep.sc: Enclose __CTOR_LIST__, ___CTOR_LIST__,
__DTOR_LIST__ and ___DTOR_LIST__ in PROVIDE statements so that
they can be overrridden by crt input files.
* scripttempl/pe.sc: Likewise.

6 years agoFix memory corruption when assembling an i386 darwin source file.
Nick Clifton [Thu, 10 Aug 2017 10:51:42 +0000 (11:51 +0100)] 
Fix memory corruption when assembling an i386 darwin source file.

PR gas/21939
* config/obj-macho.c (obj_mach_o_set_indirect_symbols): Increase
size of indirect_syms array so that it is large enough to hold
every symbol if necessary.

6 years agoFix out of bounds memory access when trying to allocate space for a note of size -1.
Nick Clifton [Thu, 10 Aug 2017 08:37:36 +0000 (09:37 +0100)] 
Fix out of bounds memory access when trying to allocate space for a note of size -1.

PR 21933
* elf.c (elf_read_notes): Check for a note size of -1.

6 years agoAutomatic date update in version.in
GDB Administrator [Thu, 10 Aug 2017 00:01:40 +0000 (00:01 +0000)] 
Automatic date update in version.in

6 years agoLD_CLASS: Check .libs/ld-new for linker first
H.J. Lu [Wed, 9 Aug 2017 23:32:30 +0000 (16:32 -0700)] 
LD_CLASS: Check .libs/ld-new for linker first

When --enable-shared is used, ./ld-new may be a shell script and the
real linker is .libs/ld-new.  We should check .libs/ld-new first.

* testsuite/config/default.exp (LD_CLASS): Check .libs/ld-new
for linker first.

6 years agoReplace home-grown linked-lists in FreeBSD's native target with STL lists.
John Baldwin [Wed, 9 Aug 2017 22:24:46 +0000 (15:24 -0700)] 
Replace home-grown linked-lists in FreeBSD's native target with STL lists.

FreeBSD's native target uses linked-lists to keep track of pending fork
events and fake vfork done events.  Replace the first list with std::list
and the second with std::forward_list.

gdb/ChangeLog:

* fbsd-nat.c (struct fbsd_fork_info): Remove.
(fbsd_pending_children): Use std::list.
(fbsd_remember_child): Likewise.
(fbsd_is_child_pending): Likewise.
(fbsd_pending_vfork_done): Use std::forward_list.
(fbsd_add_vfork_done): Likewise.
(fbsd_is_vfork_done_pending): Likewise.
(fbsd_next_vfork_done): Likewise.

6 years agoReplace remaining cleanups in fbsd-nat.c.
John Baldwin [Wed, 9 Aug 2017 22:24:46 +0000 (15:24 -0700)] 
Replace remaining cleanups in fbsd-nat.c.

- Use a custom deleter with std::unique_ptr to free() memory returned
  by kinfo_getvmmap().
- Use std::string with string_printf() to generate the pathname of the
  procfs 'map' file.
- Use gdb::byte_vector to manage the dynamic buffer for
  TARGET_OBJECT_AUXV and the dynamically allocated array of LWP IDs.

gdb/ChangeLog:

* fbsd-nat.c [HAVE_KINFO_GETVMMAP] (struct free_deleter): New.
(fbsd_find_memory_regions): Use free_deleter with std::unique_ptr.
[!HAVE_KINFO_GETVMMAP] (fbsd_find_memory_regions): Use std::string
for `mapfilename'.
(fbsd_xfer_partial): Use gdb::byte_vector.
(fbsd_add_threads): Likewise.

6 years agoFix compile in the !HAVE_KINFO_GETVMMAP case.
John Baldwin [Wed, 9 Aug 2017 22:24:46 +0000 (15:24 -0700)] 
Fix compile in the !HAVE_KINFO_GETVMMAP case.

gdb/ChangeLog:

* fbsd-nat.c: [!HAVE_KINFO_GETVMMAP]: Include <sys/user.h> and
"filestuff.h".
(fbsd_find_memory_regions): Fix `mapfile' initialization.

6 years agoRun PR ld/17618 test only with 64-bit ELF linker
H.J. Lu [Wed, 9 Aug 2017 22:04:05 +0000 (15:04 -0700)] 
Run PR ld/17618 test only with 64-bit ELF linker

PR ld/17618 test requires 64-bit linker to run.  Set LD_CLASS to "64bit"
for 64-bit ELF linker and run PR ld/17618 test only if $LD_CLASS is
"64bit".  More checks can be added to support 64-bit linkers in non-ELF
format.

* testsuite/config/default.exp (LD_CLASS): New.  Set to "64bit"
for 64-bit ELF linker.
* testsuite/ld-x86-64/pr17618.d (#notarget): Removed.
* testsuite/ld-x86-64/x86-64.exp: Run pr17618 only for 64-bit
linker.

6 years agodoc: Fix copy-pasto in Z0 packet documentation
Simon Marchi [Wed, 9 Aug 2017 20:16:14 +0000 (22:16 +0200)] 
doc: Fix copy-pasto in Z0 packet documentation

The documentation for the cmd_list field of the Z0 packet refers to its
content as a conditional expression, which seems like a copy-paste error
from the cond_list field.

gdb/doc/ChangeLog:

* gdb.texinfo (Packets): Fix Z0 cmd_list doc referring to
conditional expression.

6 years agoC++-ify skip.c
Tom Tromey [Sat, 5 Aug 2017 22:40:56 +0000 (16:40 -0600)] 
C++-ify skip.c

I happened to notice that skiplist_entry, in skip.c, contains a
gdb::optional<compiled_regex> -- but that this object's destructor is
never run.  This can result in a memory leak.

This patch fixes the bug by applying a bit more C++: changing this
code to use new and delete, and std::unique_ptr; and removing cleanups
in the process.

Built and regression tested on x86-64 Fedora 25.

ChangeLog
2017-08-09  Tom Tromey  <tom@tromey.com>

* skip.c (skiplist_entry): New constructor.
(skiplist_entry::enabled, skiplist_entry::function_is_regexp)
(skiplist_entry::file_is_glob): Now bool.
(skiplist_entry::file, skiplist_entry::function): Now
std::string.
(make_skip_entry): Return a unique_ptr.  Use new.
(free_skiplist_entry, free_skiplist_entry_cleanup)
(make_free_skiplist_entry_cleanup): Remove.
(skip_command, skip_disable_command, add_skiplist_entry)
(skip_form_bytes, compile_skip_regexp, skip_command, skip_info)
(skip_file_p, skip_gfile_p, skip_function_p, skip_rfunction_p)
(function_name_is_marked_for_skip): Update.
(skip_delete_command): Update.  Use delete.

6 years ago[ARM] Don't warn on REG_SP when used in CRC32 instructions
Jiong Wang [Wed, 9 Aug 2017 16:52:54 +0000 (17:52 +0100)] 
[ARM] Don't warn on REG_SP when used in CRC32 instructions

According to ARMv8-A architecture manual, REG_SP is allowed in CRC32
instructions in Thumb mode.  It is REG_PC that will cause unpredictable
behaviours on both ARM and Thumb.

This patch removes the incorrect warning on Thumb mode.

Meanwhile the disassembler is updated to use format "<bitfield>R" instead of
"<bitfield>S".  "<bitfield>S" is not used elsewhere. so I have deleted related
code from the disassembler.

gas/
* config/tc-arm.c (do_crc32_1): Remove warning on REG_SP for thumb_mode.
* testsuite/gas/arm/crc32-armv8-a-bad.d: Update exepcted result.
* testsuite/gas/arm/crc32-armv8-r-bad.d: Likewise.
* testsuite/gas/arm/crc32-armv8-a.d: Likewise.
* testsuite/gas/arm/crc32-armv8-r.d: Likewise.
* testsuite/gas/arm/crc32-armv8-ar-bad.s: Update test case.
* testsuite/gas/arm/crc32-armv8-ar.s: Likewise.
* testsuite/gas/arm/crc32-bad.l: Update expected error message.

opcode/
* arm-dis.c (thumb32_opcodes): Use format 'R' instead of 'S' for
register operands in CRC instructions.
(print_insn_thumb32): Remove "<bitfield>S" support.  Updated the
comments.

6 years ago[AArch64] Implement gdbarch_core_read_description
Jiong Wang [Wed, 9 Aug 2017 16:43:00 +0000 (17:43 +0100)] 
[AArch64] Implement gdbarch_core_read_description

Recommit with missing header files added.

gdb/
* aarch64-linux-tdep.c: Include "auxv.h" and "elf/common.h".
(aarch64_linux_core_read_description): New function.
(aarch64_linux_init_abi): Register gdbarch_core_read_description.

6 years agoRevert "[AArch64] Implement gdbarch_core_read_description"
Jiong Wang [Wed, 9 Aug 2017 14:51:56 +0000 (15:51 +0100)] 
Revert "[AArch64] Implement gdbarch_core_read_description"

This reverts commit b1a6c1cea365f80b90c0bca795c8d16fa0681560.

6 years ago[AArch64] Implement gdbarch_core_read_description
Jiong Wang [Wed, 9 Aug 2017 14:37:20 +0000 (15:37 +0100)] 
[AArch64] Implement gdbarch_core_read_description

Currently, AArch64 only have one target description which is tdesc_aarch64.  So,
we haven't implemented any target description detection mechanism for core file.

This patch is an initial implementation of core_read_description method.  Future
features can use this to return selected description.

gdb/
* aarch64-linux-tdep.c (aarch64_linux_core_read_description): New
function.
(aarch64_linux_init_abi): Register gdbarch_core_read_description.

6 years agoMake cp_comp_to_string return a gdb::unique_xmalloc_ptr<char>
Pedro Alves [Wed, 9 Aug 2017 14:04:32 +0000 (15:04 +0100)] 
Make cp_comp_to_string return a gdb::unique_xmalloc_ptr<char>

To help avoid issues like the one fixed by e88e8651cf34 ("Fix memory
leak in cp-support.c").

gdb/ChangeLog:
2017-08-09  Pedro Alves  <palves@redhat.com>

* cp-name-parser.y (cp_comp_to_string): Return a
gdb::unique_xmalloc_ptr<char>.
* cp-support.c (replace_typedefs_qualified_name)
(replace_typedefs): Adjust to use gdb::unique_xmalloc_ptr<char>.
(cp_canonicalize_string_full): Use op= instead of explicit
convertion.
(cp_class_name_from_physname, method_name_from_physname)
(cp_func_name, cp_remove_params): Adjust to use
gdb::unique_xmalloc_ptr<char>.
* cp-support.h (cp_comp_to_string): Return a
gdb::unique_xmalloc_ptr<char>.
* python/py-type.c (typy_lookup_type): Adjust to use
gdb::unique_xmalloc_ptr<char>.

6 years agogdb: Fix build failure with GCC 7
H.J. Lu [Wed, 9 Aug 2017 12:01:55 +0000 (05:01 -0700)] 
gdb: Fix build failure with GCC 7

Fix:

/export/gnu/import/git/sources/binutils-gdb/gdb/dwarf2read.c: In function ‘const char* dwarf2_string_attr(die_info*, unsigned int, dwarf2_cu*)’:
/export/gnu/import/git/sources/binutils-gdb/gdb/dwarf2read.c:17626:39: error: enum constant in boolean context [-Werror=int-in-bool-context]
    || attr->form == DW_FORM_string || DW_FORM_GNU_str_index

* dwarf2read.c (dwarf2_string_attr): Fix a typo.

6 years agoFix memory leak in cp-support.c
Yao Qi [Wed, 9 Aug 2017 11:39:16 +0000 (12:39 +0100)] 
Fix memory leak in cp-support.c

The return value of cp_comp_to_string was never freed, creating a
sizable memory leak detectable with valgrind.

==21225== 8 bytes in 1 blocks are definitely lost in loss record 4,599 of 10,949^M
==21225==    at 0x4C2DB8F: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)^M
==21225==    by 0x4C2FDEF: realloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)^M
==21225==    by 0x76CB31: d_growable_string_resize (cp-demangle.c:3963)^M
==21225==    by 0x76CB31: d_growable_string_init (cp-demangle.c:3942)^M
==21225==    by 0x76CB31: cplus_demangle_print (cp-demangle.c:4308)^M
==21225==    by 0x4C9535: cp_comp_to_string(demangle_component*, int) (cp-name-parser.y:1972)^M
==21225==    by 0x53E1D4: cp_canonicalize_string_full[abi:cxx11](char const*, char const* (*)(type*, void*), void*) (cp-support.c:530)^M
==21225==    by 0x53E360: cp_canonicalize_string_no_typedefs[abi:cxx11](char const*) (cp-support.c:548)^M
==21225==    by 0x5D51D2: find_linespec_symbols(linespec_state*, VEC_symtab_ptr*, char const*, VEC_symbolp**, VEC_bound_minimal_symbol_d**) (linespec.c:4030)^M
==21225==    by 0x5D6CF6: linespec_parse_basic (linespec.c:1907)

==21279== 32 bytes in 1 blocks are definitely lost in loss record 6,066 of 10,947^M
==21279==    at 0x4C2DB8F: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)^M
==21279==    by 0x4C2FDEF: realloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)^M
==21279==    by 0x76CB31: d_growable_string_resize (cp-demangle.c:3963)^M
==21279==    by 0x76CB31: d_growable_string_init (cp-demangle.c:3942)^M
==21279==    by 0x76CB31: cplus_demangle_print (cp-demangle.c:4308)^M
==21279==    by 0x4C9535: cp_comp_to_string(demangle_component*, int) (cp-name-parser.y:1972)^M
==21279==    by 0x53EF14: cp_canonicalize_string[abi:cxx11](char const*) (cp-support.c:569)^M
==21279==    by 0x561B75: dwarf2_canonicalize_name(char const*, dwarf2_cu*, obstack*) [clone .isra.210] (dwarf2read.c:20159)

This patch fixes the leak.  It is a regression by 2f408ecb.

gdb:

2017-08-09  Alex Lindsay  <alexlindsay239@gmail.com>
    Yao Qi  <yao.qi@linaro.org>

* cp-support.c (cp_canonicalize_string_full): Use
gdb::unique_xmalloc_ptr<char>.
(cp_canonicalize_string): Likewise.

6 years agoClean up x86 non-linux GDBserver target descriptions
Yao Qi [Wed, 9 Aug 2017 11:27:24 +0000 (12:27 +0100)] 
Clean up x86 non-linux GDBserver target descriptions

In GDBserver, only tdesc_i386 and tdesc_amd64 are used.  There is no point
of generating these *.dat files (which are used to generate *.c files during
GDBserver build.).

gdb:

2017-08-09  Yao Qi  <yao.qi@linaro.org>

* features/Makefile (WHICH): Remove i386/ non-linux stuff.
* regformats/i386/amd64-avx-avx512.dat: Remove.
* regformats/i386/amd64-avx-mpx-avx512-pku.dat: Remove.
* regformats/i386/amd64-avx-mpx.dat:Remove.
* regformats/i386/amd64-avx.dat: Remove.
* regformats/i386/amd64-mpx.dat: Remove.
* regformats/i386/i386-avx-avx512.dat: Remove.
* regformats/i386/i386-avx-mpx-avx512-pku.dat: Remove.
* regformats/i386/i386-avx-mpx.dat: Remove.
* regformats/i386/i386-mmx.dat: Remove.
* regformats/i386/i386-mpx.dat: Remove.

gdb/gdbserver:

2017-08-09  Yao Qi  <yao.qi@linaro.org>

* configure.srv (srv_i386_regobj): Remove i386-avx.o,
i386-avx-avx512.o, i386-avx-mpx-avx512-pku.o, i386-mpx.o,
i386-avx-mpx.o and i386-mmx.o.
(srv_amd64_regobj): Remove amd64-avx.o, amd64-avx-avx512.o,
amd64-avx-mpx-avx512-pku.o, amd64-mpx.o and amd64-avx-mpx.o.
(srv_i386_xmlfiles): Remove i386/i386-avx.xml,
i386/i386-avx-avx512.xml, i386/i386-avx-mpx-avx512-pku.xml,
i386/i386-mpx.xml, i386/i386-avx-mpx.xml and i386/i386-mmx.xml.
(srv_amd64_xmlfile):i386/amd64-avx.xml, i386/amd64-avx-avx512.xml,
i386/amd64-avx-mpx-avx512-pku.xml, i386/amd64-mpx.xml,
i386/amd64-avx-mpx.xml.

6 years agoRemove x32 non-linux target descriptions
Yao Qi [Wed, 9 Aug 2017 11:27:23 +0000 (12:27 +0100)] 
Remove x32 non-linux target descriptions

x32 non-linux target descriptions are not used in GDB or GDBserver.  This
patch removes them.

gdb:

2017-08-09  Yao Qi  <yao.qi@linaro.org>

* amd64-tdep.h (tdesc_x32): Remove the declaration.
* amd64-tdep.c: Don't include features/i386/x32*.c.
(_initialize_amd64_tdep): Don't call initialize_tdesc_x32*
functions.
* features/Makefile (WHICH): Remove i386/x32, i386/x32-avx,
and i386/x32-avx-avx512.
(XMLTOC): Remove i386/x32-avx.xml, i386/x32-avx-avx512.xml,
and i386/x32.xml.
* features/i386/x32-avx-avx512.c: Removed.
* features/i386/x32-avx-avx512.xml: Removed.
* features/i386/x32-avx.c: Removed.
* features/i386/x32-avx.xml: Removed.
* features/i386/x32.c: Removed.
* features/i386/x32.xml: Removed.
* regformats/i386/x32-avx-avx512.dat: Removed.
* regformats/i386/x32-avx.dat: Removed.
* regformats/i386/x32.dat: Removed.

gdb/gdbserver:

2017-08-09  Yao Qi  <yao.qi@linaro.org>

* configure.srv (srv_amd64_regobj): Remove x32.o, x32-avx.o
and x32-avx-avx512.o.
(srv_amd64_xmlfiles): Remove i386/x32.xml, i386/x32-avx.xml
i386/x32-avx-avx512.xml.

6 years agold: Require GCC 5 or above for 3 x86 tests
H.J. Lu [Wed, 9 Aug 2017 03:20:43 +0000 (20:20 -0700)] 
ld: Require GCC 5 or above for 3 x86 tests

Require GCC 5 or above for 3 x86 tests which fail with GCC 4.9.3.

PR ld/21924
* testsuite/ld-i386/i386.exp: Require GCC 5 or above for
"weakundef1 with PIE" test.
* testsuite/ld-x86-64/tls.exp: Require GCC 5 or above for
"tlsdesc1" and "tlsdesc1 with PIE" tests.

6 years agold: Add a ',' after -Wl,--rpath
H.J. Lu [Wed, 9 Aug 2017 03:01:28 +0000 (20:01 -0700)] 
ld: Add a ',' after -Wl,--rpath

* configure.ac (TESTBFDLIB): Add a ',' after -Wl,--rpath.
* configure: Regenerated.

6 years agoAutomatic date update in version.in
GDB Administrator [Wed, 9 Aug 2017 00:00:58 +0000 (00:00 +0000)] 
Automatic date update in version.in

6 years agold: Replace --rpath with -Wl,--rpath
H.J. Lu [Tue, 8 Aug 2017 21:13:46 +0000 (14:13 -0700)] 
ld: Replace --rpath with -Wl,--rpath

"--rpath ../bfd/.libs ../bfd/.libs/libbfd.so" isn't a valid compiler
command-line option.  We should use -Wl,--rpath instead of --rpath.

PR ld/21923
* configure.ac (TESTBFDLIB): Replace --rpath with -Wl,--rpath
for --disable-static.
* configure: Regenerated.

6 years agoFix address violation problems when parsing corrupt ELF binaries.
Nick Clifton [Tue, 8 Aug 2017 12:20:02 +0000 (13:20 +0100)] 
Fix address violation problems when parsing corrupt ELF binaries.

PR 21916
* elf-attrs.c (_bfd_elf_parse_attributes): Complain about very
small section lengths.
* elf.c (_bfd_elf_setup_sections): Skip empty entries in the group
table.
(elfcore_grok_freebsd_prstatus): Add checks to make sure that
there is enough data present in the note.

6 years agoUpdated Serbian translation for gprof
Nick Clifton [Tue, 8 Aug 2017 10:59:32 +0000 (11:59 +0100)] 
Updated Serbian translation for gprof

6 years agoFix address violation bugs when writing beyond the end of a local string buffer.
Nick Clifton [Tue, 8 Aug 2017 10:57:22 +0000 (11:57 +0100)] 
Fix address violation bugs when writing beyond the end of a local string buffer.

PR 21909
* prdbg.c (pr_int_type): Increase size of local string buffer.
(pr_float_type): Likewise.
(pr_bool_type): Likewise.

6 years agoPR21017, microblaze missing _GLOBAL_OFFSET_TABLE_ symbol
Alan Modra [Tue, 8 Aug 2017 04:35:33 +0000 (14:05 +0930)] 
PR21017, microblaze missing _GLOBAL_OFFSET_TABLE_ symbol

PR 21017
* elf32-microblaze.c (microblaze_elf_check_relocs): Don't bump
got.refcount for GOTOFF relocs, just create .got section.

6 years agoAutomatic date update in version.in
GDB Administrator [Tue, 8 Aug 2017 00:00:54 +0000 (00:00 +0000)] 
Automatic date update in version.in

6 years agoAdd configure flag to enable gnu hash style by default.
Romain Geissler [Mon, 7 Aug 2017 21:55:39 +0000 (07:25 +0930)] 
Add configure flag to enable gnu hash style by default.

ld/
* configure.ac: Add --enable-default-hash-style option.
* ldmain.c (main): Set link_info.emit_hash to DEFAULT_EMIT_SYSV_HASH.
Set link_info.emit_gnu_hash to DEFAULT_EMIT_GNU_HASH.
* configure: Regenerate.
* config.in: Regenerate.

gold/
* configure.ac: Add --enable-default-hash-style option.
* options.h (hash_style): Use DEFAULT_HASH_STYLE as default value.
* configure: Regenerate.
* config.in: Regenerate.

6 years agoMore support for ld --hash-style in the ld testsuite
Alan Modra [Mon, 7 Aug 2017 21:45:29 +0000 (07:15 +0930)] 
More support for ld --hash-style in the ld testsuite

These were discovered when running --hash-style=gnu as default, the
previous batch being --hash-style=both.

* testsuite/ld-aarch64/ifunc-1-local.d: Run ld with --hash-style=sysv.
* testsuite/ld-aarch64/ifunc-2-local.d: Likewise.
* testsuite/ld-aarch64/ifunc-3a.d: Likewise.
* testsuite/ld-frv/fdpic-pie-1.d: Likewise.
* testsuite/ld-frv/fdpic-pie-2.d: Likewise.
* testsuite/ld-frv/fdpic-pie-7.d: Likewise.
* testsuite/ld-frv/fdpic-pie-8.d: Likewise.
* testsuite/ld-arm/arm-elf.exp: Add --hash-style=sysv to "Using
Thumb lib by another lib" test's ld options.
* testsuite/ld-elf/note-3.l: Match .gnu.hash.
* testsuite/ld-elf/note-3.t: Add .gnu.hash output section.

6 years agoAdd missing PR mention in ChangeLog
Simon Marchi [Mon, 7 Aug 2017 16:25:59 +0000 (18:25 +0200)] 
Add missing PR mention in ChangeLog

I noticed that the patch pushed previously had an open bug about it, so
add a reference to it.

6 years agoPR breakpoints/21886: mem-break: Fix breakpoint insertion location
Maciej W. Rozycki [Mon, 7 Aug 2017 16:02:04 +0000 (17:02 +0100)] 
PR breakpoints/21886: mem-break: Fix breakpoint insertion location

Fix a commit cd6c3b4ffc4e ("New gdbarch methods breakpoint_kind_from_pc
and sw_breakpoint_from_kind") regression and restore the use of
`->placed_address' rather than `->reqstd_address' as the location for a
memory breakpoint to be inserted at.  Previously
`gdbarch_breakpoint_from_pc' was used that made that adjustment in
`default_memory_insert_breakpoint' from the preinitialized value,
however with the said commit that call is gone, so the passed
`->placed_address' has to be used for the initialization.

The regression manifests itself as the inability to debug any MIPS/Linux
compressed ISA dynamic executable as GDB corrupts the dynamic loader
with one of its implicit breakpoints, causing the program to crash, as
seen for example with the `mips-linux-gnu' target, o32 ABI, MIPS16 code,
and the gdb.base/advance.exp test case:

(gdb) continue
Continuing.

Program received signal SIGBUS, Bus error.
_dl_debug_initialize (ldbase=0, ns=0) at dl-debug.c:51
51     r = &_r_debug;
(gdb) FAIL: gdb.base/advance.exp: Can't run to main

gdb/
PR breakpoints/21886
* mem-break.c (default_memory_insert_breakpoint): Use
`->placed_address' rather than `->reqstd_address' for the
breakpoint location.

6 years agoMark big and mach with ATTRIBUTE_UNUSED
H.J. Lu [Mon, 7 Aug 2017 15:07:26 +0000 (08:07 -0700)] 
Mark big and mach with ATTRIBUTE_UNUSED

Fix build on x86:

opcodes/disassemble.c: In function ‘disassembler’:
opcodes/disassemble.c:113:52: error: unused parameter ‘big’ [-Werror=unused-parameter]
 disassembler (enum bfd_architecture a, bfd_boolean big, unsigned long mach,
                                                    ^~~
opcodes/disassemble.c:113:71: error: unused parameter ‘mach’ [-Werror=unused-parameter]
 disassembler (enum bfd_architecture a, bfd_boolean big, unsigned long mach,
                                                                       ^~~~
cc1: all warnings being treated as errors

* disassemble.c (disassembler): Mark big and mach with
ATTRIBUTE_UNUSED.

6 years agoMove common symbol check after bed->common_definition
H.J. Lu [Mon, 7 Aug 2017 15:02:12 +0000 (08:02 -0700)] 
Move common symbol check after bed->common_definition

bfd/

* elflink.c (elf_link_add_object_symbols): Move common symbol
check after bed->common_definition.

ld/

* testsuite/ld-elf/pr21903.s (start): Removed.
(_start): Likewise.
(__start): Likewise.
(main): Likewise.
(bar): New.

6 years agoGDB/opcodes: Remove arch/mach/endian disassembler assertions
Maciej W. Rozycki [Mon, 7 Aug 2017 14:53:54 +0000 (15:53 +0100)] 
GDB/opcodes: Remove arch/mach/endian disassembler assertions

Fix `set architecture' and `set endian' command disassembly regressions
from commit 39503f82427e ("Delegate opcodes to select disassembler in
GDB"), and commit 003ca0fd2286 ("Refactor disassembler selection"), as
well as a MIPS compressed ISA disassembly target regression from commit
6394c606997f ("Don't use print_insn_XXX in GDB"), which caused assertion
failures to trigger.

For example with the `mips-linux-gnu' target we get:

$ cat main.c
int
main (void)
{
  return 0;
}
$ gcc -mips32r2 -O2 main.c -o main
$ gcc -mips16 -mips32r2 -O2 main.c -o main16
$ gdb
GNU gdb (GDB) 8.0.50.20170731-git
[...]
(gdb) file main
Reading symbols from main...done.
(gdb) show architecture
The target architecture is set automatically (currently mips:isa32r2)
(gdb) show endian
The target endianness is set automatically (currently big endian)
(gdb) disassemble main
Dump of assembler code for function main:
   0x00400500 <+0>: jr ra
   0x00400504 <+4>: move v0,zero
End of assembler dump.
(gdb) set architecture mips:isa64r2
The target architecture is assumed to be mips:isa64r2
(gdb) disassemble main
Dump of assembler code for function main:
   0x00400500 <+0>:
.../gdb/arch-utils.c:979: internal-error: int default_print_insn(bfd_vma, disassemble_info*): Assertion `info->mach == bfd_get_mach (exec_bfd)' failed.
A problem internal to GDB has been detected,
further debugging may prove unreliable.
Quit this debugging session? (y or n) n
[...]
Command aborted.
(gdb) set architecture auto
The target architecture is set automatically (currently mips:isa32r2)
(gdb) set endian little
The target is assumed to be little endian
(gdb) disassemble main
Dump of assembler code for function main:
   0x00400500 <+0>:
.../gdb/arch-utils.c:978: internal-error: int default_print_insn(bfd_vma, disassemble_info*): Assertion `info->endian == (bfd_big_endian (exec_bfd) ? BFD_ENDIAN_BIG : BFD_ENDIAN_LITTLE)' failed.
A problem internal to GDB has been detected,
further debugging may prove unreliable.
Quit this debugging session? (y or n) n
[...]
Command aborted.
(gdb) set endian auto
The target endianness is set automatically (currently big endian)
(gdb) set architecture i386
The target architecture is assumed to be i386
(gdb) disassemble main
Dump of assembler code for function main:
   0x00400500 <+0>:
.../gdb/arch-utils.c:976: internal-error: int default_print_insn(bfd_vma, disassemble_info*): Assertion `info->arch == bfd_get_arch (exec_bfd)' failed.
A problem internal to GDB has been detected,
further debugging may prove unreliable.
Quit this debugging session? (y or n) n
[...]
Command aborted.
(gdb) set architecture auto
The target architecture is set automatically (currently mips:isa32r2)
(gdb) file main16
Load new symbol table from "main16"? (y or n) y
Reading symbols from main16...done.
(gdb) disassemble main
Dump of assembler code for function main:
   0x00400501 <+0>:
.../gdb/arch-utils.c:979: internal-error: int default_print_insn(bfd_vma, disassemble_info*): Assertion `info->mach == bfd_get_mach (exec_bfd)' failed.
A problem internal to GDB has been detected,
further debugging may prove unreliable.
Quit this debugging session? (y or n) n
Command aborted.
(gdb)

Remove the assertions then, restoring previous semantics:

(gdb) file main
Reading symbols from main...done.
(gdb) set architecture mips:isa64r2
The target architecture is assumed to be mips:isa64r2
(gdb) disassemble main
Dump of assembler code for function main:
   0x00400500 <+0>: jr ra
   0x00400504 <+4>: move v0,zero
End of assembler dump.
(gdb) set endian little
The target is assumed to be little endian
(gdb) disassemble main
Dump of assembler code for function main:
   0x00400500 <+0>: j 0x3800c
   0x00400504 <+4>: addiu s0,t0,0
End of assembler dump.
(gdb) set architecture i386
The target architecture is assumed to be i386
(gdb) disassemble main
Dump of assembler code for function main:
   0x00400500 <+0>: add    %eax,%esp
   0x00400502 <+2>: add    %cl,(%eax)
   0x00400504 <+4>: add    %al,(%eax)
   0x00400506 <+6>: adc    %ah,0x0
End of assembler dump.
(gdb) set architecture auto
The target architecture is set automatically (currently mips:isa32r2)
(gdb) set endian auto
The target endianness is set automatically (currently big endian)
(gdb) file main16
Load new symbol table from "main16"? (y or n) y
Reading symbols from main16...done.
(gdb) disassemble main
Dump of assembler code for function main:
   0x00400501 <+0>: jr ra
   0x00400503 <+2>: li v0,0
End of assembler dump.
(gdb)

gdb/
* arch-utils.c (default_print_insn): Remove arch/mach/endian
assertions.

opcodes/
* disassemble.c (disassembler): Remove arch/mach/endian
assertions.

6 years agogdbarch: Use an anonymous union for target data in `gdbarch_info'
Maciej W. Rozycki [Mon, 7 Aug 2017 14:53:54 +0000 (15:53 +0100)] 
gdbarch: Use an anonymous union for target data in `gdbarch_info'

As an update to commit ede5f15146ae ("gdbarch.h: Change
gdbarch_info::tdep_info's type to void *") replace the definition of the
`tdep_info' member in `struct gdbarch_info' with an anonymous union,
comprising the original member, with its type reverted to `struct
gdbarch_tdep_info *', a `tdesc_data' member of a `struct tdesc_arch_data
*' type and an `id' member of an `int *' type.  Remove now unnecessary
casts throughout use places then, making code easier to read an less
prone to errors, which may happen with casting.

gdb/
* gdbarch.sh (gdbarch_info): Replace the `tdep_info' member with
a union of `tdep_info', `tdesc_data' and `id'.
* aarch64-tdep.c (aarch64_gdbarch_init): Use `info.tdesc_data'
rather than `info.tdep_info'.
* amd64-linux-tdep.c (amd64_linux_init_abi): Likewise.
* i386-linux-tdep.c (i386_linux_init_abi): Likewise.
* i386-tdep.c (i386_gdbarch_init): Likewise.
* mips-linux-tdep.c (mips_linux_init_abi): Likewise.
* mips-tdep.c (mips_gdbarch_init): Likewise.
* nds32-tdep.c (nds32_gdbarch_init): Likewise.
* rs6000-tdep.c (rs6000_gdbarch_init): Likewise.
* ppc-linux-tdep.c (ppu2spu_sniffer): Use `info.id' rather than
`info.tdep_info'.
(ppc_linux_init_abi): Use `info.tdesc_data' rather than
`info.tdep_info'.
* sparc-tdep.c (sparc32_gdbarch_init): Likewise.
* spu-multiarch.c (spu_gdbarch): Use `info.id' rather than
`info.tdep_info'.
* spu-tdep.c (spu_gdbarch_init): Likewise.
* gdbarch.h: Regenerate.

6 years agoFix dwarf2_string_attr for -gsplit-dwarf
Leszek Swirski [Mon, 7 Aug 2017 14:40:38 +0000 (16:40 +0200)] 
Fix dwarf2_string_attr for -gsplit-dwarf

The dwarf2_string_attr did not allow DW_FORM_GNU_str_index as a form for
string types. This manifested as null strings in the namespace_name
lookup (replaced with "(anonymous namespace)") when debugging
Fission-compiled code.

gdb/ChangeLog:

* dwarf2read.c (dwarf2_string_attr): Allow DW_FORM_GNU_strp_alt.

6 years agoSupport different ld --hash-style in the ld testsuite
Alan Modra [Sun, 6 Aug 2017 12:34:25 +0000 (22:04 +0930)] 
Support different ld --hash-style in the ld testsuite

When ld is running with something other than --hash-style=sysv by
default, numerous tests need tweaking.  Most of the changes just add
--hash-style=sysv.  I didn't want to make --hash-style=sysv global as
that means --hash-style=gnu isn't well tested.

* testsuite/ld-alpha/alpha.exp: Add --hash-style=sysv to various
test's ld options.
* testsuite/ld-arm/arm-elf.exp: Likewise.
* testsuite/ld-elf/elf.exp: Likewise.
* testsuite/ld-elf/readelf.exp: Likewise.
* testsuite/ld-elfvsb/elfvsb.exp: Likewise.
* testsuite/ld-i386/i386.exp: Likewise.
* testsuite/ld-ia64/ia64.exp: Likewise.
* testsuite/ld-m68k/m68k.exp: Likewise.
* testsuite/ld-metag/metag.exp: Likewise.
* testsuite/ld-powerpc/powerpc.exp: Likewise.
* testsuite/ld-s390/s390.exp: Likewise.
* testsuite/ld-sh/sh-vxworks.exp: Likewise.
* testsuite/ld-shared/shared.exp: Likewise.
* testsuite/ld-sparc/sparc.exp: Likewise.
* testsuite/ld-tic6x/tic6x.exp: Likewise.
* testsuite/ld-vax-elf/vax-elf.exp: Likewise.
* testsuite/ld-x86-64/mpx.exp: Likewise.
* testsuite/ld-x86-64/x86-64.exp: Likewise.
* testsuite/ld-xtensa/xtensa.exp: Likewise.

* testsuite/ld-elf/comm-data2.ld: Add .gnu.hash output section.
* testsuite/ld-elf/pr20828-v.ld: Likewise.
* testsuite/ld-elf/pr20828.ld: Likewise.
* testsuite/ld-elf/pr21233.ld: Likewise.
* testsuite/ld-elf/pr21384.ld: Likewise.
* testsuite/ld-elf/provide-hidden-1.ld: Likewise.
* testsuite/ld-elf/provide-hidden-2.ld: Likewise.
* testsuite/ld-elf/provide-hidden-s.ld: Likewise.
* testsuite/ld-scripts/cross1.t: Likewise.

* testsuite/ld-elf/stab.d: Adjust allowed section indices.

* testsuite/ld-i386/pie1.d: Don't match addresses.
* testsuite/ld-i386/plt-pic2.dd: Likewise.
* testsuite/ld-i386/pr19636-1d.d: Likewise.
* testsuite/ld-i386/pr19636-2c.d: Likewise.
* testsuite/ld-powerpc/elfv2so.d: Likewise.
* testsuite/ld-powerpc/tlsopt5.d: Likewise.
* testsuite/ld-powerpc/tlsopt5.wf: Likewise.
* testsuite/ld-powerpc/tlsopt5_32.d: Likewise.

* testsuite/ld-i386/pr19636-2b.d: Don't match _start.

* testsuite/ld-powerpc/ambiguousv1.d: Relax symbol count, index
and address match.
* testsuite/ld-powerpc/ambiguousv1b.d: Likewise.
* testsuite/ld-powerpc/ambiguousv2.d: Likewise.
* testsuite/ld-powerpc/ambiguousv2b.d: Likewise.

* testsuite/ld-aarch64/gc-plt-relocs.d: Run ld with --hash-style=sysv.
* testsuite/ld-aarch64/ifunc-1.d: Likewise.
* testsuite/ld-aarch64/ifunc-2.d: Likewise.
* testsuite/ld-aarch64/ifunc-21.d: Likewise.
* testsuite/ld-aarch64/relasz.d: Likewise.
* testsuite/ld-aarch64/tls-small-ld.d: Likewise.
* testsuite/ld-aarch64/tls-tiny-ld.d: Likewise.
* testsuite/ld-arc/tls_gd-01.d: Likewise.
* testsuite/ld-cris/libdso-10.d: Likewise.
* testsuite/ld-cris/libdso-2.d: Likewise.
* testsuite/ld-cris/pic-gc-72.d: Likewise.
* testsuite/ld-cris/pic-gc-73.d: Likewise.
* testsuite/ld-cris/tls-gd-1.d: Likewise.
* testsuite/ld-cris/tls-gd-1h.d: Likewise.
* testsuite/ld-cris/tls-gd-2.d: Likewise.
* testsuite/ld-cris/tls-gd-2h.d: Likewise.
* testsuite/ld-cris/tls-ie-10.d: Likewise.
* testsuite/ld-cris/tls-ie-11.d: Likewise.
* testsuite/ld-cris/tls-ie-8.d: Likewise.
* testsuite/ld-cris/tls-ie-9.d: Likewise.
* testsuite/ld-cris/tls-ld-4.d: Likewise.
* testsuite/ld-cris/tls-ld-5.d: Likewise.
* testsuite/ld-cris/tls-ld-6.d: Likewise.
* testsuite/ld-cris/tls-ld-7.d: Likewise.
* testsuite/ld-cris/tls-ldgd-14.d: Likewise.
* testsuite/ld-cris/tls-ldgd-15.d: Likewise.
* testsuite/ld-cris/tls-ldgdx-14.d: Likewise.
* testsuite/ld-cris/tls-ldgdx-15.d: Likewise.
* testsuite/ld-cris/tls-local-54.d: Likewise.
* testsuite/ld-cris/tls-local-60.d: Likewise.
* testsuite/ld-cris/tls-local-61.d: Likewise.
* testsuite/ld-cris/weakhiddso.d: Likewise.
* testsuite/ld-elf/linkinfo1a.d: Likewise.
* testsuite/ld-elf/linkinfo1b.d: Likewise.
* testsuite/ld-elf/pr19617a.d: Likewise.
* testsuite/ld-elfvsb/hidden2.d: Likewise.
* testsuite/ld-frv/fdpic-pie-6.d: Likewise.
* testsuite/ld-frv/fdpic-shared-2.d: Likewise.
* testsuite/ld-frv/fdpic-shared-5.d: Likewise.
* testsuite/ld-frv/fdpic-shared-6.d: Likewise.
* testsuite/ld-frv/fdpic-shared-8.d: Likewise.
* testsuite/ld-frv/fdpic-shared-local-2.d: Likewise.
* testsuite/ld-frv/fdpic-shared-local-8.d: Likewise.
* testsuite/ld-frv/tls-dynamic-2.d: Likewise.
* testsuite/ld-i386/ibt-plt-1.d: Likewise.
* testsuite/ld-i386/ibt-plt-2a.d: Likewise.
* testsuite/ld-i386/ibt-plt-2c.d: Likewise.
* testsuite/ld-i386/ibt-plt-3a.d: Likewise.
* testsuite/ld-i386/ibt-plt-3c.d: Likewise.
* testsuite/ld-i386/pr20830.d: Likewise.
* testsuite/ld-ia64/merge1.d: Likewise.
* testsuite/ld-ia64/merge2.d: Likewise.
* testsuite/ld-ia64/merge3.d: Likewise.
* testsuite/ld-ia64/merge4.d: Likewise.
* testsuite/ld-ia64/merge5.d: Likewise.
* testsuite/ld-ifunc/ifunc-1-local-x86.d: Likewise.
* testsuite/ld-ifunc/ifunc-1-x86.d: Likewise.
* testsuite/ld-ifunc/ifunc-2-i386-now.d: Likewise.
* testsuite/ld-ifunc/ifunc-2-local-i386-now.d: Likewise.
* testsuite/ld-ifunc/ifunc-2-local-x86-64-now.d: Likewise.
* testsuite/ld-ifunc/ifunc-2-local-x86-64.d: Likewise.
* testsuite/ld-ifunc/ifunc-2-x86-64-now.d: Likewise.
* testsuite/ld-ifunc/ifunc-2-x86-64.d: Likewise.
* testsuite/ld-ifunc/ifunc-3a-x86.d: Likewise.
* testsuite/ld-ifunc/pr17154-i386-now.d: Likewise.
* testsuite/ld-ifunc/pr17154-i386.d: Likewise.
* testsuite/ld-ifunc/pr17154-x86-64-now.d: Likewise.
* testsuite/ld-ifunc/pr17154-x86-64.d: Likewise.
* testsuite/ld-m68k/got-1.d: Likewise.
* testsuite/ld-m68k/got-multigot-12-13-14-34-35-ok.d: Likewise.
* testsuite/ld-m68k/got-multigot-14-ok.d: Likewise.
* testsuite/ld-m68k/got-multigot-15-er.d: Likewise.
* testsuite/ld-m68k/got-negative-12-13-14-34-ok.d: Likewise.
* testsuite/ld-m68k/got-negative-12-13-14-35-er.d: Likewise.
* testsuite/ld-m68k/got-negative-14-ok.d: Likewise.
* testsuite/ld-m68k/got-negative-15-er.d: Likewise.
* testsuite/ld-m68k/got-single-12-ok.d: Likewise.
* testsuite/ld-m68k/got-single-13-er.d: Likewise.
* testsuite/ld-m68k/got-xgot-12-13-14-15-34-35-ok.d: Likewise.
* testsuite/ld-m68k/got-xgot-15-ok.d: Likewise.
* testsuite/ld-m68k/tls-gd-1.d: Likewise.
* testsuite/ld-m68k/tls-gd-2.d: Likewise.
* testsuite/ld-m68k/tls-gd-ie-1.d: Likewise.
* testsuite/ld-m68k/tls-ie-1.d: Likewise.
* testsuite/ld-m68k/tls-ld-1.d: Likewise.
* testsuite/ld-m68k/tls-ld-2.d: Likewise.
* testsuite/ld-sh/shared-2.d: Likewise.
* testsuite/ld-sh/tlsbin-2.d: Likewise.
* testsuite/ld-sh/tlspic-2.d: Likewise.
* testsuite/ld-x86-64/bnd-branch-1-now.d: Likewise.
* testsuite/ld-x86-64/bnd-ifunc-1-now.d: Likewise.
* testsuite/ld-x86-64/bnd-ifunc-1.d: Likewise.
* testsuite/ld-x86-64/bnd-ifunc-2-now.d: Likewise.
* testsuite/ld-x86-64/bnd-ifunc-2.d: Likewise.
* testsuite/ld-x86-64/bnd-plt-1-now.d: Likewise.
* testsuite/ld-x86-64/bnd-plt-1.d: Likewise.
* testsuite/ld-x86-64/ibt-plt-1-x32.d: Likewise.
* testsuite/ld-x86-64/ibt-plt-1.d: Likewise.
* testsuite/ld-x86-64/ibt-plt-2a-x32.d: Likewise.
* testsuite/ld-x86-64/ibt-plt-2a.d: Likewise.
* testsuite/ld-x86-64/ibt-plt-2c-x32.d: Likewise.
* testsuite/ld-x86-64/ibt-plt-2c.d: Likewise.
* testsuite/ld-x86-64/ibt-plt-3a-x32.d: Likewise.
* testsuite/ld-x86-64/ibt-plt-3a.d: Likewise.
* testsuite/ld-x86-64/ibt-plt-3c-x32.d: Likewise.
* testsuite/ld-x86-64/ibt-plt-3c.d: Likewise.
* testsuite/ld-x86-64/ilp32-4-nacl.d: Likewise.
* testsuite/ld-x86-64/ilp32-4.d: Likewise.
* testsuite/ld-x86-64/load1c-nacl.d: Likewise.
* testsuite/ld-x86-64/load1c.d: Likewise.
* testsuite/ld-x86-64/load1d-nacl.d: Likewise.
* testsuite/ld-x86-64/load1d.d: Likewise.
* testsuite/ld-x86-64/pie3-nacl.d: Likewise.
* testsuite/ld-x86-64/pie3.d: Likewise.
* testsuite/ld-x86-64/pr14207.d: Likewise.
* testsuite/ld-x86-64/pr19162.d: Likewise.
* testsuite/ld-x86-64/pr19636-2d-nacl.d: Likewise.
* testsuite/ld-x86-64/pr19636-2d.d: Likewise.
* testsuite/ld-x86-64/pr20253-1d.d: Likewise.
* testsuite/ld-x86-64/pr20253-1f.d: Likewise.
* testsuite/ld-x86-64/pr20253-1j.d: Likewise.
* testsuite/ld-x86-64/pr20253-1l.d: Likewise.
* testsuite/ld-x86-64/pr20830a-now.d: Likewise.
* testsuite/ld-x86-64/pr20830a.d: Likewise.
* testsuite/ld-x86-64/pr20830b-now.d: Likewise.
* testsuite/ld-x86-64/pr20830b.d: Likewise.
* testsuite/ld-x86-64/pr21038a-now.d: Likewise.
* testsuite/ld-x86-64/pr21038a.d: Likewise.
* testsuite/ld-x86-64/pr21038b-now.d: Likewise.
* testsuite/ld-x86-64/pr21038b.d: Likewise.
* testsuite/ld-x86-64/pr21038c-now.d: Likewise.
* testsuite/ld-x86-64/pr21038c.d: Likewise.

6 years agoPR21910, segfault in common symbol override test when hash-style=gnu
Alan Modra [Mon, 7 Aug 2017 08:32:49 +0000 (18:02 +0930)] 
PR21910, segfault in common symbol override test when hash-style=gnu

PR 21910
* elflink.c (bfd_elf_final_link): Don't segfault when sections
needed to define various dynamic tags have been discarded.

6 years agoremote-sim.c: Fix arg variables conflicts
Simon Marchi [Mon, 7 Aug 2017 10:09:37 +0000 (12:09 +0200)] 
remote-sim.c: Fix arg variables conflicts

The recent change introducing gdb_argv introduced some build failures in
remote-sim.c.

  /home/emaisin/src/binutils-gdb/gdb/remote-sim.c: In function 'void gdbsim_load(target_ops*, const char*, int)':
  /home/emaisin/src/binutils-gdb/gdb/remote-sim.c:573:22: error: conflicting declaration 'gdb_argv argv'
     gdb_argv argv (args);
                        ^
  /home/emaisin/src/binutils-gdb/gdb/remote-sim.c:565:10: note: previous declaration as 'char** argv'
     char **argv;
            ^~~~
  /home/emaisin/src/binutils-gdb/gdb/remote-sim.c: In function 'void gdbsim_open(const char*, int)':
  /home/emaisin/src/binutils-gdb/gdb/remote-sim.c:730:25: error: declaration of 'gdb_argv args' shadows a parameter
     gdb_argv args (arg_buf);

In gdbsim_load, the new gdb_argv object conflicts with old char **argv
variable.  I think the old variable should be removed.

In gdbsim_open, the new gdb_argv object conflicts with the args
parameter.  This patch renames it to argv.

Built-tested for a mips host.

gdb/ChangeLog:

* remote-sim.c (gdbsim_load): Remove char **argv local variable.
(gdbsim_open): Rename gdb_argv args object to argv.

6 years agoDo not choose a non-ELF format input file to hold the linker created GOT sections.
Nick Clifton [Mon, 7 Aug 2017 09:09:51 +0000 (10:09 +0100)] 
Do not choose a non-ELF format input file to hold the linker created GOT sections.

PR 21884
* elf32-i386.c (elf_i386_link_setup_gnu_properties): If the dynobj
has not been set then use the bfd returned by
_bfd_elf_link_setup_gnu_properties.  If that is null then search
through all the input bfds selecting the first normal, ELF format
one.
* elf64-x86-64.c (elf_x86_64_link_setup_gnu_properties): Likewise.

6 years agoAutomatic date update in version.in
GDB Administrator [Mon, 7 Aug 2017 00:01:03 +0000 (00:01 +0000)] 
Automatic date update in version.in

6 years agox86: Lookup __tls_get_addr or ___tls_get_addr once
H.J. Lu [Sun, 6 Aug 2017 15:40:56 +0000 (08:40 -0700)] 
x86: Lookup __tls_get_addr or ___tls_get_addr once

Instead of checking if a symbol is __tls_get_addr or ___tls_get_addr,
we check if there is a reference to __tls_get_addr or ___tls_get_addr
before starting relocation check.

* elf32-i386.c (elf_i386_link_hash_entry): Change tls_get_addr
to 1 bit.
(elf_i386_link_hash_newfunc): Initialize tls_get_addr to 0.
(elf_i386_check_tls_transition): Check tls_get_addr directly.
(elf_i386_convert_load_reloc): Update tls_get_addr check.
(elf_i386_link_check_relocs): New function.
(bfd_elf32_bfd_link_check_relocs): New.
* elf64-x86-64.c (elf_x86_64_link_hash_entry): Change tls_get_addr
to 1 bit.
(elf_x86_64_link_hash_newfunc): Initialize tls_get_addr to 0.
(elf_x86_64_check_tls_transition): Check tls_get_addr directly.
(elf_x86_64_convert_load_reloc): Update tls_get_addr check.
(elf_x86_64_link_check_relocs): New function.
(bfd_elf64_bfd_link_check_relocs): New.
(bfd_elf32_bfd_link_check_relocs): Likewise.

6 years agoTreat common symbol as undefined for --no-define-common
H.J. Lu [Sun, 6 Aug 2017 15:18:53 +0000 (08:18 -0700)] 
Treat common symbol as undefined for --no-define-common

When --no-define-common is used to build shared library, treat common
symbol as undefined so that common symbols that are referenced from a
shared library to be assigned addresses only in the main program.  This
eliminates the unused duplicate space in the shared library, and also
prevents any possible confusion over resolving to the wrong duplicate
when there are many dynamic modules with specialized search paths for
runtime symbol resolution.

--no-define-common is only allowed when building a shared library.

bfd/

PR ld/21903:
* elflink.c (elf_link_add_object_symbols): Treat common symbol
as undefined for --no-define-common.

include/

PR ld/21903:
* bfdlink.h (bfd_link_info): Add inhibit_common_definition.

ld/

PR ld/21903:
* ld.h (command_line): Remove inhibit_common_definition.
* ldgram.y: Replace command_line.inhibit_common_definition with
link_info.inhibit_common_definition.
* ldlang.c (lang_common): Likewise.
* lexsup.c (parse_args): Likewise.
* ldmain.c (main): Only allow --no-define-common with -shared.
* testsuite/ld-elf/pr21903.s: New file.
* testsuite/ld-elf/pr21903a.d: Likewise.
* testsuite/ld-elf/pr21903b.d: Likewise.
* testsuite/ld-elf/pr21903c.d: Likewise.
* testsuite/ld-elf/pr21903d.d: Likewise.
* testsuite/ld-elf/pr21903e.d: Likewise.

6 years agoAutomatic date update in version.in
GDB Administrator [Sun, 6 Aug 2017 00:00:44 +0000 (00:00 +0000)] 
Automatic date update in version.in

6 years agoUse gdb::unique_xmalloc_ptr when calling tilde_expand
Tom Tromey [Mon, 31 Jul 2017 21:49:21 +0000 (15:49 -0600)] 
Use gdb::unique_xmalloc_ptr when calling tilde_expand

This patch changes most sites calling tilde_expand to use
gdb::unique_xmalloc_ptr, rather than a cleanup.  It also changes
scan_expression_with_cleanup to return a unique pointer, because the
patch was already touching code in that area.

Regression tested on the buildbot.

ChangeLog
2017-08-05  Tom Tromey  <tom@tromey.com>

* compile/compile-object-load.c (compile_object_load): Use
gdb::unique_xmalloc_ptr.
* cli/cli-dump.c (scan_filename): Rename from
scan_filename_with_cleanup.  Change return type.
(scan_expression): Rename from scan_expression_with_cleanup.
Change return type.
(dump_memory_to_file, dump_value_to_file, restore_command):
Use gdb::unique_xmalloc_ptr.  Update.
* cli/cli-cmds.c (find_and_open_script): Use
gdb::unique_xmalloc_ptr.
* tracefile-tfile.c (tfile_open): Use gdb::unique_xmalloc_ptr.
* symmisc.c (maintenance_print_symbols)
(maintenance_print_msymbols): Use gdb::unique_xmalloc_ptr.
* symfile.c (symfile_bfd_open, generic_load)
(add_symbol_file_command, remove_symbol_file_command): Use
gdb::unique_xmalloc_ptr.
* source.c (openp): Use gdb::unique_xmalloc_ptr.
* psymtab.c (maintenance_print_psymbols): Use
gdb::unique_xmalloc_ptr.
* corelow.c (core_open): Use gdb::unique_xmalloc_ptr.
* breakpoint.c (save_breakpoints): Use gdb::unique_xmalloc_ptr.
* solib.c (solib_map_sections): Use gdb::unique_xmalloc_ptr.
(reload_shared_libraries_1): Likewise.

6 years agoFix Rust test suite for 1.20 beta
Tom Tromey [Sat, 5 Aug 2017 21:38:32 +0000 (15:38 -0600)] 
Fix Rust test suite for 1.20 beta

I ran the gdb.rust tests against Rust 1.20 (beta) and saw a few
failures.  The failures all came because a particular item moved to a
different module.  Since the particular choice of module name isn't
important here, I simply widened the allowable results.

Tested locally against rustc 1.19, 1.20, and 1.21.

testsuite/ChangeLog
2017-08-05  Tom Tromey  <tom@tromey.com>

* gdb.rust/simple.exp: Allow String to appear in a different
namespace.

6 years agoRemove cleanups from Rust parser
Tom Tromey [Fri, 4 Aug 2017 13:30:26 +0000 (07:30 -0600)] 
Remove cleanups from Rust parser

This removes the few remaining cleanups in the Rust language code.
The main difficulty here was that the earlier code allocated VEC heads
on an obstack.  The new code instead introduces an object that
allocates and maintains the storage for whatever vectors are needed
during the parse.

Regression tested on the buildbot.

ChangeLog
2017-08-05  Tom Tromey  <tom@tromey.com>

* rust-exp.y (rust_op_ptr, set_field): Remove typedefs.
(rust_op_vector, rust_set_vector): New typedefs.
(current_parser): New global.
(work_obstack): Change to pointer type.  Update all users.
(rust_ast, pstate): Remove globals.
(struct rust_parser): New.
(%union) <params, field_inits>: Change type.
(start, tuple_expr, unit_expr, struct_expr_list, literal)
(field_expr, expr_list, maybe_expr_list, type_list): Update.
(ast_call_ish, ast_path, ast_function_type, ast_tuple_type)
(convert_params_to_types, convert_params_to_expression): Change
type of "params".
(ast_string): Change type of "fields".
(rust_parse): Make a rust_parser.  Remove cleanups.
(rust_lex_tests): Make and install an auto_obstack.

6 years agoDon't fail in elf32_hppa_set_gp
Alan Modra [Sat, 5 Aug 2017 13:58:21 +0000 (23:28 +0930)] 
Don't fail in elf32_hppa_set_gp

The base bfd_link_hash_table works fine here, the only thing to watch
out for is to only set elf_gp if the output is ELF.

bfd/
* elf32-hppa.c (elf32_hppa_set_gp): Don't require an
hppa_link_hash_table.
ld/
* testsuite/ld-unique/pr21529.d: Don't xfail hppa.

6 years agoAutomatic date update in version.in
GDB Administrator [Sat, 5 Aug 2017 00:00:19 +0000 (00:00 +0000)] 
Automatic date update in version.in

6 years agoUnbreak GDBserver build for x32
Yao Qi [Fri, 4 Aug 2017 15:02:51 +0000 (16:02 +0100)] 
Unbreak GDBserver build for x32

When I verify my target description changes, I build GDB and GDBserver for
x32, but it failed.

/../../binutils-gdb/gdb/gdbserver/linux-amd64-ipa.c
../../../binutils-gdb/gdb/gdbserver/linux-amd64-ipa.c: In function ‘const target_desc* get_ipa_tdesc(int)’:
../../../binutils-gdb/gdb/gdbserver/linux-amd64-ipa.c:184:10: error: ‘X86_TDESC_AVX512’ was not declared in this scope
     case X86_TDESC_AVX512:
          ^
../../../binutils-gdb/gdb/gdbserver/linux-amd64-ipa.c:185:14: error: ‘tdesc_x32_avx512_linux’ was not declared in this scope
       return tdesc_x32_avx512_linux;
              ^
../../../binutils-gdb/gdb/gdbserver/linux-amd64-ipa.c: In function ‘void initialize_low_tracepoint()’:
../../../binutils-gdb/gdb/gdbserver/linux-amd64-ipa.c:282:36: error: ‘init_registers_x32_avx512_linux’ was not declared in this scope
   init_registers_x32_avx512_linux ();
                                    ^

ipa_x32_linux_regobj use to be there, but removed by
22049425ce40324139be82d9a6ec518c46b65815 by mistake.

gdb/gdbserver:

2017-08-04  Yao Qi  <yao.qi@linaro.org>

* configure.srv (ipa_x32_linux_regobj): New.
* linux-amd64-ipa.c (get_ipa_tdesc): Use X86_TDESC_AVX_AVX512
instead of X86_TDESC_AVX512.
(initialize_low_tracepoint): Call
init_registers_x32_avx_avx512_linux.

6 years agoAdd namespace std to nullptr_t
Yao Qi [Fri, 4 Aug 2017 13:27:58 +0000 (14:27 +0100)] 
Add namespace std to nullptr_t

This patch fixes the build failure for target i686-w64-mingw32,

In file included from ../../binutils-gdb/gdb/defs.h:786:0,
                 from ../../binutils-gdb/gdb/gdb.c:19:
../../binutils-gdb/gdb/utils.h:188:20: error: ‘nullptr_t’ has not been declared
   bool operator!= (nullptr_t)
                    ^
../../binutils-gdb/gdb/utils.h:193:20: error: ‘nullptr_t’ has not been declared
   bool operator== (nullptr_t)
                    ^

gdb:

2017-08-04  Yao Qi  <yao.qi@linaro.org>

* utils.h (gdb_argv): Add namespace std for nullptr_t.

6 years agoAdd a testcase for "ld -d"
H.J. Lu [Fri, 4 Aug 2017 12:39:56 +0000 (05:39 -0700)] 
Add a testcase for "ld -d"

"ld -d" assigns space to common symbols even if a relocatable output
file is specified (with '-r').

PR ld/21904
* testsuite/ld-elf/pr21904.d: New file.
* testsuite/ld-elf/pr21904.s: Likewise.

6 years agoAdd --no-relax option.
James Clarke [Fri, 4 Aug 2017 05:44:21 +0000 (22:44 -0700)] 
Add --no-relax option.

gold/
* options.h (General_options): Set a non-NULL second help string
argument for relax to allow --no-relax.

6 years agoAutomatic date update in version.in
GDB Administrator [Fri, 4 Aug 2017 00:00:52 +0000 (00:00 +0000)] 
Automatic date update in version.in

6 years agoAdd myself as a write-after-approval GDB maintainer.
Ruslan Kabatsayev [Thu, 3 Aug 2017 06:11:45 +0000 (09:11 +0300)] 
Add myself as a write-after-approval GDB maintainer.

6 years agoRemove make_cleanup_freeargv and gdb_buildargv
Tom Tromey [Sun, 23 Jul 2017 21:52:59 +0000 (15:52 -0600)] 
Remove make_cleanup_freeargv and gdb_buildargv

After the previous patches in this series, make_cleanup_freeargv and
gdb_buildargv are now unused and can be removed.

ChangeLog
2017-08-03  Tom Tromey  <tom@tromey.com>

* utils.c (make_cleanup_freeargv, do_freeargv, gdb_buildargv):
Remove.
* utils.h (make_cleanup_freeargv, gdb_buildargv): Remove.

6 years agoUse gdb_argv in Python
Tom Tromey [Mon, 1 May 2017 05:03:58 +0000 (23:03 -0600)] 
Use gdb_argv in Python

This changes one spot in the Python code to use gdb_argv.  This
removes the last cleanup from the Python layer.

ChangeLog
2017-08-03  Tom Tromey  <tom@tromey.com>

* python/py-param.c (compute_enum_values): Use gdb_argv.

6 years agoIntroduce gdb_argv, a class wrapper for buildargv
Tom Tromey [Mon, 1 May 2017 05:02:30 +0000 (23:02 -0600)] 
Introduce gdb_argv, a class wrapper for buildargv

This introduces gdb_argv, a class wrapping an "argv" pointer; that is,
a pointer to a NULL-terminated array of char*, where both the array
and each non-NULL element in the array are xmalloc'd.

This patch then changes most users of gdb_buildargv to use gdb_argv
instead.

ChangeLog
2017-08-03  Tom Tromey  <tom@tromey.com>

* utils.h (struct gdb_argv_deleter): New.
(gdb_argv): New class.
* utils.c (gdb_argv::reset): New method.
* tracepoint.c (delete_trace_variable_command): Use gdb_argv.
* tracefile.c (tsave_command): Use gdb_argv.
* top.c (new_ui_command): Use gdb_argv.
* symmisc.c (maintenance_print_symbols)
(maintenance_print_msymbols, maintenance_expand_symtabs): Use gdb_argv.
* symfile.c (symbol_file_command, generic_load)
(remove_symbol_file_command): Use gdb_argv.
* stack.c (backtrace_command): Use gdb_argv.
* source.c (add_path, show_substitute_path_command)
(unset_substitute_path_command, set_substitute_path_command):
Use gdb_argv.
* skip.c (skip_command): Use gdb_argv.  Use gdb_buildargv.
* ser-mingw.c (pipe_windows_open): Use gdb_argv.
* remote.c (extended_remote_run, remote_put_command)
(remote_get_command, remote_delete_command): Use gdb_argv.
* remote-sim.c (gdbsim_load, gdbsim_create_inferior)
(gdbsim_open): Use gdb_argv.
* python/py-cmd.c (gdbpy_string_to_argv): Use gdb_argv.
* psymtab.c (maintenance_print_psymbols): Use gdb_argv.
* procfs.c (procfs_info_proc): Use gdb_argv.
* interps.c (interpreter_exec_cmd): Use gdb_argv.
* infrun.c (handle_command): Use gdb_argv.
* inferior.c (add_inferior_command, clone_inferior_command):
Use gdb_argv.
* guile/scm-string.c (gdbscm_string_to_argv): Use gdb_argv.
* exec.c (exec_file_command): Use gdb_argv.
* cli/cli-cmds.c (alias_command): Use gdb_argv.
* compile/compile.c (build_argc_argv): Use gdb_argv.

6 years agoRemove a cleanup in Python
Tom Tromey [Mon, 1 May 2017 04:12:13 +0000 (22:12 -0600)] 
Remove a cleanup in Python

This removes cleanups from gdbpy_decode_line, in favor of a use of
unique_xmalloc_ptr.

ChangeLog
2017-08-03  Tom Tromey  <tom@tromey.com>

* python/python.c (gdbpy_decode_line): Use unique_xmalloc_ptr.

6 years agoAvoid some manual memory management in Python
Tom Tromey [Mon, 1 May 2017 04:10:41 +0000 (22:10 -0600)] 
Avoid some manual memory management in Python

This changes a few places in the Python code to avoid manual memory
management, in favor of letting std::string do the work.

ChangeLog
2017-08-03  Tom Tromey  <tom@tromey.com>

* python/python.c (compute_python_string): Return std::string.
(gdbpy_eval_from_control_command): Update.
(do_start_initialization): Use std::string.
* python/py-varobj.c (py_varobj_iter_next): Use string_printf, not
xstrprintf.
* python/py-breakpoint.c (local_setattro): Use string_printf, not
xstrprintf.

6 years agoReplace do_restore_instream_cleanup with scoped_restore
Tom Tromey [Mon, 1 May 2017 03:17:58 +0000 (21:17 -0600)] 
Replace do_restore_instream_cleanup with scoped_restore

This changes the users of do_restore_instream_cleanup to use a
scoped_restore instead.  This patch is broken out because it warrants
some additional attention: in particular it's unclear to me whether
current_ui can change in the body of these functions -- but if it can,
then the cleanup would have modified a different UI's instream member.

ChangeLog
2017-08-03  Tom Tromey  <tom@tromey.com>

* top.h (do_restore_instream_cleanup): Remove.
* top.c (do_restore_instream_cleanup): Remove.
(read_command_file): Use scoped_restore.
* cli/cli-script.c (execute_user_command): Use scoped_restore.

6 years agoUse a scoped_restore for command_nest_depth
Tom Tromey [Mon, 1 May 2017 03:15:58 +0000 (21:15 -0600)] 
Use a scoped_restore for command_nest_depth

This changes a couple of places to use a scoped_restore when
manipulating command_nest_depth.

ChangeLog
2017-08-03  Tom Tromey  <tom@tromey.com>

* cli/cli-script.c (execute_user_command)
(execute_control_command): Use scoped_restore.

6 years agoRemove user_call_depth
Tom Tromey [Mon, 1 May 2017 03:08:31 +0000 (21:08 -0600)] 
Remove user_call_depth

This changes execute_user_command to remove user_call_depth, using the
size of user_args_stack instead.  This avoids a cleanup.

ChangeLog
2017-08-03  Tom Tromey  <tom@tromey.com>

* cli/cli-script.c (do_restore_user_call_depth): Remove.
(execute_user_command): Remove user_call_depth; use
user_args_stack's size instead.

6 years agoRemove in_user_command
Tom Tromey [Mon, 1 May 2017 03:04:51 +0000 (21:04 -0600)] 
Remove in_user_command

While working on the next patch in this series, I found that the
global in_user_command is not used.  This patch removes it.  (I didn't
think to check Insight until submitting this series; and it's not very
convenient to do so, so if someone has it checked out and could look
at it, that would be nice.)

ChangeLog
2017-08-03  Tom Tromey  <tom@tromey.com>

* top.h (in_user_command): Remove.
* top.c (in_user_command): Remove.
* cli/cli-script.c (do_restore_user_call_depth)
(execute_user_command): Update.

6 years agoUse containers to avoid cleanups
Tom Tromey [Sat, 29 Apr 2017 05:34:32 +0000 (23:34 -0600)] 
Use containers to avoid cleanups

This patch introduces the use of various containers -- std::vector,
std::string, or gdb::byte_vector -- in several spots in gdb that were
using xmalloc and a cleanup.

ChangeLog
2017-08-03  Tom Tromey  <tom@tromey.com>

* valops.c (search_struct_method): Use gdb::byte_vector.
* valarith.c (value_concat): Use std::vector.
* target.c (memory_xfer_partial): Use gdb::byte_vector.
(simple_search_memory): Likewise.
* printcmd.c (find_string_backward): Use gdb::byte_vector.
* mi/mi-main.c (mi_cmd_data_write_memory): Use gdb::byte_vector.
* gcore.c (gcore_copy_callback): Use gdb::byte_vector.
* elfread.c (elf_rel_plt_read): Use std::string.
* cp-valprint.c (cp_print_value): Use gdb::byte_vector.
* cli/cli-dump.c (restore_section_callback): Use
gdb::byte_vector.

6 years agoUse unique_xmalloc_ptr in jit.c
Tom Tromey [Sat, 29 Apr 2017 05:08:16 +0000 (23:08 -0600)] 
Use unique_xmalloc_ptr in jit.c

This removes some cleanups from jit.c by using unique_xmalloc_ptr
instead.

ChangeLog
2017-08-03  Tom Tromey  <tom@tromey.com>

* jit.c (jit_reader_load_command): Use unique_xmalloc_ptr.

6 years agoReplace tui_restore_gdbout with scoped_restore
Tom Tromey [Sat, 29 Apr 2017 04:59:24 +0000 (22:59 -0600)] 
Replace tui_restore_gdbout with scoped_restore

This patch replaces tui_restore_gdbout (a cleaup function) with a use
of scoped_restore.  This one is broken out into its own patch because
it might slightly change the behavior of gdb: it saves and restores
pagination_enabled, whereas the tui_restore_gdbout unconditionally set
pagination_enabled to 1; and I think this warrants closer review.

ChangeLog
2017-08-03  Tom Tromey  <tom@tromey.com>

* tui/tui-regs.c (tui_restore_gdbout): Remove.
(tui_register_format): Use scoped_restore.

6 years agoMore uses of scoped_restore
Tom Tromey [Thu, 27 Apr 2017 04:53:40 +0000 (22:53 -0600)] 
More uses of scoped_restore

There were a few more places in gdb that could easily use
scoped_restore, replacing some cleanups.

ChangeLog
2017-08-03  Tom Tromey  <tom@tromey.com>

* reverse.c (exec_direction_default): Remove.
(exec_reverse_once): Use scoped_restore.
* remote.c (restore_remote_timeout): Remove.
(remote_flash_erase, remote_flash_write, remote_flash_done)
(readchar, remote_serial_write): Use scoped_restore.
* cli/cli-script.c (struct source_cleanup_lines_args)
(source_cleanup_lines): Remove.
(script_from_file): Use scoped_restore.
* cli/cli-cmds.c (source_verbose_cleanup): Remove.
(source_command): Use scoped_restore.

6 years agoRemove make_cleanup_free_so
Tom Tromey [Sat, 29 Apr 2017 04:43:54 +0000 (22:43 -0600)] 
Remove make_cleanup_free_so

make_cleanup_free_so is used in a single spot.  This patch introduces
a unique pointer wrapper for struct so_list, and changes this spot to
use it.

ChangeLog
2017-08-03  Tom Tromey  <tom@tromey.com>

* utils.h (make_cleanup_free_so): Remove.
* utils.c (do_free_so, make_cleanup_free_so): Remove.
* solist.h (struct so_deleter): New.
(so_list_up): New typedef.
* solib-svr4.c (svr4_read_so_list): Use so_list_up.

This page took 0.055329 seconds and 4 git commands to generate.