Commit Graph

92681 Commits

Author SHA1 Message Date
Peter Smith 036aae7930 Fix segfault in relocate_erratum_stub on aarch64.
The fix for PR21868 (an internal error when --fix-cortex-a53-843419
is applied) has a small mistake in it. When the stub_owner section
needs an erratum fix an incorrect address for the stubs for the section
is given to relocate_erratum_stub. If we are lucky we will get a segfault;
if we aren't, an incorrect patch or data corruption is possible.
The error is visible in PR21868, but the side-effects aren't fatal.

gold/
	PR gold/22233
	* aarch64.cc (AArch64_relobj::fix_errata_and_relocate_erratum_stubs):
	Fix calculation of stub address.
2017-11-30 15:08:21 -08:00
Alan Modra 4a7e523498 PR22533, dynamic relocs generated for weak aliases
This cleans up yet more craziness with non_got_ref.

	PR 22533
	* elf32-hppa.c (elf32_hppa_copy_indirect_symbol): Don't do anything
	special with non_got_ref for weak aliases.
	(elf32_hppa_check_relocs): Tweak setting of non_got_ref.
	(elf32_hppa_adjust_dynamic_symbol): When initialising weak aliases,
	don't uselessly copy non_got_ref.  Clear dyn_relocs instead if
	strong symbol is allocated in dynbss.  Tidy comments.
	(elf32_hppa_relocate_section): Comment fix.
	* elf32-ppc.c (ppc_elf_copy_indirect_symbol): Don't do anything
	special with non_got_ref for weak aliases.
	(ppc_elf_adjust_dynamic_symbol): When initialising weak aliases,
	don't uselessly copy non_got_ref.  Clear dyn_relocs instead if
	strong symbol is allocated in dynbss.  Tidy comments.
	* elf64-ppc.c (ppc64_elf_copy_indirect_symbol): Don't do anything
	special with non_got_ref for weak aliases.
	(ppc64_elf_adjust_dynamic_symbol): When initialising weak aliases,
	don't uselessly copy non_got_ref.  Clear dyn_relocs instead if
	strong symbol is allocated in dynbss.  Tidy comments.
2017-12-01 09:06:30 +10:30
Ulrich Weigand 6f14765f9f [spu] Some additional test fixes
Now that the ppc64 breakpoint regression is fixed, running the
gdb.cell test suite showed a few more test case problems, caused
by tests that haven't been updated to adapt to GDB changes.

gdb/testsuite/ChangeLog:
2017-11-30  Ulrich Weigand  <uweigand@de.ibm.com>

	* gdb.cell/gcore.exp: Fix typo when setting spu_bin.
	Update for changed thread numbering.
	* gdb.cell/bt.exp: Update for changed GDB output.
2017-11-30 18:35:54 +01:00
Simon Marchi f1af7b94c1 Use boards/local-board.exp more
local-board.exp was introduced recently, containing the code required to
force the gdbserver boards to be non-remote (from the DejaGNU point of
view).  Other board files use the same trick of forcing isremote to 0.
Instead of doing it by hand in each file, include local-board.exp.

gdb/testsuite/ChangeLog:

	* boards/cc-with-tweaks.exp: Include local-board.exp instead of
	setting isremote by hand.
	* boards/dwarf4-gdb-index.exp: Likewise.
	* boards/fission.exp: Likewise.
	* boards/stabs.exp: Likewise.
2017-11-30 11:39:31 -05:00
Pedro Alves e3919f3e89 Fix gdb.linespec/cpls-ops.exp on 32-bit
gdb.linespec/cpls-ops.exp is currently failing on x86-64 -m32 and other
32-bit ports:

 b test_op_new::operator new(unsigned int) FAIL: gdb.linespec/cpls-ops.exp: operator-new: tab complete "b test_op_new::operator" (timeout)
 ^CQuit
 (gdb) complete b test_op_new::operator
 b test_op_new::operator new(unsigned int)
 (gdb) FAIL: gdb.linespec/cpls-ops.exp: operator-new: cmd complete "b test_op_new::operator"

The problem is simply that the testcase incorrectly assumes that
size_t is "unsigned long".

Fix this by extracting the right type with the "ptype" command.

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

	* gdb.linespec/cpls-ops.exp
	(check_explicit_skips_function_argument): Extract the underlying
	type of size_t instead of hardcoding it.
2017-11-30 16:32:10 +00:00
Rainer Orth 44122162ae Remove ioctl-based procfs support on Solaris
This is the previously mentioned patch to get rid of
unstructured/ioctl-based procfs support in procfs.c.  Given that support
for structured procfs was introduced in Solaris 2.6 back in 1997 and
we're just removing support for Solaris < 10, there's no point in
carrying that baggage (and tons of support for IRIX and OSF/1 as well)
around any longer.

Most of the patch should be straightforward (removing support for
!NEW_PROC_API, non-Solaris OSes and pre-Solaris 10 quirks).

Only a few points need explanations:

* <sys/syscall.h> was already included unconditionally in most places,
  so there's no need to have guards in a few remaining ones.

* configure.host already obsoletes i?86-*-sysv4.2, i?86-*-sysv5, so
  NEW_PROC_API detection for those in configure.ac can go.

* I'm still including <sys/procfs.h> with #define _STRUCTURED_PROC 1.
  Theoretically, it would be better to include <procfs.h> on Solaris
  (which includes that define), but that breaks the build over
  <procfs.h> vs. gdb's "procfs.h", and doesn't exist on Linux.

* I've regenerated syscall_table[] in proc-events.c with a small script
  from Solaris 10, 11.3, 11.4 <sys/syscall.h>, so there should be no
  traces of older Solaris versions and other OSes left.

* prsysent_t and DYNAMIC_SYSCALLS was only used for AIX 5, but AIX
  doesn't use procfs.c any longer, so all related code can go.

The patch was generated with diff -w so one can easier see changes
without being distracted by simple reindentations.

So far, it has only been compiled and smoke-tested on
amd64-pc-solaris2.1[01], sparcv9-sun-solaris2.1[01], and
x86_64-pc-linux-gnu.  Certainly needs more testing (Solaris 11.3
vs. 11.4, 32-bit gdb, testsuite once I've figured out what's wrong on
Solaris 10 etc.), but it's enough to get a first impression how much
cleanup is possible here.

	* configure.ac Don't check for sys/fault.h, sys/syscall.h,
	sys/proc.h.
	(NEW_PROC_API): Remove.
	(prsysent_t, pr_sigset_t, pr_sigaction64_t, pr_siginfo64_t):
	Likewise.
	* common/common.m4 (GDB_AC_COMMON): Don't check for sys/syscall.h.
	* configure: Regenerate.
	* config.in: Regenerate.
	* gdbserver/configure: Regenerate.
	* gdbserver/config.in: Regenerate.

	* i386-sol2-nat.c (_initialize_amd64_sol2_nat): Remove
	NEW_PROC_API test.
	* sparc-sol2-nat.c (_initialize_sparc_sol2_nat): Likewise.

	* linux-btrace.c: Remove HAVE_SYS_SYSCALL_H test.

	* proc-api.c: Remove !NEW_PROC_API support.
	Remove HAVE_SYS_PROC_H and HAVE_SYS_USER_H tests.
	Remove tests for macros always defined on Solaris.
	* proc-events.c: Remove !NEW_PROC_API support.
	Remove Remove HAVE_SYS_SYSCALL_H, HAVE_SYS_PROC_H and
	HAVE_SYS_USER_H tests.
	(init_syscall_table): Remove non-Solaris syscalls.
	Remove tests for syscalls present on all Solaris versions.
	Add missing Solaris 10+ syscalls.
	(signal_table): Remove non-Solaris signals.
	Remove tests for signals present on all Solaris versions.
	(fault_table): Remove non-Solaris faults.
	Remove tests for faults present on all Solaris versions.
	* proc-flags.c: Remove !NEW_PROC_API support.
	(pr_flag_table): Remove non-Solaris and pre-Solaris 7 comments.
	Remove non-Solaris flags.
	* proc-why.c: Remove !NEW_PROC_API support.
	(pr_why_table): Remove meaningless comments.
	Remove tests for reasons present on all Solaris versions.
	Remove OSF/1 cases.
	(proc_prettyfprint_why): Likewise.

	* procfs.c: Remove !NEW_PROC_API and DYNAMIC_SYSCALLS support.
	Remove HAVE_SYS_FAULT_H and HAVE_SYS_SYSCALL_H tests.
	Remove WA_READ test, IRIX watchpoint support.
	(gdb_sigset_t, gdb_sigaction_t, gdb_siginfo_t): Replace by base
	types.  Change users.
	(gdb_praddset, gdb_prdelset, gdb_premptysysset, gdb_praddsysset)
	(gdb_prdelset, gdb_pr_issyssetmember): Replace by base macros.
	Change callers.
	Remove CTL_PROC_NAME_FMT tests.
	(gdb_prstatus_t, gdb_lwpstatus_t): Replace by base types.  Change
	users.
	(sysset_t_size): Remove.  Use sizeof (sysset_t) in callers.
	Remove PROCFS_DONT_PIOCSSIG_CURSIG support.
	(proc_modify_flag): Replace GDBRESET by PCUNSET.
	Remove PR_ASYNC, PR_KLC tests.
	(proc_unset_inherit_on_fork): Remove PR_ASYNC test.
	(proc_parent_pid): Remove PCWATCH etc. tests.
	(proc_set_watchpoint): Remove !PCWATCH && !PIOCSWATCH support.
	Remove PCAGENT test.
	(proc_get_nthreads) [PIOCNTHR && PIOCTLIST]: Remove.
	Remove SYS_lwpcreate || SYS_lwp_create test.
	(proc_get_current_thread): Likewise.
	[PIOCNTHR && PIOCTLIST]: Remove.
	[PIOCLSTATUS]: Remove.
	(procfs_debug_inferior): Remove non-Solaris cases, conditionals.
	[PRFS_STOPEXEC]: Remove.
	(syscall_is_lwp_exit): Remove non-Solaris cases, conditionals.
	(syscall_is_exit): Likewise.
	(syscall_is_exec): Likewise.
	(syscall_is_lwp_create): Likewise.
	Remove SYS_syssgi support.
	(procfs_wait): Remove PR_ASYNC, !PIOCSSPCACT tests.
	[SYS_syssgi]: Remove.
	Remove non-Solaris cases, conditionals.
	(unconditionally_kill_inferior) [PROCFS_NEED_PIOCSSIG_FOR_KILL]:
	Remove.
	(procfs_init_inferior) [SYS_syssgi]: Remove.
	(procfs_set_exec_trap) [PRFS_STOPEXEC]: Remove.
	(procfs_inferior_created) [SYS_syssgi]: Remove.
	(procfs_set_watchpoint): Remove !AIX5 test.
	(procfs_stopped_by_watchpoint): Remove FLTWATCH test, FLTKWATCH
	case.
	(mappingflags) [MA_PHYS]: Remove.
	(info_mappings_callback): Remove PCAGENT test.
	Remove PIOCOPENLWP || PCAGENT test.
2017-11-30 16:05:30 +01:00
Jan Beulich 7ac2002247 x86: derive DispN from BaseIndex
BaseIndex implies - with the exception of string instructions the
optional presence of a displacement. This is almost completely uniform
for all instructions (the sole exception being MPX ones, which don't
allow 16-bit addressing and hence Disp16), so there's no point in
explicitly stating this in the main opcode table. Drop those explict
specifications in favor of adding logic to i386-gen, shrinking the
table size quite a bit and hence making it more readable.

The opcodes/i386-tbl.h changes are due to a few cases where pointless
Disp* still hadn't been removed from their insns.
2017-11-30 11:48:13 +01:00
Jan Beulich b5014f7af2 x86: drop Vec_Disp8
This is fully redundant with Disp8MemShift being non-zero, and hence can
be folded with normal Disp8 handling.
2017-11-30 11:47:38 +01:00
Jan Beulich fd4e034759 x86/Intel: issue diagnostics for redundant segment override prefixes
While we shouldn't outright reject such (as was wrongly done by commit
4d36230d59 ("x86: Update segment register check in Intel syntax"), as
MASM accepts them even silently, issue (by default) a warning for such
questionable constructs.
2017-11-30 11:46:26 +01:00
Jan Beulich e21440ba62 Revert "x86: Update segment register check in Intel syntax"
This reverts commit 4d36230d59.
I was committed without maintainer ack and regresses intended
functionality. A replacement will be committed shortly.
2017-11-30 11:44:27 +01:00
Nick Clifton f425ec6600 Prevent an illegal memory access in readelf when attempting to parse a corrupt ELF file.
PR 22510
	* readelf.c (load_debug_section): Fail if there are no section
	headers available.
2017-11-30 10:25:01 +00:00
Rainer Orth e8020e54f4 Fix sol-thread.c compilation on Solaris
Building current gdb mainline with gcc 7.1 on Solaris 11.4 fails:

/vol/src/gnu/gdb/gdb/dist/gdb/sol-thread.c: In function `void _initialize_sol_thread()':
/vol/src/gnu/gdb/gdb/dist/gdb/sol-thread.c:1229:66: error: invalid conversion from `void (*)(char*, int)' to `void (*)(const char*, int)' [-fpermissive]
     _("Show info on Solaris user threads."), &maintenanceinfolist);
                                                                  ^
In file included from /vol/src/gnu/gdb/gdb/dist/gdb/completer.h:21:0,
                 from /vol/src/gnu/gdb/gdb/dist/gdb/symtab.h:31,
                 from /vol/src/gnu/gdb/gdb/dist/gdb/language.h:26,
                 from /vol/src/gnu/gdb/gdb/dist/gdb/frame.h:72,
                 from /vol/src/gnu/gdb/gdb/dist/gdb/gdbarch.h:39,
                 from /vol/src/gnu/gdb/gdb/dist/gdb/defs.h:557,
                 from /vol/src/gnu/gdb/gdb/dist/gdb/sol-thread.c:51:
/vol/src/gnu/gdb/gdb/dist/gdb/command.h:140:33: note:   initializing argument 3 of `cmd_list_element* add_cmd(const char*, command_class, void (*)(const char*, int), const char*, cmd_list_element**)'
 extern struct cmd_list_element *add_cmd (const char *, enum command_class,
                                 ^~~~~~~

The following patch allows compilation to succeed on i386-pc-solaris2.11
and sparc-sun-solaris2.11.

	* sol-thread.c (info_solthreads): Constify args.
	Cast args to void *.
2017-11-30 10:57:04 +01:00
Alan Modra 668247656d Fix testcase for PR ld/22471
ASFLAGS should be restored after any modification.  Fixes
metag-linux  +FAIL: Long branch stub
metag-linux  +FAIL: Long branch stub (PIC, app)
mn10300-elf  +FAIL: difference of two same-section symbols where the difference is held in another section
mn10300-elf  +FAIL: relaxation and alignment directives

	PR 22471
	* testsuite/ld-elf/shared.exp: Save and restore ASFLAGS.
2017-11-30 13:16:35 +10:30
John Baldwin 7505954411 Define MPFR_USE_INTMAX_T so that mpfr.h assumes intmax_t is available.
mpfr.h uses a non-portable test to guess if intmax_t is available and
if API functions using intmax_t should be exposed.  Define
MPFR_USE_INTMAX_T to override the non-portable test and always expose
these functions.  This fixes the build on platforms where the test
guesses incorrectly.

gdb/ChangeLog:

	* target-float.c [HAVE_LIBMPFR]: Define MPFR_USE_INTMAX_T.
2017-11-29 16:28:01 -08:00
GDB Administrator 8029e59279 Automatic date update in version.in 2017-11-30 00:00:20 +00:00
Joel Brobecker f5a9147212 preserve type length in ada-lang.c::to_fixed_range_type
This patch fixes a potential issue which was noticed by code inspection:
ada-lang.c::to_fixed_range_type uses gdbtypes.c::create_static_range_type
to create most of the range type, which relies on create_range_type to
do most of the work. The latter has the following piece of code which
sets the length of the range type to match the length of the index_type:

    if (TYPE_STUB (index_type))
      TYPE_TARGET_STUB (result_type) = 1;
    else
      TYPE_LENGTH (result_type) = TYPE_LENGTH (check_typedef (index_type));

In Ada, it is actually possible to have a range type whose size
is smaller than its base type. For instance, with:

    type Unsigned2_T is  range 0 .. 2 ** 16 - 1;
    for Unsigned2_T'SIZE use 16;

The compiler generates the following DWARF:

        .uleb128 0x3    # (DIE (0x4e) DW_TAG_subrange_type)
        .byte   0x2     # DW_AT_byte_size
        .byte   0       # DW_AT_lower_bound
        .value  0xffff  # DW_AT_upper_bound
        .long   .LASF64 # DW_AT_name: "try__unsigned2_t___XDLU_0__65535"
        .long   0x616   # DW_AT_type

... which points to the following base type...

        .uleb128 0x1d   # (DIE (0x616) DW_TAG_base_type)
        .byte   0x4     # DW_AT_byte_size
        .byte   0x5     # DW_AT_encoding
        .long   .LASF57 # DW_AT_name: "try__Tunsigned2_tB"
                        # DW_AT_artificial

... which has a size of 4 bytes.

With a type like this one, create_range_type returns a type whose
size is 4 bytes, instead of 2, which is not what we we would normally
expect.

Currently, this function is only used to handle array index types,
so the length of the type actually does not matter and there should
not be any user-visible consequences of the current behavior. But
it seems best to plug this latent bug now, rather than wait for it
to surface....

gdb/ChangeLog:

        * ada-lang.c (to_fixed_range_type): Make sure that the size
        of the range type being returned is the same as the size
        of the range type being fixed.

Tested on x86_64-linux, no regression.
2017-11-29 18:32:17 -05:00
Pedro Alves bd69330db8 Breakpoints in symbols with ABI tags (PR c++/19436)
Trying to set a breakpoint in a function with an ABI tag does not work
currently.  E.g., debugging gdb itself, we see this with the
"string_printf" function:

 (top-gdb) b string_print                               [TAB]
 (top-gdb) b string_printf[abi:cxx11](char const*, ...) [RET]
 No source file named string_printf[abi.
 Make breakpoint pending on future shared library load? (y or [n])

Quoting doesn't help:
 (top-gdb) b 'string_printf[abi:cxx11]'(char const*, ...)
 malformed linespec error: unexpected string, "(char const*, ...)"
 (top-gdb) b 'string_printf[abi:cxx11](char const*, ...)'
 No source file named string_printf[abi.
 Make breakpoint pending on future shared library load? (y or [n]) n

This patch fixes this, and takes it a bit further.

The actual symbol name as demangled by libiberty's demangler is really

 string_printf[abi:cxx11](char const*, ...)

however, this patch makes it possible to set the breakpoint with

 string_printf(char const*, ...)

too.  I.e., ignoring the ABI tag.

And to match, it teaches the completer to complete the symbol name
without the ABI tag, i.e.,

  "string_pri<TAB>"  -> "string_printf(char const*, ...)"

If however, you really want to break on a symbol with the tag, then
you simply start writing the tag, and GDB will preserve it, like:

  "string_printf[a<TAB>"  -> "string_printf[abi:cxx11](char const*, ...)"

Grows the gdb.linespec/ tests like this:

  -# of expected passes           8977
  +# of expected passes           9176

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

	PR c++/19436
	* NEWS: Mention setting breakpoints on functions with C++ ABI
	tags.
	* completer.h (completion_match_for_lcd) <match,
	mark_ignored_range>: New methods.
	<finish>: Consider ignored ranges.
	<clear>: Clear ignored ranges.
	<m_ignored_ranges, m_finished_storage>: New fields.
	* cp-support.c (cp_search_name_hash): Ignore ABI tags.
	(cp_symbol_name_matches_1, cp_fq_symbol_name_matches): Pass the
	completion_match_for_lcd pointer to strncmp_iw_with_mode.
	(test_cp_symbol_name_cmp): Add [abi:...] tags unit tests.
	* language.c (default_symbol_name_matcher): Pass the
	completion_match_for_lcd pointer to strncmp_iw_with_mode.
	* linespec.c (linespec_lexer_lex_string): Don't tokenize ABI tags.
	* utils.c (skip_abi_tag): New function.
	(strncmp_iw_with_mode): Add completion_match_for_lcd parameter.
	Handle ABI tags.
	* utils.h (strncmp_iw_with_mode): Add completion_match_for_lcd
	parameter.

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

	PR c++/19436
	* gdb.linespec/cpls-abi-tag.cc: New file.
	* gdb.linespec/cpls-abi-tag.exp: New file.

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

	PR c++/19436
	* gdb.texinfo (Debugging C Plus Plus): Document setting
	breakpoints in functions with ABI tags.
2017-11-29 19:46:41 +00:00
Pedro Alves a20714ff39 Make "break foo" find "A::foo", A::B::foo", etc. [C++ and wild matching]
This patch teaches GDB about setting breakpoints in all scopes
(namespaces and classes) by default.

Here's a contrived example:

  (gdb) b func<tab>
  (anonymous namespace)::A::function()            Bn::(anonymous namespace)::B::function()        function(int, int)
  (anonymous namespace)::B::function()            Bn::(anonymous namespace)::function()           gdb::(anonymous namespace)::A::function()
  (anonymous namespace)::B::function() const      Bn::(anonymous namespace)::function(int, int)   gdb::(anonymous namespace)::function()
  (anonymous namespace)::function()               Bn::B::func()                                   gdb::(anonymous namespace)::function(int, int)
  (anonymous namespace)::function(int, int)       Bn::B::function()                               gdb::A::func()
  A::func()                                       Bn::func()                                      gdb::A::function()
  A::function()                                   Bn::function()                                  gdb::func()
  B::func()                                       Bn::function(int, int)                          gdb::function()
  B::function()                                   Bn::function(long)                              gdb::function(int, int)
  B::function() const                             func()                                          gdb::function(long)
  B::function_const() const                       function()
  (gdb) b function
  Breakpoint 1 at 0x4005ce: function. (26 locations)

  (gdb) b B::function<tab>
  (anonymous namespace)::B::function()        B::function() const                         Bn::B::function()
  (anonymous namespace)::B::function() const  B::function_const() const
  B::function()                               Bn::(anonymous namespace)::B::function()
  (gdb) b B::function
  Breakpoint 1 at 0x40072c: B::function. (6 locations)

To get back the original behavior of interpreting the function name as
a fully-qualified name, you can use the new "-qualified" (or "-q")
option/flag (added by this commit).  For example:

 (gdb) b B::function
 (anonymous namespace)::B::function()        B::function() const                         Bn::B::function()
 (anonymous namespace)::B::function() const  B::function_const() const
 B::function()                               Bn::(anonymous namespace)::B::function()

vs:

 (gdb) b -qualified B::function
 B::function()              B::function() const        B::function_const() const

I've chosen "-qualified" / "-q" because "-f" (for "full" or
"fully-qualified") is already taken for "-function".

Note: the "-qualified" option works with both linespecs and explicit
locations.  I.e., these are equivalent:

 (gdb) b -q func
 (gdb) b -q -f func

and so are these:

 (gdb) b -q filename.cc:func
 (gdb) b -q -s filename.cc -f func
 (gdb) b -s filename.cc -q -f func
 (gdb) b -s filename.cc -f func -q

To better understand why I consider wild matching the better default,
consider what happens when we get to the point when _all_ of GDB is
wrapped under "namespace gdb {}".  I have a patch series that does
that, and when I started debugging that GDB, I immediately became
frustrated.  You'd have to write "b gdb::internal_error", "b
gdb::foo", "b gdb::bar", etc. etc., which gets annoying pretty
quickly.  OTOH, consider how this makes it very easy to set
breakpoints in classes wrapped in anonymous namespaces.  You just
don't think of them, GDB finds the symbols for you automatically.

(At the Cauldron a couple months ago, several people told me that they
run into a similar issue when debugging other C++ projects.  One
example was when debugging LLVM, which puts all its code under the
"llvm" namespace.)

Implementation-wise, what the patch does is:

  - makes C++ symbol name hashing only consider the last component of
    a symbol name. (so that we can look up symbol names by
    last-component name only).

  - adds a C++ symbol name matcher for symbol_name_match_type::WILD,
    which ignores missing leading specifiers / components.

  - adjusts a few preexisting testsuite tests to use "-qualified" when
    they mean it.

  - adds new testsuite tests.

  - adds unit tests.

Grows the gdb.linespec/ tests like this:

  -# of expected passes           7823
  +# of expected passes           8977

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

	* NEWS: Mention that breakpoints on C++ functions are now set on
	on all namespaces/classes by default, and mention "break
	-qualified".
	* ax-gdb.c (agent_command_1): Adjust to pass a
	symbol_name_match_type to new_linespec_location.
	* breakpoint.c (parse_breakpoint_sals): Adjust to
	get_linespec_location's return type change.
	(strace_marker_create_sals_from_location): Adjust to pass a
	symbol_name_match_type to new_linespec_location.
	(strace_marker_decode_location): Adjust to get_linespec_location's
	return type change.
	(strace_command): Adjust to pass a symbol_name_match_type to
	new_linespec_location.
	(LOCATION_HELP_STRING): Add paragraph about wildmatching, and
	mention "-qualified".
	* c-lang.c (cplus_language_defn): Install cp_search_name_hash.
	* completer.c (explicit_location_match_type::MATCH_QUALIFIED): New
	enumerator.
	(complete_address_and_linespec_locations): New parameter
	'match_type'.  Pass it down.
	(explicit_options): Add "-qualified".
	(collect_explicit_location_matches): Pass the requested match type
	to the linespec completers.  Handle MATCH_QUALIFIED.
	(location_completer): Handle "-qualified" combined with linespecs.
	* cp-support.c (cp_search_name_hash): New.
	(cp_symbol_name_matches_1): Implement wild matching for C++.
	(cp_fq_symbol_name_matches): Reimplement.
	(cp_get_symbol_name_matcher): Return different matchers depending
	on the lookup name's match type.
	(selftests::test_cp_symbol_name_matches): Add wild matching tests.
	* cp-support.h (cp_search_name_hash): New declaration.
	* dwarf2read.c
	(selftests::dw2_expand_symtabs_matching::test_symbols): Add
	symbols.
	(test_dw2_expand_symtabs_matching_symbol): Add wild matching
	tests.
	* guile/scm-breakpoint.c (gdbscm_register_breakpoint_x): Adjust to
	pass a symbol_name_match_type to new_linespec_location.
	* linespec.c (linespec_parse_basic): Lookup function symbols using
	the parser's symbol name match type.
	(convert_explicit_location_to_linespec): New
	symbol_name_match_type parameter.  Pass it down to
	find_linespec_symbols.
	(convert_explicit_location_to_sals): Pass the location's name
	match type to convert_explicit_location_to_linespec.
	(parse_linespec): New match_type parameter.  Save it in the
	parser.
	(linespec_parser_new): Default to symbol_name_match_type::WILD.
	(linespec_complete_function): New symbol_name_match_type
	parameter.  Use it.
	(complete_linespec_component): Pass down the parser's recorded
	name match type.
	(linespec_complete_label): New symbol_name_match_type parameter.
	Use it.
	(linespec_complete): New symbol_name_match_type parameter.  Save
	it in the parser and pass it down.  Adjust to
	get_linespec_location's prototype change.
	(find_function_symbols, find_linespec_symbols): New
	symbol_name_match_type parameter.  Pass it down instead of
	assuming symbol_name_match_type::WILD.
	* linespec.h (linespec_complete, linespec_complete_function)
	(linespec_complete_label): New symbol_name_match_type parameter.
	* location.c (event_location::linespec_location): Now a struct
	linespec_location.
	(EL_LINESPEC): Adjust.
	(initialize_explicit_location): Default to
	symbol_name_match_type::WILD.
	(new_linespec_location): New symbol_name_match_type parameter.
	Record it in the location.
	(get_linespec_location): Now returns a struct linespec_location.
	(new_explicit_location): Also copy func_name_match_type.
	(explicit_to_string_internal)
	(string_to_explicit_location): Handle "-qualified".
	(copy_event_location): Adjust to LINESPEC_LOCATION type change.
	Copy symbol_name_match_type fields.
	(event_location_deleter::operator()): Adjust to LINESPEC_LOCATION
	type change.
	(event_location_to_string): Adjust to LINESPEC_LOCATION type
	change.  Handle "-qualfied".
	(string_to_explicit_location): Handle "-qualified".
	(string_to_event_location_basic): New symbol_name_match_type
	parameter.  Pass it down.
	(string_to_event_location): Handle "-qualified".
	* location.h (struct linespec_location): New.
	(explicit_location::func_name_match_type): New field.
	(new_linespec_location): Now returns a const linespec_location *.
	(string_to_event_location_basic): New symbol_name_match_type
	parameter.
	(explicit_completion_info::saw_explicit_location_option): New
	field.
	* mi/mi-cmd-break.c (mi_cmd_break_insert_1): Adjust to pass a
	symbol_name_match_type to new_linespec_location.
	* python/py-breakpoint.c (bppy_init): Likewise.
	* python/python.c (gdbpy_decode_line): Likewise.

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

	* gdb.base/langs.exp: Use -qualified.
	* gdb.cp/meth-typedefs.exp: Use -qualified, and add tests without
	it.
	* gdb.cp/namespace.exp: Use -qualified.
	* gdb.linespec/cpcompletion.exp (overload-2, fqn, fqn-2)
	(overload-3, template-overload, template-ret-type, const-overload)
	(const-overload-quoted, anon-ns, ambiguous-prefix): New
	procedures.
	(test_driver): Call them.
	* gdb.cp/save-bp-qualified.cc: New.
	* gdb.cp/save-bp-qualified.exp: New.
	* gdb.linespec/explicit.exp: Test -qualified.
	* lib/completion-support.exp (completion::explicit_opts_list): Add
	"-qualified".
	* lib/gdb.exp (gdb_breakpoint): Handle "qualified".

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

	* gdb.texinfo (Linespec Locations): Document how "function" is
	interpreted in C++ and Ada.  Document "-qualified".
	(Explicit Locations): Document how "-function" is interpreted in
	C++ and Ada.  Document "-qualified".
2017-11-29 19:43:48 +00:00
Pedro Alves a207cff2da Handle custom completion match prefix / LCD
A following patch will add support for wild matching for C++ symbols,
making completing on "b push_ba" on a C++ program complete to
std::vector<...>::push_back, std::string::push_back etc., like:

 (gdb) b push_ba[TAB]
 std::vector<...>::push_back(....)
 std::string<...>::push_back(....)

Currently, we compute the "lowest common denominator" between all
completion candidates (what the input line is adjusted to) as the
common prefix of all matches.  That's problematic with wild matching
as above, as then we'd end up with TAB changing the input line to
"b std::", losing the original input, like:

 (gdb) b push_ba[TAB]
 std::vector<...>::push_back(....)
 std::string<...>::push_back(....)
 (gdb) b std::

while obviously we'd want it to adjust itself to "b push_back(" instead:

 (gdb) b push_ba[TAB]
 std::vector<...>::push_back(....)
 std::string<...>::push_back(....)
 (gdb) b push_back(

This patch adds the core code necessary to support this, though
nothing really makes use of it yet in this patch.

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

	* ada-lang.c (ada_lookup_name_info::matches): Change type of
	parameter from completion_match to completion_match_result.
	Adjust.
	(do_wild_match, do_full_match, ada_symbol_name_matches): Likewise.
	* completer.c (completion_tracker::maybe_add_completion): Add
	match_for_lcd parameter and use it.
	(completion_tracker::add_completion): Likewise.
	* completer.h (class completion_match_for_lcd): New class.
	(completion_match_result::match_for_lcd): New field.
	(completion_match_result::set_match): New method.
	(completion_tracker): Add comments.
	(completion_tracker::add_completion): Add match_for_lcd parameter.
	(completion_tracker::reset_completion_match_result): Reset
	match_for_lcd too.
	(completion_tracker::maybe_add_completion): Add match_for_lcd
	parameter.
	(completion_tracker::m_lowest_common_denominator_unique): Extend
	comments.
	* cp-support.c (cp_symbol_name_matches_1)
	(cp_fq_symbol_name_matches): Change type of parameter from
	completion_match to completion_match_result.  Adjust.
	* language.c (default_symbol_name_matcher): Change type of
	parameter from completion_match to completion_match_result.
	Adjust.
	* language.h (completion_match_for_lcd): Forward declare.
	(default_symbol_name_matcher): Change type of parameter from
	completion_match to completion_match_result.
	* symtab.c (compare_symbol_name): Adjust.
	(completion_list_add_name): Pass the match_for_lcd to the tracker.
	* symtab.h (ada_lookup_name_info::matches): Change type of
	parameter from completion_match to completion_match_result.
	(symbol_name_matcher_ftype): Likewise, and update comments.
2017-11-29 19:33:23 +00:00
Pedro Alves 4024cf2b8d Fix setting-breakpoints regression on PPC64 (function descriptors)
The recent-ish commit e5f25bc5d6 ('Fix "list ambiguous_variable"')
caused a serious regression on PPC64.  See
<https://sourceware.org/ml/gdb-patches/2017-11/msg00666.html>.

Basically, after that patch, GDB sets breakpoints in function
descriptors instead of where the descriptors point to, which is
incorrect.

The problem is that GDB now only runs a minsym's address through
gdbarch_convert_from_func_ptr_addr if msymbol_is_text returns true.
However, if the symbol points to a function descriptor,
msymbol_is_text is false since function descriptors are in fact
outside the text section.

The fix is to also run a non-text address through
gdbarch_convert_from_func_ptr_addr, and if that detects that it was
indeed a function descriptor, treat the resulting address as a
function.

While implementing that directly in linespec.c:minsym_found (where the
bad msymbol_is_text check is) fixes the issue, I noticed that
linespec.c:add_minsym has some code that also basically needs to do
the same checks, however it's implemented differently.  Also,
add_minsym is calling find_pc_sect_line on non-function symbols, which
also doesn't look right.

So I introduced msymbol_is_function, so that we have a simple place to
consider minsyms and function descriptors.

And then, the only other use of msymbol_is_text is in
find_function_alias_target, which turns out to also be incorrect.
Changing that one to use msymbol_is_function, i.e., to consider
function descriptors too fixes (on PPC64):

  -FAIL: gdb.base/symbol-alias.exp: p func_alias
  -FAIL: gdb.base/symbol-alias.exp: p *func_alias()
  +PASS: gdb.base/symbol-alias.exp: p func_alias
  +PASS: gdb.base/symbol-alias.exp: p *func_alias()

And then after that, msymbol_is_text is no longer used anywhere, so it
can be removed.

Tested on x86_64 GNU/Linux, no regressions.  Tested on PPC64 GNU/Linux
and results compared to a testrun of e5f25bc5d6db^ (before the
offending commit), also no regressions.  (there's a couple new FAILs
and some new symbol name matching unit tests are crashing, but that
looks unrelated).

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

	* linespec.c (minsym_found, add_minsym): Use msymbol_is_function.
	* minsyms.c (msymbol_is_text): Delete.
	(msymbol_is_function): New function.
	* minsyms.h (msymbol_is_text): Delete.
	(msymbol_is_function): New declaration.
	* symtab.c (find_function_alias_target): Use msymbol_is_function.
2017-11-29 19:25:58 +00:00
Tom Tromey 5dcf52c19f Fix gdb snapshots
Joel pointed out that gdb snapshots were broken by my Makefile patch
series.  The bug is that rmdir in distclean was failing, because the
directory did not exist.  This fixes the bug by only invoking rmdir when
the directory exists.

Tested using "src-release.sh gdb".

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

	* Makefile.in (distclean): Handle the case where rmdir fails.
2017-11-29 11:56:40 -07:00
Jim Wilson 6cf829987c Give Palmer co-credit for last patch. 2017-11-29 10:51:36 -08:00
Jim Wilson 36877bfb88 Fix riscv malloc error on small alignment after norvc.
gas/
	* config/tc-riscv.c (riscv_frag_align_code): New local insn_alignment.
	Early return if bytes less than or equal to insn_alignment.
	* testsuite/gas/riscv/align-1.l: New.
	* testsuite/gas/riscv/align-1.s: New.
	* testsuite/gas/riscv/riscv.exp: Use run_dump_tests.  Use run_list_test
	for align-1.
2017-11-29 10:36:46 -08:00
Jim Wilson f923328821 In x86 -n docs, mention that you need an explicit nop fill byte.
gas/
	PR gas/22464
	* doc/c-i386.texi (-n): Clarify docs.
2017-11-29 10:22:26 -08:00
Renlin Li f10e937a1c [GAS][AARCH64]Fix a typo for IP1 register alias.
This should be an obvious fix.
It corrects the register number for IP1 to 17.

gas/

2017-11-29  Renlin Li  <renlin.li@arm.com>

	* config/tc-aarch64.c (reg_names): Fix IP1 register alias error.
	* testsuite/gas/aarch64/register_aliases.s: Add IP0 and IP1 tests.
	* testsuite/gas/aarch64/register_aliases.d: Update.
2017-11-29 17:19:59 +00:00
Nick Clifton 4581a1c7d3 Check for a NULL symbol pointer when reading relocs from a COFF based file.
PR 22509
	* coffcode.h (coff_slurp_reloc_table): Check for a NULL symbol
	pointer when processing relocs.
2017-11-29 17:12:12 +00:00
Phil Muldoon f6f1d339d4 Fix Python rbreak tests setting too many breakpoints when glibc debug info is installed.
2017-11-29  Phil Muldoon  <pmuldoon@redhat.com>

	* gdb.python/py-rbreak.exp: Set nosharedlibrary before tests.
2017-11-29 16:50:36 +00:00
Tom Tromey 8ca2f0b9ac Update usage text for add-symbol-file, symbol-file, and load
This updates the usage text for the add-symbol-file, symbol-file, and
load commands.

gdb/ChangeLog
2017-11-29  Tom Tromey  <tom@tromey.com>

	* symfile.c (_initialize_symfile): Update usage text for
	add-symbol-file, symbol-file, load.
2017-11-29 09:21:43 -07:00
Tom Tromey 02ca603a48 Fix add-symbol-file usage and errors
This patch updates add-symbol-file help and error text.

It changes add-symbol-file to throw an exception if "-s" is seen but
not all of the arguments are given.  Previously this was silently
ignored.

It changes the unrecognized argument message to more clearly state
what went wrong.

Finally, it updates the usage line in the help text to follow GNU
style regarding "metasyntactic variables"; a change I believe should
be made to all gdb help messages.

gdb/ChangeLog
2017-11-29  Tom Tromey  <tom@tromey.com>

	* symfile.c (add_symbol_file_command): Error if some arguments to
	-s are missing.  Change unrecognized-argument error message.
	(_initialize_symfile): Fix usage text for add-symbol-file.

gdb/testsuite/ChangeLog
2017-11-29  Tom Tromey  <tom@tromey.com>

	* gdb.base/relocate.exp: Update invalid argument test.
	Add new tests for invalid arguments.
2017-11-29 09:21:43 -07:00
Thomas Preud'homme ed6c0bfb26 [gdb/testsuite] Fix return type of psymtab-parameter
As pointed out by Pedro Alves, psymtab-parameter testcase rely on the
return type being long. This patch revert the changes made in
f106e10e5e and change psymtab-parameter.cc
to return 0 long instead.

2017-11-29  Thomas Preud'homme  <thomas.preudhomme@arm.com>

gdb/testsuite/
	* gdb.cp/psymtab-parameter.cc (func): Change return type back to long.
	Return 0 as a long.
	* gdb.cp/psymtab-parameter.exp: Change func's return type back to long.
2017-11-29 13:41:32 +00:00
Nick Clifton d785b7d4b8 Stop objdump from attempting to allocate a huge chunk of memory when parsing relocs in a corrupt file.
PR 22508
	* objdump.c (dump_relocs_in_section): Also check the section's
	relocation count to make sure that it is reasonable before
	attempting to allocate space for the relocs.
2017-11-29 12:40:43 +00:00
H.J. Lu 08f650e6b6 ld: Add a testcase for PR ld/22471
PR ld/22471
	* testsuite/ld-elf/pr22471.t: New file.
	* testsuite/ld-elf/pr22471a.s: Likewise.
	* testsuite/ld-elf/pr22471b.s: Likewise.
	* testsuite/ld-elf/shared.exp (ASFLAGS): Define UNDERSCORE for
	underscore targets.
	Run PR ld/22471 tests.
2017-11-29 04:21:01 -08:00
Thomas Preud'homme f106e10e5e [gdb/testsuite] Fix wrong return type in tests
The following tests are marked untested with latest GCC due to a warning
being emitted for a mismatch between their return type and what the lack
of return statement:

* gdb.cp/breakpoint.exp
* gdb.cp/psymtab-parameter.exp
* gdb.cp/shadow.exp

This patch fix the return type to match the function definitions.

2017-11-29  Thomas Preud'homme  <thomas.preudhomme@arm.com>

gdb/testsuite/
	* gdb.cp/breakpoint.cc (bar): Set return type to void.
	* gdb.cp/psymtab-parameter.cc (func): Likewise.
	* gdb.cp/psymtab-parameter.exp: Update comment regarding prototype of
	func ().
	* gdb.cp/shadow.cc (B.func): Return 0.
2017-11-29 10:45:31 +00:00
Stefan Stroe ca39c2f4dd Support --localedir, --datarootdir and --datadir
bfd/
	* po/Make-in (datadir): Define as @datadir@.
	(localedir): Define as @localedir@.
	(gnulocaledir, gettextsrcdir): Use @datarootdir@.
binutils/
	* po/Make-in (datadir): Define as @datadir@.
	(localedir): Define as @localedir@.
	(gnulocaledir, gettextsrcdir): Use @datarootdir@.
gas/
	* po/Make-in (datadir): Define as @datadir@.
	(localedir): Define as @localedir@.
	(gnulocaledir, gettextsrcdir): Use @datarootdir@.
gold/
	* po/Make-in (datadir): Define as @datadir@.
	(localedir): Define as @localedir@.
	(gnulocaledir, gettextsrcdir): Use @datarootdir@.
gprof/
	* po/Make-in (datadir): Define as @datadir@.
	(localedir): Define as @localedir@.
	(gnulocaledir, gettextsrcdir): Use @datarootdir@.
ld/
	* po/Make-in (datadir): Define as @datadir@.
	(localedir): Define as @localedir@.
	(gnulocaledir, gettextsrcdir): Use @datarootdir@.
opcodes/
	* po/Make-in (datadir): Define as @datadir@.
	(localedir): Define as @localedir@.
	(gnulocaledir, gettextsrcdir): Use @datarootdir@.
2017-11-29 20:10:52 +10:30
Nick Clifton ed9c7ee037 Use the record_alignment function when creating a .note section, in case the user has already created the section.
PR 22492
	* config/obj-elf.c (obj_elf_version): Use record_alignment rather
	than bfd_set_section_alignment.
2017-11-29 09:32:49 +00:00
Cary Coutant 5dc824ed42 Allow multiply-defined absolute symbols when they have the same value.
gold/
	* resolve.cc (Symbol_table::resolve): Allow multiply-defined absolute
	symbols when they have the same value.
2017-11-28 18:48:12 -08:00
Cary Coutant 8de0e07bf3 Allow multiple .eh_frame sections per object file.
LLVM is experimenting with placing .eh_frame sections in the COMDAT group
with the function's text. This triggers an internal error in gold because
we don't expect to see but one .eh_frame section in an object, and we use
a single data member in class Sized_relobj_file to keep track of that section.

This patch removes that data member, and instead checks the output section
and the input section offset to identify an optimized .eh_frame section.

gold/
	* object.h (class Sized_relobj_file): Remove discarded_eh_frame_shndx_.
	* object.cc (Sized_relobj_file::Sized_relobj_file): Likewise.
	(Sized_relobj_file::layout_eh_frame_section): Likewise.
	(Sized_relobj_file::do_count_local_symbols): Check for optimized
	.eh_frame section by other means.
	(Sized_relobj_file::compute_final_local_value_internal): Likewise.
2017-11-28 18:09:41 -08:00
GDB Administrator 144653ec15 Automatic date update in version.in 2017-11-29 00:00:23 +00:00
Nick Clifton b0029dce68 Prevent a memory exhaustion problem when trying to read in strings from a COFF binary with a corrupt string table size.
PR 22507
	* coffgen.c (_bfd_coff_read_string_table): Check for an excessive
	size of the external string table.
2017-11-28 18:00:29 +00:00
H.J. Lu ff174d3ffa gold: Add a newline at end of pr22266_a.c
This patch fixes the build with GCC 4.2:

gold/testsuite/pr22266_a.c:13:2: error: no newline at end of file

	* testsuite/pr22266_a.c: Add a newline at end of file.
2017-11-28 09:00:44 -08:00
H.J. Lu 82ed9683ec Properly handle note sections and segments
When dumping notes, get note alignment from either note section or note
segment.  To support notes generated by assemblers with

https://sourceware.org/bugzilla/show_bug.cgi?id=22492

we treate alignment as 4 bytes if it is less than 4.  Otherwise, we skip
notes if alignment isn't 4 nor 8 bytes.

We should call load_separate_debug_file only if e_shstrndx != SHN_UNDEF.

	PR binutils/22490
	* readelf.c (process_notes_at): Add an argument for note
	alignment.  If note alignment is less than 4, use 4 byte
	alignment.  Otherwise, skip notes if alignment isn't 4 nor
	8 bytes.
	(process_corefile_note_segments): Pass segment alignment to
	process_notes_at.
	(process_note_sections): Pass section alignment to
	process_notes_at.
	(process_object): Call load_separate_debug_file only if
	e_shstrndx != SHN_UNDEF.
2017-11-28 08:18:46 -08:00
Nick Clifton b23dc97fe2 Fix a memory access violation when attempting to parse a corrupt COFF binary with a relocation that points beyond the end of the section to be relocated.
PR 22506
	* reloc.c (reloc_offset_in_range): Rename to
	bfd_reloc_offset_in_range and export.
	(bfd_perform_relocation): Rename function invocation.
	(bfd_install_relocation): Likewise.
	(bfd_final_link_relocate): Likewise.
	* bfd-in2.h: Regenerate.
	* coff-arm.c (coff_arm_reloc): Use bfd_reloc_offset_in_range.
	* coff-i386.c (coff_i386_reloc): Likewise.
	* coff-i860.c (coff_i860_reloc): Likewise.
	* coff-m68k.c (mk68kcoff_common_addend_special_fn): Likewise.
	* coff-m88k.c (m88k_special_reloc): Likewise.
	* coff-mips.c (mips_reflo_reloc): Likewise.
	* coff-x86_64.c (coff_amd64_reloc): Likewise.
2017-11-28 13:20:31 +00:00
H.J. Lu 6c6bc89930 ELF: Don't set non_ir_ref_regular in check_relocs
Since elf_link_add_object_symbols sets non_ir_ref_regular now, there is
no need to set non_ir_ref_regular in check_relocs.

Tested on i686 and x86-64.

	* elf-m10300.c (mn10300_elf_check_relocs): Don't set
	non_ir_ref_regular.
	* elf32-arm.c (elf32_arm_check_relocs): Likewise.
	* elf32-bfin.c (bfin_check_relocs): Likewise.
	* elf32-cr16.c (cr16_elf_check_relocs): Likewise.
	* elf32-cris.c (cris_elf_check_relocs): Likewise.
	* elf32-d10v.c (elf32_d10v_check_relocs): Likewise.
	* elf32-dlx.c (elf32_dlx_check_relocs): Likewise.
	* elf32-fr30.c (fr30_elf_check_relocs): Likewise.
	* elf32-frv.c (elf32_frv_check_relocs): Likewise.
	* elf32-hppa.c (elf32_hppa_check_relocs): Likewise.
	* elf32-i370.c (i370_elf_check_relocs): Likewise.
	* elf32-i386.c (elf_i386_check_relocs): Likewise.
	* elf32-iq2000.c (iq2000_elf_check_relocs): Likewise.
	* elf32-lm32.c (lm32_elf_check_relocs): Likewise.
	* elf32-m32c.c (m32c_elf_check_relocs): Likewise.
	* elf32-m32r.c (m32r_elf_check_relocs): Likewise.
	* elf32-m68hc1x.c (elf32_m68hc11_check_relocs): Likewise.
	* elf32-m68k.c (elf_m68k_check_relocs): Likewise.
	* elf32-mcore.c (mcore_elf_check_relocs): Likewise.
	* elf32-metag.c (elf_metag_check_relocs): Likewise.
	* elf32-microblaze.c (microblaze_elf_check_relocs): Likewise.
	* elf32-moxie.c (moxie_elf_check_relocs): Likewise.
	* elf32-msp430.c (elf32_msp430_check_relocs): Likewise.
	* elf32-mt.c (mt_elf_check_relocs): Likewise.
	* elf32-nios2.c (nios2_elf32_check_relocs): Likewise.
	* elf32-or1k.c (or1k_elf_check_relocs): Likewise.
	* elf32-ppc.c (ppc_elf_check_relocs): Likewise.
	* elf32-rl78.c (rl78_elf_check_relocs): Likewise.
	* elf32-s390.c (elf_s390_check_relocs): 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_check_relocs): Likewise.
	* elf32-tic6x.c (elf32_tic6x_check_relocs): Likewise.
	* elf32-tilepro.c (tilepro_elf_check_relocs): Likewise.
	* elf32-v850.c (v850_elf_check_relocs): Likewise.
	* elf32-vax.c (elf_vax_check_relocs): Likewise.
	* elf32-xstormy16.c (xstormy16_elf_check_relocs): Likewise.
	* elf32-xtensa.c (elf_xtensa_check_relocs): Likewise.
	* elf64-aarch64.c (elf64_aarch64_check_relocs): Likewise.
	* elf64-alpha.c (elf64_alpha_check_relocs): Likewise.
	* elf64-hppa.c (elf64_hppa_check_relocs): Likewise.
	* elf64-ia64-vms.c (elf64_ia64_check_relocs): Likewise.
	* elf64-mmix.c (mmix_elf_check_relocs): Likewise.
	* elf64-ppc.c (ppc64_elf_check_relocs): Likewise.
	* elf64-s390.c (elf_s390_check_relocs): Likewise.
	* elf64-sh64.c (sh_elf64_check_relocs): Likewise.
	* elf64-x86-64.c (elf_x86_64_check_relocs): Likewise.
	* elfnn-aarch64.c (elfNN_aarch64_check_relocs): Likewise.
	* elfnn-ia64.c (elfNN_ia64_check_relocs): Likewise.
	* elfnn-riscv.c (riscv_elf_check_relocs): Likewise.
	* elfxx-mips.c (_bfd_mips_elf_check_relocs): Likewise.
	* elfxx-sparc.c (_bfd_sparc_elf_check_relocs): Likewise.
	* elfxx-tilegx.c (tilegx_elf_check_relocs): Likewise.
2017-11-28 04:55:34 -08:00
Alan Modra 165f707ac8 PR22471, undefined reference to linker-defined symbols
This patch processes linker script assignment statements before ld
opens DT_NEEDED libraries, in order to define symbols like __bss_start
that might also be defined by a library, falsely triggering an error
about "DSO missing from command line".

The initial value won't be correct when assigning a symbol from dot,
and I make no attempt to handle all expressions.  For example, an
assignment like "_start_foo = ADDR (.foo)" isn't valid until sections
are laid out, so won't define _start_foo early.  What's here should be
enough for most common scripts, and hopefully won't perturb fragile
scripts.

bfd/
	PR 22471
	* elflink.c (_bfd_elf_merge_symbol): Allow weak symbols to override
	early passes over linker script symbols.
	* linker.c (_bfd_generic_link_add_one_symbol): Allow symbols to
	override early passes over linker script symbols.  Clear ldscript_def
	on symbol definitions.
ld/
	PR 22471
	* ldexp.c (struct definedness_hash_entry): Delete "by_script".  Make
	"iteration" an 8-bit field, and update mask in all uses.
	(definedness_newfunc): Don't init "by_script".
	(update_definedness): Test ldscript_def rather than by_script.
	(is_sym_value): Likewise.
	(fold_name <DEFINED>): Return a result for first phase.  Test
	ldscript_def.
	(fold_name <NAME>): Return a result for first phase.
	* ldlang.c (open_input_bfds): Process all assignments, not just
	defsym.
	(lang_process): Increment lang_statement_iteration before
	open_input_bfds.
	* testsuite/ld-mips-elf/tlsdyn-o32-1.d: Adjust for larger .dynsym.
	* testsuite/ld-mips-elf/tlsdyn-o32-1.got: Likewise.
	* testsuite/ld-mips-elf/tlsdyn-o32-2.d: Likewise.
	* testsuite/ld-mips-elf/tlsdyn-o32-2.got: Likewise.
	* testsuite/ld-mips-elf/tlsdyn-o32-3.d: Likewise.
	* testsuite/ld-mips-elf/tlsdyn-o32-3.got: Likewise.
2017-11-28 22:57:00 +10:30
Alan Modra cd5b2babea Copying symbol type in ld script assignments
There is a call to update_definedness between code that evaluates an
assignment expression value and code that transfers symbol
attributes.  When script assignment expressions contain DEFINED, that
can mean the wrong symbol type is copied.  This patch tracks symbols
read during expression evaluation, rather than examining the
expression and re-evaluating conditionals.  Not only does this
simplify the code, it also means ld can now copy symbol types in more
complex expressions.

An unfortunate side effect of copying symbol type for more complex
expressions affects mmix, which uses
 PROVIDE (Main = DEFINED (Main) ? Main : (DEFINED (_start) ? _start : _start.));
in a default script.  So now _start or _start. symbol type may be
copied, losing the function type specially set up for Main.  This can
be avoided by making bfd_copy_link_hash_symbol_type do nothing for
mmix.

bfd/
	* elf64-mmix.c (bfd_elf64_bfd_copy_link_hash_symbol_type): Define.
ld/
	* ldexp.h (struct ldexp_control): Add "assign_src".
	* ldexp.c (fold_trinary): Save and restore assign_src around
	condition evaluation.
	(fold_name <NAME>): Set expld.assign_src.
	(try_copy_symbol_type): Delete.
	(exp_fold_tree_1): Set symbol type using expld.assign_src.
2017-11-28 22:56:59 +10:30
H.J. Lu a83ef4d139 ld: Set non_ir_ref_regular on symbols referenced in regular objects
If linker plugin is enabled, set non_ir_ref_regular on symbols referenced
in regular objects so that linker plugin will get the correct symbol
resolution.

bfd/

	PR ld/22502
	* elflink.c (_bfd_elf_merge_symbol): Also skip definition from
	an IR object.
	(elf_link_add_object_symbols): If linker plugin is enabled, set
	non_ir_ref_regular on symbols referenced in regular objects so
	that linker plugin will get the correct symbol resolution.

ld/

	PR ld/22502
	* testsuite/ld-plugin/lto.exp: Run PR ld/22502 test.
	* testsuite/ld-plugin/pr22502a.c: New file.
	* testsuite/ld-plugin/pr22502b.c: Likewise.
2017-11-28 03:48:44 -08:00
Jim Wilson f0531ed6a4 Compress loads/stores with implicit 0 offset.
gas/
	* config/tc-riscv.c (riscv_handle_implicit_zero_offset): New.
	(riscv_ip): Cases 'k', 'l', 'm', 'n', 'M', 'N', add call to
	riscv_handle_implicit_zero_offset.  At label load_store, replace
	existing code with call to riscv_handle_implicit_zero_offset.
	* testsuite/gas/riscv/c-ld.d, testsuite/gas/riscv/c-ld.s: New.
	* testsuite/gas/riscv/c-lw.d, testsuite/gas/riscv/c-lw.s: New.
	* testsuite/gas/riscv/riscv.exp: Run new tests.
2017-11-27 19:20:53 -08:00
Cary Coutant 033bfb739b Fix symbol values and relocation addends for relocatable links.
The fix for PR 19291 broke some other cases where -r is used with scripts,
as reported in PR 22266. The original fix for PR 22266 ended up breaking
many cases for REL targets, where the addends are stored in the section data,
and are not being adjusted properly.

The problem was basically that in a relocatable output file (ET_REL),
symbol values are supposed to be relative to the start address of their
section. Usually in a relocatable file, all sections start at 0, so the
failure to get this right is often irrelevant, but with a linker script,
we occasionally see an output section whose starting address is not 0,
and gold would occasionally write a symbol with its relocated value instead
of its section-relative value.

This patch reverts the recent fix for PR 22266 as well as my original fix
for PR 19291. The original fix moved the symbol value adjustment to
write_local_symbols, but neglected to undo a few places where the adjustment
was also being applied, resulting in an occasional double adjustment. The
more recent fix removed those other adjustments, but then failed to
re-account for the adjustment when rewriting the relocations on REL targets.

With the old attempts reverted, we now apply the symbol value adjustment to
the one case that had been missed (non-section symbols in merge sections).
But now we also need to account for the adjustment when rewriting the addends
for RELA relocations.

gold/
	PR gold/19291
	PR gold/22266
	* object.cc (Sized_relobj_file::compute_final_local_value_internal):
	Revert changes from 2017-11-08 patch.  Adjust symbol value in
	relocatable links for non-section symbols.
	(Sized_relobj_file::compute_final_local_value): Revert changes from
	2017-11-08 patch.
	(Sized_relobj_file::do_finalize_local_symbols): Likewise.
	(Sized_relobj_file::write_local_symbols): Revert changes from
	2015-11-25 patch.
	* object.h (Sized_relobj_file::compute_final_local_value_internal):
	Revert changes from 2017-11-08 patch.
	* powerpc.cc (Target_powerpc::relocate_relocs): Adjust addend for
	relocatable links.
	* target-reloc.h (relocate_relocs): Adjust addend for relocatable links.
	* testsuite/pr22266_a.c (hello): New function.
	* testsuite/pr22266_main.c (main): Add test for merge sections.
	* testsuite/pr22266_script.t: Add rule for .rodata.
2017-11-27 17:32:55 -08:00
GDB Administrator 57c1b6811a Automatic date update in version.in 2017-11-28 00:00:24 +00:00
Tom Tromey 18ca73470a Remove REMOTE_OBS
This removes REMOTE_OBS from the Makefile.  It is no longer needed, as
remote support is always built into gdb.  The relevant sources are now
added to COMMON_SFILES, where they are treated like other ordinary
sources.

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

	* Makefile.in (REMOTE_OBS): Remove.
	(SFILES): Remove remote sources.
	(COMMON_SFILES): Add remote sources.
	(ALLDEPFILES): Remove dcache.c.
2017-11-27 16:53:27 -07:00