summaryrefslogtreecommitdiff
path: root/ld
AgeCommit message (Collapse)Author
2018-01-03Update year range in copyright notice of binutils filesAlan Modra
2018-01-03ChangeLog rotationAlan Modra
2017-12-14Update the address of the FSF in the copyright notice of files which were ↵Nick Clifton
using the old address. top * COPYING.LIBGLOSS: Update address of FSF in copyright notice. bfd * cpu-mt.c: Update address of FSF in copyright notice. * elf32-m32c.c: Likewise. * elf32-mt.c: Likewise. * elf32-rl78.c: Likewise. * elf32-rx.c: Likewise. * elf32-rx.h: Likewise. * elf32-spu.h: Likewise. * hosts/x86-64linux.h: Likewise. etc * add-log.el: Update address of FSF in copyright notice. gas * config/tc-m32c.c: Update address of FSF in copyright notice. * config/tc-m32c.h: Likewise. * config/tc-mt.c: Likewise. * config/tc-mt.h: Likewise. * config/tc-visium.c: Likewise. * config/tc-visium.h: Likewise. * testsuite/gas/rx/explode: Likewise. ld * testsuite/ld-mn10300/mn10300.exp: Update address of FSF in copyright notice.
2017-12-13[BFD][AARCH64]Disallow R_AARCH64_ABS32(LP64) & R_AARCH64_ABS16 in const ↵Renlin Li
section of shared object. R_AARCH64_ABS64, R_AARCH64_ABS32 and R_AARCH64_ABS16 are data relocations supported in AArch64 elf ABI. R_AARCH64_ABS64 under LP64 is allowed in shared object and a dynamic relocation entry will be generated. This allows the dynamic linker to do further symbol resolution. R_AARCH64_ABS32 likewise is allowed in shared object, however under ILP32 abi. The original behavior for R_AARCH64_ABS32 under LP64 is that, it's allowed in shared object and silently resolved at static linking time. No dynamic relocation entry is generate for it. R_AARCH64_ABS16 is allowed in shared object under both L64 and ILP32. It's resolved at static linking time as well. Under LP64, the address should be 64-bit. R_AARCH64_ABS32 relocation indicates an address that is only sized 32 bits which is meaningless in LP64 shared object. It's useful to error out. I have checked glibc dynamic linker code, R_AARCH64_ABS16 is not supported at all. So R_AARCH64_ABS16 should be reject in shared object completely. In this patch, R_AARCH64_ABS32 is rejected under LP64 in constant section of shared object. R_AARCH64_ABS16 is rejected in constant section of shared object in both ABI. This will sometimes provide useful information for buggy code.
2017-12-07Objcopy interleave testAlan Modra
PR 22465 * testsuite/ld-elf/interleave.s: Use .data sections and provide section attrs. * testsuite/ld-elf/interleave.ld: Discard other sections. Adjust for changed section names.
2017-12-07mcore-elf lacks shared lib supportAlan Modra
elf32-mcore.c has no backend create_dynamic_sections function so can't support shared libs. * emulparams/elf32mcore.sh (GENERATE_SHLIB_SCRIPT): Don't define.
2017-12-07Rewrite check_shared_lib_supportAlan Modra
* testsuite/lib/ld-lib.exp (check_shared_lib_support): Ask ld under test whether -shared is supported.
2017-12-06Objcopy interleave fails if section address not multiple of interleave.Jim Wilson
PR 22465 binutils/ * objcopy.c (copy_section): New local extra. If isection->lma not exactly divisible by interleave, then bias from. Also adjust osection->lma if necessary. ld/ * testsuite/ld-elf/interleave-0.d, testsuite/ld-elf/interleave-4.d, * testsuite/ld-elf/interleave.ld, testsuite/ld-elf/interleave.s: New.
2017-12-06Tell the linker testsuite that lm32-rtems toolchains do not support the ↵Nick Clifton
generation of shared libraries. * testsuite/lib/ld-lib.exp (check_shared_lib_support): Return false for lm32-rtems targets.
2017-12-06Enable shared lib tests for frv, lm32, m32r, microblaze, nds32 and or1kAlan Modra
These claim to support shared libs when configuring for <target>-linux (in contrast to <target>-elf which doesn't support shared libs). * testsuite/lib/ld-lib.exp (check_shared_lib_support): Return true for frv, lm32, m32r, microblaze, nds32 and or1k linux targets.
2017-12-05Really fix riscv shared library __global_pointer$ problem.Jim Wilson
ld/ * emulparams/elf32lriscv-defs.sh (SDATA_START_SYMBOLS): Remove HIDDEN. Don't define __global_pointer$ when CREATE_SHLIB. * testsuite/ld-riscv-elf/gp-hidden-64.rd, * testsuite/ld-riscv-elf/gp-hidden-lib.rd, * testsuite/ld-riscv-elf/gp-hidden-lib.s, * testsuite/ld-riscv-elf/gp-hidden-ver-64.rd, * testsuite/ld-riscv-elf/gp-hidden-ver.rd, * testsuite/ld-riscv-elf/gp-hidden-ver.s, * testsuite/ld-riscv-elf/gp-hidden-ver.ver, * testsuite/ld-riscv-elf/gp-hidden.rd, * testsuite/ld-riscv-elf/gp-hidden.s, * testsuite/ld-riscv-elf/gp-hidden.sd: Delete. * testsuite/ld-riscv-elf/gp-test-lib.sd, * testsuite/ld-riscv-elf/gp-test.s, * testsuite/ld-riscv-elf/gp-test.sd: New. * testsuite/ld-riscv-elf/ld-riscv-elf.exp: Rewrite gp tests.
2017-12-04Riscv shared libraries should not export __global_pointer$.Jim Wilson
ld/ * emulparams/elf32lriscv-defs.sh (SDATA_START_SYMBOLS): Mark __global_pointer$ as HIDDEN. * testsuite/ld-riscv-elf/gp-hidden-64.rd: New. * testsuite/ld-riscv-elf/gp-hidden-lib.rd: New. * testsuite/ld-riscv-elf/gp-hidden-lib.s: New. * testsuite/ld-riscv-elf/gp-hidden-ver-64.rd: New. * testsuite/ld-riscv-elf/gp-hidden-ver.rd: New. * testsuite/ld-riscv-elf/gp-hidden-ver.s: New. * testsuite/ld-riscv-elf/gp-hidder-ver.ver: New. * testsuite/ld-riscv-elf/gp-hidden.rd: New. * testsuite/ld-riscv-elf/gp-hidden.s: New. * testsuite/ld-riscv-elf/gp-hidden.sd: New. * testsuite/ld-riscv-elf/ld-riscv-elf.exp: Change riscv to riscv*. Run the new tests with run_ld_link_tests.
2017-12-04x86 map file textrelAlan Modra
bfd/ * elfxx-x86.c (readonly_dynrelocs): New function. (maybe_set_textrel): New function. Always prints via minfo and correct "readonly" to "read-only" in warning message., replacing.. (_bfd_x86_elf_readonly_dynrelocs): ..this. (_bfd_x86_elf_size_dynamic_sections): Correct "readonly" to "read-only" in warning message. Formatting. (_bfd_x86_elf_adjust_dynamic_symbol): Use readonly_dynrelocs. * linker.c (bfd_link_hash_traverse): Comment typo fix. ld/ * testsuite/ld-i386/pr17935-1.d: Adjust expected error. * testsuite/ld-i386/pr17935-2.d: Likewise. * testsuite/ld-x86-64/pr17935-1.d: Likewise. * testsuite/ld-x86-64/pr17935-2.d: Likewise.
2017-12-04Modify ppceabi ld tests to run on all powerpc ELF targetsAlan Modra
* testsuite/ld-powerpc/powerpc.exp (ppceabitests): Add -a32 -mbig to assembler options, and -melf32ppc to linker options. Always run these tests.
2017-12-01Check return value of bfd_new_link_orderTobias Ulmer
* ldwrite.c (build_link_order): Check return value of all bfd_new_link_order calls.
2017-12-01weak alias testAlan Modra
This adds the test I was using when testing 60d67dc8. * testsuite/ld-elfweak/alias.c, * testsuite/ld-elfweak/alias.dat, * testsuite/ld-elfweak/aliasmain.c, * testsuite/ld-elfweak/weakref1.c, * testsuite/ld-elfweak/weakref2.c: New test. * testsuite/ld-elfweak/elfweak.exp: Run it. Don't return on fails, attempt other tests.
2017-12-01readonly_dynrelocsAlan Modra
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-11-30Fix testcase for PR ld/22471Alan Modra
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-29ld: Add a testcase for PR ld/22471H.J. Lu
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-29Support --localedir, --datarootdir and --datadirStefan Stroe
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-28PR22471, undefined reference to linker-defined symbolsAlan Modra
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 Modra
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-28ld: Set non_ir_ref_regular on symbols referenced in regular objectsH.J. Lu
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-24Update PR ld/21562 tests for underscore targetsH.J. Lu
We also need to provide __start_scnfoo and __stop_scnfoo with the extra leading underscore for underscore targets. This patch fixed: FAIL: ld-elf/pr21562k FAIL: ld-elf/pr21562l FAIL: ld-elf/pr21562m FAIL: ld-elf/pr21562n for metag-linux, * testsuite/ld-elf/pr21562c.t: Also provide ___start_scnfoo and ___stop_scnfoo. * testsuite/ld-elf/pr21562d.t: Likewise.
2017-11-23Add libmsvcrt, libmsvcrt-os and libucrtbase to the list of libraries for ↵Martin Storsjo
which the automatic generation of exported variables should be disabled. In the latest git version of mingw-w64, one can set the default libmsvcrt.a to actually be the import library of another CRT version, to facilitate switching to ucrtbase.dll. In these versions, the traditional libmsvcrt.a (for linking to msvcrt.dll) is also provided with the name libmsvcrt-os.a. The import libraries for the CRT also contain a number of compatibility wrapper functions. The ones in libmsvcrt.a have so far been excluded automatically since they in most cases come with a corresponding __imp_foo function. None of these make sense to export automatically from a DLL though, so add these libraries to the exclude list. libucrtbase.a contains a number of compatibility wrapper functions that don't have a corresponding __imp_foo symbol, which cause these symbols to be exported from DLLs. This can be worked around on the mingw-w64 side by adding extra __imp_ symbols, but since they aren't strictly necessary for linking to succeed, it's probably better long-term to add these libraries to the exclusion list. ld * pe-dll.c (autofilter_liblist): Add libmsvcrt, libmsvcrt-os and libucrtbase.
2017-11-23x86-64: always use unsigned 32-bit reloc for 32-bit addressing w/o base regJan Beulich
Except for %eip-relative addressing, where we don't have a suitable relocation type silently wrapping at the 4G boundary, consistently force use of R_X86_64_32 (in ELF terms) instead of its sign-extending counterpart. This wasn't right in case there was no base register in the addressing expression.
2017-11-21Stop the v850 linker from converting to other output formats whilst linking.Nick Clifton
PR 22419 * emultempl/v850elf.em (v850_create_output_section_statements): New function. Generate an error if attempting to convert the format of the output file. * testsuite/ld-unique/pr21529.d: Skip for the V850. * testsuite/ld-elf/pr21884.d: Skip for the V850.
2017-11-21[ARC] Improve printing of pc-relative instructions.claziss
opcodes/ 2017-11-21 Claudiu Zissulescu <claziss@synopsys.com> * arc-dis.c (print_insn_arc): Pretty print pc-relative offsets. * arc-opc.c (SIMM21_A16_5): Make it pc-relative. gas/ 2017-11-21 Claudiu Zissulescu <claziss@synopsys.com> * testsuite/gas/arc/b.d : Update test. * testsuite/gas/arc/bl.d: Likewise. * testsuite/gas/arc/jli-1.d: Likewise. * testsuite/gas/arc/lp.d: Likewise. * testsuite/gas/arc/pcl-relocs.d: Likewise. * testsuite/gas/arc/pcrel-relocs.d: Likewise. * testsuite/gas/arc/pic-relocs.d: Likewise. * testsuite/gas/arc/plt-relocs.d: Likewise. * testsuite/gas/arc/pseudos.d: Likewise. * testsuite/gas/arc/relax-avoid2.d: Likewise. * testsuite/gas/arc/relax-avoid3.d: Likewise. * testsuite/gas/arc/relax-b.d: Likewise. * testsuite/gas/arc/tls-relocs.d: Likewise. * testsuite/gas/arc/relax-add01.d: Likewise. * testsuite/gas/arc/relax-add04.d: Likewise. * testsuite/gas/arc/relax-ld01.d: Likewise. * testsuite/gas/arc/relax-sub01.d: Likewise. * testsuite/gas/arc/relax-sub02.d: Likewise. * testsuite/gas/arc/relax-sub04.d: Likewise. * testsuite/gas/arc/pcl-print.s: New file. * testsuite/gas/arc/pcl-print.d: Likewise. * testsuite/gas/arc/nps400-12.d: Likewise. ld/ 2017-11-21 Claudiu Zissulescu <claziss@synopsys.com> * testsuite/ld-arc/jli-simple.d: Update test.
2017-11-20Fix handling of GNU Property notes that are not in a GNU NOTE PROPERTY section.Nick Clifton
PR 22450 gas * elf-properties.c (_bfd_elf_link_setup_gnu_properties): Skip objects without a GNU_PROPERTY note section when looking for a bfd onto which notes can be accumulated. ld * testsuite/ld-elf/elf.exp: Add --defsym ALIGN=2|3 to assembler command line depending upon the size of the target address space. * testsuite/ld-elf/pr22450.s: New test file. * testsuite/ld-elf/pr22450.d: New test driver. * testsuite/config/default.exp: Add note that LD_CLASS refers to the size of the host linker not the size of the target linker.
2017-11-15Add support to readelf and objdump for following links to separate debug ↵Nick Clifton
information files. Hi Guys, I am applying the rather large patch attached to this email to enhance the readelf and objdump programs so that they now have the ability to follow links to separate debug info files. (As requested by PR 15152). So for example whereas before we had this output: $ readelf -wi main.exe Contents of the .debug_info section: [...] <15> DW_AT_comp_dir : (alt indirect string, offset: 0x30c) [...] With the new option enabled we get: $ readelf -wiK main.exe main.exe: Found separate debug info file: dwz.debug Contents of the .debug_info section (loaded from main.exe): [...] <15> DW_AT_comp_dir : (alt indirect string, offset: 0x30c) /home/nickc/Downloads/dwzm [...] The link following feature also means that we can get two lots of output if the same section exists in both the main file and the separate debug info file: $ readelf -wiK main.exe main.exe: Found separate debug info file: dwz.debug Contents of the .debug_info section (loaded from main.exe): [...] Contents of the .debug_info section (loaded from dwz.debug): [...] The patch also adds the ability to display the contents of debuglink sections: $ readelf -wk main.exe Contents of the .gnu_debugaltlink section: Separate debug info file: dwz.debug Build-ID (0x14 bytes): c4 a8 89 8d 64 cf 70 8a 35 68 21 f2 ed 24 45 3e 18 7a 7a 93 Naturally there are long versions of these options (=follow-links and =links). The documentation has been updated as well, and since both readelf and objdump use the same set of debug display options, I have moved the text into a separate file. There are also a couple of new binutils tests to exercise the new behaviour. There are a couple of missing features in the current patch however, although I do intend to address them in follow up submissions: Firstly the code does not check the build-id inside separate debug info files when it is searching for a file specified by a .gnu_debugaltlink section. It just assumes that if the file is there, then it contains the information being sought. Secondly I have not checked the DWARF-5 version of these link features, so there will probably be code to add there. Thirdly I have only implemented link following for the DW_FORM_GNU_strp_alt format. Other alternate formats (eg DW_FORM_GNU_ref_alt) have yet to be implemented. Lastly, whilst implementing this feature I found it necessary to move some of the global variables used by readelf (eg section_headers) into a structure that can be passed around. I have moved all of the global variables that were necessary to get the patch working, but I need to complete the operation and move the remaining, file-specific variables (eg dynamic_strings). Cheers Nick binutils PR 15152 * dwarf.h (enum dwarf_section_display_enum): Add gnu_debuglink, gnu_debugaltlink and separate_debug_str. (struct dwarf_section): Add filename field. Add prototypes for load_separate_debug_file, close_debug_file and open_debug_file. * dwarf.c (do_debug_links): New. (do_follow_links): New. (separate_debug_file, separate_debug_filename): New. (fetch_alt_indirect_string): New function. Retrieves a string from the debug string table in the separate debug info file. (read_and_display_attr_value): Use it with DW_FORM_GNU_strp_alt. (load_debug_section_with_follow): New function. Like load_debug_section, but if the first attempt fails, then tries again in the separate debug info file. (introduce): New function. (process_debug_info): Use load_debug_section_with_follow and introduce. (load_debug_info): Likewise. (display_debug_lines_raw): Likewise. (display_debug_lines_decoded): Likewise. (display_debug_macinfo): Likewise. (display_debug_macro): Likewise. (display_debug_abbrev): Likewise. (display_debug_loc): Likewise. (display_debug_str): Likewise. (display_debug_aranges): Likewise. (display_debug_addr); Likewise. (display_debug_frames): Likewise. (display_gdb_index): Likewise. (process_cu_tu_index): Likewise. (load_cu_tu_indexes): Likewise. (display_debug_links): New function. Displays the contents of a .gnu_debuglink or .gnu_debugaltlink section. (calc_gnu_debuglink_ctc32):New function. Calculates a CRC32 value. (check_gnu_debuglink): New function. Checks the CRC of a potential separate debug info file. (parse_gnu_debuglink): New function. Reads a CRC value out of a .gnu_debuglink section. (check_gnu_debugaltlink): New function. (parse_gnu_debugaltlink): New function. Reads the build-id value out of a .gnu_debugaltlink section. (load_separate_debug_info): New function. Finds and loads a separate debug info file. (load_separate_debug_file): New function. Attempts to find and follow a link to a separate debug info file. (free_debug_memory): Free the separate debug info file information. (opts_table): Add "follow-links" and "links". (dwarf_select_sections_by_letters): Add "k" and "K". (debug_displays): Reformat. Add .gnu-debuglink and .gnu_debugaltlink. Add an extra entry for .debug_str in a separate debug info file. * doc/binutils.texi: Move description of debug dump features common to both readelf and objdump into... * objdump.c (usage): Add -Wk and -WK. (load_specific_debug_section): Initialise the filename field in the dwarf_section structure. (close_debug_file): New function. (open_debug_file): New function. (dump_dwarf): Load and dump the separate debug info sections. * readelf.c (struct filedata): New structure. Contains various variables that used to be global: (current_file_size, string_table, string_table_length, elf_header) (section_headers, program_headers, dump_sects, num_dump_sects): Move into filedata structure. (cmdline): New global variable. Contains list of sections to dump by number, as specified on the command line. Add filedata parameter to most functions. (load_debug_section): Load the string table if it has not already been retrieved. (close_file): New function. (close_debug_file): New function. (open_file): New function. (open_debug_file): New function. (process_object): Process sections in any separate debug info files. * doc/debug.options.texi: New file. Add description of =links and =follow-links options. * NEWS: Mention the new feature. * elfcomm.c: Have the byte gte functions take a const pointer. * elfcomm.h: Update prototypes. * testsuite/binutils-all/dw5.W: Update expected output. * testsuite/binutils-all/objdump.WL: Update expected output. * testsuite/binutils-all/objdump.exp: Add test of -WK and -Wk. * testsuite/binutils-all/readelf.exp: Add test of -wK and -wk. * testsuite/binutils-all/readelf.k: New file. * testsuite/binutils-all/objdump.Wk: New file. * testsuite/binutils-all/objdump.WK2: New file. * testsuite/binutils-all/linkdebug.s: New file. * testsuite/binutils-all/debuglink.s: New file. gas * testsuite/gas/avr/large-debug-line-table.d: Update expected output. * testsuite/gas/elf/dwarf2-11.d: Likewise. * testsuite/gas/elf/dwarf2-12.d: Likewise. * testsuite/gas/elf/dwarf2-13.d: Likewise. * testsuite/gas/elf/dwarf2-14.d: Likewise. * testsuite/gas/elf/dwarf2-15.d: Likewise. * testsuite/gas/elf/dwarf2-16.d: Likewise. * testsuite/gas/elf/dwarf2-17.d: Likewise. * testsuite/gas/elf/dwarf2-18.d: Likewise. * testsuite/gas/elf/dwarf2-5.d: Likewise. * testsuite/gas/elf/dwarf2-6.d: Likewise. * testsuite/gas/elf/dwarf2-7.d: Likewise. ld * testsuite/ld-avr/gc-section-debugline.d: Update expected output.
2017-11-15ld einfo positional arg supportAlan Modra
To allow translators to reorder values in translated strings. This should mean that all binutils messages now have support for reordering. Note to translators: Not all % letters take arguments, so for example the following only has two arguments, the two %s strings. "%P%F: output format %s cannot represent section called %s: %E\n" You could reorder this if you liked to: "%P%F: %E: section %2$s cannot be represented in output format %1$s\n" einfo lacks support for flags, field width, precision and length modifier (apart from %ld and %lu) so don't try to use them in translations. Both ld and bfd lack support to use a positional arg twice. These features could be added if needed.. * ldmisc.c (vfinfo): Support up to 9 positional args.
2017-11-14Add modified file I missed in last commit.Jim Wilson
2017-11-14Fix riscv ld testsuite failure for compressed1d.Jim Wilson
ld/ * testsuite/ld-elf/compress1-alt.s: New. * testsuite/ld-elf/compressed1d-alt.d: New. * testsuite/ld-elf/compressed1d.d: Add riscv*-*-* to notarget list.
2017-11-14PR22431, powerpc64 ld segfault when .plt discardedAlan Modra
The fix for the PR is to not use input_section->output_section->owner to get to the output bfd, but use the output bfd directly since it is available nowadays in struct bfd_link_info. I thought it worth warning when non-empty dynamic sections are discarded too, which meant a tweak to one of the ld tests to avoid the warning. bfd/ PR 22431 * elf64-ppc.c (ppc64_elf_size_dynamic_sections): Warn on discarding non-empty dynamic section. (ppc_build_one_stub): Take elf_gp from output bfd, not output section owner. (ppc_size_one_stub, ppc64_elf_next_toc_section): Likewise. ld/ * testsuite/ld-elf/note-3.t: Don't discard .got.
2017-11-14ld-ifunc non-PIC testsAlan Modra
* testsuite/ld-ifunc/ifunc.exp: Ensure non-PIC tests are really not PIE by default gcc options.
2017-11-13ld: Replace exp_dataseg_none with exp_seg_noneH.J. Lu
* emultempl/ppc32elf.em (ppc_before_allocation): Replace exp_dataseg_none with exp_seg_none. * emultempl/ppc64elf.em (prelim_size_sections): Likewise. * emultempl/spuelf.em (spu_before_allocation): Likewise.
2017-11-12ld: Add ldlang_check_relro_region/update lang_find_relro_sections_1H.J. Lu
Extract GNU_RELRO region check into a new funtion and pass a pointer to seg_align_type to lang_find_relro_sections_1 so that they can also be used for text-only LOAD segment. * ldlang.c (lang_size_sections_1): Extract GNU_RELRO region check into ... (ldlang_check_relro_region): New function. (lang_find_relro_sections_1): Add an argument for pointer to seg_align_type and replace expld.dataseg with the pointer. (lang_find_relro_sections): Pass address of expld.dataseg to lang_find_relro_sections_1.
2017-11-12clH.J. Lu
2017-11-12ld: Add lang_size_relro_segmentH.J. Lu
Break lang_size_sections down into separate functions so that they can also be used for text-only LOAD segment. lang_size_relro_segment will call lang_size_relro_segment_1 and lang_size_segment for both GNU_RELRO segment and text-only LOAD segment. * ldlang.c (lang_size_segment): New function. (lang_size_relro_segment_1): Likewise. (lang_size_relro_segment): Likewise. (lang_size_sections): Rewrite to call lang_size_relro_segment.
2017-11-12ld: Add fold_segment_align/fold_segment_relro_end/fold_segment_endH.J. Lu
Extract DATA_SEGMENT_END/DATA_SEGMENT_ALIGN/DATA_SEGMENT_RELRO_END cases for GNU_RELRO segment into separate functions so that they can also be used for text-only LOAD segment. * ldexp.c (fold_unary): Extract the DATA_SEGMENT_END case to ... (fold_segment_end): New function. (fold_binary): Extract the DATA_SEGMENT_ALIGN case to ... (fold_segment_align): New function. (fold_binary): Extract the DATA_SEGMENT_RELRO_END case to ... (fold_segment_relro_end): New function.
2017-11-12ld: Update phase_enum/relro_enum and add seg_align_typeH.J. Lu
Update GNU_RELRO date type so that they can also be used for text-only LOAD segment. * ldexp.h (phase_enum): Rename exp_dataseg_none, exp_dataseg_align_seen, exp_dataseg_relro_seen, exp_dataseg_end_seen, exp_dataseg_relro_adjust, exp_dataseg_adjust and exp_dataseg_done to exp_seg_none, exp_seg_align_seen, exp_seg_relro_seen, exp_seg_end_seen, exp_seg_relro_adjust, exp_seg_adjust and exp_seg_done. (relro_enum): Rename exp_dataseg_relro_none, exp_dataseg_relro_start and exp_dataseg_relro_end to exp_seg_relro_none, exp_seg_relro_start and exp_seg_relro_end. (seg_align_type): New struct type. (ldexp_control): Use seg_align_type. * ldexp.c (fold_unary): Updated. (fold_binary): Likewise. * ldlang.c (strip_excluded_output_sections): Likewise. (lang_size_sections_1): Likewise. (lang_size_sections): Likewise.
2017-11-12ld: Remove PF_X from PT_PHDR segmentH.J. Lu
It was reasonable to mark PT_PHDR segment with PF_X for compatibility with UnixWare and Solaris linkers 20 years ago. But it is inappropriate today when the primary OS of GNU ld is Linux. This patch removes PF_X from PT_PHDR segment as gold does. Tested natively on Linux/x86 as well as crosss-binutils for alpha-linux, ia64-linux, powerpc64-linux, powerpc-linux, s390-linux, s390x-linux, sparc64-linux and sparc-linux. bfd/ PR ld/22423 * elf.c (_bfd_elf_map_sections_to_segments): Remove PF_X from PT_PHDR segment. ld/ PR ld/22423 * testsuite/ld-alpha/tlsbin.rd: Replace "R E " with "R +" for PT_PHDR segment. * testsuite/ld-alpha/tlsbinr.rd: Likewise. * testsuite/ld-ia64/tlsbin.rd: Likewise. * testsuite/ld-powerpc/tlsexe.r: Likewise. * testsuite/ld-powerpc/tlsexe32.r: Likewise. * testsuite/ld-powerpc/tlsexetoc.r: Likewise. * testsuite/ld-s390/tlsbin.rd: Likewise. * testsuite/ld-s390/tlsbin_64.rd: Likewise. * testsuite/ld-sparc/tlssunbin32.rd: Likewise. * testsuite/ld-sparc/tlssunbin64.rd: Likewise. * testsuite/ld-elf/pr22423.d: New test.
2017-11-12ld: Add OTHER_PLT_SECTIONSH.J. Lu
OTHER_PLT_SECTIONS contains sections which should be placed right after .plt section. * emulparams/elf32_x86_64.sh (TINY_READONLY_SECTION): Renamed to ... (OTHER_PLT_SECTIONS): This. * emulparams/elf_i386.sh: Likewise. * emulparams/elf_iamcu.sh: Likewise. * emulparams/elf_x86_64.sh: Likewise. * scripttempl/elf.sc: Place ${OTHER_PLT_SECTIONS} just after .plt.
2017-11-09ld: Reformat emultempl/elf32.emH.J. Lu
Reformat emultempl/elf32.em to generate consistent codes. * emultempl/elf32.em (gld${EMULATION_NAME}_get_script): Reformat to generate consistent codes.
2017-11-07readelf ngettext fixesAlan Modra
This patch is a first pass at fixing readelf message pluralization. I've deliberately not fixed the "out of memory" errors since it's very unlikely that they will ever be complaining about not being able to allocate for a single entry, and a few others where the size is very unlikely to be 1 byte. Then there are messages like this one: "Out of %lu items there are %zu bucket clashes (longest of %zu entries).\n" I suppose this could be split into three parts, "Of %lu items ", "there are %zu bucket clashes ", and "(longest of %zu entries).\n", each part being printed separately, but that might not be ideal for sentence construction in other languages. For now I'm punting on this one. Changes to readelf output require lots of testsuite adjustment.. binutils/ * dwarf.c (read_uleb128): Properly pluralize messages. (display_debug_lines_raw, display_debug_loc): Likewise. (display_debug_names, process_cu_tu_index): Likewise. * od-macho.c (dump_code_signature_superblob): Likewise. * readelf.c (process_program_headers): Likewise. (process_section_header, process_relocs): Likewise. (hppa_process_unwind, arm_process_unwind): Likewise. (process_dynamic_section, process_version_sections): Likewise. (process_symbol_table, process_syminfo): Likewise. (apply_relocations, process_mips_specific): Likewise. (process_gnu_liblist, process_notes_at): Likewise. (process_archive): Likewise. * testsuite/binutils-all/dw2-1.W, * testsuite/binutils-all/dw2-3.W, * testsuite/binutils-all/dw2-3gabi.W, * testsuite/binutils-all/dw5.S, * testsuite/binutils-all/dw5.W, * testsuite/binutils-all/i386/compressed-1a.d, * testsuite/binutils-all/libdw2-compressedgabi.out, * testsuite/binutils-all/objdump.W, * testsuite/binutils-all/readelf.r, * testsuite/binutils-all/readelf.r-64, * testsuite/binutils-all/x86-64/compressed-1a.d: Update for pluralization fixes. gas/ * testsuite/gas/arm/got_prel.d, * testsuite/gas/elf/dwarf2-1.d, * testsuite/gas/elf/dwarf2-2.d, * testsuite/gas/elf/dwarf2-3.d, * testsuite/gas/elf/dwarf2-5.d, * testsuite/gas/elf/dwarf2-6.d, * testsuite/gas/i386/debug1.d, * testsuite/gas/i386/dw2-compress-1.d, * testsuite/gas/i386/dw2-compress-3a.d, * testsuite/gas/i386/dw2-compress-3b.d, * testsuite/gas/i386/dw2-compressed-1.d, * testsuite/gas/i386/dw2-compressed-3a.d, * testsuite/gas/i386/dw2-compressed-3b.d, * testsuite/gas/i386/ilp32/x86-64-localpic.d, * testsuite/gas/i386/localpic.d, * testsuite/gas/i386/x86-64-localpic.d, * testsuite/gas/ia64/pr13167.d, * testsuite/gas/mips/loc-swap-2.d, * testsuite/gas/mips/loc-swap.d, * testsuite/gas/mips/micromips@loc-swap-2.d, * testsuite/gas/mips/micromips@loc-swap.d, * testsuite/gas/mips/mips16-dwarf2-n32.d, * testsuite/gas/mips/mips16-dwarf2.d, * testsuite/gas/mips/mips16@loc-swap-2.d, * testsuite/gas/mips/mips16@loc-swap.d, * testsuite/gas/mips/mips16e@loc-swap.d, * testsuite/gas/mmix/bspec-1.d, * testsuite/gas/mmix/bspec-2.d, * testsuite/gas/tic6x/unwind-1.d, * testsuite/gas/tic6x/unwind-2.d, * testsuite/gas/tic6x/unwind-3.d: Update for pluralization fixes. ld/ * testsuite/ld-aarch64/ifunc-13.d, * testsuite/ld-aarch64/ifunc-15.d, * testsuite/ld-aarch64/ifunc-20.d, * testsuite/ld-alpha/tlsbin.rd, * testsuite/ld-alpha/tlspic.rd, * testsuite/ld-arm/ifunc-3.rd, * testsuite/ld-arm/ifunc-9.rd, * testsuite/ld-arm/unwind-mix.d, * testsuite/ld-arm/unwind-rel.d, * testsuite/ld-cris/hiddef1.d, * testsuite/ld-cris/libdso-13.d, * testsuite/ld-cris/libdso-2.d, * testsuite/ld-cris/pr16044.d, * testsuite/ld-cris/tls-local-63.d, * testsuite/ld-cris/tls-local-64.d, * testsuite/ld-cris/tls-und-38.d, * testsuite/ld-cris/tls-und-42.d, * testsuite/ld-cris/tls-und-46.d, * testsuite/ld-cris/tls-und-50.d, * testsuite/ld-cris/weakref3.d, * testsuite/ld-cris/weakref4.d, * testsuite/ld-elf/comm-data2r.rd, * testsuite/ld-elf/discard1.d, * testsuite/ld-elf/discard2.d, * testsuite/ld-elf/pr19539.d, * testsuite/ld-elf/pr22374-1.r, * testsuite/ld-elf/pr22374-2.r, * testsuite/ld-i386/combreloc.d, * testsuite/ld-i386/emit-relocs-nacl.rd, * testsuite/ld-i386/emit-relocs.rd, * testsuite/ld-i386/pr13302.d, * testsuite/ld-i386/pr17709-nacl.rd, * testsuite/ld-i386/pr17709.rd, * testsuite/ld-i386/pr19539.d, * testsuite/ld-i386/pr19615.d, * testsuite/ld-i386/pr19636-1a.d, * testsuite/ld-i386/pr19636-1e.d, * testsuite/ld-i386/pr19636-1f.d, * testsuite/ld-i386/pr19636-2a.d, * testsuite/ld-i386/pr19636-2b.d, * testsuite/ld-i386/pr19636-2d-nacl.d, * testsuite/ld-i386/pr19636-2e-nacl.d, * testsuite/ld-i386/pr19636-3a.d, * testsuite/ld-i386/pr19636-3d.d, * testsuite/ld-i386/pr19636-3e.d, * testsuite/ld-i386/pr19636-4a.d, * testsuite/ld-i386/pr19645.d, * testsuite/ld-i386/pr19827-nacl.rd, * testsuite/ld-i386/pr19827.rd, * testsuite/ld-i386/pr20253-4a.d, * testsuite/ld-i386/pr20253-4b.d, * testsuite/ld-i386/pr20253-5.d, * testsuite/ld-i386/tlsbin-nacl.rd, * testsuite/ld-i386/tlsbin.rd, * testsuite/ld-i386/tlspic-nacl.rd, * testsuite/ld-i386/tlspic.rd, * testsuite/ld-i386/undefweakb.d, * testsuite/ld-ia64/tlsbin.rd, * testsuite/ld-ia64/tlspic.rd, * testsuite/ld-ifunc/ifunc-13-i386.d, * testsuite/ld-ifunc/ifunc-13-x86-64.d, * testsuite/ld-ifunc/ifunc-15-i386.d, * testsuite/ld-ifunc/ifunc-15-x86-64.d, * testsuite/ld-ifunc/ifunc-20-i386.d, * testsuite/ld-ifunc/ifunc-20-x86-64.d, * testsuite/ld-ifunc/ifunc-23a-x86.d, * testsuite/ld-ifunc/ifunc-23b-x86.d, * testsuite/ld-ifunc/ifunc-23c-x86.d, * testsuite/ld-ifunc/ifunc-24a-x86.d, * testsuite/ld-ifunc/ifunc-24b-x86.d, * testsuite/ld-ifunc/ifunc-24c-x86.d, * testsuite/ld-ifunc/ifunc-25a-x86.d, * testsuite/ld-ifunc/ifunc-25b-x86.d, * testsuite/ld-ifunc/ifunc-25c-x86.d, * testsuite/ld-m68k/got-1.d, * testsuite/ld-mips-elf/vxworks1.rd, * testsuite/ld-powerpc/ambiguousv1.d, * testsuite/ld-powerpc/ambiguousv1b.d, * testsuite/ld-powerpc/ambiguousv2.d, * testsuite/ld-powerpc/ambiguousv2b.d, * testsuite/ld-powerpc/tlsexe.r, * testsuite/ld-powerpc/tlsexe32.r, * testsuite/ld-powerpc/tlsexetoc.r, * testsuite/ld-powerpc/tlsso.r, * testsuite/ld-powerpc/tlsso32.r, * testsuite/ld-powerpc/tlstocso.r, * testsuite/ld-powerpc/vle-multiseg-1.d, * testsuite/ld-powerpc/vle-multiseg-2.d, * testsuite/ld-powerpc/vle-multiseg-3.d, * testsuite/ld-s390/tlsbin.rd, * testsuite/ld-s390/tlsbin_64.rd, * testsuite/ld-s390/tlspic.rd, * testsuite/ld-s390/tlspic_64.rd, * testsuite/ld-sh/ld-r-1.d, * testsuite/ld-sh/sh64/gotplt.d, * testsuite/ld-sh/shared-1.d, * testsuite/ld-sh/tlsbin-2.d, * testsuite/ld-sh/tlspic-2.d, * testsuite/ld-sparc/gotop32.rd, * testsuite/ld-sparc/gotop64.rd, * testsuite/ld-sparc/tlssunpic32.rd, * testsuite/ld-sparc/tlssunpic64.rd, * testsuite/ld-sparc/vxworks1-lib.rd, * testsuite/ld-tic6x/shlib-app-1.rd, * testsuite/ld-tic6x/shlib-app-1b.rd, * testsuite/ld-tic6x/shlib-app-1r.rd, * testsuite/ld-tic6x/shlib-app-1rb.rd, * testsuite/ld-tic6x/shlib-noindex.rd, * testsuite/ld-vax-elf/export-class-data.rd, * testsuite/ld-x86-64/pr13082-1a.d, * testsuite/ld-x86-64/pr13082-1b.d, * testsuite/ld-x86-64/pr13082-2a.d, * testsuite/ld-x86-64/pr13082-2b.d, * testsuite/ld-x86-64/pr13082-3a.d, * testsuite/ld-x86-64/pr13082-3c.d, * testsuite/ld-x86-64/pr13082-4a.d, * testsuite/ld-x86-64/pr13082-5a.d, * testsuite/ld-x86-64/pr13082-5b.d, * testsuite/ld-x86-64/pr13082-6a.d, * testsuite/ld-x86-64/pr13082-6b.d, * testsuite/ld-x86-64/pr17709-nacl.rd, * testsuite/ld-x86-64/pr17709.rd, * testsuite/ld-x86-64/pr19539a.d, * testsuite/ld-x86-64/pr19539b.d, * testsuite/ld-x86-64/pr19615.d, * testsuite/ld-x86-64/pr19636-1a.d, * testsuite/ld-x86-64/pr19636-1d.d, * testsuite/ld-x86-64/pr19636-1e.d, * testsuite/ld-x86-64/pr19636-2a.d, * testsuite/ld-x86-64/pr19636-2e.d, * testsuite/ld-x86-64/pr19636-2f.d, * testsuite/ld-x86-64/pr19636-3a.d, * testsuite/ld-x86-64/pr19645.d, * testsuite/ld-x86-64/pr19807-2b.d, * testsuite/ld-x86-64/pr19807-2d.d, * testsuite/ld-x86-64/pr19827-nacl.rd, * testsuite/ld-x86-64/pr19827.rd, * testsuite/ld-x86-64/pr20253-4a.d, * testsuite/ld-x86-64/pr20253-4b.d, * testsuite/ld-x86-64/pr20253-4d.d, * testsuite/ld-x86-64/pr20253-4e.d, * testsuite/ld-x86-64/pr20253-5a.d, * testsuite/ld-x86-64/pr20253-5b.d, * testsuite/ld-x86-64/tlsbin-nacl.rd, * testsuite/ld-x86-64/tlsbin.rd, * testsuite/ld-x86-64/tlspic-nacl.rd, * testsuite/ld-x86-64/tlspic.rd, * testsuite/ld-x86-64/tlspic2-nacl.rd: Update for pluralization fixes.
2017-11-07gas and ld pluralization fixesAlan Modra
gas/ * as.c (main): Properly pluralize messages. * frags.c (frag_grow): Likewise. * read.c (emit_expr_with_reloc, emit_expr_fix): Likewise. (parse_bitfield_cons): Likewise. * write.c (fixup_segment, compress_debug, write_contents): Likewise. (relax_segment): Likewise. * config/tc-arm.c (s_arm_elf_cons): Likewise. * config/tc-cr16.c (l_cons): Likewise. * config/tc-i370.c (i370_elf_cons): Likewise. * config/tc-m68k.c (m68k_elf_cons): Likewise. * config/tc-msp430.c (msp430_operands): Likewise. * config/tc-s390.c (s390_elf_cons, s390_literals): Likewise. * config/tc-mcore.c (md_apply_fix): Likewise. * config/tc-tic54x.c (md_assemble): Likewise. * config/tc-xtensa.c (xtensa_elf_cons): Likewise. (xg_expand_assembly_insn): Likewise. * config/xtensa-relax.c (build_transition): Likewise. ld/ * ldlang.c (lang_size_sections_1): Properly pluralize messages. (lang_check_section_addresses): Likewise.
2017-11-07ngettext supportAlan Modra
binutils has lacked proper pluralization of output messages for a long time, for example, readelf will display information about a section that "contains 1 entries" or "There are 1 section headers". Fixing this properly requires us to use ngettext, because other languages have different rules to English. This patch defines macros for ngettext and friends to handle builds with --disable-nls, and tidies the existing nls support. I've redefined gettext rather than just defining "_" as dgettext in bfd and opcodes in case someone wants to use gettext there (which might conceivably happen with generated code). bfd/ * sysdep.h: Formatting, comment fixes. (gettext, ngettext): Redefine when ENABLE_NLS. (ngettext, dngettext, dcngettext): Define when !ENABLE_NLS. (_): Define using gettext. (textdomain, bindtextdomain): Use safer "do nothing". * hosts/alphavms.h (textdomain, bindtextdomain): Likewise. (ngettext, dngettext, dcngettext): Define when !ENABLE_NLS. opcodes/ * opintl.h: Formatting, comment fixes. (gettext, ngettext): Redefine when ENABLE_NLS. (ngettext, dngettext, dcngettext): Define when !ENABLE_NLS. (_): Define using gettext. (textdomain, bindtextdomain): Use safer "do nothing". binutils/ * sysdep.h (textdomain, bindtextdomain): Use safer "do nothing". (ngettext, dngettext, dcngettext): Define when !ENABLE_NLS. gas/ * asintl.h (textdomain, bindtextdomain): Use safer "do nothing". (ngettext, dngettext, dcngettext): Define when !ENABLE_NLS. gold/ * system.h (textdomain, bindtextdomain): Use safer "do nothing". (ngettext, dngettext, dcngettext): Define when !ENABLE_NLS. ld/ * ld.h (textdomain, bindtextdomain): Use safer "do nothing". (ngettext, dngettext, dcngettext): Define when !ENABLE_NLS.
2017-11-01PR22374, PowerPC unnecessary PLT entriesAlan Modra
We don't need a PLT entry when function pointer initialization in a read/write section is the only reference to a given function symbol. This patch prevents the unnecessary PLT entry, and ensures no dynamic relocs are emitted when UNDEFWEAK_NO_DYNAMIC_RELOC says so. bfd/ PR 22374 * elf32-ppc.c (ppc_elf_adjust_dynamic_symbol): Don't create a plt entry when just a dynamic reloc can serve. Ensure no dynamic relocations when UNDEFWEAK_NO_DYNAMIC_RELOC by setting non_got_ref. Expand and move the non_got_ref comment. * elf64-ppc.c (ppc64_elf_adjust_dynamic_symbol): Likewise. ld/ * testsuite/ld-powerpc/ambiguousv2.d: Remove FIXME.
2017-11-01PR22374 testcase, function pointer references in .dataAlan Modra
Function pointer references in .data ought to use a dynamic reloc. There shouldn't be any need for a PLT entry and definitely no copy reloc. This test fails on quite a few targets, but isn't something that anyone should worry about too much. It's really just a missed optimization. PR 22374 * testsuite/ld-elf/pr22374a.s, * testsuite/ld-elf/pr22374b.s, * testsuite/ld-elf/pr22374-1.r, * testsuite/ld-elf/pr22374-2.r: New test. * testsuite/ld-elf/elf.exp: Run it.
2017-11-01Tidy elf.expAlan Modra
* testsuite/ld-elf/elf.exp: Merge some conditionals, a better name than "shared library for next test", and use xfail arg of run_ld_link_tests in a few places.