aboutsummaryrefslogtreecommitdiff
path: root/ld
AgeCommit message (Collapse)AuthorFilesLines
2017-10-20Add a compile-time test for PR ld/22269H.J. Lu4-0/+33
This compile-time test requires a target C compiler to run. It fails on many targets where ELF backend linkers fail to check undefined weak symbol in static PIE via UNDEFWEAK_NO_DYNAMIC_RELOC. PR ld/22269 * testsuite/ld-elf/pr22269-1.rd: New file. * testsuite/ld-elf/pr22269-1.c: Likewise. * testsuite/ld-elf/shared.exp: Run pr22269-1.
2017-10-19RISC-V: Add R_RISCV_DELETE, which marks bytes for deletionPalmer Dabbelt2-1/+6
We currently delete bytes by shifting an entire BFD backwards to overwrite the bytes we no longer need. The result is that relaxing a BFD is quadratic time. This patch adds an additional relocation that specifies a byte range that will be deleted from the final object file, and adds a relaxation pass (between the existing passes that delete bytes and the alignment pass) that actually deletes the bytes. Note that deletion is still quadratic time, and nothing uses R_RISCV_DELETE yet. I've been meaning to go convert all the other relaxations to use R_RISCV_DELETE and then make it faster, but this patch has been sitting around for months so it looks like that won't happen for a bit. The PCREL->GPREL relaxation that comes next uses this, and since we've been using these two patches out of tree since I wrote them months ago I figure it's better to just get them in now. I (or someone else :)) can convert all the relocations later... R_RISCV_DELETE will never be emitted into ELF objects, so therefor isn't exposed to the rest of binutils. As such, we're not considering this as part of the ABI. bfd/ChangeLog 2017-10-19 Palmer Dabbelt <palmer@dabbelt.com> * elfnn-riscv (R_RISCV_DELETE): New define. (_bfd_riscv_relax_delete): New function. (perform_relocation): Handle R_RISCV_DELETE. (_bfd_riscv_relax_section): Likewise. ld/ChangeLog 2017-10-19 Palmer Dabbelt <palmer@dabbelt.com> * emultempl/riscvelf.em (riscv_elf_before_allocation): Add a third relaxation pass.
2017-10-17Correct -z text and other -z documentationAlan Modra2-95/+94
-z text applies to all dynamic binaries, not just shared libraries. A lot of the other options needed attention too. * ld.texinfo (-z): Combine negative options with corresponding positive option. Sort the table. Expand and correct "combreloc", "common", "common-page-size", "interpose", "loadfltr", "max-page-size", "muldefs", "nodefaultlib", "nodelete", "nodlopen", "nodump", "noextern-protected-data", "now", "origin", and "text".
2017-10-16ELF: Call check_relocs after opening all inputsH.J. Lu55-130/+194
For all ELF targers, call check_relocs after opening all inputs and garbage collection. Since the symbol resolution is known, check_relocs can be simplified. Also garbage collection doesn't need to undo what check_relocs has done for symbols which have been garbage collected. Since ELF targets never see the removed sections, gc_sweep_hook can be removed from elf_backend_data and we can avoid GOT/PLT with garbage collection now. Set link_info.check_relocs_after_open_input to TRUE for all linker targets which use ELF linker and update garbage collection tests to remove unused GOT section. ldemul_after_check_relocs is added for powerpc to support --secure-plt, --bss-plt and --sdata-got. Tested natively without regressions on i686, x86-64 and x32. Tested cross binutils on x86-64 without regressions for aarch64-linux, alpha-linux, arm-linux, bfin-elf, cr16-elf, cris-elf, crx-elf, frv-linux, hppa64-linux, hppa-linux, ia64-linux, lm32-elf, m32r-elf, m68k-linux, mcore-elf, metag-elf, microblaze-linux, mips-linux, mmix, mn10300-elf, nds32le-linux, nios2-linux, or1k-elf, powerpc64-linux, powerpc-linux, riscv32-linux, riscv64-linux, s390-linux, s390x-linux, score-elf, sh3-linux, sparc64-linux, sparc-linux, tic6x-elf, tilegx-linux, tilepro-linux, vax-linux, x86_64-mingw32 and xtensa-linux. bfd/ * elf-bfd.h (elf_backend_data): Remove gc_sweep_hook. * elf32-arm.c (elf32_arm_gc_sweep_hook): Removed. (elf_backend_gc_sweep_hook): Likewise. * elf32-bfin.c (bfin_gc_sweep_hook): Likewise. (bfinfdpic_gc_sweep_hook): Likewise. (elf_backend_gc_sweep_hook): Likewise. * elf32-cr16.c (elf32_cr16_gc_sweep_hook): Likewise. (elf_backend_gc_sweep_hook): Likewise. * elf32-cris.c (cris_elf_gc_sweep_hook): Likewise. (elf_backend_gc_sweep_hook): Likewise. * elf32-hppa.c (elf32_hppa_gc_sweep_hook): Likewise. (elf_backend_gc_sweep_hook): Likewise. * elf32-lm32.c (lm32_elf_gc_sweep_hook): Likewise. (elf_backend_gc_sweep_hook): Likewise. * elf32-m32r.c (m32r_elf_gc_sweep_hook): Likewise. (elf_backend_gc_sweep_hook): Likewise. * elf32-m68k.c (elf_m68k_got_entry): Remove elf_m68k_gc_sweep_hook from comments. (elf_m68k_remove_got_entry_type): Removed. (elf_m68k_find_got_entry_ptr): Likewise. (elf_m68k_remove_got_entry): Likewise. (elf_m68k_gc_sweep_hook): Likewise. (elf_backend_gc_sweep_hook): Likewise. * elf32-mcore.c (mcore_elf_gc_sweep_hook): Likewise. (elf_backend_gc_sweep_hook): Likewise. * elf32-metag.c (elf_metag_gc_sweep_hook): Likewise. (elf_backend_gc_sweep_hook): Likewise. * elf32-microblaze.c (elf_backend_gc_sweep_hook): Likewise. (elf_backend_gc_sweep_hook): Likewise. * elf32-mips.c (elf_backend_gc_sweep_hook): Likewise. (elf_backend_gc_sweep_hook): Likewise. * elf32-nds32.c (nds32_elf_gc_sweep_hook): Likewise. (elf_backend_gc_sweep_hook): Likewise. * elf32-nios2.c (nios2_elf32_gc_sweep_hook): Likewise. (elf_backend_gc_sweep_hook): Likewise. * elf32-or1k.c (or1k_elf_gc_sweep_hook): Likewise. (elf_backend_gc_sweep_hook): Likewise. * elf32-ppc.c (ppc_elf_gc_sweep_hook): Likewise. (elf_backend_gc_sweep_hook): Likewise. * elf32-s390.c (elf_s390_gc_sweep_hook): Likewise. (elf_backend_gc_sweep_hook): Likewise. * elf32-sparc.c (elf_backend_gc_sweep_hook): Likewise. * elf32-tic6x.c (elf32_tic6x_gc_sweep_hook): Likewise. (elf_backend_gc_sweep_hook): Likewise. * elf32-tilegx.c (elf_backend_gc_sweep_hook): Likewise. * elf32-tilepro.c (tilepro_elf_gc_sweep_hook): Likewise. (elf_backend_gc_sweep_hook): Likewise. * elf32-vax.c (elf_vax_gc_sweep_hook): Likewise. (elf_backend_gc_sweep_hook): Likewise. * elf32-xtensa.c (elf_xtensa_gc_sweep_hook): Likewise. (elf_backend_gc_sweep_hook): Likewise. * elf64-alpha.c (elf64_alpha_gc_sweep_hook): Likewise. (elf_backend_gc_sweep_hook): Likewise. * elf64-mips.c (elf_backend_gc_sweep_hook): Likewise. * elf64-mmix.c (mmix_elf_gc_sweep_hook): Likewise. (elf_backend_gc_sweep_hook): Likewise. * elf64-ppc.c (elf_backend_gc_sweep_hook): Likewise. (ppc64_elf_gc_sweep_hook): Likewise. * elf64-s390.c (elf_s390_gc_sweep_hook): Likewise. (elf_backend_gc_sweep_hook): Likewise. * elf64-sparc.c (elf_backend_gc_sweep_hook): Likewise. * elf64-tilegx.c (elf_backend_gc_sweep_hook): Likewise. * elflink.c (elf_link_add_object_symbols): Don't call _bfd_elf_link_check_relocs here. (gc_sweep_hook_fn): Removed. (elf_gc_sweep): Remove gc_sweep_hook. * elfnn-aarch64.c (elfNN_aarch64_gc_sweep_hook): Removed. (elf_backend_gc_sweep_hook): Likewise. * elfnn-riscv.c (riscv_elf_gc_sweep_hook): Likewise. (elf_backend_gc_sweep_hook): Likewise. * elfxx-mips.c (_bfd_mips_elf_gc_sweep_hook): Likewise. * elfxx-mips.h (_bfd_mips_elf_gc_sweep_hook): Likewise. (elf_backend_gc_sweep_hook): Likewise. * elfxx-sparc.c (_bfd_sparc_elf_gc_sweep_hook): Likewise. * elfxx-sparc.h (_bfd_sparc_elf_gc_sweep_hook): Likewise. * elfxx-target.h (elf_backend_gc_sweep_hook): Likewise. (elfNN_bed): Remove elf_backend_gc_sweep_hook. * elfxx-tilegx.c (tilegx_elf_gc_sweep_hook): Removed. * elfxx-tilegx.h (tilegx_elf_gc_sweep_hook): Likewise. ld/ * emulparams/elf32_x86_64.sh (CHECK_RELOCS_AFTER_OPEN_INPUT): Removed. * emulparams/elf_i386_be.sh (CHECK_RELOCS_AFTER_OPEN_INPUT): Likewise. * emulparams/elf_i386_chaos.sh (CHECK_RELOCS_AFTER_OPEN_INPUT): Likewise. * emulparams/elf_i386_ldso.sh (CHECK_RELOCS_AFTER_OPEN_INPUT): Likewise. * emulparams/elf_i386_vxworks.sh (CHECK_RELOCS_AFTER_OPEN_INPUT): Likewise. * emulparams/elf_iamcu.sh (CHECK_RELOCS_AFTER_OPEN_INPUT): Likewise. * emulparams/elf_k1om.sh (CHECK_RELOCS_AFTER_OPEN_INPUT): Likewise. * emulparams/elf_l1om.sh (CHECK_RELOCS_AFTER_OPEN_INPUT): Likewise. * emulparams/elf_x86_64.sh (CHECK_RELOCS_AFTER_OPEN_INPUT): Likewise. * emulparams/i386lynx.sh (CHECK_RELOCS_AFTER_OPEN_INPUT): Likewise. * emulparams/i386moss.sh (CHECK_RELOCS_AFTER_OPEN_INPUT): Likewise. * emulparams/i386nto.sh (CHECK_RELOCS_AFTER_OPEN_INPUT): Likewise. * emulparams/i386nw.sh (CHECK_RELOCS_AFTER_OPEN_INPUT): Likewise. * emulparams/shelf.sh (CHECK_RELOCS_AFTER_OPEN_INPUT): Likewise. * emulparams/shelf32.sh (CHECK_RELOCS_AFTER_OPEN_INPUT): Likewise. * emulparams/shelf_nto.sh (CHECK_RELOCS_AFTER_OPEN_INPUT): Likewise. * emulparams/shelf_vxworks.sh (CHECK_RELOCS_AFTER_OPEN_INPUT): Likewise. * emulparams/shlelf32_linux.sh (CHECK_RELOCS_AFTER_OPEN_INPUT): Likewise. * emulparams/shlelf_linux.sh (CHECK_RELOCS_AFTER_OPEN_INPUT): Likewise. * emulparams/shlelf_nto.sh (CHECK_RELOCS_AFTER_OPEN_INPUT): Likewise. * emultempl/aarch64elf.em (gld${EMULATION_NAME}_before_parse): Set link_info.check_relocs_after_open_input to TRUE. * emultempl/armelf.em (gld${EMULATION_NAME}_before_parse): Likewise. * emultempl/scoreelf.em (gld${EMULATION_NAME}_before_parse): Likewise. * emultempl/aix.em (ld_${EMULATION_NAME}_emulation): Add after_parse_default. * emultempl/armcoff.em (ld_${EMULATION_NAME}_emulation): Likewise. * emultempl/beos.em (ld_${EMULATION_NAME}_emulation): Likewise. * emultempl/generic.em (ld_${EMULATION_NAME}_emulation): Likewise. * emultempl/gld960.em (ld_${EMULATION_NAME}_emulation): Likewise. * emultempl/gld960c.em (ld_${EMULATION_NAME}_emulation): Likewise. * emultempl/lnk960.em (ld_${EMULATION_NAME}_emulation): Likewise. * emultempl/m68kcoff.em (ld_${EMULATION_NAME}_emulation): Likewise. * emultempl/msp430.em (ld_${EMULATION_NAME}_emulation): Likewise. * emultempl/pe.em (ld_${EMULATION_NAME}_emulation): Likewise. * emultempl/pep.em (ld_${EMULATION_NAME}_emulation): Likewise. * emultempl/sunos.em (ld_${EMULATION_NAME}_emulation): Likewise. * emultempl/ticoff.em (ld_${EMULATION_NAME}_emulation): Likewise. * emultempl/vanilla.em (ld_${EMULATION_NAME}_emulation): Likewise. * emultempl/elf32.em (gld${EMULATION_NAME}_before_parse): Always set link_info.check_relocs_after_open_input to TRUE. (ld_${EMULATION_NAME}_emulation): Add $LDEMUL_AFTER_CHECK_RELOCS. * emultempl/linux.em (gld${EMULATION_NAME}_before_parse): Set link_info.check_relocs_after_open_input to TRUE. (ld_${EMULATION_NAME}_emulation): Add after_check_relocs_default. * emultempl/mmix-elfnmmo.em (mmix_before_parse): New function. (LDEMUL_BEFORE_PARSE): New. * emultempl/mmixelf.em (elfmmix_before_parse): Replace gld${EMULATION_NAME}_before_parse with mmix_before_parse. * emultempl/ppc32elf.em (ppc_after_open): Renamed to ... (ppc_after_check_relocs): This. Call after_check_relocs_default instead of gld${EMULATION_NAME}_after_open. (LDEMUL_AFTER_OPEN): Removed. (LDEMUL_AFTER_CHECK_RELOCS): New. * ldemul.c (ldemul_after_check_relocs): New. (after_check_relocs_default): Likewise. * ldemul.h (ldemul_after_check_relocs): Likewise. (after_check_relocs_default): Likewise. (ld_emulation_xfer_struct): Add after_check_relocs. * ldlang.c (lang_process): Call ldemul_after_check_relocs after lang_check_relocs. * testsuite/ld-aarch64/gc-got-relocs.d: Don't expect GOT section. * testsuite/ld-aarch64/gc-tls-relocs.d: Likewise. * testsuite/ld-cris/tls-gc-68.d: Likewise. * testsuite/ld-cris/tls-gc-69.d: Likewise. * testsuite/ld-cris/tls-gc-70.d: Likewise. * testsuite/ld-cris/tls-gc-75.d: Likewise. * testsuite/ld-cris/tls-gc-79.d: Likewise. * testsuite/ld-mmix/bpo-10.d: Don't expect .MMIX.reg_contents section.
2017-10-14cris: Check UNDEFWEAK_NO_DYNAMIC_RELOCH.J. Lu2-10/+13
Don't generate dynamic relocation against weak undefined symbol if it is resolved to zero. FIXME: UNDEFWEAK_NO_DYNAMIC_RELOC may need to be checked in more places. bfd/ PR ld/22269 * elf32-cris.c (cris_elf_relocate_section): Don't generate dynamic relocation if UNDEFWEAK_NO_DYNAMIC_RELOC is true. (cris_elf_check_relocs): Don't allocate dynamic relocation if UNDEFWEAK_NO_DYNAMIC_RELOC is true. ld/ PR ld/22269 * testsuite/ld-cris/weakhiddso.d: Update and remove R_CRIS_NONE.
2017-10-14PR22263 testcaseAlan Modra3-3/+12
A number of targets need dynamic relocs in PIEs for reasons other than relocating thread variables. The PR is about text relocations, and, reading between the lines, unnecessary dynamic tprel relocations. Change the test to check for those conditions rather than no dynamic relocations PR ld/22263 * testsuite/ld-elf/tls.exp: Link with -z text. * testsuite/ld-elf/pr22263-1.rd: Test for tprel relocs.
2017-10-12Add a compile-time test for PR ld/22263H.J. Lu5-0/+80
This compile-time test requires a target C compiler to run. It fails on many targets where ELF backend linkers incorrectly check bfd_link_pic for TLS relocations, which should check bfd_link_executable instead. PR ld/22263 * testsuite/ld-elf/pr22263-1.rd: New file. * testsuite/ld-elf/pr22263-1a.c: Likewise. * testsuite/ld-elf/pr22263-1b.c: Likewise. * testsuite/ld-elf/tls.exp: Likewise.
2017-10-12ld whitespace fixesAlan Modra133-1238/+1235
* pe-dll.c: Formatting, whitespace fixes. * NEWS: Whitespace fixes. * configure.ac: Likewise. * configure.tgt: Likewise. * deffilep.y: Likewise. * genscripts.sh: Likewise. * ld.texinfo: Likewise. * ldgram.y: Likewise. * ldlang.c: Likewise. * ldlex.l: Likewise. * lexsup.c: Likewise. * plugin.c: Likewise. * emulparams/arc-endianness.sh: Likewise. * emulparams/elf32_x86_64.sh: Likewise. * emulparams/elf64mmix.sh: Likewise. * emulparams/elf_x86_64.sh: Likewise. * emulparams/h8300elf.sh: Likewise. * emulparams/h8300elf_linux.sh: Likewise. * emulparams/vxworks.sh: Likewise. * emultempl/aarch64elf.em: Likewise. * emultempl/aix.em: Likewise. * emultempl/armelf.em: Likewise. * emultempl/avrelf.em: Likewise. * emultempl/beos.em: Likewise. * emultempl/hppaelf.em: Likewise. * emultempl/m68kcoff.em: Likewise. * emultempl/m68kelf.em: Likewise. * emultempl/metagelf.em: Likewise. * emultempl/msp430.em: Likewise. * emultempl/nds32elf.em: Likewise. * emultempl/pe.em: Likewise. * emultempl/pep.em: Likewise. * emultempl/ppc64elf.em: Likewise. * emultempl/sh64elf.em: Likewise. * emultempl/spu_ovl.S: Likewise. * emultempl/spuelf.em: Likewise. * emultempl/tic6xdsbt.em: Likewise. * emultempl/ticoff.em: Likewise. * emultempl/vms.em: Likewise. * po/Make-in: Likewise. * scripttempl/DWARF.sc: Likewise. * scripttempl/aix.sc: Likewise. * scripttempl/alpha.sc: Likewise. * scripttempl/alphavms.sc: Likewise. * scripttempl/aout.sc: Likewise. * scripttempl/arclinux.sc: Likewise. * scripttempl/armaout.sc: Likewise. * scripttempl/armbpabi.sc: Likewise. * scripttempl/armcoff.sc: Likewise. * scripttempl/avr.sc: Likewise. * scripttempl/crisaout.sc: Likewise. * scripttempl/delta68.sc: Likewise. * scripttempl/dlx.sc: Likewise. * scripttempl/elf.sc: Likewise. * scripttempl/elf32cr16.sc: Likewise. * scripttempl/elf32cr16c.sc: Likewise. * scripttempl/elf32crx.sc: Likewise. * scripttempl/elf32msp430.sc: Likewise. * scripttempl/elf32msp430_3.sc: Likewise. * scripttempl/elf32sh-symbian.sc: Likewise. * scripttempl/elf32xc16x.sc: Likewise. * scripttempl/elf32xc16xl.sc: Likewise. * scripttempl/elf32xc16xs.sc: Likewise. * scripttempl/elf64hppa.sc: Likewise. * scripttempl/elf_chaos.sc: Likewise. * scripttempl/elfarc.sc: Likewise. * scripttempl/elfarcv2.sc: Likewise. * scripttempl/elfd10v.sc: Likewise. * scripttempl/elfd30v.sc: Likewise. * scripttempl/elfi370.sc: Likewise. * scripttempl/elfm68hc11.sc: Likewise. * scripttempl/elfm68hc12.sc: Likewise. * scripttempl/elfmicroblaze.sc: Likewise. * scripttempl/elfxgate.sc: Likewise. * scripttempl/elfxtensa.sc: Likewise. * scripttempl/epiphany_4x4.sc: Likewise. * scripttempl/epocpe.sc: Likewise. * scripttempl/h8300.sc: Likewise. * scripttempl/h8300h.sc: Likewise. * scripttempl/h8300hn.sc: Likewise. * scripttempl/h8300s.sc: Likewise. * scripttempl/h8300sn.sc: Likewise. * scripttempl/h8300sx.sc: Likewise. * scripttempl/h8300sxn.sc: Likewise. * scripttempl/h8500.sc: Likewise. * scripttempl/h8500b.sc: Likewise. * scripttempl/h8500c.sc: Likewise. * scripttempl/h8500m.sc: Likewise. * scripttempl/h8500s.sc: Likewise. * scripttempl/hppaelf.sc: Likewise. * scripttempl/i386beos.sc: Likewise. * scripttempl/i386coff.sc: Likewise. * scripttempl/i386go32.sc: Likewise. * scripttempl/i386msdos.sc: Likewise. * scripttempl/i860coff.sc: Likewise. * scripttempl/i960.sc: Likewise. * scripttempl/ia64vms.sc: Likewise. * scripttempl/ip2k.sc: Likewise. * scripttempl/iq2000.sc: Likewise. * scripttempl/m68kaux.sc: Likewise. * scripttempl/m68kcoff.sc: Likewise. * scripttempl/m88kbcs.sc: Likewise. * scripttempl/mcorepe.sc: Likewise. * scripttempl/mep.sc: Likewise. * scripttempl/mips.sc: Likewise. * scripttempl/mipsbsd.sc: Likewise. * scripttempl/mmo.sc: Likewise. * scripttempl/moxie.sc: Likewise. * scripttempl/nds32elf.sc: Likewise. * scripttempl/nw.sc: Likewise. * scripttempl/pe.sc: Likewise. * scripttempl/pep.sc: Likewise. * scripttempl/pj.sc: Likewise. * scripttempl/ppcpe.sc: Likewise. * scripttempl/psos.sc: Likewise. * scripttempl/riscix.sc: Likewise. * scripttempl/sh.sc: Likewise. * scripttempl/sparccoff.sc: Likewise. * scripttempl/st2000.sc: Likewise. * scripttempl/tic30aout.sc: Likewise. * scripttempl/tic30coff.sc: Likewise. * scripttempl/tic4xcoff.sc: Likewise. * scripttempl/tic54xcoff.sc: Likewise. * scripttempl/tic80coff.sc: Likewise. * scripttempl/v850.sc: Likewise. * scripttempl/v850_rh850.sc: Likewise. * scripttempl/vanilla.sc: Likewise. * scripttempl/visium.sc: Likewise. * scripttempl/w65.sc: Likewise. * scripttempl/xstormy16.sc: Likewise. * scripttempl/z80.sc: Likewise. * scripttempl/z8000.sc: Likewise. * configure: Regenerate.
2017-10-12Force the AArch64 linker backend to refuse to link when it encounters ↵Nick Clifton3-14/+34
unresoleable relocations. * reloc.c (enum bfd_reloc_status): Start values at 2. * bfd-in2.h: Regenerate. * elfnn-aarch64.c (aarch64_relocate): Invert sense of function, so that a TRUE return indicates success. Compare the result of calling _bfd_aarch64_elf_put_addend against bfd_reloc_ok. (build_one_stub): Change sense of tests against aarch64_relocate return value. (elfNN_aarch64_tls_relax): Return bfd_reloc_notsupported, rather than FALSE, when an error is detected. (elfNN_aarch64_final_link_relocate): Likewise. * testsuite/ld-aarch64/pcrel_pic_defined.d: Expect errors not warnings. Expect errors about unsupported relocations. * testsuite/ld-aarch64/pcrel_pic_undefined.d: Likewise.
2017-10-12ld: Update tests for warning of "-z dynamic-undefined-weak ignored"H.J. Lu9-9/+29
Update tests to expect warning of "-z dynamic-undefined-weak ignored" from commit 22b1ee183d19a92cc57859c04307d31c06792d13 Author: Alan Modra <amodra@gmail.com> Date: Thu Oct 12 13:19:10 2017 +1030 Set dynamic_undefined_weak to zero for static PIEs * testsuite/ld-elf/pr22269b.d: Expect warning of "-z dynamic-undefined-weak ignored". * testsuite/ld-i386/pr19636-1j.d: Likewise. * testsuite/ld-i386/pr19636-1k.d: Likewise. * testsuite/ld-i386/pr19636-1l.d: Likewise. * testsuite/ld-x86-64/pr19636-2j.d: Likewise. * testsuite/ld-x86-64/pr19636-2k.d: Likewise. * testsuite/ld-x86-64/pr19636-2l.d: Likewise. * testsuite/ld-x86-64/pr19636-2m.d: Likewise.
2017-10-12Set dynamic_undefined_weak to zero for static PIEsAlan Modra2-0/+14
I believe we should be warning if ld is given both --no-dynamic-linker and -z dynamic-undefined-weak. The two options are contradictory, the first says an executable has no dynamic interpreter to resolve dynamic symbols, while the second is asking for dynamic symbols to be emitted. (And even if a static PIE's relocation code, which is needed to process R_*_RELATIVE relocs, could process symbols, there are no DT_NEEDED dynamic objects to define such symbols.) I also think that dynamic_undefined_weak is the right flag to control whether undefined weaks are made dynamic, whether in static PIEs or anywhere else. So force it to 0 for static PIEs, fixing PR 22269 for powerpc and any other target where the backend usually defaults to undefined weaks being made dynamic. This patch introduces regressions. I'd normally not do that, but these are all in very recently added test cases, or expose bugs in the x86 backend. The test cases were added after I'd made it known that this patch or one like it was imminent. PR 22269 * emultempl/elf32.em (after_parse): Warn on --no-dynamic-linker -z dynamic-undefined-weak combination. Set dynamic_undefined_weak to zero when nointerp.
2017-10-12_bfd_elf_link_hash_hide_symbol calls in generic ELF codeAlan Modra2-32/+40
This function shouldn't be called directly, except from backend code. bfd/ * elflink.c (_bfd_elf_adjust_dynamic_symbol): Call elf_backend_hide_symbol, not _bfd_elf_link_hash_hide_symbol. (bfd_elf_define_start_stop): Likewise. ld/ * emultempl/elf32.em (before_allocation): Call elf_backend_hide_symbol, not _bfd_elf_link_hash_hide_symbol. Formatting.
2017-10-11Add 2 testcases for PR ld/22269H.J. Lu4-0/+40
Since undefined weak symbols in static PIE are always resolved to 0 at run-time, linker should resolve them as 0 at link-time, regardless of whether "-z dynamic-undefined-weak" is used. "-z dynamic-undefined-weak" only makes undefined weak symbols dynamic, but doesn't change undefined weak symbol resolution in static PIE at link-time. These tests currently pass on x86, but fails on many other targets. The framework to resolve weak symbols in static PE at link-time is posted at https://sourceware.org/ml/binutils/2017-10/msg00087.html which requires users/hjl/check_relocs branch to call check_relocs after opening all inputs. I will submit backend patches for failling targets after merging users/hjl/check_relocs branch next. * PR ld/22269 * testsuite/ld-elf/pr22269.s: New file. * testsuite/ld-elf/pr22269a.d: Likewise. * testsuite/ld-elf/pr22269b.d: Likewise.
2017-10-11x86: Run PR ld/19636 tests with -z dynamic-undefined-weakH.J. Lu15-0/+190
"-z dynamic-undefined-weak" makes undefined weak symbols dynamic, but undefined weak symbols are still resolved to 0 at link-time if there is no dynamic linker in executable. * testsuite/ld-i386/i386.exp: Run pr19636-1j, pr19636-1k, pr19636-1l, pr19636-3h and pr19636-3i. * testsuite/ld-i386/pr19636-1j.d: New file. * testsuite/ld-i386/pr19636-1k.d: Likewise. * testsuite/ld-i386/pr19636-1l.d: Likewise. * testsuite/ld-i386/pr19636-3h.d: Likewise. * testsuite/ld-i386/pr19636-3i.d: Likewise. * testsuite/ld-x86-64/pr19636-1h.d: Likewise. * testsuite/ld-x86-64/pr19636-1i.d: Likewise. * testsuite/ld-x86-64/pr19636-1j.d: Likewise. * testsuite/ld-x86-64/pr19636-2j.d: Likewise. * testsuite/ld-x86-64/pr19636-2k.d: Likewise. * testsuite/ld-x86-64/pr19636-2l.d: Likewise. * testsuite/ld-x86-64/pr19636-2m.d: Likewise. * testsuite/ld-x86-64/x86-64.exp: Run pr19636-1h, pr19636-1i, pr19636-1j, pr19636-2j, pr19636-2k, pr19636-2l and pr19636-2m.
2017-10-11ld internationalization fixesAlan Modra43-296/+369
* emultempl/aarch64elf.em: Wrap einfo strings in _(). Formatting. * emultempl/aix.em: Likewise. * emultempl/armcoff.em: Likewise. * emultempl/armelf.em: Likewise. * emultempl/avrelf.em: Likewise. * emultempl/beos.em: Likewise. * emultempl/cr16elf.em: Likewise. * emultempl/elf-generic.em: Likewise. * emultempl/elf32.em: Likewise. * emultempl/genelf.em: Likewise. * emultempl/hppaelf.em: Likewise. * emultempl/linux.em: Likewise. * emultempl/lnk960.em: Likewise. * emultempl/m68hc1xelf.em: Likewise. * emultempl/m68kcoff.em: Likewise. * emultempl/m68kelf.em: Likewise. * emultempl/metagelf.em: Likewise. * emultempl/mipself.em: Likewise. * emultempl/mmix-elfnmmo.em: Likewise. * emultempl/mmo.em: Likewise. * emultempl/msp430.em: Likewise. * emultempl/nds32elf.em: Likewise. * emultempl/nios2elf.em: Likewise. * emultempl/pe.em: Likewise. * emultempl/pep.em: Likewise. * emultempl/ppc32elf.em: Likewise. * emultempl/ppc64elf.em: Likewise. * emultempl/riscvelf.em: Likewise. * emultempl/s390.em: Likewise. * emultempl/scoreelf.em: Likewise. * emultempl/spuelf.em: Likewise. * emultempl/sunos.em: Likewise. * emultempl/tic6xdsbt.em: Likewise. * emultempl/v850elf.em: Likewise. * emultempl/vms.em: Likewise. * emultempl/vxworks.em: Likewise. * ldcref.c: Likewise. * ldlang.c: Likewise. * ldlex.l: Likewise. * ldmain.c: Likewise. * pe-dll.c: Likewise. * plugin.c: Likewise.
2017-10-10[ARM] PR ld/21402, only override the symbol dynamic decision on undefined ↵Renlin Li4-15/+19
weak symbol. Similar as aarch64 backend, arm backend only overrides the decision on undefined weak symbols. arm backend part already emits necessary relative relocation for this case. bfd/ PR ld/21402 * elf32-arm.c (allocate_dynrelocs_for_symbol): Only make undefined weak symbols into dynamic. ld/ PR ld/21402 * testsuite/ld-arm/tls-app.d: Update address. * testsuite/ld-arm/tls-app.r: Remove relocations. * testsuite/ld-arm/unresolved-1-dyn.d: Update.
2017-10-10Correct ld/Makefile earmelfb_fuchsia dependenciesAlan Modra3-2/+7
There were two copies of earmelf_fuchsia.c dependencies. * Makefile.am (earmelfb_fuchsia.c): Rename rule from earmelf_fuchsia.c. * Makefile.in: Regenerate.
2017-10-09Fix link time warning message when running the srec linker tests.Nick Clifton2-1/+3
* testsuite/ld-srec/srec.exp (run_srec_test): Set start address.
2017-10-09Fix compile time warning message when running the PR19874 linker test.Nick Clifton2-1/+6
PR ld/19874 * testsuite/ld-x86-64/pr19784c.c (bar): Change return type to void.
2017-10-09ld: Don't allow '~' as the first char in symbol nameH.J. Lu6-2/+36
Don't allow '~' as the first character in symbol name in linker script. PR ld/22267 * ldlex.l (SYMBOLNAMECHAR1) New. (DEFSYMEXP): Replace FILENAMECHAR1 with SYMBOLNAMECHAR1. (EXPRESSION): Likewise. * testsuite/ld-scripts/expr.exp: Run pr22267. * testsuite/ld-scripts/pr22267.d: New file. * testsuite/ld-scripts/pr22267.s: Likewise. * testsuite/ld-scripts/pr22267.t: Likewise.
2017-10-07ld-elf/merge.d: Don't expect to fail for sparcH.J. Lu2-1/+5
It passed with cross binutils to sparc-linux and sparc64-linux. * testsuite/ld-elf/merge.d: Don't expect to fail for sparc.
2017-10-05Updated Turkish translation for the ld sub-directory.Nick Clifton2-663/+1504
* po/tr.po: Updated Turkish translation.
2017-10-05Change readelf so that when --wide is active a relocation's full name is ↵Nick Clifton2-1/+7
displayed. PR 22262 binutils* readelf.c (dump_relocations): Do not truncate reloc names when displaying output in wide mode. ld * testsuite/ld-powerpc/relocsort.d: Update expected output (for longer reloc names).
2017-10-05PR21167, relocation sections not included in groupsAlan Modra2-4/+10
This fixes a wart I've known about for years, but haven't done anything about because BFD treats relocation sections as an adjunct to the section they relocate. SHF_GROUP on the section thus implicitly applies to its relocation section(s), but it is an error that the reloc sections aren't part of the group. Like many patches to gas, this wasn't as straightforward as it could be due to a number of backends, i386, cr16 and others, removing relocs in tc_get_reloc rather than marking them as "done" earlier in md_apply_reloc. So it isn't possible for the group support to reliably detect the presence of relocs by looking at fixups earlier than write_relocs. However the group support needs to create signature symbols, and that must be done before the symbol table is frozen, before write_relocs. So split off the group sizing from elf_adjust_symtab and put it in elf_frob_file_after_relocs. bfd/ PR 21167 * elf.c (_bfd_elf_setup_sections): Don't trim reloc sections from groups. (_bfd_elf_init_reloc_shdr): Pass sec_hdr, use it to copy SHF_GROUP flag from section. (elf_fake_sections): Adjust calls. Exit immediately on failure. (bfd_elf_set_group_contents): Add associated reloc section indices to group contents gas/ PR 21167 * config/obj-elf.c (struct group_list): Delete elt_count. (groups): New static. (build_group_lists): Don't count elements. (elf_adjust_symtab): Use groups rather than auto list. Set up pointer from group member to SHT_GROUP section. Don't size SHT_GROUP section or clean up here.. (elf_frob_file_after_relocs): ..do so here instead. * testsuite/gas/arc/jli-1.d, * testsuite/gas/elf/groupautob.d, * testsuite/gas/mips/compact-eh-eb-2.d, * testsuite/gas/mips/compact-eh-eb-5.d, * testsuite/gas/mips/compact-eh-el-2.d, * testsuite/gas/mips/compact-eh-el-5.d: Adjust. ld/ PR 21167 * testsuite/ld-elf/group9b.d: Adjust for relocs included in group.
2017-10-03PR21294, Binary size regression on PPC embeddedAlan Modra2-1/+8
PR 21294 * NEWS: Note that defaulting to -z relro results in increased memory and disk size.
2017-10-03ld -z relro documentationAlan Modra2-6/+18
* ld.texinfo (-z relro): Expand description. (DATA_SEGMENT_ALIGN): Note that -z relro is not effective when running with system page size larger than commonpagesize. (DATA_SEGMENT_RELRO_END): Be explicit about the alignment.
2017-10-01PR21970, assertion failed when more than one overlay has subalign specifiedAlan Modra2-0/+6
PR 21970 * ldlang.c (lang_leave_overlay): Reset overlay_subalign.
2017-09-30Add a test for PR binutils/21978H.J. Lu5-0/+20
PR binutils/21978 * testsuite/ld-elf/pr21978.od: New file. * testsuite/ld-elf/pr21978a.c: Likewise. * testsuite/ld-elf/pr21978b.c: Likewise. * testsuite/ld-elf/shared.exp: Run PR binutils/21978 test.
2017-09-28Skip the PR 14918 linker test for ARM targets.Nick Clifton2-3/+19
I am applying a patch that has been lying around in the Fedora binutils sources for a while. It skips the PR14918 linker test for ARM based targets. This test checks that libgcc is not included in a link of an empty executable. This works for most targets, but on the ARM the crt1.o startup code calls __libc_csu_init which is in /usr/lib/libc_nonshared.a(elf-init.oS). This in turn needs __aeabi_unwind_cpp_pr0@@GCC_3.5 which is provided by libgcc_s.so.1, and so the test fails.
2017-09-28PR22220, BFD linker wrongly marks symbols as PREVAILING_DEF_IRONLYAlan Modra6-0/+47
non_ir_ref_dynamic wasn't being set in the case where we have a versioned dynamic symbol definition with a non-versioned matching IR symbol. bfd/ PR 22220 * elflink.c (_bfd_elf_merge_symbol): Set non_ir_ref_dynamic in a case where plugin_notice isn't called. ld/ * testsuite/ld-plugin/pr22220.h, * testsuite/ld-plugin/pr22220lib.cc, * testsuite/ld-plugin/pr22220lib.ver, * testsuite/ld-plugin/pr22220main.cc: New test. * testsuite/ld-plugin/lto.exp: Run it.
2017-09-26LD/testsuite: Fix undefined symbol tests for MIPS and S+core targetsMaciej W. Rozycki2-3/+28
Fix commit 647d4de92e06 ("Test undefined symbols in shared libraries") and remove "undefined symbols in shared lib (dyn reloc)" test failures for MIPS and S+core targets. This test assumes 3 dynamic relocation entries, however the respective psABIs define an extra single dummy *_NONE relocation at the beginning of the dynamic relocation table, which results in test output like the following for MIPS: Relocation section '.rel.dyn' at offset 0x33c contains 4 entries: Offset Info Type Sym.Value Sym. Name 00000000 00000000 R_MIPS_NONE 00010364 00000903 R_MIPS_REL32 00000000 undef_pfun 00010360 00000a03 R_MIPS_REL32 00000000 undef_data 00010368 00000b03 R_MIPS_REL32 00000000 undef_notype and S+core: Relocation section '.rel.dyn' at offset 0x274 contains 4 entries: Offset Info Type Sym.Value Sym. Name 00000000 00000000 R_SCORE_NONE 5ffe0464 00000e12 R_SCORE_REL32 00000000 undef_notype 5ffe045c 00000f12 R_SCORE_REL32 00000000 undef_data 5ffe0460 00001012 R_SCORE_REL32 00000000 undef_pfun targets respectively, and also n64 MIPS targets pad relocation triplets they use with extra *_NONE relocations, resulting in output like this: Relocation section '.rel.dyn' at offset 0x4c0 contains 4 entries: Offset Info Type Sym. Value Sym. Name 000000000000 000000000000 R_MIPS_NONE Type2: R_MIPS_NONE Type3: R_MIPS_NONE 000000010508 000900001203 R_MIPS_REL32 0000000000000000 undef_pfun Type2: R_MIPS_64 Type3: R_MIPS_NONE 000000010500 000a00001203 R_MIPS_REL32 0000000000000000 undef_data Type2: R_MIPS_64 Type3: R_MIPS_NONE 000000010510 000b00001203 R_MIPS_REL32 0000000000000000 undef_notype Type2: R_MIPS_64 Type3: R_MIPS_NONE Expect the right number of *_NONE relocations then, and adjust the total number of relocations expected accordingly. ld/ * testsuite/ld-undefined/undefined.exp: Correct the dyn reloc test for MIPS and S+core targets.
2017-09-22Add a test for PR ld/22150H.J. Lu6-0/+59
PR ld/22150 * testsuite/ld-elf/pr22150.vd: New file. * testsuite/ld-elf/pr22150.ver: Likewise. * testsuite/ld-elf/pr22150a.s: Likewise. * testsuite/ld-elf/pr22150b.s: Likewise. * testsuite/ld-elf/shared.exp: Run PR ld/22150 tests.
2017-09-21Reduce excessive .eh_frame alignment for powerpcAlan Modra2-6/+6
PowerPC64 .cfi directives use DW_EH_PE_sdata4 encoding for .eh_frame, so there is no real reason why .eh_frame should be 8 byte aligned. gas/ * config/tc-ppc.h (EH_FRAME_ALIGNMENT): Define. ld/ * testsuite/ld-powerpc/tlsopt5.wf: Update for reduced alignment.
2017-09-19MIPS/LD: Add OpenBSD/mips64 supportMaciej W. Rozycki2-0/+11
Complement commit 26eebcf553d7 ("Update OpenBSD/mips64 support"), <https://sourceware.org/ml/binutils/2005-04/msg00382.html>, which added OpenBSD/mips64 support to GAS, and also add it to LD, avoiding a build failure at the configuration stage, like: *** ld does not support target mips64-unknown-openbsd *** see ld/configure.tgt for supported targets make[1]: *** [configure-ld] Error 1 As per OS support only include n64 MIPS emulations, and use the traditional ones, matching the choice already made with the addition of GAS support. ld/ * configure.tgt <mips64el-*-openbsd*, mips64-*-openbsd*>: New targets.
2017-09-15PR22118, Incorrectly-capitalized regexpAlan Modra2-1/+6
PR 22118 * testsuite/ld-aarch64/erratum843419.d: Correct regexp.
2017-09-14globalaudit.rd: Allow additional bits in DT_FLAGS_1H.J. Lu2-1/+7
With -PIE on x86-64, we get 0x000000006ffffffb (FLAGS_1) Flags: GLOBAUDIT PIE We should allow additional bits in DT_FLAGS_1. PR ld/22139 * testsuite/ld-elf/globalaudit.rd: Allow additional bits in DT_FLAGS_1.
2017-09-14x86: Cache section contents and relocationsH.J. Lu7-0/+58
bfd/ PR ld/22135 * elf32-i386.c (elf_i386_convert_load_reloc): Add an argument to indicate if conversion is performed. (elf_i386_check_relocs): Cache section contents and relocations if conversion is performed. * elf64-x86-64.c (elf_x86_64_check_relocs): Cache section contents and relocations if conversion is performed. ld/ PR ld/22135 * testsuite/ld-i386/i386.exp: Run pr22135. * testsuite/ld-x86-64/x86-64.exp: Likewise. * testsuite/ld-i386/pr22135.d: New file. * testsuite/ld-i386/pr22135.s: Likewise. * testsuite/ld-x86-64/pr22135.d: Likewise. * testsuite/ld-x86-64/pr22135.s: Likewise.
2017-09-10PowerPC64 --plt-alignAlan Modra6-19/+34
This changes the PowerPC64 --plt-align option to perform the usual alignment of code as suggested by its name, as well as the previous behaviour of padding so as to reduce boundary crossing. The old behaviour is had by using a negative parameter. The default is also changed to align plt stub code by default to 32 byte boundaries, the point being to get better bctr branch prediction on power8 and power9 hardware. bfd/ * elf64-ppp.c (plt_stub_pad): Handle positive and negative plt_stub_align. ld/ * ld.texinfo (--plt-align): Describe new behaviour of option. * emultempl/ppc64elf.em (params): Default plt_stub_align to 5. * testsuite/ld-powerpc/powerpc.exp: Pass --no-plt-align for selected tests. * testsuite/ld-powerpc/relbrlt.d: Pass --no-plt-align. * testsuite/ld-powerpc/elfv2so.d: Adjust expected output.
2017-09-09x86: Properly handle __ehdr_startH.J. Lu17-0/+160
After _bfd_i386_elf_convert_load and _bfd_x86_64_elf_convert_load are removed, elf_i386_convert_load_reloc and elf_x86_64_convert_load_reloc see __ehdr_start as an undefined symbol when they are called from check_relocs to convert GOT relocations against local symbols. But __ehdr_start will be defined as a hidden symbol by linker at the later stage if it is referenced. This patch marks __ehdr_start as a defined local symbol at the start of check_relocs if it is referenced and not defined. bfd/ PR ld/22115 * elf32-i386.c (elf_i386_convert_load_reloc): Check linker_def. Don't use UNDEFINED_WEAK_RESOLVED_TO_ZERO. * elf64-x86-64.c (elf_x86_64_convert_load_reloc): Check linker_def. Don't use UNDEFINED_WEAK_RESOLVED_TO_ZERO. * elfxx-x86.c (_bfd_x86_elf_link_check_relocs): Set local_ref and linker_def on __ehdr_start if it is referenced and not defined. (_bfd_x86_elf_link_symbol_references_local): Also set local_ref and return TRUE when building executable, if a symbol has non-GOT/non-PLT relocations in text section or there is no dynamic linker. * elfxx-x86.h (elf_x86_link_hash_entry): Add linker_def. ld/ PR ld/22115 * ld-i386/i386.exp: Run PR ld/22115 tests, * ld/testsuite/ld-x86-64/x86-64.exp: Likewise. * testsuite/ld-i386/pr22115-1.s: New file. * testsuite/ld-i386/pr22115-1a.d: Likewise. * testsuite/ld-i386/pr22115-1b.d: Likewise. * testsuite/ld-i386/pr22115-1c.d: Likewise. * testsuite/ld-i386/pr22115-1d.d: Likewise. * testsuite/ld-x86-64/pr22115-1.s: Likewise. * testsuite/ld-x86-64/pr22115-1a-x32.d: Likewise. * testsuite/ld-x86-64/pr22115-1a.d: Likewise. * testsuite/ld-x86-64/pr22115-1b-x32.d: Likewise. * testsuite/ld-x86-64/pr22115-1b.d: Likewise. * testsuite/ld-x86-64/pr22115-1c-x32.d: Likewise. * testsuite/ld-x86-64/pr22115-1c.d: Likewise. * testsuite/ld-x86-64/pr22115-1d-x32.d: Likewise. * testsuite/ld-x86-64/pr22115-1d.d: Likewise.
2017-09-06x86-64: Add R_X86_64_converted_reloc_bitH.J. Lu5-6/+11
Add R_X86_64_converted_reloc_bit to relocation type to indicate if a relocation is converted from a GOTPCREL relocation. Linker now generates failed to convert GOTPCREL relocation; relink with --no-relax for all cases, including relocations against local symbols. bfd/ * elf64-x86-64.c (R_X86_64_converted_reloc_bit): New. (elf_x86_64_info_to_howto): Get the real relocation type by masking out R_X86_64_converted_reloc_bit. (elf_x86_64_check_tls_transition): Get the real relocation type by masking out R_X86_64_converted_reloc_bit. (elf_x86_64_convert_load_reloc): Set R_X86_64_converted_reloc_bit instead of setting converted_reloc. (elf_x86_64_relocate_section): Check R_X86_64_converted_reloc_bit instead of converted_reloc. Get the real relocation type by masking out R_X86_64_converted_reloc_bit. (elf_x86_64_link_setup_gnu_properties): Verify that the value of R_X86_64_converted_reloc_bit is valid. * elfxx-x86.h (converted_reloc): Removed. ld/ * testsuite/ld-x86-64/pr19609-2a.d: Updated. * testsuite/ld-x86-64/pr19609-2b.d: Likewise. * testsuite/ld-x86-64/pr19609-4a.d: Likewise. * testsuite/ld-x86-64/pr19609-4c.d: Likewise.
2017-09-05x86-64: Properly set converted_relocH.J. Lu4-3/+9
Linker now generates failed to convert GOTPCREL relocation; relink with --no-relax for more cases. bfd/ * elf64-x86-64.c (elf_x86_64_convert_load_reloc): Properly set converted_reloc. ld/ * testsuite/ld-x86-64/pr19609-5d.d: Updated. * testsuite/ld-x86-64/pr19609-7a.d: Likewise. * testsuite/ld-x86-64/pr19609-7c.d: Likewise.
2017-09-05x86-64: Improve GOTPCREL relocation conversionH.J. Lu3-3/+8
When GOTPCREL relocation conversion leads to relocation overflow, we may get a mysterious linker message, like relocation truncated to fit: R_X86_64_32S against symbol `foo' This patch changes the linker message to failed to convert GOTPCREL relocation; relink with --no-relax bfd/ * elf64-x86-64.c (elf_x86_64_convert_load_reloc): Remove the sec argument. Don't check relocation overflow. Avoid relocation overflow if --no-relax is used. Set converted_reloc on symbol if a GOTPCREL relocation is converted. (elf_x86_64_relocate_section): Issue a fatal error and suggest --no-relax if GOTPCREL relocation conversion leads to relocation overflow. * elfxx-x86.h (elf_x86_link_hash_entry): Add converted_reloc. ld/ * testsuite/ld-x86-64/pr19609-4e.d: Updated. * testsuite/ld-x86-64/pr19609-6a.d: Likewise.
2017-09-03x86-64: Set tlsdesc_plt if GOT_TLS_GDESC_P is trueH.J. Lu4-0/+94
We need to set tlsdesc_plt for x86-64 if GOT_TLS_GDESC_P is true when allocating dynamic relocations so that _bfd_x86_elf_size_dynamic_sections will generate TLSDESC_PLT and TLSDESC_GOT in x86-64 output. bfd/ PR ld/22071 * elfxx-x86.c (elf_x86_allocate_dynrelocs): Set tlsdesc_plt for x86-64 if GOT_TLS_GDESC_P is true. ld/ PR ld/22071 * testsuite/ld-x86-64/pr22071.d: New file. * testsuite/ld-x86-64/pr22071.s: Likewise. * testsuite/ld-x86-64/x86-64.exp: Run pr22071.
2017-09-02LTO rescan archivesAlan Modra4-7/+103
ld ought to be more clever about where it puts LTO recompiled objects. Ideally the recompiled objects ought to be ordered to the same place their IR objects were, and files extracted from archives on the second pass ought to go in the same place as they would if extracted on the first pass. This patch addresses the archive problem. Without this fix, objects extracted from archives might be placed after the crt files intended to go at the end of an executable or shared library, possibly causing exception handling failures. * ldlang.h (lang_input_statement_type): Expand comments. (LANG_FOR_EACH_INPUT_STATEMENT): Rewrite without casts. * ldlang.c (lang_for_each_input_file): Likewise. (load_symbols): Set usrdata for archives. (find_rescan_insertion): New function. (lang_process): Trim off and reinsert entries added to file chain when rescanning archives for LTO. * ldmain.c (add_archive_element): Set my_archive input_statement next pointer to last element added.
2017-09-01x86-64: Check ELF_COMMON_DEF_P for common symbolsH.J. Lu4-0/+77
bfd/ PR ld/22064 * elf64-x86-64.c (elf_x86_64_finish_dynamic_symbol): Check ELF_COMMON_DEF_P for common symbols. ld/ PR ld/22064 * testsuite/ld-x86-64/pr22064a.S: New file. * testsuite/ld-x86-64/pr22064b.c: Likewise. * testsuite/ld-x86-64/x86-64.exp: Run PR ld/22064 test.
2017-09-02-Og warning fixesAlan Modra2-13/+21
Found when building with gcc 4.9.4 using -Og. bfd/ * elf-eh-frame.c (offset_adjust): Avoid false positive gcc warning. * elflink.c (bfd_elf_size_dynsym_hash_dynstr): Likewise. * elfnn-aarch64.c (elfNN_aarch64_final_link_relocate): Likewise. ld/ * emultempl/msp430.em (eval_upper_either_sections): Make base_sec_name a const char*. (eval_lower_either_sections): Likewise. (msp430_elf_after_allocation): Likewise, and don't needlessly concat and free. Warning fix.
2017-09-01x86: Correct unwind information for the second PLTH.J. Lu23-49/+549
For i386, generate unwind information for the second PLT. For x32, correct alignment of .eh_frame section for the second PLT. bfd/ PR ld/22061 * elf32-i386.c (elf_i386_link_setup_gnu_properties): Create .eh_frame section for the second PLT. * elf64-x86-64.c (elf_x86_64_link_setup_gnu_properties): Correct alignment of .eh_frame section for the second PLT. ld/ PR ld/22061 * testsuite/ld-i386/ibt-plt-1.d: Updated. * testsuite/ld-i386/ibt-plt-2a.d: Likewise. * testsuite/ld-i386/ibt-plt-2c.d: Likewise. * testsuite/ld-i386/ibt-plt-3a.d: Likewise. * testsuite/ld-i386/ibt-plt-3c.d: Likewise. * testsuite/ld-x86-64/ibt-plt-1-x32.d: Likewise. * testsuite/ld-x86-64/ibt-plt-2a-x32.d: Likewise. * testsuite/ld-x86-64/ibt-plt-2c-x32.d: Likewise. * testsuite/ld-x86-64/ibt-plt-3a-x32.d: Likewise. * testsuite/ld-x86-64/ibt-plt-3c-x32.d: Likewise. * testsuite/ld-i386/ibt-plt-2b.d: Pass --hash-style=sysv to ld and dump unwind information. * testsuite/ld-i386/ibt-plt-2d.d: Likewise. * testsuite/ld-i386/ibt-plt-3b.d: Likewise. * testsuite/ld-i386/ibt-plt-3d.d: Likewise. * testsuite/ld-x86-64/ibt-plt-2b-x32.d: Likewise. * testsuite/ld-x86-64/ibt-plt-2b.d: Likewise. * testsuite/ld-x86-64/ibt-plt-2d-x32.d: Likewise. * testsuite/ld-x86-64/ibt-plt-2d.d: Likewise. * testsuite/ld-x86-64/ibt-plt-3b-x32.d: Likewise. * testsuite/ld-x86-64/ibt-plt-3b.d: Likewise. * testsuite/ld-x86-64/ibt-plt-3d-x32.d: Likewise. * testsuite/ld-x86-64/ibt-plt-3d.d: Likewise.
2017-08-31Add a test for PR ld/22048H.J. Lu5-0/+46
PR ld/22048 * testsuite/ld-x86-64/pr22048.d: New file. * testsuite/ld-x86-64/pr22048a.s: Likewise. * testsuite/ld-x86-64/pr22048b.s: Likewise. * testsuite/ld-x86-64/x86-64.exp: Run pr22048.
2017-08-31Remove .eh_frame zero terminatorsAlan Modra3-13/+8
The machinery to do this was there, but not enabled if the terminator was the only thing in the section. bfd/ * elf-eh-frame.c (_bfd_elf_parse_eh_frame): Don't exit early for a section containing just a terminator. Allow multiple terminators at end of section. * elflink.c (bfd_elf_discard_info): Iterate over .eh_frame sections when not adding alignment. Assert on terminator in the middle of FDEs. ld/ * testsuite/ld-elf/eh3.d: Update. * testsuite/ld-elf/eh4.d: Update.
2017-08-30LD/testsuite: Also discard `.MIPS.options' in orphan testsMaciej W. Rozycki2-2/+7
Complement commit 5b5f4e6f8cd2 ("ld: Early detection of orphans we know will be discarded") and add `.MIPS.options' to the list of sections discarded with orphan tests, removing failures like: ./ld-new: error: unplaced orphan section `.MIPS.options' from `tmpdir/orphan-11.o'. FAIL: ld-elf/orphan-11 and: ./ld-new: error: unplaced orphan section `.MIPS.options' from `tmpdir/orphan-12.o'. FAIL: ld-elf/orphan-12 from n64 MIPS testing. ld/ * testsuite/ld-elf/orphan-11.ld: Also discard `.MIPS.options' sections.