aboutsummaryrefslogtreecommitdiff
path: root/ld
AgeCommit message (Collapse)AuthorFilesLines
2015-08-18Add another test for PR ld/18841H.J. Lu3-5/+44
PR ld/18841 * ld-ifunc/ifunc.exp: Add another test for PR ld/18841. * ld-ifunc/pr18841c.c: New file.
2015-08-18Return reloc_class_ifunc for reloc against IFUNCH.J. Lu5-0/+58
elf_XXX_reloc_type_class should return reloc_class_ifunc for relocation against STT_GNU_IFUNC symbol. bfd/ PR ld/18841 * elf-bfd.h (elf_link_hash_table): Add dynsym. * elf32-i386.c (elf_i386_reloc_type_class): Return reloc_class_ifunc for relocation against STT_GNU_IFUNC symbol. * elf64-x86-64.c (elf_x86_64_reloc_type_class): Likewise. * elflink.c (_bfd_elf_link_create_dynamic_sections): Set dynsym. (bfd_elf_size_dynsym_hash_dynstr): Use dynsym. (elf_final_link_info): Remove dynsym_sec. (elf_link_output_extsym): Replace dynsym_sec with dynsym. (bfd_elf_final_link): Remove reference to dynsym_sec. Replace dynsym_sec with dynsym. ld/testsuite/ PR ld/18841 * ld-ifunc/ifunc.exp: Add a test for PR ld/18841. * ld-ifunc/pr18841.out: New file. * ld-ifunc/pr18841a.c: Likewise. * ld-ifunc/pr18841b.c: Likewise.
2015-08-18Add output_type to bfd_link_infoH.J. Lu51-229/+320
The "shared" field in bfd_link_info is set for both DSO and and PIE. There are separate fields for executable and relocatable outputs. This patch adds an "output_type" field: enum output_type { type_unknown = 0, type_executable, type_dll, type_relocatable }; and a "pic" field to bfd_link_info to replace shared, executable and relocatable fields so that we can use the "output_type" field to check for output type and the "pic" field check if output is PIC. Macros, bfd_link_executable, bfd_link_dll, bfd_link_relocatable, bfd_link_pic and bfd_link_pie, are provided to check for output features. bfd/ * bfd/aoutx.h: Replace shared, executable, relocatable and pie fields with bfd_link_executable, bfd_link_dll, bfd_link_relocatable, bfd_link_pic and bfd_link_pie. * bfd/bout.c: Likewise. * bfd/coff-alpha.c: Likewise. * bfd/coff-arm.c: Likewise. * bfd/coff-i386.c: Likewise. * bfd/coff-i960.c: Likewise. * bfd/coff-m68k.c: Likewise. * bfd/coff-mcore.c: Likewise. * bfd/coff-mips.c: Likewise. * bfd/coff-ppc.c: Likewise. * bfd/coff-rs6000.c: Likewise. * bfd/coff-sh.c: Likewise. * bfd/coff-tic80.c: Likewise. * bfd/coff-x86_64.c: Likewise. * bfd/coff64-rs6000.c: Likewise. * bfd/coffgen.c: Likewise. * bfd/cofflink.c: Likewise. * bfd/ecoff.c: Likewise. * bfd/ecofflink.c: Likewise. * bfd/elf-bfd.h: Likewise. * bfd/elf-eh-frame.c: Likewise. * bfd/elf-ifunc.c: Likewise. * bfd/elf-m10200.c: Likewise. * bfd/elf-m10300.c: Likewise. * bfd/elf-s390-common.c: Likewise. * bfd/elf-vxworks.c: Likewise. * bfd/elf.c: Likewise. * bfd/elf32-arm.c: Likewise. * bfd/elf32-avr.c: Likewise. * bfd/elf32-bfin.c: Likewise. * bfd/elf32-cr16.c: Likewise. * bfd/elf32-cr16c.c: Likewise. * bfd/elf32-cris.c: Likewise. * bfd/elf32-crx.c: Likewise. * bfd/elf32-d10v.c: Likewise. * bfd/elf32-dlx.c: Likewise. * bfd/elf32-epiphany.c: Likewise. * bfd/elf32-fr30.c: Likewise. * bfd/elf32-frv.c: Likewise. * bfd/elf32-ft32.c: Likewise. * bfd/elf32-h8300.c: Likewise. * bfd/elf32-hppa.c: Likewise. * bfd/elf32-i370.c: Likewise. * bfd/elf32-i386.c: Likewise. * bfd/elf32-i860.c: Likewise. * bfd/elf32-ip2k.c: Likewise. * bfd/elf32-iq2000.c: Likewise. * bfd/elf32-lm32.c: Likewise. * bfd/elf32-m32c.c: Likewise. * bfd/elf32-m32r.c: Likewise. * bfd/elf32-m68hc11.c: Likewise. * bfd/elf32-m68hc1x.c: Likewise. * bfd/elf32-m68k.c: Likewise. * bfd/elf32-mcore.c: Likewise. * bfd/elf32-mep.c: Likewise. * bfd/elf32-metag.c: Likewise. * bfd/elf32-microblaze.c: Likewise. * bfd/elf32-moxie.c: Likewise. * bfd/elf32-msp430.c: Likewise. * bfd/elf32-mt.c: Likewise. * bfd/elf32-nds32.c: Likewise. * bfd/elf32-nios2.c: Likewise. * bfd/elf32-or1k.c: Likewise. * bfd/elf32-ppc.c: Likewise. * bfd/elf32-rl78.c: Likewise. * bfd/elf32-rx.c: Likewise. * bfd/elf32-s390.c: Likewise. * bfd/elf32-score.c: Likewise. * bfd/elf32-score7.c: Likewise. * bfd/elf32-sh-symbian.c: Likewise. * bfd/elf32-sh.c: Likewise. * bfd/elf32-sh64.c: Likewise. * bfd/elf32-spu.c: Likewise. * bfd/elf32-tic6x.c: Likewise. * bfd/elf32-tilepro.c: Likewise. * bfd/elf32-v850.c: Likewise. * bfd/elf32-vax.c: Likewise. * bfd/elf32-visium.c: Likewise. * bfd/elf32-xc16x.c: Likewise. * bfd/elf32-xstormy16.c: Likewise. * bfd/elf32-xtensa.c: Likewise. * bfd/elf64-alpha.c: Likewise. * bfd/elf64-hppa.c: Likewise. * bfd/elf64-ia64-vms.c: Likewise. * bfd/elf64-mmix.c: Likewise. * bfd/elf64-ppc.c: Likewise. * bfd/elf64-s390.c: Likewise. * bfd/elf64-sh64.c: Likewise. * bfd/elf64-x86-64.c: Likewise. * bfd/elflink.c: Likewise. * bfd/elfnn-aarch64.c: Likewise. * bfd/elfnn-ia64.c: Likewise. * bfd/elfxx-mips.c: Likewise. * bfd/elfxx-sparc.c: Likewise. * bfd/elfxx-tilegx.c: Likewise. * bfd/i386linux.c: Likewise. * bfd/linker.c: Likewise. * bfd/m68klinux.c: Likewise. * bfd/pdp11.c: Likewise. * bfd/pe-mips.c: Likewise. * bfd/peXXigen.c: Likewise. * bfd/reloc.c: Likewise. * bfd/reloc16.c: Likewise. * bfd/sparclinux.c: Likewise. * bfd/sunos.c: Likewise. * bfd/vms-alpha.c: Likewise. * bfd/xcofflink.c: Likewise. include/ * include/bfdlink.h (output_type): New enum. (bfd_link_executable): New macro. (bfd_link_dll): Likewise. (bfd_link_relocatable): Likewise. (bfd_link_pic): Likewise. (bfd_link_pie): Likewise. (bfd_link_info): Remove shared, executable, pie and relocatable. Add output_type and pic. ld/ * ld/ldctor.c: Replace shared, executable, relocatable and pie fields with bfd_link_executable, bfd_link_dll, bfd_link_relocatable, bfd_link_pic and bfd_link_pie. * ld/ldemul.c: Likewise. * ld/ldfile.c: Likewise. * ld/ldlang.c: Likewise. * ld/ldmain.c: Likewise. * ld/ldwrite.c: Likewise. * ld/lexsup.c: Likewise. * ld/pe-dll.c: Likewise. * ld/plugin.c: Likewise. * ld/emultempl/aarch64elf.em: Likewise. * ld/emultempl/aix.em: Likewise. * ld/emultempl/alphaelf.em: Likewise. * ld/emultempl/armcoff.em: Likewise. * ld/emultempl/armelf.em: Likewise. * ld/emultempl/avrelf.em: Likewise. * ld/emultempl/beos.em: Likewise. * ld/emultempl/cr16elf.em: Likewise. * ld/emultempl/elf-generic.em: Likewise. * ld/emultempl/elf32.em: Likewise. * ld/emultempl/genelf.em: Likewise. * ld/emultempl/generic.em: Likewise. * ld/emultempl/gld960.em: Likewise. * ld/emultempl/gld960c.em: Likewise. * ld/emultempl/hppaelf.em: Likewise. * ld/emultempl/irix.em: Likewise. * ld/emultempl/linux.em: Likewise. * ld/emultempl/lnk960.em: Likewise. * ld/emultempl/m68hc1xelf.em: Likewise. * ld/emultempl/m68kcoff.em: Likewise. * ld/emultempl/m68kelf.em: Likewise. * ld/emultempl/metagelf.em: Likewise. * ld/emultempl/mipself.em: Likewise. * ld/emultempl/mmo.em: Likewise. * ld/emultempl/msp430.em: Likewise. * ld/emultempl/nds32elf.em: Likewise. * ld/emultempl/needrelax.em: Likewise. * ld/emultempl/nios2elf.em: Likewise. * ld/emultempl/pe.em: Likewise. * ld/emultempl/pep.em: Likewise. * ld/emultempl/ppc32elf.em: Likewise. * ld/emultempl/ppc64elf.em: Likewise. * ld/emultempl/sh64elf.em: Likewise. * ld/emultempl/solaris2.em: Likewise. * ld/emultempl/spuelf.em: Likewise. * ld/emultempl/sunos.em: Likewise. * ld/emultempl/tic6xdsbt.em: Likewise. * ld/emultempl/ticoff.em: Likewise. * ld/emultempl/v850elf.em: Likewise. * ld/emultempl/vms.em: Likewise. * ld/emultempl/vxworks.em: Likewise.
2015-08-18PPC64: Allow .TOC. in linker script to override backend calculated valueAlan Modra2-0/+5
bfd/ * elf64-ppc.c (ppc64_elf_func_desc_adjust): Don't redefine .TOC. if already defined, and set linker_def. (ppc64_elf_set_toc): Use .TOC. value if defined other than by the backend. ld/ * ldexp.c (exp_fold_tree_1): Clear linker_def on symbol assignment.
2015-08-13Issue an error for read-only segment with dynamic IFUNC relocationsH.J. Lu7-0/+48
To load an ELF binary with DT_TEXTREL tag, the dynamic linker calls __mprotect on the read-only segment with PROT_READ|PROT_WRITE before applying dynamic relocation. It leads to segfault when performing IFUNC relocations since the read-only segment has no execute permission. This patch changes x86 linker to issue an error for read-only segment with dynamic IFUNC relocations. Other backends with IFUNC support may need a similar change. bfd/ PR ld/18801 * elf32-i386.c (elf_i386_size_dynamic_sections): Issue an error for read-only segment with dynamic IFUNC relocations. * elf64-x86-64.c (elf_x86_64_size_dynamic_sections): Likewise. ld/testsuite/ PR ld/18801 * ld-i386/i386.exp: Run pr18801. * ld-x86-64/x86-64.exp: Likewise. * ld-i386/pr18801.d: New file. * ld-i386/pr18801.s: Likewise. * ld-x86-64/pr18801.d: Likewise. * ld-x86-64/pr18801.s: Likewise.
2015-08-13Add ChangeLog for check_ifunc_attribute_availableH.J. Lu1-0/+1
2015-08-12Set EI_OSABI to ELFOSABI_GNU for local IFUNC symbolsH.J. Lu6-0/+50
Since the backend elf_add_symbol_hook isn't called on local symbols, the EI_OSABI field isn't to ELFOSABI_GNU where are local IFUNC symbols. This patch changes the x86 backends to set has_gnu_symbols if there are relocations against IFUNC symbols. Other backends with IFUNC support may need a similar change. This patch also changes the type of has_gnu_symbols from bfd_boolean to enum elf_gnu_symbols. bfd/ PR ld/18815 * elf-bfd.h (elf_gnu_symbols): New enum. (elf_obj_tdata): Use elf_gnu_symbols on has_gnu_symbols. * elf-s390-common.c (elf_s390_add_symbol_hook): Set has_gnu_symbols to elf_gnu_symbol_any. * elf32-arm.c (elf32_arm_add_symbol_hook): Likewise. * elf32-m68k.c (elf_m68k_add_symbol_hook): Likewise. * elf32-ppc.c (ppc_elf_add_symbol_hook): Likewise. * elf32-sparc.c (elf32_sparc_add_symbol_hook): Likewise. * elf64-ppc.c (ppc64_elf_add_symbol_hook): Likewise. * elf64-sparc.c (elf64_sparc_add_symbol_hook): Likewise. * lfxx-aarch64.c (_bfd_aarch64_elf_add_symbol_hook): Likewise. * elf32-i386.c (elf_i386_check_relocs): Update has_gnu_symbols if there are relocations against IFUNC symbols. (elf_i386_add_symbol_hook): Don't check STT_GNU_IFUNC here. * elf64-x86-64. (elf_x86_64_check_relocs): Update has_gnu_symbols if there are relocations against IFUNC symbols. (elf_x86_64_add_symbol_hook): Don't check STT_GNU_IFUNC here. ld/testsuite/ PR ld/18815 * ld-i386/i386.exp: Run pr18815. * ld-x86-64/x86-64.exp: Likewise. * ld-i386/pr18815.d: New file. * ld-i386/pr18815.s: Likewise. * ld-x86-64/pr18815.d: Likewise. * ld-x86-64/pr18815.s: Likewise.
2015-08-12[MIPS] Map 'move' to 'or'.Simon Dardis30-71/+102
The MIPS assembly idiom 'move' now maps to the 'or' machine instruction. This change affects microMIPS, MIPS32, MIPS64. 2015-08-12 Simon Dardis <simon.dardis@imgtec.com> opcodes/ * micromips-opc.c (micromips_opcodes): Re-order table so that move based on 'or' is first. * mips-opc.c (mips_builtin_opcodes): Ditto. bfd/ * elfxx-mips.c (STUB_MOVE): Change to use 'or' only. (mips_o32_exec_plt0_entry, mips_n32_exec_plt0_entry, mips_n64_exec_plt0_entry, micromips_insn32_o32_exec_plt0_entry): Update to use 'or' instead of 'addu/daddu'. (_bfd_mips_elf_finish_dynamic_symbol): Update usage of STUB_MOVE. (move_insns_32): Reorder table. gas/ * config/tc-mips.c (move_register): Change to use 'or' only. (s_cpload, s_cpsetup, s_cprestore, s_cpreturn): Update to use or for move. gas/testsuite/ * gas/mips/elf-rel23.d: Update test. * gas/mips/elf-rel23.d: Ditto. * gas/mips/elf-rel23a.d: Ditto. * gas/mips/elf-rel23b.d: Ditto. * gas/mips/elf_e_flags1.d: Ditto. * gas/mips/elf_e_flags2.d: Ditto. * gas/mips/elf_e_flags3.d: Ditto. * gas/mips/elf_e_flags4.d: Ditto. * gas/mips/loc-swap-dis.d: Ditto. * gas/mips/micromips-insn32.d: Ditto. * gas/mips/micromips-noinsn32.d: Ditto. * gas/mips/micromips-trap.d: Ditto. * gas/mips/micromips.d: Ditto. * gas/mips/mips-abi32-pic.d: Ditto. * gas/mips/mips-abi32.d: Ditto. * gas/mips/mips-gp32-fp32-pic.d: Ditto. * gas/mips/mips-gp32-fp32.d: Ditto. * gas/mips/mips-gp32-fp64-pic.d: Ditto. * gas/mips/mips-gp32-fp64.d: Ditto. * gas/mips/mips-gp64-fp32-pic.d: Ditto. * gas/mips/mips-gp64-fp32.d: Ditto. * gas/mips/mips-gp64-fp64-pic.d: Ditto. * gas/mips/mips-gp64-fp64.d: Ditto. * gas/mips/mipsr6@loc-swap-dis.d: Ditto. * gas/mips/tls-o32.d: Ditto. * gas/mips/uld2-eb.d: Ditto. * gas/mips/uld2-el.d: Ditto. * gas/mips/ulw2-eb-ilocks.d: Ditto. * gas/mips/ulw2-eb.d: Ditto. * gas/mips/ulw2-el-ilocks.d: Ditto. * gas/mips/ulw2-el.d: Ditto. * gas/mips/move.d: New test. * gas/mips/move.s: Ditto. * gas/mips/micromips32-move.d: Ditto. * gas/mips/micromips32-move.s: Ditto. * gas/mips/mips.exp: Run the new tests. gold/ * mips.cc (plt0_entry_o32, plt0_entry_n32, plt0_entry_n64, lazy_stub_normal_1, lazy_stub_normal_1_n64, lazy_stub_normal_2, lazy_stub_normal_2_n64, lazy_stub_big, lazy_stub_big_n64, lazy_stub_micromips32_normal_1_n64, lazy_stub_micromips32_normal_2_n64, lazy_stub_micromips32_big, lazy_stub_micromips32_big_n64): Update to use 'or' for move instead of 'addu/daddu'. ld/testsuite/ * ld-mips-elf/compressed-plt-1-n32-mips16.od: Update test. * ld-mips-elf/compressed-plt-1-n32-umips.od: Ditto. * ld-mips-elf/compressed-plt-1-o32-mips16-got.od: Ditto. * ld-mips-elf/compressed-plt-1-o32-mips16-only.od: Ditto. * ld-mips-elf/compressed-plt-1-o32-mips16-word.od: Ditto. * ld-mips-elf/compressed-plt-1-o32-mips16.od: Ditto. * ld-mips-elf/compressed-plt-1-o32-se.od: Ditto. * ld-mips-elf/compressed-plt-1-o32-umips-got.od: Ditto. * ld-mips-elf/compressed-plt-1-o32-umips-word.od: Ditto. * ld-mips-elf/compressed-plt-1-o32-umips.od: Ditto. * ld-mips-elf/jalx-2.dd: Ditto. * ld-mips-elf/mips16-pic-3.dd: Ditto. * ld-mips-elf/pic-and-nonpic-3a.dd: Ditto. * ld-mips-elf/pic-and-nonpic-3b.dd: Ditto. * ld-mips-elf/pic-and-nonpic-5b.dd: Ditto. * ld-mips-elf/pic-and-nonpic-6-n32.dd: Ditto. * ld-mips-elf/pic-and-nonpic-6-o32.dd: Ditto. * ld-mips-elf/stub-dynsym-1-10000.d: Ditto. * ld-mips-elf/stub-dynsym-1-2fe80.d: Ditto. * ld-mips-elf/stub-dynsym-1-7fff.d: Ditto. * ld-mips-elf/stub-dynsym-1-8000.d: Ditto. * ld-mips-elf/stub-dynsym-1-fff0.d: Ditto. * ld-mips-elf/tlsbin-o32.d: Ditto. * ld-mips-elf/tlsdyn-o32-1.d: Ditto. * ld-mips-elf/tlsdyn-o32-2.d: Ditto. * ld-mips-elf/tlsdyn-o32-3.d: Ditto. * ld-mips-elf/tlsdyn-o32.d: Ditto. * ld-mips-elf/tlslib-o32.d: Ditto.
2015-08-12Remove ChangeLog separatorAlan Modra1-1/+1
2015-08-12[AArch64] Fix test failures on elf configurationJiong Wang6-29/+47
This patch fixed those failures on elf configuration by: * Improve the ILP32 target selector "aarch64_choose_ilp32_emul", makes it more robust. Target triples copied from configure.tgt * Updated emit-relocs-86/-overflow.d to use aarch64_choose_ilp32_emul which is following what have done with emit-relocs-28. * Those instruction encoding mismatch is because those encoding contains pc-relative address. As for elf, we may have different start address. relaxed encodind check, especially for aarch64-farcall-b/bl-plt, as the main purpose of those check are ELF text/data layout, we just want to make sure veneer to plt stub is generated. 2015-08-12 Jiong Wang <jiong.wang@arm.com> ld/testsuite/ * ld-aarch64/aarch64-elf.exp (aarch64_choose_ilp32_emul): Support all four triple shapes: aarch64-*-linux*, aarch64-*-elf, aarch64_be-*-linux*, aarch64_be-*-elf. * ld-aarch64/emit-relocs-86.d: Use aarch64_choose_ilp32_emul. * ld-aarch64/emit-relocs-86-overflow.d: Likewise. * ld-aarch64/ld-aarch64/farcall-b-plt.d: Relax instrucion encoding check when they reflect address. * ld-aarch64/ld-aarch64/farcall-bl-plt.d: Likewise.
2015-08-12Remove trailing spaces in ldH.J. Lu6-54/+54
2015-08-12[AArch64] Rename relocs-257-symbolic-func ld test to relocs-1027-symbolic-func.Thomas Preud'homme4-2/+11
2015-08-12 Thomas Preud'homme <thomas.preudhomme@arm.com> ld/testsuite/ * ld-aarch64/aarch64-elf.exp: Rename relocs-257-symbolic-func to relocs-1027-symbolic-func. * ld-aarch64/relocs-257-symbolic-func.d: Rename to ... * ld-aarch64/relocs-1027-symbolic-func.d: ... this. * ld-aarch64/relocs-257-symbolic-func.s: Rename to ... * ld-aarch64/relocs-1027-symbolic-func.s: ... this.
2015-08-11[AArch64] Commit missing testcasesJiong Wang4-0/+56
2015-08-11[AArch64] Long branch veneer support far symbol defined by --defsymJiong Wang2-0/+9
2015-08-11 Jiong Wang <jiong.wang@arm.com> bfd/ * bfd/elfnn-aarch64.c (aarch64_type_of_stub): New parameter "sym_sec". Loose the check for symbol from ABS section. (elfNN_aarch64_size_stubs): Pass sym_sec. ld/testsuite/ * ld-aarch64/farcall-b-defsym.s: New test. * ld-aarch64/farcall-bl-defsym.s: Likewise. * ld-aarch64/farcall-b-defsym.d: New expectation. * ld-aarch64/farcall-bl-defsym.d: Likewise.
2015-08-11[AArch64] PR18668, repair long branch veneer for plt stubJiong Wang8-0/+133
2015-08-11 Jiong Wang <jiong.wang@arm.com> bfd/ PR ld/18668 * elfnn-aarch64.c (aarch64_type_of_stub): Update destination for calls go through plt stub. (elfNN_aarch64_final_link_relocate): Adjust code logic for CALL26, JUMP26 relocation to support inserting veneer for call to plt stub. ld/testsuite/ * ld-aarch64/farcall-b-gsym.s: New test. * ld-aarch64/farcall-b-plt.s: Likewise. * ld-aarch64/farcall-bl-plt.s: Likewise. * ld-aarch64/farcall-b-gsym.d: New expect file. * ld-aarch64/farcall-b-plt.d: Likewise. * ld-aarch64/farcall-bl-plt.d: Likewise.
2015-08-11[AArch64][8/8] LD support BFD_RELOC_AARCH64_TLSLD_ADD_DTPREL_LO12Jiong Wang10-0/+82
2015-08-11 Jiong Wang <jiong.wang@arm.com> bfd/ * elfnn-aarch64.c (IS_AARCH64_TLS_RELOC): Recognize BFD_RELOC_AARCH64_TLSLD_ADD_DTPREL_LO12. (aarch64_reloc_got_type): Likewise. (elfNN_aarch64_final_link_relocate): Likewise. (elfNN_aarch64_relocate_section): Likewise. * elfxx-aarch64.c (_bfd_aarch64_elf_put_addend): Likewise. (_bfd_aarch64_elf_resolve_relocation): Likewise. ld/testsuite/ * ld-aarch64/emit-relocs-529.s: New testcase. * ld-aarch64/emit-relocs-529-overflow.s: Likewise. * ld-aarch64/emit-relocs-86.s: Likewise. * ld-aarch64/emit-relocs-86-overflow.s: Likewise. * ld-aarch64/emit-relocs-529.d: New expectation file. * ld-aarch64/emit-relocs-529-overflow.d: Likewise. * ld-aarch64/emit-relocs-86.d: Likewise. * ld-aarch64/emit-relocs-86-overflow.d: Likewise. * ld-aarch64/aarch64-elf.exp: Run new testcases.
2015-08-11[AArch64][6/8] LD support BFD_RELOC_AARCH64_TLSLD_ADD_LO12_NCJiong Wang2-1/+6
2015-08-11 Jiong Wang <jiong.wang@arm.com> bfd/ * elfnn-aarch64.c (IS_AARCH64_TLS_RELOC): Recognize BFD_RELOC_AARCH64_TLSLD_ADD_LO12_NC. (aarch64_reloc_got_type): Likewise. (elfNN_aarch64_final_link_relocate): Likewise. (elfNN_aarch64_relocate_section): Likewise. (elfNN_aarch64_gc_sweep_hook): Likewise. (elfNN_aarch64_check_relocs): Likewise. * elfxx-aarch64.c (_bfd_aarch64_elf_put_addend): Likewise. (_bfd_aarch64_elf_resolve_relocation): Likewise. ld/testsuite/ * ld-aarch64/tls-small-ld.s: Update testcase.
2015-08-11[AArch64][3/8] LD support BFD_RELOC_AARCH64_TLSLD_ADR_PAGE21Jiong Wang4-0/+23
2015-08-11 Jiong Wang <jiong.wang@arm.com> bfd/ * elfnn-aarch64.c (IS_AARCH64_TLS_RELOC): Recognize BFD_RELOC_AARCH64_TLSLD_ADR_PAGE21. (aarch64_reloc_got_type): Likewise. (elfNN_aarch64_final_link_relocate): Likewise. (elfNN_aarch64_relocate_section): Likewise. (elfNN_aarch64_gc_sweep_hook): Likewise. (elfNN_aarch64_check_relocs): Likewise. * elfxx-aarch64.c (_bfd_aarch64_elf_put_addend): Likewise. (_bfd_aarch64_elf_resolve_relocation): Likewise. ld/testsuite/ * ld-aarch64/tls-small-ld.s: New file. * ld-aarch64/tls-small-ld.d: Likewise. * ld-aarch64/aarch64-elf.exp: Run new test.
2015-08-11Skip IFUNC relocations in debug sectionsH.J. Lu6-0/+114
Skip IFUNC relocations in debug sections ignored by ld.so. bfd/ PR ld/18808 * elf32-i386.c (elf_i386_relocate_section): Skip IFUNC relocations in debug sections. * elf64-x86-64.c (elf_x86_64_relocate_section): Likewise. ld/testsuite/ PR ld/18808 * ld-ifunc/ifunc.exp: Add a test for PR ld/18808. * ld-ifunc/pr18808.out: New file. * ld-ifunc/pr18808a.c: Likewise. * ld-ifunc/pr18808b.c: Likewise.
2015-08-07Properly merge hidden versioned symbolH.J. Lu6-1/+88
The hidden versioned symbol can only be merged with the versioned symbol with the same symbol version. _bfd_elf_merge_symbol should check the symbol version before merging the new hidden versioned symbol with the existing symbol. _bfd_elf_link_hash_copy_indirect can't copy any references to the hidden versioned symbol. We need to bind a symbol locally when linking executable if it is locally defined, hidden versioned, not referenced by shared library and not exported. bfd/ PR ld/18720 * elflink.c (_bfd_elf_merge_symbol): Add a parameter to indicate if the new symbol matches the existing one. The new hidden versioned symbol matches the existing symbol if they have the same symbol version. Update the existing symbol only if they match. (_bfd_elf_add_default_symbol): Update call to _bfd_elf_merge_symbol. (_bfd_elf_link_assign_sym_version): Don't set the hidden field here. (elf_link_add_object_symbols): Override a definition only if the new symbol matches the existing one. (_bfd_elf_link_hash_copy_indirect): Don't copy any references to the hidden versioned symbol. (elf_link_output_extsym): Bind a symbol locally when linking executable if it is locally defined, hidden versioned, not referenced by shared library and not exported. Turn on VERSYM_HIDDEN only if the hidden vesioned symbol is defined locally. ld/testsuite/ PR ld/18720 * ld-elf/indirect.exp: Run tests for PR ld/18720. * ld-elf/pr18720.out: New file. * ld-elf/pr18720a.c: Likewise. * ld-elf/pr18720b.c: Likewise. * ld-elf/pr18720c.c: Likewise.
2015-08-06Revert ALIGN changesAlan Modra4-52/+43
Reverts a2c59f28 and e474ab13. Since the unary form of ALIGN only references "dot" implicitly, there isn't really a strong argument for making ALIGN use a relative value when inside an output section. * ldexp.c (align_dot_val): Delete. (fold_unary <ALIGN_K, NEXT>): Revert 2015-07-10 change. (is_align_conditional): Revert 2015-07-20 change. (exp_fold_tree_1): Likewise, but keep expanded comment. * scripttempl/elf.sc (.ldata, .bss): Revert 2015-07-20 change. * ld.texinfo (<ALIGN>): Correct description.
2015-08-04ld: map option for run_dump_test requires no program.Andrew Burgess2-0/+10
When using run_dump_test with the map option to compare the linker map file produced, no additional dump program should be required. A dump program can still be given if needed, but leaving it off will no longer produce an error. ld/testsuite/ChangeLog: * ld/ld-lib.exp (run_dump_test): When using the map option, no program is required.
2015-08-04ld: Add file based error/warning regexp for run_dump_test.Andrew Burgess2-17/+78
The run_dump_test mechanism supports options error and warning, which allow regexp to be specified within the test file, these regexp are matched against the stderr output from the linker. Similar dump test style functions for gas and gdb also support file based matching versions of these options; the patterns are placed into a file which the test driver then references. It is sometimes clearer, when the pattern to be matched spans multiple lines if the patterns can be placed into a separate file. This patch adds new options error_output and warning_output for the linker run_dump_test function. These new options take a filename parameter, this file is then used (with regexp_diff) to compare against the linker output. ld/testsuite/ChangeLog: * ld/ld-lib.exp (run_dump_test): Add error_output and warning_output options.
2015-08-04ld: Add '--require-defined' command line option.Andrew Burgess15-0/+209
Add a new command line option '--require-defined' to the linker. This option operates identically to the '--undefined' option, except that if the symbol is not defined in the final output file then the linker will exit with an error. When making use of --gc-section, or just when trying to pull in parts of a library, it is not uncommon for a user to use the '--undefined' command line option to specify a symbol that the user then expects to be defined by one of the object files supplied to the link. However, if for any reason the symbol is not satisfied by an object provided to the link the user will be left with an undefined symbol in the output file, instead of a defined symbol. In some cases the above behaviour is what the user wants, in other cases though we can do better. The '--require-defined' option tries to fill this gap. The symbol passed to the '--require-defined' option is treated exactly as if the symbol was passed to '--undefined', however, before the linker exits a check is made that all symbols passed to '--require-defined' are actually defined, if any are not then the link will fail with an error. ld/ChangeLog: * ld.texinfo (Options): Document --require-defined option. * ldlang.c (struct require_defined_symbol): New structure. (require_defined_symbol_list): New variable. (ldlang_add_require_defined): New function. (ldlang_check_require_defined_symbols): New function. (lang_process): Check required symbols are defined. * ldlang.h (ldlang_add_require_defined): Declare. * ldlex.h (enum option_values): Add OPTION_REQUIRE_DEFINED_SYMBOL. * lexsup.c (ld_options): Add '--require-defined' entry. (parse_args): Handle '--require-defined' entry. * NEWS: Mention new '--require-defined' option. ld/testsuite/ChangeLog: * ld-undefined/require-defined-1.d: New file. * ld-undefined/require-defined-2.d: New file. * ld-undefined/require-defined-3.d: New file. * ld-undefined/require-defined-4.d: New file. * ld-undefined/require-defined-5.d: New file. * ld-undefined/require-defined.exp: New file. * ld-undefined/require-defined.s: New file.
2015-08-03ld/doc: Document that multiple MEMORY commands are allowed.Andrew Burgess2-3/+9
The linker documentation explicitly states that there can be only one MEMORY command. This is not true. Multiple MEMORY commands are allowed, the contents of all will be treated as if a single MEMORY command was given. Update the documentation to make this clear to the users. ld/ChangeLog: * ld.texinfo (MEMORY): Explain that multiple MEMORY commands are acceptable.
2015-07-30Don't change the default symbol for relocatable linkH.J. Lu3-0/+29
We should change the default symbol for the versioned symbol only when not performing a relocatable link. bfd/ PR ld/18735 * elflink.c (_bfd_elf_add_default_symbol): Add the default symbol if not performing a relocatable link. (elf_link_add_object_symbols): Adjust the default symbol if not performing a relocatable link. ld/testsuite/ PR ld/18735 * ld-elf/pr18735.d: New file. * ld-elf/pr18735.s: Likewise.
2015-07-29Use noclone attribute only for GCC 4.5 or newerH.J. Lu2-0/+9
noclone attribute was added to GCC 4.5. We should check GCC version before using it. * ld-elf/pr18718.c (bar): Use noclone attribute only for GCC 4.5 or newer.
2015-07-29Move run-time support check for size relocationH.J. Lu2-14/+18
We must check run-time support for size relocation first before running the tests. * ld-size/size.exp: Move run-time support check.
2015-07-29Don't set link_info.executable for "ld -r"H.J. Lu2-1/+6
This patch changes "ld -r" not to set link_info.executable. It removes !info->relocatable check for info->executable and adds it for !info->executable in elflink.c. bfd/ * elflink.c (elf_link_add_object_symbols): Remove !info->relocatable check for info->executable. Add !info->relocatable check for !info->executable. (elf_link_output_extsym): Remove !info->relocatable check for info->executable. ld/ * lexsup.c (parse_args): Don't set link_info.executable to TRUE for link_info.relocatable.
2015-07-28Fallout from "Reorder more powerpc64 sections for -z relro"Alan Modra2-9/+13
Commit 23283c1b changed the layout of some bss style sections on powerpc64, but neglected to add a page gap before the third PT_LOAD segment created by this reording. Without a page gap we get two PT_LOAD headers that overlap by one page in memory. That shouldn't be allowed because the dynamic loader will load garbage from the first page of the last segment over the last page of the previous segment. bfd/ * elf.c (_bfd_elf_map_sections_to_segments): Do not make a new segment for loaded sections after nonloaded sections if the sections are on the same page. ld/testsuite/ * ld-powerpc/elfv2so.d: Update
2015-07-27Set NOPIE_CFLAGS and NOPIE_LDFLAGSH.J. Lu3-94/+276
GCC 6 can be configured to generate PIE by default. But some linker size tests expect non-PIE. This patch defines NOPIE_CFLAGS to "-fno-PIE" and NOPIE_LDFLAGS to "-no-pie" if target compiler supports them. Add $NOPIE_CFLAGS and $NOPIE_LDFLAGS to linker size tests if needed. * config/default.exp (NOPIE_CFLAGS): New. (NOPIE_LDFLAGS): Likewise. * ld-size/size.exp (run_cc_link_tests): Add $NOPIE_CFLAGS and $NOPIE_LDFLAGS if needed. (run_ld_link_exec_tests): Add $NOPIE_CFLAGS if needed.
2015-07-27Check address of versined symbolH.J. Lu3-5/+19
Since GCC 5 folds symbol address comparison, assuming each symbol has a different address, &foo == &bar is always false for GCC 5. This patch adds check_ptr_eq if 2 addresses are the same and uses it to check the address of versined symbol. PR ld/18718 * ld-elf/check-ptr-eq.c: New file. * ld-elf/pr18718.c (main): Call check_ptr_eq. * ld-elf/shared.exp: Add check-ptr-eq.c to PR ld/18718 tests.
2015-07-27Regenerate configure filesH.J. Lu2-2/+6
bfd/ * configure: Regenerated. binutils/ * configure: Regenerated. gas/ * configure: Regenerated. gold/ * configure: Regenerated. gprof/ * configure: Regenerated. ld/ * configure: Regenerated. opcodes/ * configure: Regenerated.
2015-07-27Append $PLT_CFLAGS to CC/CXX for S-records testsH.J. Lu2-0/+22
S-records tests don't work with -fno-plt. This path appends $PLT_CFLAGS to CC and CXX for S-records tests. * ld-srec/srec.exp (CC): Save and restore. Append $PLT_CFLAGS. (CXX): Likewise.
2015-07-27Pass $PLT_CFLAGS to ld_compileH.J. Lu2-3/+8
Some linker shard library tests without PIC expect PLT. This patch passes $PLT_CFLAGS to ld_compile. * ld-shared/shared.exp: Pass $PLT_CFLAGS to ld_compile.
2015-07-27Append $PLT_CFLAGS to CC for NOCROSSREFS testsH.J. Lu2-0/+15
NOCROSSREFS tests don't work with -fno-plt. This path appends $PLT_CFLAGS to CC for NOCROSSREFS tests. * ld-scripts/crossref.exp (CC): Save and restore. Append $PLT_CFLAGS.
2015-07-27Add $PLT_CFLAGS to -fPIC for run_cc_link_testsH.J. Lu4-25/+69
Some x86 linker tests expect PLT. This patch adds $PLT_CFLAGS to -fPIC for run_cc_link_tests. * ld-i386/i386.exp (run_cc_link_tests): Add $PLT_CFLAGS to -fPIC if needed. * ld-x86-64/mpx.exp (run_cc_link_tests): Likewise. * ld-x86-64/x86-64.exp (run_cc_link_tests): Likewise.
2015-07-27Pass $PLT_CFLAGS to ld_compileH.J. Lu2-5/+12
Some linker visibility tests without PIC expect PLT. This patch passes $PLT_CFLAGS to ld_compile. * ld-elfvsb/elfvsb.exp (visibility_run): Pass $PLT_CFLAGS to ld_compile.
2015-07-27Pass $PLT_CFLAGS to build_binaryH.J. Lu2-1/+8
Some linker symbol version tests without PIC expect PLT. This patch adds $PLT_CFLAGS to CFLAGS. * ld-elfvers/vers.exp (build_vers_lib_no_pic): Pass $PLT_CFLAGS to build_binary.
2015-07-27Set PLT_CFLAGS to "-fplt" if supportedH.J. Lu2-0/+39
GCC 6 supports -fno-plt. But some linker tests expect PLT. This patch defines PLT_CFLAGS to "-fplt" if target compiler supports it. * config/default.exp (PLT_CFLAGS): New.
2015-07-27[AArch64] Fix extern protected data handlingSzabolcs Nagy4-0/+30
Emit *GLOB_DAT instead of *RELATIVE relocs for protected data in shared objects. This is needed for the fix of glibc bug 17711: https://sourceware.org/bugzilla/show_bug.cgi?id=17711 bfd: PR ld/18705 * elfnn-aarch64.c (elf_backend_extern_protected_data): Define. ld/testsuite: PR ld/18705 * ld-aarch64/protected-data.d: New. * ld-aarch64/protected-data.s: New. * ld-aarch64/aarch64-elf.exp: Add new test.
2015-07-27[ARM] Fix extern protected data handlingSzabolcs Nagy4-0/+41
Emit *GLOB_DAT instead of *RELATIVE relocs for protected data in shared objects. This is needed for the fix of glibc bug 17711: https://sourceware.org/bugzilla/show_bug.cgi?id=17711 bfd: PR ld/18705 * elf32-arm.c (elf_backend_extern_protected_data): Define. ld/testsuite: PR ld/18705 * ld-arm/protected-data.d: New. * ld-arm/protected-data.s: New. * ld-arm/arm-elf.exp: Add new test.
2015-07-26Compile PR ld/18718 tests with -O2H.J. Lu2-5/+10
PR ld/18718 * ld-elf/shared.exp: Compile PR ld/18718 tests with -O2.
2015-07-26Set errcnt and warncnt to 0 in run_host_cmd_yesnoH.J. Lu2-0/+9
run_host_cmd_yesno should set errcnt and warncnt to 0. Otherwise, they may leak to the next run. * lib/ld-lib.exp (run_host_cmd_yesno): Set errcnt and warncnt to 0.
2015-07-25Add missing ChangeLog filesH.J. Lu1-0/+6
2015-07-25Skip missing symbol version section check for executableH.J. Lu2-0/+71
Missing symbol version section is a run-time problem only if it will be referenced dynamically at run-time. We should skip the check for locally defined symbol, which isn't referenced by shared library, when linking executable. bfd/ PR ld/18718 * elflink.c (elf_link_output_extsym): Check symbol version section check only if not linking executable, the symbol is referenced by shared library or not locally defined. ld/testsuite/ PR ld/18718 * ld-elf/pr18718.c: New file. * ld-elf/shared.exp: Run tests for PR ld/18718.
2015-07-25Fix broken -Bsymbolic-functionsAlan Modra4-1/+46
For selected targets. The testcase reveals a number of targets that still need fixing. bfd/ * elf32-arm.c (elf32_arm_final_link_relocate): Use SYMBOLIC_BIND to check if a symbol should be bound symbolically. * elf32-hppa.c (elf32_hppa_check_relocs, elf32_hppa_adjust_dynamic_symbol, elf32_hppa_relocate_section, elf32_hppa_finish_dynamic_symbol): Likewise. * elf32-m68k.c (elf_m68k_check_relocs, elf_m68k_relocate_section): Likewise. * elf32-nios2.c (nios2_elf32_relocate_section, nios2_elf32_check_relocs, allocate_dynrelocs): Likewise. * elf32-tic6x.c (elf32_tic6x_finish_dynamic_symbol, elf32_tic6x_relocate_section): Likewise. ld/testsuite/ * ld-elf/symbolic-func.s, * ld-elf/symbolic-func.r: New test. * ld-elf/elf.exp: Run it.
2015-07-24Fix the evaluation of RL78 complex relocs, by making immediate values be ↵Nick Clifton2-2/+8
computed relative to a new absolute symbol. gas * config/tc-rl78.c (rl78_abs_sym): New local variable. (md_begin): Initialise the new symbol. (OPIMM): Define the value to be relative to the new symbol and not the absolute section symbol. ld * emulparams/elf32rl78.sh (OTHER_SECTIONS): Provide a value for the _-rl78_abs__ symbol. tests * gas/all/struct.d: Allow for extra symbols in the output. * gas/macros/test1.d: Likewise. * gas/elf/elf.exp: Add an rl78 machine. * gas/elf/sections2e-rl78: New file. tests * binutils-all/localize-hidden-1.d: Allow for extra symbols in the output. * binutils-all/strip-11.d: Skip for the RL78.
2015-07-24Replace -g with -ggdb3 in ld compress testsH.J. Lu4-12/+18
Use -ggdb3 to generate .debug_macro sections, which are bigger and are always compressed. * ld-elf/compress.exp (build_tests): Replace -g with -ggdb3. * ld-elf/zlibbegin.rS: Also expect "GC". * ld-elf/zlibnormal.rS: Likewise.
2015-07-24Remove leading/trailing white spaces in ChangeLogH.J. Lu1-12/+12