aboutsummaryrefslogtreecommitdiff
AgeCommit message (Collapse)AuthorFilesLines
2017-12-01readonly_dynrelocsAlan Modra25-321/+618
In early October, HJ Lu added support for a number of targets to "Dump dynamic relocation in read-only section with minfo". This extends that support to more targets, displays the symbol involved, and splits the existing function that sets TEXTREL into a "readonly_dynrelocs" and "maybe_set_textrel" function. I'll need "readonly_dynrelocs" if I ever get around to fixing "pr22374 function pointer initialization" fails. am33_2.0, arc, bfin, hppa64, mn10300, and nios2 fail to mark a binary needing text relocations with DT_TEXTREL. That's not good. xtensa also fails to do so but complains about "dangerous relocation: dynamic relocation in read-only section" so I reckon that is fine and have marked the test as an xfail. The other targets need maintainer attention. Curiously, the map file dump wasn't added for x86, so the map test currently fail on x86. It also fails on alpha, am33_2.0, arc, bfin, hppa64, ia64, m68k, mips, mn10300, nios2, score and vax. cris complains with "tmpdir/textrel.o, section .rodata: relocation R_CRIS_32 should not be used in a shared object; recompile with -fPIC" so I've marked it as an xfail. bfd/ * elf32-hppa.c (maybe_set_textrel): Print symbol for map file output. * elf32-ppc.c (maybe_set_textrel): Likewise. * elf64-ppc.c (maybe_set_textrel): Likewise. * elf32-arm.c (readonly_dynrelocs): New function. (maybe_set_textrel): New function, replacing.. (elf32_arm_readonly_dynrelocs): ..this. * elf32-lm32.c (readonly_dynrelocs): New function. (maybe_set_textrel): New function, replacing old version of.. (readonly_dynrelocs): ..this. * elf32-m32r.c (readonly_dynrelocs): New function. (maybe_set_textrel): New function, replacing old version of.. (readonly_dynrelocs): ..this. * elf32-metag.c (readonly_dynrelocs): New function. (maybe_set_textrel): New function, replacing old version of.. (readonly_dynrelocs): ..this. * elf32-nds32.c: Delete unnecessary forward declarations. (readonly_dynrelocs): New function. (maybe_set_textrel): New function, replacing old version of.. (readonly_dynrelocs): ..this. * elf32-or1k.c (readonly_dynrelocs): New function. (maybe_set_textrel): New function, replacing old version of.. (readonly_dynrelocs): ..this. * elf32-s390.c (readonly_dynrelocs): New function. (maybe_set_textrel): New function, replacing old version of.. (readonly_dynrelocs): ..this. * elf32-sh.c (readonly_dynrelocs): New function. (maybe_set_textrel): New function, replacing old version of.. (readonly_dynrelocs): ..this. * elf32-tic6x.c (readonly_dynrelocs): New function. (maybe_set_textrel): New function, replacing.. (elf32_tic6x_readonly_dynrelocs): ..this. * elf32-tilepro.c (readonly_dynrelocs): New function. (maybe_set_textrel): New function, replacing old version of.. (readonly_dynrelocs): ..this. * elf64-s390.c (readonly_dynrelocs): New function. (maybe_set_textrel): New function, replacing old version of.. (readonly_dynrelocs): ..this. * elfnn-aarch64.c (readonly_dynrelocs): New function. (maybe_set_textrel): New function, replacing.. (aarch64_readonly_readonly_dynrelocs): ..this. * elfnn-riscv.c (readonly_dynrelocs): New function. (maybe_set_textrel): New function, replacing old version of.. (readonly_dynrelocs): ..this. * elfxx-sparc.c (readonly_dynrelocs): New function. (maybe_set_textrel): New function, replacing old version of.. (readonly_dynrelocs): ..this. * elfxx-tilegx.c (readonly_dynrelocs): New function. (maybe_set_textrel): New function, replacing old version of.. (readonly_dynrelocs): ..this. ld/ * testsuite/ld-elf/shared.exp: Run new textrel tests. * testsuite/ld-elf/textrel.map: New file. * testsuite/ld-elf/textrel.rd: New file. * testsuite/ld-elf/textrel.s: New file. * testsuite/ld-elf/textrel.warn: New file.
2017-12-01Automatic date update in version.inGDB Administrator1-1/+1
2017-11-30New gdb.ada/repeat_dyn testcase.Joel Brobecker5-0/+108
This patch introduces a testcase that exercises a scenario which used to trigger an internal-error, but no longer does: Consider the following array: type Small is new Integer range Ident (1) .. Ident (10); type Table is array (1 .. 3) of Small; A1 : Table := (3, 5, 8); The particularity of this array is that the type of each element is a range type whose bounds are dynamic, since they depend on the value returned by Ident (1) and Ident (10). Trying to apply the repeat operator ('@') on one of its elements used to yield an internal error: (gdb) p a1(1)@3 $1 = /[...]/gdbtypes.c:4512: internal-error: copy_type: Assertion `TYPE_OBJFILE_OWNED (type)' failed. Although the issue no longer appears, the testcase is still interesting to have. gdb/testsuite/ChangeLog: * gdb.ada/repeat_dyn: New testcase. Tested on x86_64-linux with clean results.
2017-11-30Fix internal error in fix_errata on aarch64.Peter Smith2-0/+32
The addresses of erratum stubs can be changed by relaxation passes, and need to be updated. gold/ PR gold/20765 * aarch64.cc (Aarch64_relobj::update_erratum_address): New method. (AArch64_relobj::scan_errata): Update addresses in stub table after relaxation pass.
2017-11-30Fix problem where erratum stubs are not always applied.Cary Coutant2-3/+11
I checked over the results of applying --fix-cortex-a53-843419 to a very large program (gitit) with two stub tables and thousands of erratum fixes. I noticed that all the erratum_stubs were being created but about 1/3 of them were being skipped over by fix_errata_and_relocate_erratum_stubs(). By skipped over I mean no branch relocation or adrp -> adr transformation was applied to the erratum address, leaving the erratum_stub unreachable, and with a branch with a 0 immediate. The root cause of the skipped over erratum_stubs is Erratum_stub::invalidate_erratum_stub() that is used to set relobj_ to NULL when an erratum_stub has been processed. Unfortunately relobj_ is used in operator<() so altering relobj makes the results from erratum_stubs_.lower_bound() as used in find_erratum_stubs_for_input_section() unreliable. 2017-11-30 Peter Smith <peter.smith@linaro.org> Cary Coutant <ccoutant@gmail.com> gold/ PR gold/20765 * aarch64.cc (Erratum_stub::invalidate_erratum_stub): Use erratum_insn_ instead of relobj_ to invalidate the stub. (Erratum_stub::is_invalidated_erratum_stub): Likewise.
2017-11-30Fix segfault in relocate_erratum_stub on aarch64.Peter Smith2-1/+7
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-12-01PR22533, dynamic relocs generated for weak aliasesAlan Modra4-63/+53
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-11-30[spu] Some additional test fixesUlrich Weigand3-4/+9
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-30Use boards/local-board.exp moreSimon Marchi5-16/+14
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-30Fix gdb.linespec/cpls-ops.exp on 32-bitPedro Alves2-2/+17
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-30Remove ioctl-based procfs support on SolarisRainer Orth16-3656/+449
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-30x86: derive DispN from BaseIndexJan Beulich4-4142/+4196
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-30x86: drop Vec_Disp8Jan Beulich8-16281/+16253
This is fully redundant with Disp8MemShift being non-zero, and hence can be folded with normal Disp8 handling.
2017-11-30x86/Intel: issue diagnostics for redundant segment override prefixesJan Beulich6-7/+64
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-30Revert "x86: Update segment register check in Intel syntax"Jan Beulich7-57/+18
This reverts commit 4d36230d59903b92fbe2b53b31ed64a884860f0e. I was committed without maintainer ack and regresses intended functionality. A replacement will be committed shortly.
2017-11-30Prevent an illegal memory access in readelf when attempting to parse a ↵Nick Clifton2-0/+10
corrupt ELF file. PR 22510 * readelf.c (load_debug_section): Fail if there are no section headers available.
2017-11-30Fix sol-thread.c compilation on SolarisRainer Orth2-2/+7
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-30Fix testcase for PR ld/22471Alan Modra2-0/+9
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-29Define MPFR_USE_INTMAX_T so that mpfr.h assumes intmax_t is available.John Baldwin2-0/+6
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-30Automatic date update in version.inGDB Administrator1-1/+1
2017-11-29preserve type length in ada-lang.c::to_fixed_range_typeJoel Brobecker2-0/+10
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-29Breakpoints in symbols with ABI tags (PR c++/19436)Pedro Alves13-18/+721
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-29Make "break foo" find "A::foo", A::B::foo", etc. [C++ and wild matching]Pedro Alves29-125/+1233
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-29Handle custom completion match prefix / LCDPedro Alves9-39/+170
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-29Fix setting-breakpoints regression on PPC64 (function descriptors)Pedro Alves5-75/+66
The recent-ish commit e5f25bc5d6db ('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-29Fix gdb snapshotsTom Tromey2-1/+5
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-29Give Palmer co-credit for last patch.Jim Wilson1-0/+1
2017-11-29Fix riscv malloc error on small alignment after norvc.Jim Wilson5-11/+23
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-29In x86 -n docs, mention that you need an explicit nop fill byte.Jim Wilson2-1/+7
gas/ PR gas/22464 * doc/c-i386.texi (-n): Clarify docs.
2017-11-29[GAS][AARCH64]Fix a typo for IP1 register alias.Renlin Li4-2/+12
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-29Check for a NULL symbol pointer when reading relocs from a COFF based file.Nick Clifton2-1/+7
PR 22509 * coffcode.h (coff_slurp_reloc_table): Check for a NULL symbol pointer when processing relocs.
2017-11-29Fix Python rbreak tests setting too many breakpoints when glibc debug info ↵Phil Muldoon2-0/+5
is installed. 2017-11-29 Phil Muldoon <pmuldoon@redhat.com> * gdb.python/py-rbreak.exp: Set nosharedlibrary before tests.
2017-11-29Update usage text for add-symbol-file, symbol-file, and loadTom Tromey2-4/+16
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-29Fix add-symbol-file usage and errorsTom Tromey4-8/+31
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[gdb/testsuite] Fix return type of psymtab-parameterThomas Preud'homme3-2/+9
As pointed out by Pedro Alves, psymtab-parameter testcase rely on the return type being long. This patch revert the changes made in f106e10e5e80265e1c43532bba4cb997a7dfa022 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-29Stop objdump from attempting to allocate a huge chunk of memory when parsing ↵Nick Clifton2-1/+17
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-29ld: Add a testcase for PR ld/22471H.J. Lu5-0/+63
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[gdb/testsuite] Fix wrong return type in testsThomas Preud'homme5-3/+12
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-29Support --localedir, --datarootdir and --datadirStefan Stroe14-28/+70
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-29Use the record_alignment function when creating a .note section, in case the ↵Nick Clifton2-2/+7
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-28Allow multiply-defined absolute symbols when they have the same value.Cary Coutant2-5/+20
gold/ * resolve.cc (Symbol_table::resolve): Allow multiply-defined absolute symbols when they have the same value.
2017-11-28Allow multiple .eh_frame sections per object file.Cary Coutant3-16/+19
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-29Automatic date update in version.inGDB Administrator1-1/+1
2017-11-28Prevent a memory exhaustion problem when trying to read in strings from a ↵Nick Clifton2-2/+8
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-28gold: Add a newline at end of pr22266_a.cH.J. Lu2-1/+5
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-28Properly handle note sections and segmentsH.J. Lu2-16/+39
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-28Fix a memory access violation when attempting to parse a corrupt COFF binary ↵users/ARM/embedded-gdb-master-2017q4users/ARM/embedded-binutils-master-2017q4Nick Clifton10-48/+126
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-28ELF: Don't set non_ir_ref_regular in check_relocsH.J. Lu53-196/+57
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-28PR22471, undefined reference to linker-defined symbolsAlan Modra12-53/+82
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-28Copying symbol type in ld script assignmentsAlan Modra5-34/+38
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.