summaryrefslogtreecommitdiff
path: root/ld
Commit message (Collapse)AuthorAgeFilesLines
* Update year range in copyright notice of all files.Alan Modra2017-01-02363-455/+459
|
* ChangeLog rotationAlan Modra2017-01-022-4112/+4126
|
* PRU LD PortDimitar Dimitrov2016-12-3156-9/+812
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * NEWS: Mention new PRU target. * Makefile.am: Add PRU target. * configure.tgt: Ditto. * emulparams/pruelf.sh: New file. * emultempl/pruelf.em: New file. * scripttempl/pru.sc: New file. * Makefile.in: Regenerate. * testsuite/ld-pru/emit-relocs-1.d: New PRU testcase file. * testsuite/ld-pru/emit-relocs-1.ld: Ditto. * testsuite/ld-pru/emit-relocs-1a.s: Ditto. * testsuite/ld-pru/emit-relocs-1b.s * testsuite/ld-pru/ldi32.d: Ditto. * testsuite/ld-pru/ldi32.s: Ditto. * testsuite/ld-pru/ldi32_symbol.s: Ditto. * testsuite/ld-pru/norelax_ldi32-data.d: Ditto. * testsuite/ld-pru/norelax_ldi32-dis.d: Ditto. * testsuite/ld-pru/pcrel_s10.d: Ditto. * testsuite/ld-pru/pcrel_s10.s: Ditto. * testsuite/ld-pru/pcrel_s10_label.s: Ditto. * testsuite/ld-pru/pcrel_u8-illegal.d: Ditto. * testsuite/ld-pru/pcrel_u8-illegal.s: Ditto. * testsuite/ld-pru/pcrel_u8-illegal2.d: Ditto. * testsuite/ld-pru/pcrel_u8-illegal2.s: Ditto. * testsuite/ld-pru/pcrel_u8-illegal3.d: Ditto. * testsuite/ld-pru/pcrel_u8-illegal3.s: Ditto. * testsuite/ld-pru/pcrel_u8.d: Ditto. * testsuite/ld-pru/pcrel_u8.s: Ditto. * testsuite/ld-pru/pcrel_u8_label.s: Ditto. * testsuite/ld-pru/pmem.d: Ditto. * testsuite/ld-pru/pmem.s: Ditto. * testsuite/ld-pru/pmem_symbol.s: Ditto. * testsuite/ld-pru/pru.exp: Ditto. * testsuite/ld-pru/relax_ldi32-data.d: Ditto. * testsuite/ld-pru/relax_ldi32-dis.d: Ditto. * testsuite/ld-pru/relax_ldi32.s: Ditto. * testsuite/ld-pru/relax_ldi32_symbol.s: Ditto. * testsuite/ld-pru/reloc.d: Ditto. * testsuite/ld-pru/reloc.s: Ditto. * testsuite/ld-pru/reloc_symbol.s: Ditto. * testsuite/ld-pru/u16.d: Ditto. * testsuite/ld-pru/u16.s: Ditto. * testsuite/ld-pru/u16_symbol.s: Ditto. PRU does not export __end symbol because it is ambiguous for it. Users are expected to use instead the section markers __text_end, __data_end, __bss_end or __noinit_end. * testsuite/lib/ld-lib.exp (check_shared_lib_support): No shared libraries are supported for PRU. (check_gc_sections_available): Mark PRU as not supported. * testsuite/ld-elf/eh-frame-hdr.d: Disable for PRU. * testsuite/ld-elf/endsym.d: Likewise. * testsuite/ld-elf/group8a.d: Likewise. * testsuite/ld-elf/group8b.d: Likewise. * testsuite/ld-elf/group9a.d: Likewise. * testsuite/ld-elf/group9b.d: Likewise. * testsuite/ld-elf/merge.d: Likewise. * testsuite/ld-elf/pr12851.d: Likewise. * testsuite/ld-elf/pr14926.d: Likewise. * testsuite/ld-elf/sec-to-seg.exp: Likewise. * testsuite/ld-elf/sec64k.exp: Mark sec64k case as too big for PRU. * testsuite/ld-srec/srec.exp (run_srec_test): Add setup for PRU. Signed-off-by: Dimitar Dimitrov <dimitar@dinux.eu>
* ld testsuite: Sanitize output from ldDimitar Dimitrov2016-12-312-3/+7
| | | | | | | | | | | | | | | | | | | Leading dashes from an LD error message confuse send_log, because the string is taken to be an option. This patch fixes the following DejaGnu error: --defsym:1: undefined symbol `foo2' referenced in expression failed with: <--defsym:1: undefined symbol `foo2' referenced in expression>, no expected output ERROR: tcl error sourcing .../ld/testsuite/ld-gc/gc.exp. ERROR: usage: send [args] string while executing "send_log "$comp_output\n"" (procedure "run_dump_test" line 376) * testsuite/lib/ld-lib.exp (run_dump_test): Pass -- to send_log. Signed-off-by: Dimitar Dimitrov <dimitar@dinux.eu>
* Use dynrelro for symbols in relro sections tooAlan Modra2016-12-284-0/+35
| | | | | | | | | | | PR ld/20995 bfd/ * elflink.c (elf_link_add_object_symbols): Mark relro sections in dynamic objects SEC_READONLY. ld/ * testsuite/ld-elf/pr20995c.s: New test file. * testsuite/ld-elf/pr20995-2so.r: Likewise. * testsuite/ld-elf/elf.exp: Run it.
* dynrelro section for read-only dynamic symbols copied into executableAlan Modra2016-12-269-32/+88
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Variables defined in shared libraries are copied into an executable's .bss section when code in the executable is non-PIC and thus would require dynamic text relocations to access the variable directly in the shared library. Recent x86 toolchains also copy variables into the executable to gain a small speed improvement. The problem is that if the variable was originally read-only, the copy in .bss is writable, potentially opening a security hole. This patch cures that problem by putting the copy in a section that becomes read-only after ld.so relocation, provided -z relro is in force. The patch also fixes a microblaze linker segfault on attempting to use dynamic bss variables. bfd/ PR ld/20995 * elf-bfd.h (struct elf_link_hash_table): Add sdynrelro and sreldynrelro. (struct elf_backend_data): Add want_dynrelro. * elfxx-target.h (elf_backend_want_dynrelro): Define. (elfNN_bed): Update initializer. * elflink.c (_bfd_elf_create_dynamic_sections): Create sdynrelro and sreldynrelro sections. * elf32-arm.c (elf32_arm_adjust_dynamic_symbol): Place variables copied into the executable from read-only sections into sdynrelro. (elf32_arm_size_dynamic_sections): Handle sdynrelro. (elf32_arm_finish_dynamic_symbol): Select sreldynrelro for dynamic relocs in sdynrelro. (elf_backend_want_dynrelro): Define. * elf32-hppa.c (elf32_hppa_adjust_dynamic_symbol) (elf32_hppa_size_dynamic_sections, elf32_hppa_finish_dynamic_symbol) (elf_backend_want_dynrelro): As above. * elf32-i386.c (elf_i386_adjust_dynamic_symbol) (elf_i386_size_dynamic_sections, elf_i386_finish_dynamic_symbol) (elf_backend_want_dynrelro): As above. * elf32-metag.c (elf_metag_adjust_dynamic_symbol) (elf_metag_size_dynamic_sections, elf_metag_finish_dynamic_symbol) (elf_backend_want_dynrelro): As above. * elf32-microblaze.c (microblaze_elf_adjust_dynamic_symbol) (microblaze_elf_size_dynamic_sections) (microblaze_elf_finish_dynamic_symbol) (elf_backend_want_dynrelro): As above. * elf32-nios2.c (nios2_elf32_finish_dynamic_symbol) (nios2_elf32_adjust_dynamic_symbol) (nios2_elf32_size_dynamic_sections) (elf_backend_want_dynrelro): As above. * elf32-or1k.c (or1k_elf_finish_dynamic_symbol) (or1k_elf_adjust_dynamic_symbol, or1k_elf_size_dynamic_sections) (elf_backend_want_dynrelro): As above. * elf32-ppc.c (ppc_elf_adjust_dynamic_symbol) (ppc_elf_size_dynamic_sections, ppc_elf_finish_dynamic_symbol) (elf_backend_want_dynrelro): As above. * elf32-s390.c (elf_s390_adjust_dynamic_symbol) (elf_s390_size_dynamic_sections, elf_s390_finish_dynamic_symbol) (elf_backend_want_dynrelro): As above. * elf32-tic6x.c (elf32_tic6x_adjust_dynamic_symbol) (elf32_tic6x_size_dynamic_sections) (elf32_tic6x_finish_dynamic_symbol) (elf_backend_want_dynrelro): As above. * elf32-tilepro.c (tilepro_elf_adjust_dynamic_symbol) (tilepro_elf_size_dynamic_sections) (tilepro_elf_finish_dynamic_symbol) (elf_backend_want_dynrelro): As above. * elf64-ppc.c (ppc64_elf_adjust_dynamic_symbol) (ppc64_elf_size_dynamic_sections, ppc64_elf_finish_dynamic_symbol) (elf_backend_want_dynrelro): As above. * elf64-s390.c (elf_s390_adjust_dynamic_symbol) (elf_s390_size_dynamic_sections, elf_s390_finish_dynamic_symbol) (elf_backend_want_dynrelro): As above. * elf64-x86-64.c (elf_x86_64_adjust_dynamic_symbol) (elf_x86_64_size_dynamic_sections) (elf_x86_64_finish_dynamic_symbol) (elf_backend_want_dynrelro): As above. * elfnn-aarch64.c (elfNN_aarch64_adjust_dynamic_symbol) (elfNN_aarch64_size_dynamic_sections) (elfNN_aarch64_finish_dynamic_symbol) (elf_backend_want_dynrelro): As above. * elfnn-riscv.c (riscv_elf_adjust_dynamic_symbol) (riscv_elf_size_dynamic_sections, riscv_elf_finish_dynamic_symbol) (elf_backend_want_dynrelro): As above. * elfxx-mips.c (_bfd_mips_elf_adjust_dynamic_symbol) (_bfd_mips_elf_size_dynamic_sections) (_bfd_mips_vxworks_finish_dynamic_symbol): As above. * elfxx-sparc.c (_bfd_sparc_elf_adjust_dynamic_symbol) (_bfd_sparc_elf_size_dynamic_sections) (_bfd_sparc_elf_finish_dynamic_symbol): As above. * elfxx-tilegx.c (tilegx_elf_adjust_dynamic_symbol) (tilegx_elf_size_dynamic_sections) (tilegx_elf_finish_dynamic_symbol): As above. * elf32-mips.c (elf_backend_want_dynrelro): Define. * elf64-mips.c (elf_backend_want_dynrelro): Define. * elf32-sparc.c (elf_backend_want_dynrelro): Define. * elf64-sparc.c (elf_backend_want_dynrelro): Define. * elf32-tilegx.c (elf_backend_want_dynrelro): Define. * elf64-tilegx.c (elf_backend_want_dynrelro): Define. * elf32-microblaze.c (microblaze_elf_adjust_dynamic_symbol): Tidy. (microblaze_elf_size_dynamic_sections): Handle sdynbss. * elf32-nios2.c (nios2_elf32_size_dynamic_sections): Make use of linker shortcuts to dynamic sections rather than comparing names. Correctly set "got" flag. ld/ PR ld/20995 * testsuite/ld-arm/farcall-mixed-app-v5.d: Update to suit changed stub hash table traversal caused by section id increment. Accept the previous output too. * testsuite/ld-arm/farcall-mixed-app.d: Likewise. * testsuite/ld-arm/farcall-mixed-lib-v4t.d: Likewise. * testsuite/ld-arm/farcall-mixed-lib.d: Likewise. * testsuite/ld-elf/pr20995a.s, * testsuite/ld-elf/pr20995b.s, * testsuite/ld-elf/pr20995.r: New test. * testsuite/ld-elf/elf.exp: Run it.
* Correct .dynbss in scriptAlan Modra2016-12-262-1/+5
| | | | | | | The only target that renames .bss is tic6x, turning .bss into .far, and .sbss into .bss. .dynbss is not renamed to .dynfar by BFD. * scripttempl/elf.sc: Don't use $BSS_NAME in .dynbss.
* Bump version to 2.28.51Tristan Gingold2016-12-232-10/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | bfd/ 2016-12-23 Tristan Gingold <gingold@adacore.com> * version.m4: Bump version to 2.28.51 * configure: Regenerate. binutils/ 2016-12-23 Tristan Gingold <gingold@adacore.com> * configure: Regenerate. gas/ 2016-12-23 Tristan Gingold <gingold@adacore.com> * configure: Regenerate. gprof/ 2016-12-23 Tristan Gingold <gingold@adacore.com> * configure: Regenerate. ld/ 2016-12-23 Tristan Gingold <gingold@adacore.com> * configure: Regenerate. opcodes/ 2016-12-23 Tristan Gingold <gingold@adacore.com> * configure: Regenerate.
* Add marker in NEWS filesTristan Gingold2016-12-232-0/+6
| | | | | | | | | | | | | | | | | binutils/ 2016-12-23 Tristan Gingold <gingold@adacore.com> * NEWS: Add marker for 2.28. gas/ 2016-12-23 Tristan Gingold <gingold@adacore.com> * NEWS: Add marker for 2.28. ld/ 2016-12-23 Tristan Gingold <gingold@adacore.com> * NEWS: Add marker for 2.28.
* Regenerate pot files.Tristan Gingold2016-12-232-528/+909
|
* Don't call "error" in sysroot-prefix.expAlan Modra2016-12-222-3/+8
| | | | | | | We don't want to report a test failure as a tcl error. * testsuite/ld-scripts/sysroot-prefix.exp (sysroot_prefix_test_setup): Call perror rather than error on "as" or "ar" failures.
* Do not add padding if an output section is marked as ignoredIgor Kudrin2016-12-222-1/+7
| | | | | * ldlang.c (size_input_section): Avoid calling insert_pad if output_section_statement->ignored is set.
* Remove high bit set charactersAlan Modra2016-12-212-3/+7
| | | | | | | | | | | | | gas/ * doc/c-lm32.texi: Fix chars with high bit set. * testsuite/gas/bfin/vector2.s: Likewise. gold/ * arm.cc: Fix comment chars with high bit set. include/ * coff/pe.h: Fix comment chars with high bit set. * opcode/xgate.h: Likewise. ld/ * testsuite/ld-scripts/sysroot-prefix.exp: Fix chars with high bit set.
* Implement and document --gc-keep-exportedfincs2016-12-164-0/+25
| | | | | | | | | | | | | include/ * bfdlink.h (struct bfd_link_info): Add gc_keep_exported. bfd/ * elflink.c (bfd_elf_gc_mark_dynamic_ref_symbol): Add handling for info->gc_keep_exported. (bfd_elf_gc_sections): Likewise. ld/ * ld.texinfo: Document --gc-keep-exported. * ldlex.h (enum option_values): Add OPTION_GC_KEEP_EXPORTED. * lexsup.c (parse_args): Add handling for --gc-keep-exported.
* ld: aarch64: fix TLS relaxation where TCB_SIZE is usedYury Norov2016-12-144-0/+36
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | TCB_SIZE is 2*sizeof(void *), which is 0x10 for lp64, and 0x8 for ilp32. During relaxation, ld goes to do a replace: bl __tls_get_addr => add R0, R0, TCB_SIZE But actual implementation is: bfd_putl32 (0x91004000, contents + rel->r_offset + 4); Which is equivalent of add x0, x0, 0x10. This is wrong for ilp32. The possible fix for it is: bfd_putl32 (0x91000000 | (TCB_SIZE<<10), contents + rel->r_offset + 4); But ilp32 also needs w-registers, so it's simpler to put proper instruction in #if/#else condition. There are 2 such relaxations in elfNN_aarch64_tls_relax(), and so 2 new tests added for ilp32 mode to test it. Yury * bfd/elfnn-aarch64.c: fix TLS relaxations for ilp32 where TCB_SIZE is used. * ld/testsuite/ld-aarch64/aarch64-elf.exp: Add tests for the case. * ld/testsuite/ld-aarch64/tls-relax-ld-le-small-ilp32.d: New file. * ld/testsuite/ld-aarch64/tls-relax-ld-le-tiny-ilp32.d: New file. Signed-off-by: Yury Norov <ynorov@caviumnetworks.com>
* Revert "ld: aarch64: fix TLS relaxation where TCB_SIZE is used"Yury Norov2016-12-143-29/+0
| | | | This reverts commit 6650f7bd18f8161b9f666d3e65a6346e23a9d85f.
* ld: aarch64: fix TLS relaxation where TCB_SIZE is usedYury Norov2016-12-143-0/+29
| | | | | | | | | | | | | | | | | | | | | | TCB_SIZE is 2*sizeof(void *), which is 0x10 for lp64, and 0x8 for ilp32. During relaxation, ld goes to do a replace: bl __tls_get_addr => add R0, R0, TCB_SIZE But actual implementation is: bfd_putl32 (0x91004000, contents + rel->r_offset + 4); Which is equivalent of add x0, x0, 0x10. This is wrong for ilp32. The possible fix for it is: bfd_putl32 (0x91000000 | (TCB_SIZE<<10), contents + rel->r_offset + 4); But ilp32 also needs w-registers, so it's simpler to put proper instruction in #if/#else condition. THere are 2 such relaxations in elfNN_aarch64_tls_relax(), and so 2 new tests added for ilp32 mode to test it. Yury
* PE linker script improvements.Nick Clifton2016-12-132-3/+10
| | | | | | | PR ld/19254 * scripttempl/pe.sc (.fini): KEEP this section. (.gcc_except_table): Likewise. (.pdata): Also accept .pdata*.
* [AArch64] Make LD testcases support ILP32 modeJiong Wang2016-12-1323-207/+265
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | ld/ * testsuite/ld-aarch64/aarch64-elf.exp (aarch64_choose_lp64_emul): New function. (run_dump_test_lp64): New function which pass LP64 mode options to both assembler and linker when building test binary. (aarch64elftests): Remove eh-frame-merge test. (eh-frame-merge-lp64): Restrict eh-frame-merge test to LP64 only. (run_dump_test): Migrate to run_dump_test_lp64 if the test source was written for LP64 only. * testsuite/ld-aarch64/erratum843419.d: Support ILP32 mode. * testsuite/ld-aarch64/farcall-b-defsym.d: Likewise. * testsuite/ld-aarch64/farcall-b-plt.d: Likewise. * testsuite/ld-aarch64/farcall-b.d: Likewise. * testsuite/ld-aarch64/farcall-bl-defsym.d: Likewise. * testsuite/ld-aarch64/farcall-bl-plt.d: Likewise. * testsuite/ld-aarch64/farcall-bl.d: Likewise. * testsuite/ld-aarch64/ifunc-15.d: Likewise. * testsuite/ld-aarch64/ifunc-16.d: Likewise. * testsuite/ld-aarch64/ifunc-5a-local.d: Likewise. * testsuite/ld-aarch64/ifunc-5a.d: Likewise. * testsuite/ld-aarch64/ifunc-5b-local.d: Likewise. * testsuite/ld-aarch64/ifunc-5b.d: Likewise. * testsuite/ld-aarch64/ifunc-5r-local.d: Likewise. * testsuite/ld-aarch64/ifunc-6a.d: Likewise. * testsuite/ld-aarch64/ifunc-6b.d: Likewise. * testsuite/ld-aarch64/ifunc-7a.d: Likewise. * testsuite/ld-aarch64/ifunc-7b.d: Likewise. * testsuite/ld-aarch64/ifunc-8.d: Likewise. * testsuite/ld-aarch64/limit-b.d: Likewise. * testsuite/ld-aarch64/limit-bl.d: Likewise.
* Don't add PHDR for objcopy/strip or ld script specifying PHDRSAlan Modra2016-12-134-6/+6
| | | | | | | | | | | | | | HPPA64 needs to add a DT_PHDR header for shared libs. That's fine when linking but shouldn't happen for strip/objcopy. Also PHDR must come first so there's no need to look at all program headers. bfd/ * elf64-hppa.c (elf64_hppa_modify_segment_map): Don't add PHDR for objcopy/strip or when a ld script specifies PHDRS. ld/ * testsuite/ld-elf/nobits-1.d: Remove xfail for hppa64. * testsuite/ld-elf/note-1.d: Likewise. * testsuite/ld-elf/note-2.d: Likewise.
* Don't fudge p_vaddr when PHDR in segmentAlan Modra2016-12-135-11/+9
| | | | | | | | | | | | | | | | | RX does horrible fudges to PT_LOAD p_vaddr, that affect the testsuite and mean the target won't support dynamic objects. The latter probably doesn't matter too much since RX is an embedded target, but it's easy to stop some of the fudges in order to reduce special cases for RX in the testsuite. The changes make sense in isolation too. bfd/ * elf32-rx.c (elf32_rx_modify_program_headers): Don't adjust segments that include the ELF file header or program headers. ld/ * testsuite/ld-elf/flags1.d: Run for RX. * testsuite/ld-scripts/phdrs.exp: Likewise. * testsuite/ld-scripts/pr14962.d: Likewise. * testsuite/ld-scripts/pr14962-2.d: Likewise.
* sync binutils config/ with gccAlan Modra2016-12-082-1/+5
| | | | | | | | | | | | | | | | | config/ * acx.m4: Import from gcc. * bootstrap-asan.mk: Likewise. * multi.m4: Likewise. / * configure: Regnerate. gas/ * configure: Regnerate. ld/ * configure: Regnerate. libiberty/ * configure: Regnerate. zlib/ * configure: Regnerate.
* PowerPC64 toc optimisation for power9Alan Modra2016-12-067-0/+543
| | | | | | | | | | | | | | | | | | Recognize power9 and a few other insns from older machines. Fixes linker complaints like "toc optimization is not supported for 0xf4090002 instruction". 0xf4090002 is stxsd v0,0(r9) bfd/ * elf64-ppc.c (ok_lo_toc_insn): Add r_type param. Recognize lq,lfq,lxv,lxsd,lxssp,lfdp,stq,stfq,stxv,stxsd,stxssp,stfdp. Don't match lmd and stmd. ld/ * testsuite/ld-powerpc/tocopt7.s, * testsuite/ld-powerpc/tocopt7.out, * testsuite/ld-powerpc/tocopt7.d: New test. * testsuite/ld-powerpc/tocopt8.s, * testsuite/ld-powerpc/tocopt8.d: New test. * testsuite/ld-powerpc/powerpc.exp: Run them.
* Fix seg-fault in linker when passed a bogus input script.Nick Clifton2016-12-052-2/+13
| | | | | PR ld/20906 * ldlex.l: Check for bogus strings in linker scripts.
* bfd,ld: Continue after partially-successful relaxed call relocations in sparc.Alyssa Milburn2016-12-044-0/+41
| | | | | | | | | | | | | | | | | bfd/ChangeLog: 2016-12-05 Alyssa Milburn <amilburn@zall.org> * elfxx-sparc.c: Do not stop processing relocations after partially relaxing a call with WDISP30. ld/ChangeLog: 2016-12-05 Alyssa Milburn <amilburn@zall.org> * testsuite/ld-sparc/wdispcall.s: New file. * testsuite/ld-sparc/wdispcall.dd: Likewise. * testsuite/ld-sparc/sparc.exp: Run new test.
* PowerPC64 dot-symbol compatibility bugfixesAlan Modra2016-12-039-1/+95
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Lots of fixes for the compatibility code that handles linking of -mcall-aixdesc code (or that generated by 12 year old gcc) with current ELFv1 ABI code. 1) A reference to a dot-symbol in an object file wasn't satisfied by a function descriptor in later object files. 2) The as-needed code had bit-rotted; Shared libs now need a strong reference to be counted as needed. 3) --gc-sections involving dot-symbols was broken, needing func_desc_adjust to be run early and lots of other fixes. bfd/ * elf64-ppc.c (struct ppc_link_hash_entry): Delete "was_undefined". (struct ppc_link_hash_table): Delete "twiddled_syms". Add "need_func_desc_adj". (lookup_fdh): Link direct fdh sym via oh field and set flags. (make_fdh): Make strong and weak undefined function descriptor symbols. (ppc64_elf_merge_symbol): New function. (elf_backend_merge_symbol): Define. (ppc64_elf_archive_symbol_lookup): Don't test undefweak for fake function descriptors. (add_symbol_adjust): Don't twiddle symbols to undefweak. Propagate more ref flags to function descriptor symbol. Make some function descriptor symbols dynamic. (ppc64_elf_before_check_relocs): Only run add_symbol_adjust for ELFv1. Set need_func_desc_adj. Don't fix undefs list. (ppc64_elf_check_relocs): Set non_ir_ref for descriptors. Don't call lookup_fdh here. (ppc64_elf_gc_sections): New function. (bfd_elf64_bfd_gc_sections): Define. (ppc64_elf_gc_mark_hook): Mark descriptor. (func_desc_adjust): Don't make fake function descriptor syms strong here. Exit earlier on non-dotsyms. Take note of elf.dynamic flag when deciding whether a dynamic function descriptor might be needed. Transfer elf.dynamic and set elf.needs_plt. Move plt regardless of visibility. Make descriptor dynamic if entry sym is dynamic, not for other cases. (ppc64_elf_func_desc_adjust): Don't run func_desc_adjust if already done. (ppc64_elf_edit_opd): Use oh field rather than lookup_fdh. (ppc64_elf_size_stubs): Likewise. (ppc_build_one_stub): Don't clear was_undefined. Only set sym undefweak if stub symbol is defined. (undo_symbol_twiddle, ppc64_elf_restore_symbols): Delete. * elf64-ppc.h (ppc64_elf_restore_symbols): Don't declare. ld/ * emultempl/ppc64elf.em (gld${EMULATION_NAME}_finish): Don't call ppc64_elf_restore_symbols. * testsuite/ld-powerpc/dotsym1.d: New. * testsuite/ld-powerpc/dotsym2.d: New. * testsuite/ld-powerpc/dotsym3.d: New. * testsuite/ld-powerpc/dotsym4.d: New. * testsuite/ld-powerpc/dotsymref.s: New. * testsuite/ld-powerpc/nodotsym.s: New. * testsuite/ld-powerpc/powerpc.exp: Run new tests.
* PowerPC64 dot-sym testsuite fixesAlan Modra2016-12-0356-118/+241
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This illustrates quite well why dot-symbols had to go. PowerPC64 gcc for Linux stopped producing them 12 years ago, but the Linux kernel still persists in using them so it's necessary to keep and regression test ld support. * testsuite/ld-elf/indirect1b.c: Give dot-symbol a version too. * testsuite/ld-elf/indirect2.c: Likewise. * testsuite/ld-elf/indirect3b.c: Likewise. * testsuite/ld-elf/indirect4b.c: Likewise. * testsuite/ld-elf/pr18718.c: Likewise. * testsuite/ld-elf/pr18720b.c: Likewise. * testsuite/ld-elf/pr19553c.c: Likewise. * testsuite/ld-elfvers/vers.h (FUNC_SYMVER): Define. * testsuite/ld-elfvers/vers1.c: Use FUNC_SYMVER for functions. * testsuite/ld-elfvers/vers4.c: Likewise. * testsuite/ld-elfvers/vers5.c: Likewise. * testsuite/ld-elfvers/vers6.c: Likewise. * testsuite/ld-elfvers/vers7a.c: Likewise. * testsuite/ld-elfvers/vers9.c: Likewise. * testsuite/ld-elfvers/vers15.c: Likewise. * testsuite/ld-elfvers/vers18.c: Likewise. * testsuite/ld-elfvers/vers22a.c: Likewise. * testsuite/ld-elfvers/vers23a.c: Likewise. * testsuite/ld-elfvers/vers27d1.c: Likewise. * testsuite/ld-elfvers/vers21.c: Likewise. (_old_bar): Use attribute weak rather than asm weak. * testsuite/ld-ifunc/pr16467b.c: Give dot-symbol a version. * testsuite/ld-plugin/pr12760b.c: Define warning on .bar rather than bar for ppc64 -mcall-aixdesc. * testsuite/ld-plugin/pr16746a.c: Similarly for foobar. * testsuite/ld-plugin/pr16746b.c: Likewise. * testsuite/ld-elf/shared.exp: Allow dot-symbol in warnings and errors. * testsuite/ld-plugin/lto.exp: Likewise. * testsuite/ld-plugin/plugin-6.d: Likewise. * testsuite/ld-plugin/plugin-7.d: Likewise. * testsuite/ld-plugin/plugin-8.d: Likewise. * testsuite/ld-plugin/plugin-13.d: Likewise. * testsuite/ld-plugin/plugin-14.d: Likewise. * testsuite/ld-plugin/plugin-15.d: Likewise. * testsuite/ld-plugin/plugin-16.d: Likewise. * testsuite/ld-plugin/plugin-20.d: Likewise. * testsuite/ld-plugin/plugin-21.d: Likewise. * testsuite/ld-plugin/plugin-22.d: Likewise. * testsuite/ld-plugin/plugin-23.d: Likewise. * testsuite/ld-plugin/plugin.exp: Define .main and .puts for ppc64 -mcall-aixdesc. * testsuite/ld-elfvers/vers.exp (test_ar): Trim dot-symbols. (objdump_dynsymstuff): Likewise. (objdump_symstuff): Likewise. Pack flags to keep column count consistent. * testsuite/ld-elfweak/elfweak.exp (objdump_dynsymstuff, objdump_symstuff): As for vers.exp. * testsuite/ld-elfvers/vers6.sym: Allow dot-symbols. * testsuite/ld-elfvers/vers1.sym: Allow missing F flag for -mcall-aixdesc .opd syms and adjust for flag packing. * testsuite/ld-elfvers/vers4.sym: Likewise. * testsuite/ld-elfvers/vers4a.sym: Likewise. * testsuite/ld-elfvers/vers7a.sym: Likewise. * testsuite/ld-elfvers/vers9.sym: Likewise. * testsuite/ld-elfvers/vers15.sym: Likewise. * testsuite/ld-elfvers/vers18.sym: Likewise. * testsuite/ld-elfvers/vers21.sym: Likewise. * testsuite/ld-elfvers/vers22a.sym: Likewise. * testsuite/ld-elfvers/vers23a.sym: Likewise. * testsuite/ld-elfvers/vers27d.sym: Likewise. * testsuite/ld-elfweak/strong.sym: Likewise. * testsuite/ld-elfweak/strongcomm.sym: Likewise. * testsuite/ld-elfweak/strongdata.sym: Likewise.
* ld-elfvers don't fail on non-empty resultsAlan Modra2016-12-032-2/+11
| | | | | * testsuite/ld-elfvers/vers.exp (objdump_dynsymstuff): Don't abort on non-empty results with empty expected.
* Correct cdtest g++ version testAlan Modra2016-12-032-1/+5
| | | | | | Fixes declaration conflict with built-in strncpy. * testsuite/ld-cdtest/cdtest-foo.cc: Test for __GNUG__ >= 2.
* try_copy_symbol_type node_class checkAlan Modra2016-12-032-9/+9
| | | | * ldexp.c (try_copy_symbol_type): Remove unnecessary check.
* Fix seg-fault in the linker when attempting to print out a malicious linker ↵Nick Clifton2016-12-022-1/+5
| | | | | | | | script. PR ld/20910 * ldmain.c (main): Prevent evaluation of %<char> sequences when printing out a linker script.
* Fix seg-fault in linker when applying relocs to a corrupt binary.Nick Clifton2016-12-022-4/+15
| | | | | | PR ld/20911 * ldctor.c (ldctor_build_sets): Produce alternative error message if the reloc was being applied to a special section.
* Fix seg-fault linking corrupt binary.Nick Clifton2016-12-022-3/+9
| | | | | | PR ld/20912 * emultempl/elf32.em (_place_orphan): Test for ELF format of the orphan before looking for the SHF_EXCLUDE flag.
* Add support for Fushia OS.Josh Conner2016-12-026-1/+71
| | | | | | | | | | | | | | | | * configure.ac: Add fuchsia to targets that use ELF. * configure: Regenerated. bfd * configure.tgt: Add support for fuchsia (OS). gas * configure.tgt: Add support for fuchsia (OS). ld * Makefile.am: Add dependency information for earmelf_fuchsia.c. * Makefile.in: Regenerate. * configure.tgt: Add support for aarch64-*-fuchsia, arm*-*-fuchsia*, and x86_64-*-fuchsia* targets. * emulparams/armelf_fuchsia.sh: New file. * emulparams/armelfb_fuchsia.sh: New file.
* Fix generation of IDATA[6] for PE files.Rudy Y2016-12-012-2/+14
| | | | | PR ld/20880 * pe-dll.c (make_one): Use the hint if the ordinal is -1.
* Fix accesses to the GOT for AARCH64 operating in 32-bit mode.Yury Norov2016-12-014-0/+38
| | | | | | | | | | | PR ld/20868 bfd * elfnn-aarch64.c (elfNN_aarch64_tls_relax): Use 32-bit accesses to the GOT when operating in 32-bit mode. ld * testsuite/ld-aarch64/tls-relax-gd-ie-ilp32.d: New test. * testsuite/ld-aarch64/relocs-ilp32.ld: Linker script for the new test. * testsuite/ld-aarch64/aarch64-elf.exp: Run the new test.
* arc/ld: Remove duplicate TEMPLATE_NAME from emulparam fileAndrew Burgess2016-11-282-1/+4
| | | | | | | | | | Remove duplicate definition of TEMPLATE_NAME, only the last of these will have any effect, so this should result in no visible changes to the user. ld/ChangeLog: * emulparams/arclinux_prof.sh: Remove duplicate TEMPLATE_NAME.
* Update linker tests after partial reversion of PR 20815 patch.Nick Clifton2016-11-284-5/+12
| | | | | | | PR 20815 * testsuite/ld-elf/loadaddr1.d: Update. * testsuite/ld-powerpc/vle-multiseg-5.d: Update. * testsuite/ld-scripts/phdrs3a.d: Update.
* Properly hide hidden versioned symbol in executableH.J. Lu2016-11-283-0/+12
| | | | | | | | | | | | | | | | | | A hidden versioned symbol in executable should be forced local if it is locally defined, not referenced by shared library and not exported. We must do it before _bfd_elf_link_renumber_dynsyms. bfd/ * elflink.c (_bfd_elf_fix_symbol_flags): Hide hidden versioned symbol in executable. (elf_link_output_extsym): Don't change bind from global to local when linking executable. ld/ * testsuite/ld-elf/indirect.exp: Add a test for PR 18720. * testsuite/ld-elf/pr18720.rd: New file.
* Fix powerpc vle test for sorting of program headersAlan Modra2016-11-272-3/+8
| | | | | | | 1a9ccd70f changed the order of headers. PR 20815 * testsuite/ld-powerpc/vle-multiseg-5.d: Update.
* Fix spelling in comments in .y files (ld)Ambrogino Modigliani2016-11-272-2/+6
| | | | * deffilep.y: Fix spelling in comments.
* Fix spelling in comments in .sc files (ld)Ambrogino Modigliani2016-11-275-6/+13
| | | | | | | * scripttempl/ia64vms.sc: Fix spelling in comments. * scripttempl/ip2k.sc: Fix spelling in comments. * scripttempl/v850.sc: Fix spelling in comments. * scripttempl/v850_rh850.sc: Fix spelling in comments.
* Fix spelling in comments in .em files (ld)Ambrogino Modigliani2016-11-276-6/+14
| | | | | | | | * emultempl/avrelf.em: Fix spelling in comments. * emultempl/elf32.em: Fix spelling in comments. * emultempl/pe.em: Fix spelling in comments. * emultempl/pep.em: Fix spelling in comments. * emultempl/spuelf.em: Fix spelling in comments.
* Fix spelling in comments in Expect scripts (ld)Ambrogino Modigliani2016-11-275-4/+11
| | | | | | | * testsuite/ld-sh/arch/arch.exp: Fix spelling in comments. * testsuite/ld-sh/rd-sh.exp: Fix spelling in comments. * testsuite/ld-sh/sh64/rd-sh64.exp: Fix spelling in comments. * testsuite/ld-undefined/undefined.exp: Fix spelling in comments.
* Fix spelling in comments in Assembler files (ld)Ambrogino Modigliani2016-11-277-9/+18
| | | | | | | | | * testsuite/ld-arm/stm32l4xx-fix-all.s: Fix spelling in comments. * testsuite/ld-arm/thumb2-b-interwork.s: Fix spelling in comments. * testsuite/ld-arm/thumb2-bl.s: Fix spelling in comments. * testsuite/ld-s390/tlspic1.s: Fix spelling in comments. * testsuite/ld-s390/tlspic1_64.s: Fix spelling in comments. * testsuite/ld-scripts/section-match-1.d: Fix spelling in comments.
* Fix spelling in comments in C source files (ld)Ambrogino Modigliani2016-11-276-7/+15
| | | | | | | | * deffile.h: Fix spelling in comments. * ld.h: Fix spelling in comments. * ldlang.c: Fix spelling in comments. * ldmisc.c: Fix spelling in comments. * pe-dll.c: Fix spelling in comments.
* [ARM] Bind defined symbol locally in PIEJiong Wang2016-11-245-0/+29
| | | | | | | | | | | | | bfd/ PR target/20737 * elf32-arm.c (elf32_arm_final_link_relocate): Bind defined symbol locally in PIE. ld/ * testsuite/ld-arm/pie-bind-locally-a.s: New test source. * testsuite/ld-arm/pie-bind-locally-b.s: Likewise. * testsuite/ld-arm/pie-bind-locally.d: New testcase. * testsuite/ld-arm/arm-elf.exp: Run new testcase.
* Fix snafu parsing $ORIGIN.Nick Clifton2016-11-242-1/+8
| | | | | | | PR ld/20858 * emultempl/elf32.em (_search_needed): Allow for path separator and terminating NUL byte when allocating space for new $ORIGIN path.
* Adjust linker test for arm-vxworks in wake of patch for PR 20815.Nick Clifton2016-11-232-1/+3
|
* Fix the linker so that it will not silently generate ELF binaries with ↵Nick Clifton2016-11-2337-20/+104
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | invalid program headers. Fix readelf to report such invalid binaries. PR ld/20815 bfd * elf.c (elf_modify_segment_map): Allow empty LOAD segments if they contain the program headers. (_bfd_elf_map_sections_to_segments): If the linker created the PHDR segment then always attempt to include it in a LOAD segment. (assign_file_positions_for_non_load_sections): Allow LOAD segments to overlap PHDR segments. (phdr_sorter): New function. Sorts program headers. (assign_file_positions_except_relocs): Sort the program headers before writing them out. Issue an error if the PHDR segment is not covered by a LOAD segment, unless the backend allows it. * elf-bfd.h (struct elf_backend_data): Add elf_backend_allow_non_load_phdr. * elfxx-target.h (elf_backend_allow_non_load_phdr): Provide default definition that returns FALSE. (elfNN_bed): Initialise the elf_backend_allow_non_load_phdr field. * elf64-hppa.c (elf64_hppa_allow_non_load_phdr): New function. Returns TRUE. (elf_backend_allow_non_load_phdr): Define. * elf-m10300.c (_bfd_mn10300_elf_size_dynamic_sections): Do not place the interpreter string into the .interp section if the nointerp flag is set in the link info structure. * elf32-arc.c (elf_arc_size_dynamic_sections): Likewise. * elf32-score7.c (score_elf_final_link_relocate): Allow for the _gp symbol not being part of the output. binutils* readelf.c (process_program_headers): Check PT_LOAD and PT_PHDR segments for validity. ld * ld.texinfo: Note that PT_TLS can be used as a segment type. * testsuite/ld-discard/discard.ld: Add space for program headers. * testsuite/ld-elf/flags1.ld: Likewise. * testsuite/ld-elf/maxpage3.t: Likewise. * testsuite/ld-elf/noload-1.t: Likewise. * testsuite/ld-elf/orphan.ld: Likewise. * testsuite/ld-elf/overlay.t: Likewise. * testsuite/ld-elf/pr14052.t: Likewise. * testsuite/ld-elf/pr19539.t: Likewise. * testsuite/ld-elf/provide-hidden-1.ld: Likewise. * testsuite/ld-elf/provide-hidden-s.ld: Likewise. * testsuite/ld-elf/weak-dyn-1.ld: Likewise. * testsuite/ld-i386/pr19539.t: Likewise. * testsuite/ld-scripts/defined.t: Likewise. * testsuite/ld-scripts/defined6.t: Likewise. * testsuite/ld-scripts/dynamic-sections.t: Likewise. * testsuite/ld-scripts/empty-aligned.t: Likewise. * testsuite/ld-scripts/provide-2.t: Likewise. * testsuite/ld-scripts/provide-4.t: Likewise. * testsuite/ld-vax-elf/plt-local.ld: Likewise. * testsuite/ld-x86-64/pr19539.t: Likewise. * testsuite/ld-elf/ehdr_start-missing.d: Do not initialise the dynamic linker. * testsuite/ld-elf/ehdr_start-weak.d: Likewise. * testsuite/ld-elf/elf.exp (pr14170, pr17068): Likewise. * testsuite/ld-elf/loadaddr1.d: Update expected readelf output. * testsuite/ld-elf/noload-2.d: Likewise. * testsuite/ld-powerpc/vxworks2.sd: Likewise. * testsuite/ld-scripts/phdrs3a.d: Likewise. * testsuite/ld-scripts/size-2.d: Likewise. * testsuite/ld-elf/group.ld: Add program headers. * testsuite/ld-elf/overlay.d: Skip for SPU. * testsuite/ld-elf/flags1.d: Skip for RX. * testsuite/ld-elf/pr19162.d: Skip for HPPA64. * testsuite/ld-elf/pr19539.d: Skip for ALPHA. * testsuite/ld-scripts/empty-orphan.t: Update program headers. * testsuite/ld-scripts/size-2.t: Likewise.