aboutsummaryrefslogtreecommitdiff
path: root/ld
AgeCommit message (Collapse)AuthorFilesLines
2014-02-26Resolve PR ld/16569 by emitting (and comparing) unmangled names, unlessDan Mick2-9/+31
demangling has specifically been requested.
2014-02-21Add file missed from last commit.Alan Modra1-0/+7
2014-02-21Add ppc476 workaround bootstrap testAlan Modra2-2/+15
I was running this by hand to test out --ppc476-workaround. Another bootstrap test doesn't take all that long, so let's add it to the testsuite. * ld-bootstrap/bootstrap.exp: Add ppc476 workaround test. * ld-bootstrap/ppc476.t: New file.
2014-02-19Create the second PLT for BND relocationsH.J. Lu7-0/+95
Intel MPX introduces 4 bound registers, which will be used for parameter passing in x86-64. Bound registers are cleared by branch instructions. Branch instructions with BND prefix will keep bound register contents. This leads to 2 requirements to 64-bit MPX run-time: 1. Dynamic linker (ld.so) should save and restore bound registers during symbol lookup. 2. Change the current 16-byte PLT0: ff 35 08 00 00 00 pushq GOT+8(%rip) ff 25 00 10 00 jmpq *GOT+16(%rip) 0f 1f 40 00 nopl 0x0(%rax) and 16-byte PLT1: ff 25 00 00 00 00 jmpq *name@GOTPCREL(%rip) 68 00 00 00 00 pushq $index e9 00 00 00 00 jmpq PLT0 which clear bound registers, to preserve bound registers. We use 2 new relocations: to mark branch instructions with BND prefix. When linker sees any R_X86_64_PC32_BND or R_X86_64_PLT32_BND relocations, it switches to a different PLT0: ff 35 08 00 00 00 pushq GOT+8(%rip) f2 ff 25 00 10 00 bnd jmpq *GOT+16(%rip) 0f 1f 00 nopl (%rax) to preserve bound registers for symbol lookup and it also creates an external PLT section, .pl.bnd. Linker will create a BND PLT1 entry in .plt: 68 00 00 00 00 pushq $index f2 e9 00 00 00 00 bnd jmpq PLT0 0f 1f 44 00 00 nopl 0(%rax,%rax,1) and a 8-byte BND PLT entry in .plt.bnd: f2 ff 25 00 00 00 00 bnd jmpq *name@GOTPCREL(%rip) 90 nop Otherwise, linker will create a legacy PLT1 entry in .plt: 68 00 00 00 00 pushq $index e9 00 00 00 00 jmpq PLT0 66 0f 1f 44 00 00 nopw 0(%rax,%rax,1) and a 8-byte legacy PLT in .plt.bnd: ff 25 00 00 00 00 jmpq *name@GOTPCREL(%rip) 66 90 xchg %ax,%ax The initial value of the GOT entry for "name" will be set to the the "pushq" instruction in the corresponding entry in .plt. Linker will resolve reference of symbol "name" to the entry in the second PLT, .plt.bnd. Prelink stores the offset of pushq of PLT1 (plt_base + 0x10) in GOT[1] and GOT[1] is stored in GOT[3]. We can undo prelink in GOT by computing the corresponding the pushq offset with GOT[1] + (GOT offset - &GOT[3]) * 2 Since for each entry in .plt except for PLT0 we create a 8-byte entry in .plt.bnd, there is extra 8-byte per PLT symbol. We also investigated the 16-byte entry for .plt.bnd. We compared the 8-byte entry vs the the 16-byte entry for .plt.bnd on Sandy Bridge. There are no performance differences in SPEC CPU 2000/2006 as well as micro benchmarks. Pros: No change to undo prelink in dynamic linker. Only 8-byte memory overhead for each PLT symbol. Cons: Extra .plt.bnd section is needed. Extra 8 byte for legacy branches to PLT. GDB is unware of the new layout of .plt and .plt.bnd. bfd/ * elf64-x86-64.c (elf_x86_64_bnd_plt0_entry): New. (elf_x86_64_legacy_plt_entry): Likewise. (elf_x86_64_bnd_plt_entry): Likewise. (elf_x86_64_legacy_plt2_entry): Likewise. (elf_x86_64_bnd_plt2_entry): Likewise. (elf_x86_64_bnd_arch_bed): Likewise. (elf_x86_64_link_hash_entry): Add has_bnd_reloc and plt_bnd. (elf_x86_64_link_hash_table): Add plt_bnd. (elf_x86_64_link_hash_newfunc): Initialize has_bnd_reloc and plt_bnd. (elf_x86_64_copy_indirect_symbol): Also copy has_bnd_reloc. (elf_x86_64_check_relocs): Create the second PLT for Intel MPX in 64-bit mode. (elf_x86_64_allocate_dynrelocs): Handle the second PLT for IFUNC symbols. Resolve call to the second PLT if it is created. (elf_x86_64_size_dynamic_sections): Keep the second PLT section. (elf_x86_64_relocate_section): Resolve PLT references to the second PLT if it is created. (elf_x86_64_finish_dynamic_symbol): Use BND PLT0 and fill the second PLT entry for BND relocation. (elf_x86_64_finish_dynamic_sections): Use MPX backend data if the second PLT is created. (elf_x86_64_get_synthetic_symtab): New. (bfd_elf64_get_synthetic_symtab): Likewise. Undefine for NaCl. ld/ * emulparams/elf_x86_64.sh (TINY_READONLY_SECTION): New. ld/testsuite/ * ld-x86-64/mpx.exp: Run bnd-ifunc-1 and bnd-plt-1. * ld-x86-64/bnd-ifunc-1.d: New file. * ld-x86-64/bnd-ifunc-1.s: Likewise. * ld-x86-64/bnd-plt-1.d: Likewise.
2014-02-19Control powerpc64-ld provision of register save/restoreAlan Modra2-2/+32
This patch allows the user to override powerpc64-ld's default for providing linker generated register save and restore functions as used by gcc -Os code. Normally these are not provided by ld -r, so Linux kernel modules have needed to include their own copies. bfd/ * elf64-ppc.h (struct ppc64_elf_params): Add save_restore_funcs. * elf64-ppc.c (ppc64_elf_func_desc_adjust): Use it to control provision of out-of-line register save/restore routines. ld/ * emultempl/ppc64elf.em (params): Init new field. (ppc_create_output_section_statements): Set params.save_restore_funcs default. (PARSE_AND_LIST_*): Add support for --save-restore-funcs and --no-save-restore-funcs.
2014-02-18The PT_DYNAMIC segment was being hard coded to have read, write, andJack Carter2-1/+5
execute permission regardless of the underlying PT_LOAD segment permissions. Deleting this code allows the default linker behavior which is to set the dynamic segment to the same permissions as the sections that make it up. This change alters one existing test case to check the segment flags for PT_DYNAMIC. bfd/ChangeLog * elfxx-mips.c(_bfd_mips_elf_modify_segment_map): Deleted hard coding of PT_DYNAMIC segment flags. ld/testsuite/ChangeLog * ld-mips-elf/pic-and-nonpic-3a.sd: Check DYNAMIC segment flags.
2014-02-17Consolidate ppc64 ld/bfd communicationAlan Modra2-50/+39
Moves assorted variables used to communicate between ld and bfd into a struct, hooks it into the bfd link_hash_table early, and removes all other places where such variables were passed piecemeal. bfd/ * elf64-ppc.h (struct ppc64_elf_params): Define. (ppc64_elf_init_stub_bfd, ppc64_elf_edit_opd, ppc64_elf_tls_setup, ppc64_elf_setup_section_lists, ppc64_elf_size_stubs, ppc64_elf_build_stubs): Update prototype. * elf64-ppp.c (struct ppc_link_hash_table): Add params, delete other fields now in params. Adjust code throughout file. (ppc64_elf_init_stub_bfd): Delete "abfd" parameter, add "params". Save params pointer in htab. (ppc64_elf_edit_opd, ppc64_elf_tls_setup, ppc64_elf_setup_section_lists, ppc64_elf_size_stubs, ppc64_elf_build_stubs): Remove parameters now in "params". ld/ * emultemps/ppc64elf.em (params): New static struct replacing various other static vars. Adjust code throughout file.
2014-02-17ppc476 workaround for ld -r fixesAlan Modra2-2/+5
This fixes the glaring error that the ppc476 workaround wasn't actually enabled for ld -r, and adjusts relocations to match moved code. bfd/ * elf32-ppc.c (ppc_elf_relocate_section): Move relocs on insns patched for ppc476 workaround. Reapply branch taken/not taken relocs. ld/ * emultempl/ppc32elf.em (ppc_after_open_output): Really enable ppc476 workaround for ld -r.
2014-02-16Missing ChangeLog entry from commit 60ef20e28534cf093d5bd799b3830c68381bb27f.Thomas Schwinge1-0/+5
2014-02-16ld: Remove Hurd-specific XFAILs related to weak symbols.Thomas Schwinge1-17/+0
This has been fixed properly, in glibc. ld/testsuite/ * ld-elfweak/elfweak.exp (setup_xfail_gnu_hurd): Remove function and all usage of it.
2014-02-12Enable ppc476 workaround for ld -r.Alan Modra2-5/+14
The Linux kernel builds modules using ld -r. These might need the ppc476 workaround, so enable it for ld -r if sections have sufficient alignment to tell location within a page. bfd/ * elf32-ppc.c (ppc_elf_relax_section): Enable ppc476 workaround for ld -r, when code sections are sufficiently aligned. * elf32-ppc.h (struct ppc_elf_params): Delete pagesize. Add pagesize_p2. ld/ * emultempl/ppc32elf.em (pagesize): New static var. (ppc_after_open_output): Set params.pagesize_p2 from pagesize. (PARSE_AND_LIST_ARGS_CASES): Adjust to use pagesize.
2014-02-112014-02-11 Andrew Pinski <apinski@cavium.com>Andrew Pinski3-1/+10
* emulparams/aarch64linux32.sh (LIBPATH_SUFFIX): Change to ilp32. (ELF_INTERPRETER_NAME): Define. * emulparams/aarch64linux32b.sh (ELF_INTERPRETER_NAME): Define.
2014-02-10Mark symbol in executables if it matches dynamic_listH.J. Lu5-0/+30
bfd/ PR gold/16530 * elflink.c (bfd_elf_gc_mark_dynamic_ref_symbol): Mark symbol in executables if it matches dynamic_list. ld/testsuite/ PR gold/16530 * ld-elf/dynamic-1.c: New file. * ld-elf/dynamic-1.rd: Likewise. * ld-elf/dynamic-1.syms: Likewise. * ld-elf/shared.exp (build_tests): Add dynamic-1.
2014-02-10binutils potfiles regenAlan Modra2-497/+543
Adds nds32 files to POTFILES.in
2014-02-03ppc476 icache bug workaroundAlan Modra2-21/+70
This implements a work-around for an icache bug on 476 that can cause execution of stale instructions when control falls through from one page to the next. The idea is to prevent such fall-through by replacing the last instruction on a page with a branch to a patch area containing the instruction, then branch to the next page. The patch also fixes a number of bugs in the existing support for long branch trampolines. bfd/ * elf32-ppc.c (struct ppc_elf_link_hash_table): Add params. Delete emit_stub_syms, no_tls_get_addr_opt. Update all uses. (ppc_elf_link_params): New function. (ppc_elf_create_glink): Align .glink to 64 bytes for ppc476 workaround. (ppc_elf_select_plt_layout): Remove plt_style and emit_stub_syms parameters. Use htab->params instead. (ppc_elf_tls_setup): Remove no_tls_get_addr_opt parameter. (ppc_elf_size_dynamic_sections): Align __glink_PLTresolve to 64 bytes for ppc476 workaround. (struct ppc_elf_relax_info): New. (ppc_elf_relax_section): Exclude linker created sections and those too small to hold one instruction. Don't add another branch around trampolines on later relax passes. Don't generate trampolines for undefined symbols when !relocatable, nor for plugin symbols. Allocate space for ppc476 workaround patch area. Free fixups on error return path. (ppc_elf_relocate_section): Handle ppc476 workaround patching. * elf32-ppc.h (struct ppc_elf_params): New. (ppc_elf_select_plt_layout, ppc_elf_tls_setup): Update prototype. (ppc_elf_link_params): Declare. * section.c (SEC_INFO_TYPE_TARGET): Define. * bfd-in2.h: Regenerate. ld/ * emultempl/ppc32elf.em (no_tls_get_addr_opt, emit_stub_syms) plt_style): Delete. Adjust all refs to instead use.. (params): ..this. New variable. (ppc_after_open_output): New function. Tweak params and pass to ppc_elf_link_params. (ppc_after_open): Adjust ppc_elf_select_plt_layout call. (ppc_before_allocation): Adjust ppc_elf_tls_setup call. Enable relaxation for ppc476 workaround. (PARSE_AND_LIST_*): Add --{no-,}ppc476-workaround support. (LDEMUL_CREATE_OUTPUT_SECTION_STATEMENTS): Define.
2014-02-02Fix ALIGN_WITH_INPUTSebastian Huber11-20/+127
ld/ 2014-02-02 Sebastian Huber <sebastian.huber@embedded-brains.de> * ld/ld.texinfo: Change ALIGN_WITH_INPUT documentation. * ld/ldlang.c (lang_size_sections_1): Add dotdelta variable which reflects the VMA change due to alignment requirements. Use dotdelta do change the LMA if ALIGN_WITH_INPUT is requested. ld/testsuite/ChangeLog 2014-02-02 Sebastian Huber <sebastian.huber@embedded-brains.de> * ld-scripts/rgn-at9.d: New file. * ld-scripts/rgn-at9.t: Likewise. * ld-scripts/rgn-at10.d: Likewise. * ld-scripts/rgn-at10.s: Likewise. * ld-scripts/rgn-at10.t: Likewise. * ld-scripts/rgn-at11.d: Likewise. * ld-scripts/rgn-at11.t: Likewise.
2014-02-01Fix MMIX build breakage from bfd_set_section_vma change.Hans-Peter Nilsson2-1/+7
* emultempl/mmix-elfnmmo.em (mmix_after_allocation): Fix typo in call to bfd_set_section_vma exposed by recent bfd_set_section_vma change.
2014-01-30Nios II CALL26 linker relaxationSandra Loosemore30-6/+715
2014-01-30 Sandra Loosemore <sandra@codesourcery.com> bfd/ * bfd-in2.h: Update from reloc.c. * elf32-nios2.c: Include elf32-nios2.h. (elf_nios2_howto_table_rel): Add entry for R_NIOS2_CALL26_NOAT. (nios2_reloc_map): Likewise. (enum elf32_nios2_stub_type): Declare. (struct elf32_nios2_stub_hash_entry): Declare. (nios2_stub_hash_entry, nios2_stub_hash_lookup): New macros. (struct elf32_nios2_link_hash_entry): Add hsh_cache field. (struct elf32_nios2_link_hash_table): Add new fields bstab, stub_bfd, add_stub_section, layout_sections_again, stub_group, bfd_count, top_index, input_list, all_local_syms. (nios2_call26_stub_entry): New. (nios2_elf32_install_imm16): Move up in file. (nios2_elf32_install_data): Move up in file. (hiadj): Move up in file. (stub_hash_newfunc): New. (link_hash_newfunc): Initialize hsh_cache field. (STUB_SUFFIX): New. (nios2_stub_name): New. (nios2_get_stub_entry): New. (nios2_add_stub): New. (nios2_elf32_setup_section_lists): New. (nios2_elf32_next_input_section): New. (CALL26_SEGMENT): New. (MAX_STUB_SECTION_SIZE): New. (group_sections): New. (nios2_type_of_stub): New. (nios2_build_one_stub): New. (nios2_size_one_stub): New. (get_local_syms): New. (nios2_elf32_size_stubs): New. (nios2_elf32_build_stubs): New. (nios2_elf32_do_call26_relocate): Correct CALL26 overflow test. (nios2_elf32_relocate_section): Handle R_NIOS2_CALL26_NOAT. Add trampolines for R_NIOS2_CALL26 stubs. (nios2_elf32_check_relocs): Handle R_NIOS2_CALL26_NOAT. (nios2_elf32_gc_sweep_hook): Likewise. (nios2_elf32_link_hash_table_create): Initialize the stub hash table. (nios2_elf32_link_hash_table_free): New. (bfd_elf32_bfd_link_hash_table_free): Define. * elf32-nios2.h: New file. * libbfd.h: Update from reloc.c. * reloc.c (BFD_RELOC_NIOS2_CALL26_NOAT): New. gas/ * config/tc-nios2.c (md_apply_fix): Handle BFD_RELOC_NIOS2_CALL26_NOAT. (nios2_assemble_args_m): Likewise. (md_assemble): Likewise. gas/testsuite/ * gas/nios2/call26_noat.d: New. * gas/nios2/call26_noat.s: New. * gas/nios2/call_noat.d: New. * gas/nios2/call_noat.s: New. include/elf/ * nios2.h (elf_nios2_reloc_type): Add R_NIOS2_CALL26_NOAT. ld/ * Makefile.am (enios2elf.c, enios2linux.c): Update dependencies. * Makefile.in: Regenerated. * emulparams/nios2elf.sh (EXTRA_EM_FILE): Set. * emulparams/nios2linux.sh (EXTRA_EM_FILE): Set. * emultempl/nios2elf.em: New file. * gen-doc.texi (NIOSII): Set. * ld.texinfo (NIOSII): Set. ld/testsuite/ * ld-nios2/relax_call26.s: New. * ld-nios2/relax_call26_boundary.ld: New. * ld-nios2/relax_call26_boundary.s: New. * ld-nios2/relax_call26_boundary_c8.d: New. * ld-nios2/relax_call26_boundary_cc.d: New. * ld-nios2/relax_call26_boundary_d0.d: New. * ld-nios2/relax_call26_boundary_d4.d: New. * ld-nios2/relax_call26_boundary_d8.d: New. * ld-nios2/relax_call26_boundary_dc.d: New. * ld-nios2/relax_call26_boundary_f0.d: New. * ld-nios2/relax_call26_boundary_f4.d: New. * ld-nios2/relax_call26_boundary_f8.d: New. * ld-nios2/relax_call26_boundary_fc.d: New. * ld-nios2/relax_call26_cache.d: New. * ld-nios2/relax_call26_cache.ld: New. * ld-nios2/relax_call26_cache.s: New. * ld-nios2/relax_call26_multi.d: New. * ld-nios2/relax_call26_multi.ld: New. * ld-nios2/relax_call26_norelax.d: New. * ld-nios2/relax_call26_shared.d: New. * ld-nios2/relax_call26_shared.ld: New.
2014-01-29Add rdynamic-1 testH.J. Lu4-0/+25
It is added for commit 409ff343a402799563f71f938138b29f8baf7a1c Author: Alan Modra <amodra@gmail.com> Date: Tue Nov 8 13:49:11 2011 +0000 * elflink.c (bfd_elf_gc_mark_dynamic_ref_symbol): Mark syms in executables when export_dynamic. * ld-elf/rdynamic-1.c: New file. * ld-elf/rdynamic-1.rd: Likewise. * ld-elf/shared.exp (build_tests): Add rdynamic-1.
2014-01-28The MSP430 linker contains emulations for old and obsolete MCU types.Nick Clifton5-1183/+21
Since all MCUs now have their own specific linker script (courtesy of TI) there is no need for these emulations and so this patch removes them. * Makefile.am: Remove obsolete MSP430 emulations. * configure.tgt: Likewise. * emulparams/msp430all.sh: Likewise. * Makefile.in: Regenerate.
2014-01-28Update the tic6x linker tests to match the current behaviour of the linker ↵Nick Clifton15-40/+58
and readelf. PR binutils/16317 * ld-tic6x/shlib-1.rd: Expect I attribute with RELA sections. * ld-tic6x/shlib-1b.rd: Likewise. * ld-tic6x/shlib-1r.rd: Likewise. * ld-tic6x/shlib-1rb.rd: Likewise. * ld-tic6x/shlib-app-1rd: Likewise. * ld-tic6x/shlib-app-1b.rd: Likewise. * ld-tic6x/shlib-app-1r.rd: Likewise. * ld-tic6x/shlib-app-1rb.rd: Likewise. * ld-tic6x/shlib-noindex.rd: Likewise. * ld-tic6x/static-app-1.rd: Likewise. * ld-tic6x/static-app-1b.rd: Likewise. * ld-tic6x/static-app-1r.rd: Likewise. * ld-tic6x/static-app-1rb.rd: Likewise. PR binutils/16318 * ld-tic6x/tic6x.exp: Expect C6000 osabi value in relocatable objects.
2014-01-24Replace .align with .p2alignH.J. Lu2-3/+7
* ld-elf/pr16498a.s: Replace .align with .p2align.
2014-01-24Add another testcase for PR ld/16498H.J. Lu3-0/+22
PR ld/16498 * ld-elf/pr16498b.d: New file. * ld-elf/pr16498b.t: Likewise.
2014-01-24Improve orphaned TLS section handlingH.J. Lu6-0/+57
ld/ PR ld/16498 * emultempl/elf32.em (gld${EMULATION_NAME}_place_orphan): Improve orphaned TLS section handling. ld/testsuite/ PR ld/16498 * ld-elf/pr16498a.d: New file. * ld-elf/pr16498a.s: Likewise. * ld-elf/pr16498a.t: Likewise.
2014-01-24TLS orphan section placementAlan Modra2-52/+89
Ensures TLS orphans are placed adjacent to existing TLS sections, and fixes places where the output_section_statement flags (which might not be set) were tested when bfd_section flags were available. * ldlang.c (lang_output_section_find_by_flags): Be careful to test look->bfd_section->flags if available rather than look->flags. Separate SEC_THREAD_LOCAL handling from SEC_READONLY loop, and rewrite.
2014-01-22Display the reference causing a shared library to be neededAlan Modra5-2/+82
Adds a section for --as-needed libraries to a linker map file, similar to what we do for archive libraries. bfd/ * elflink.c (elf_link_add_object_symbols): Call minfo for --as-needed. ld/ * ldlang.c (asneeded_list_head, asneeded_list_tail): New vars. (lang_init): Initialise them. (lang_print_asneeded): New function. (lang_process): Call lang_print_asneeded. * ldlang.h (struct asneeded_minfo): New. (asneeded_list_tail): Declare. * ldmain.c (add_archive_element): Improve archive map heading. * ldmisc.c (minfo): Stash --as-needed info.
2014-01-22Miscellaneous ld tidiesAlan Modra6-7/+18
Localise a struct, prevent an unneeded symbol lookup, and fix a testcase. ld/ * ld.h (struct map_symbol_def): Move to.. * ldlang.h: ..here. * ldlang.c (print_assignment): Don't set expld.assign_name to dot. ld/testsuite/ * ld-scripts/pr14962-2.d: Correct target triple.
2014-01-22Make assignments to dot keep an empty output section.Alan Modra19-38/+157
An assignment to dot in an output section that allocates space of course keeps the output section. Here, I'm changing the behaviour for assignments that don't allocate space. The idea is not so much to allow people to force output of an empty section with ". = .", but to fix cases where an otherwise empty section has padding added by an alignment expression that changes with relaxation or .eh_frame editing. Such a section might have zero size before relaxation and so be stripped incorrectly. ld/ * ld.texinfo (Output Section Discarding): Mention assigning to dot as a way of keeping otherwise empty sections. * ldexp.c (is_dot, is_value, is_sym_value, is_dot_ne_0, is_dot_plus_0, is_align_conditional): New predicates. (exp_fold_tree_1): Set SEC_KEEP when assigning to dot inside an output section, except for some special cases. * scripttempl/elfmicroblaze.sc: Use canonical form to align at end of .heap and .stack. ld/testsuite/ * ld-shared/elf-offset.ld: Align end of .bss with canonical form of ALIGN that allows an empty .bss to be removed. * ld-arm/arm-dyn.ld: Likewise. * ld-arm/arm-lib.ld: Likewise. * ld-elfvsb/elf-offset.ld: Likewise. * ld-mips-elf/mips-dyn.ld: Likewise. * ld-mips-elf/mips-lib.ld: Likewise. * ld-arm/arm-no-rel-plt.ld: Remove duplicate ALIGN. * ld-powerpc/vle-multiseg-1.ld: Remove ALIGN at start of section. ALIGN address of section instead. * ld-powerpc/vle-multiseg-2.ld: Likewise. * ld-powerpc/vle-multiseg-3.ld: Likewise. * ld-powerpc/vle-multiseg-4.ld: Likewise. * ld-powerpc/vle-multiseg-6.ld: Likewise. * ld-scripts/empty-aligned.d: Check section headers not program headers. Remove xfail and notarget. * ld-scripts/empty-aligned.t: Use canonical ALIGN for end of .text2.
2014-01-21Check incompatible existing default symbol definitionH.J. Lu9-0/+90
After resolving a versioned reference, foo@VER1, to a default versioned definition, foo@@VER1, from a shared object, we also merge it with the existing regular default symbol definition, foo. When foo is IFUNC and foo@@VER1 aren't, we will merge 2 incompatible definitions. This patch avoids merging foo@@VER1 definition with foo definition if one is IFUNC and the other isn't.
2014-01-21Don't check shared/export_dynamic/ref_dynamic for type mismatchH.J. Lu2-0/+31
There is nothing linker can do when a type mismatched default definition are made dynamic by info->shared, info->export_dynamic or h->ref_dynamic. But we do want to avoid exporting it when building PIE. Let's remove those checks. bfd/ PR ld/2404 * elflink.c (_bfd_elf_merge_symbol): Don't check info->shared, info->export_dynamic, nor !h->ref_dynamic for type mismatch when adding the default version. ld/testsuite/ PR ld/2404 * ld-elf/shared.exp: Add a PIE test for PR ld/2404.
2014-01-20[AArch64] Define LP64 BE linker name.Marcus Shawcroft2-0/+5
2014-01-20[AArch64] Define LP64 LE loader name.Marcus Shawcroft2-0/+6
2014-01-20Add a testcase for PR ld/2404H.J. Lu5-0/+55
PR ld/2404 was fixed without a testcase. This patch to add one. PR ld/2404 * ld-elf/pr2404.out: New file. * ld-elf/pr2404a.c: Likewise. * ld-elf/pr2404b.c: Likewise. * ld-elf/shared.exp (build_tests): Build libpr2404a.so and libpr2404b.a. (run_tests): Run pr2404.
2014-01-20Allow self-assignment for absolute symbols defined in a linker scriptAlan Modra8-60/+98
Modifies ld machinery tracking linker script assignments to notice all assignments, not just those symbols mentioned in DEFINED(). ld/ PR ld/14962 * ldlang.h (struct lang_definedness_hash_entry): Add by_object and by_script. Make iteration a single bit field. (lang_track_definedness, lang_symbol_definition_iteration): Delete. (lang_symbol_defined): Declare. * ldlang.c (lang_statement_iteration): Expand comment a little. (lang_init <lang_definedness_table>): Make it bigger. (lang_track_definedness, lang_symbol_definition): Delete. (lang_definedness_newfunc): Update. (lang_symbol_defined): New function. (lang_update_definedness): Create entries here. Do track whether script definition of symbol is valid, even when also defined in an object file. * ldexp.c (fold_name <DEFINED>): Update. (fold_name <NAME>): Allow self-assignment for absolute symbols defined in a linker script. ld/testsuite/ * ld-scripts/pr14962-2.d, * ld-scripts/pr14962-2.t: New test. * ld-scripts/expr.exp: Run it.
2014-01-20Fix duplicate output section statement lookupGuy Martin12-25/+43
Tie output section statements to their associated output section via output section userdata. This allows us to avoid hash lookups which are slower and fail when multiple output sections have the same name. * ldlang.h (lang_output_section_get): Define. * ldlang.c (lang_output_section_get): Likewise. (init_os): Set the output_section userdata to the output section statement. * emultempl/hppaelf.em: Use lang_output_section_get instead of lang_output_section_find where applicable. * emultempl/aarch64elf.em: Likewise. * emultempl/aix.em: Likewise. * emultempl/armelf.em: Likewise. * emultempl/m68hc1xelf.em: Likewise. * emultempl/metagelf.em: Likewise. * emultempl/mipself.em: Likewise. * emultempl/ppc64elf.em: Likewise. * emultempl/spuelf.em: Likewise.
2014-01-17Allow ld target customiser script to force on disk scripts.Alan Modra16-22/+38
Mucking with EMULATION_LIBPATH has unwanted side effects. Allow nds32 emulparams scripts to disable compiled-in scripts naturally, by setting COMPILE_IN=no. * genscripts.sh (COMPILE_IN): Don't set if already set. * emulparams/nds32elf.sh: Don't clear EMULATION_LIBPATH, set COMPILE_IN=no. * emulparams/nds32elf16m.sh: Likewise. * emulparams/nds32elf_linux.sh: Likewise. * emultempl/aix.em: Test COMPILE_IN value is "yes". * emultempl/armcoff.em: Likewise. * emultempl/elf32.em: Likewise. * emultempl/generic.em: Likewise. * emultempl/gld960.em: Likewise. * emultempl/gld960c.em: Likewise. * emultempl/linux.em: Likewise. * emultempl/lnk960.em: Likewise. * emultempl/m68kcoff.em: Likewise. * emultempl/sunos.em: Likewise. * emultempl/ticoff.em: Likewise.
2014-01-15Skip directories with LIBPATH_SUFFIX_SKIP suffixH.J. Lu4-13/+41
On Linux/x86-64, when binutils is configured with --libdir=/usr/lib64, genscripts.sh treats /usr/lib64 as the default search directory. It puts /usr/lib64 in linker scripts for all emulations, like --- /* Script for -z combreloc: combine and sort reloc sections */ OUTPUT_FORMAT("elf32-i386", "elf32-i386", "elf32-i386") OUTPUT_ARCH(i386) ENTRY(_start) SEARCH_DIR("/usr/x86_64-redhat-linux/lib32"); SEARCH_DIR("/usr/i386-redhat-linux/lib32"); SEARCH_DIR("/usr/lib6432"); SEARCH_DIR("/usr/local/lib32"); SEARCH_DIR("/lib32"); SEARCH_DIR("/usr/lib32"); SEARCH_DIR("/usr/i386-redhat-linux/lib"); SEARCH_DIR("/usr/lib64"); SEARCH_DIR("/usr/local/lib"); SEARCH_DIR("/lib"); SEARCH_DIR("/usr/lib"); --- /usr/lib6432 is odd and /usr/lib64 is wrong. This patch changes genscripts.sh to check LIBPATH_SUFFIX_SKIP if it is defined. It skips directories with LIBPATH_SUFFIX_SKIP suffix. PR ld/16456 * genscripts.sh: Don't search directory with LIBPATH_SUFFIX_SKIP suffix. * emulparams/elf32_x86_64.sh (LIBPATH_SUFFIX_SKIP): Set to 64 for elf32_x86_64 emulation. * emulparams/elf_i386.sh (LIBPATH_SUFFIX_SKIP): Set to 64 for elf_i386 emulation.
2014-01-16Tidy ld use of bfd_section userdata.Alan Modra4-53/+38
A long time ago ld made use of userdata to tie an output section to its lang_input_statement_struct object file. Some time later Joern made map file printing of symbols at lot faster, using userdata on input sections. That complicated allocation of userdata, and when the output section use disappeared a year later, the code wasn't properly cleaned up. This patch does that cleanup, and also tidies the symbol printing code to not allocate userdata where it won't be needed. We don't print symbols defined in the absolute section or in output sections. * ld.h (fat_section_userdata_type, get_userdata): Move to.. * ldlang.h (input_section_userdata_type, get_userdata): ..here. * ldlang.c (init_map_userdata): Delete. Fold into.. (sort_def_symbol): ..here. Don't attach input section userdata to output sections or global bfd sections. (lang_map): Don't pre-allocate input section userdata. (init_os): Don't allocate userdata for output sections. (print_all_symbols): Update.
2014-01-15Silence uninitialized warning on ehdr_start_saveH.J. Lu2-1/+7
Older GCC, like 4.1/4.2, will issue an uninitialized warning on ehdr_start_save. This patch silences by using struct bfd_link_hash_entry ehdr_start_save = ehdr_start_save; * emultempl/elf32.em (gld${EMULATION_NAME}_before_allocation): Silence uninitialized warning on ehdr_start_save with older GCC.
2014-01-15non-PIC references to __ehdr_start in pie and sharedAlan Modra7-0/+44
Rather than hacking every backend to not discard dynamic relocations against an undefined hidden __ehdr_start, make it appear to be defined early. We want __ehdr_start hidden before size_dynamic_sections so that it isn't put in .dynsym, but we do need the dynamic relocations for a PIE or shared library with a non-PIC reference. Defining it early is wrong if we don't actually define the symbol later to its proper value. (In some cases we want to leave the symbol undefined, for example, when the ELF header isn't loaded, and we don't have this infomation available in before_allocation.) ld/ * emultempl/elf32.em (gld${EMULATION_NAME}_before_allocation): Define __ehdr_start before size_dynamic_sections and restore afterwards. ld/testsuite/ * ld-elf/ehdr_start-shared.d: New. * ld-elf/ehdr_start-userdef.d: xfail frv. * ld-elf/ehdr_start-weak.d: Likewise. * ld-elf/ehdr_start.d: Likewise.
2014-01-14 * lib/ld-lib.exp (default_ld_link): Remove support for ldflags.Vidya Praveen2-9/+6
(default_ld_simple_link): Likewise.
2014-01-10Don't adjust LOAD segment to match GNU_RELRO segmentAlan Modra5-15/+27
Instead, fix Jakub's original code setting up the PR_GNU_RELRO header from the PT_LOAD header. PR ld/14207 PR ld/16322 PR binutils/16323 bfd/ * elf.c (assign_file_positions_for_load_sections): Revert last change. (assign_file_positions_for_non_load_sections): When setting up PT_GNU_RELRO header, don't require a corresponding PT_LOAD header that completely covers the relro region. ld/ * ldlang.c (lang_size_sections): Remove unneeded RELRO base adjust. Tidy comments. * ld.texinfo (DATA_SEGMENT_RELRO_END): Correct description. ld/testsuite/ * ld-x86-64/pr14207.d: Adjust
2014-01-10 * emulparams/crislinux.sh (COMMONPAGESIZE): Define.Hans-Peter Nilsson2-0/+5
2014-01-09Fix copyright yearH.J. Lu1-1/+1
2014-01-09Check if GNU_RELRO segment is is generatedH.J. Lu2-1/+30
Fail if GNU_RELRO segment isn't generated, but should. * ld-elf/binutils.exp (binutils_test): Check if GNU_RELRO segment is generated.
2014-01-09Add and use check_lto_shared_availableH.J. Lu3-2/+45
2014-01-09 Vidya Praveen <vidyapraveen@arm.com> * lib/ld-lib.exp (check_lto_shared_available): New check. * ld-plugin/lto.exp: Use check_lto_shared_available.
2014-01-08Adjust LOAD segment to generate GNU_RELRO segmentH.J. Lu6-5/+51
This patch fixes 2 GNU_RELRO segment bugs: 1. lang_size_sections didn't properly align base to the maximum alignment power of sections between DATA_SEGMENT_ALIGN and DATA_SEGMENT_RELRO_END. 2. ld failed to adjust LOAD segment to generate GNU_RELRO segment when LOAD segment doesn't fit GNU_RELRO segment. This is https://sourceware.org/bugzilla/show_bug.cgi?id=14207 We "fixed" ld by not generating GNU_RELRO segment. This patch adjusts LOAD segment to generate GNU_RELRO segment. It fixes PR ld/16322 and at the same time it also fixes PR binutils/16323 since now we can adjust LOAD segment if it is too small. bfd/ PR ld/14207 PR ld/16322 PR binutils/16323 * elf.c (_bfd_elf_map_sections_to_segments): Don't check section size for PT_GNU_RELRO segment. (assign_file_positions_for_load_sections): If PT_LOAD segment doesn't fit PT_GNU_RELRO segment, adjust its p_filesz and p_memsz. ld/ PR ld/14207 PR ld/16322 PR binutils/16323 * ldlang.c (lang_size_sections): Properly align RELRO base. ld/testsuite/ PR ld/14207 PR ld/16322 PR binutils/16323 * ld-elf/pr16322.d: New file. * ld-elf/pr16322.s: Likewise. * ld-x86-64/pr14207.d: Expect PT_GNU_RELRO segment.
2014-01-08Update copyright year to 2014H.J. Lu2-2/+6
binutils/ * version.c (print_version): Update copyright year to 2014. gas/ * as.c (parse_args): Update copyright year to 2014. gold/ * version.cc (print_version): Update copyright year to 2014. ld/ * ldver.c (ldversion): Update copyright year to 2014. opcodes/ * i386-gen.c (process_copyright): Update copyright year to 2014.
2014-01-08New Year - binutils ChangeLog rotationH.J. Lu4-2523/+2551
2013-12-20Define IREL_IN_PLT for elf_k1om.sh and elf_l1om.shH.J. Lu3-0/+7
* emulparams/elf_k1om.sh (IREL_IN_PLT): Define. * emulparams/elf_l1om.sh (IREL_IN_PLT): Likewise.