aboutsummaryrefslogtreecommitdiff
path: root/ld
AgeCommit message (Collapse)AuthorFilesLines
2015-05-09Ignore 0x66 prefix for call/jmp/jcc in 64-bit modeH.J. Lu2-6/+6
The operand size prefix (0x66) is ignored for 32-bit PC-relative call, jmp and jcc in 64-bit mode. gas/testsuite/ PR binutis/18386 * gas/i386/i386.exp: Run x86-64-jump. * gas/i386/x86-64-branch.d: Updated. * gas/i386/ilp32/x86-64-branch.d: Likewise. * gas/i386/x86-64-branch.s: Add tests for the operand size prefix with call, jmp and jb. * gas/i386/x86-64-jump.d: New file. * gas/i386/x86-64-jump.s: Likewise. ld/testsuite/ PR binutis/18386 * ld-x86-64/tlsgdesc.dd: Updated. * ld-x86-64/tlspic.dd: Likewise. opcodes/ PR binutis/18386 * i386-dis.c (X86_64_E8): New. (X86_64_E9): Likewise. Update comments on 'T', 'U', 'V'. Add comments for '^'. (dis386): Replace callT/jmpT with X86_64_E8/X86_64_E9. (x86_64_table): Add X86_64_E8 and X86_64_E9. (mod_table): Replace {T|} with ^ on Jcall/Jmp. (putop): Handle '^'. (OP_J): Ignore the operand size prefix in 64-bit. Don't check REX_W.
2015-05-05Add support to the MSP430 linker for the automatic placement of code and ↵Nick Clifton6-2/+336
data into either low or high memory regions. gas * config/tc-msp430.c (MAX_OP_LEN): Increase to 4096. (msp430_make_init_symbols): New function. (msp430_section): Call it. (msp430_frob_section): Likewise. ld * emulparams/msp430elf.sh (TEMPLATE_NAME): Change to msp430. * scripttempl/msp430.sc (.text): Add .lower.text and .either.text. (.data): Add .lower.data and .either.data. (.bss): Add .lower.bss and .either.bss. (.rodata): Add .lower.rodata and .either.rodata. * emultempl/msp430.em: New file. Implements a new orphan placement algorithm that divides sections between lower and upper memory regions. * Makefile.am (emsp430elf.c): Depend upon msp430.em. *emsp430X.c): Likewise. * Makefine.in: Regenerate.
2015-04-29Link the last *normal against libfoozlib.soH.J. Lu1-0/+6
Link the last zlibnormal gnunormal and gabinormal against libfoozlib.so so that their only differences are DWARF debug sections. PR ld/18354 * ld-elf/compress.exp (run_tests): Link the last zlibnormal, gnunormal and gabinormal against libfoozlib.so.
2015-04-29Fix 18354H.J. Lu1-1/+10
2015-04-29[ARM] Update ld testcasesJiong Wang3-3/+8
2015-04-29 Renlin Li <renlin.li@arm.com> ld/testsuite/ * ld-arm/ifunc-10.dd: Adjust expected output. * ld-arm/ifunc-2.dd: Likewise.
2015-04-28Eat newlines inside INPUT statements in linker scriptsAndreas Schwab2-1/+6
ld/ PR ld/18344 * ldlex.l (INPUTLIST): Increment lineno on newline.
2015-04-27S/390: Fix gotreloc_31-1 testcase.Andreas Krebbel2-3/+6
Since we changed the default arch for objdump to zarch the following testcase needs to check for the real instruction mnemonics instead of just bytes. This fixes the following testsuite fail on s390x: FAIL: GOT: symbol address load from got to larl
2015-04-25Non-alloc sections don't belong in PT_LOAD segmentsAlan Modra4-8/+20
Taking them out showed a bug in the powerpc64 backend with .branch_lt being removed from output_bfd but not from previously set up segment section maps. Removing the bfd sections meant their sh_flags (and practically everything else) remaining zero, ie. not SHF_ALLOC, triggering complaints about "`.branch_lt' can't be allocated in segment". include/elf/ * internal.h (ELF_SECTION_IN_SEGMENT_1): Ensure PT_LOAD and similar segments only contain alloc sections. ld/ * emultempl/ppc64elf.em (gld${EMULATION_NAME}_after_allocation): Call gld${EMULATION_NAME}_map_segments regardless of need_laying_out. ld/testsuite/ * ld-powerpc/tocnovar.d: Revert last change.
2015-04-24[AArch64] Improve PC-relative relocation check for shared libraryJiong Wang4-0/+39
2015-04-24 Jiong. Wang <jiong.wang@arm.com> bfd/ * elfnn-aarch64.c (elfNN_aarch64_final_link_relocate): Reject PC-relative relocation for external symbol. ld/testsuite/ * ld-aarch64/pcrel.s: New testcase. * ld-aarch64/pcrel_pic_defiend_local.d: New expect file. * ld-aarch64/pcrel_pic_undefined.d: Ditto. * ld-aarch64/aarch64-elf.exp: Run them.
2015-04-24Fix typoDJ Delorie1-1/+1
2015-04-24Change msp430 emulation to msp430elfDJ Delorie6-9/+19
* Makefile.am (msp430): Rename primary emulation to msp430elf. (emsp430.c): Rename to emsp430elf.c, update dependencies (emsp430X.c): Update dependencies. * Makefile.in: Likewise. * configure.tgt (msp430-*-*): Rename primary emulation to msp430elf. * emulparame/msp430.sh: Rename to msp430elf.sh. * emulparams/msp430X.sh: Update.
2015-04-24[ARM]: Don't tail-pad over-aligned functions to the alignment boundary.Richard Earnshaw24-114/+98
2015-04/24 Richard Earnshaw <rearnsha@arm.com> gas/ * config/tc-arm.h (arm_min): New function. (SUB_SEGMENT_ALIGN): Define. gas/testsuite/ * gas/arm/align64.d: Delete trailing padding NOPs. ld/testsuite/ * ld-arm/armthumb-lib.d: Regenerate expected output. * ld-arm/armthumb-lib.d: Likewise. * ld-arm/armthumb-lib.sym: Likewise. * ld-arm/cortex-a8-fix-b-rel-arm.d: Likewise. * ld-arm/cortex-a8-fix-b-rel-thumb.d: Likewise. * ld-arm/cortex-a8-fix-b.d: Likewise. * ld-arm/cortex-a8-fix-bcc-rel-thumb.d: Likewise. * ld-arm/cortex-a8-fix-bcc.d: Likewise. * ld-arm/cortex-a8-fix-bl-rel-arm.d: Likewise. * ld-arm/cortex-a8-fix-bl-rel-plt.d: Likewise. * ld-arm/cortex-a8-fix-bl-rel-thumb.d: Likewise. * ld-arm/cortex-a8-fix-bl.d: Likewise. * ld-arm/cortex-a8-fix-blx-bcond.d: Likewise. * ld-arm/cortex-a8-fix-blx-rel-arm.d: Likewise. * ld-arm/cortex-a8-fix-blx-rel-thumb.d: Likewise. * ld-arm/cortex-a8-fix-blx.d: Likewise. * ld-arm/cortex-a8-fix-hdr.d: Likewise. * ld-arm/farcall-mixed-app-v5.d: Likewise. * ld-arm/farcall-mixed-app.d: Likewise. * ld-arm/farcall-mixed-lib-v4t.d: Likewise. * ld-arm/farcall-mixed-lib.d: Likewise. * ld-arm/mixed-app-v5.d: Likewise. * ld-arm/mixed-app.d: Likewise. * ld-arm/mixed-lib.d: Likewise.
2015-04-24Skip the compressed1d test for targets which do not use the elf32.em linker ↵Nick Clifton2-0/+7
emulation file. * ld-elf/compressed1d.d: Add notarget for ELF based targets that do not use elf.em.
2015-04-24Correct ld-elf/compressed1e.d to use notarget and for cris-elf, not cris-*.Hans-Peter Nilsson2-1/+6
Don't XPASS cris-linux which *does* support -shared. And xfail is for bugs, notarget is for not-applicable.
2015-04-23Xfail cris and frv for ld-elf/compressed1e.dH.J. Lu2-0/+7
cris and frv don't support -shared. * ld-elf/compressed1e.d: Only run for Linux/gnu. Xfail cris and frv.
2015-04-23Delay setting up compressed debug section namesH.J. Lu3-0/+24
When we set up st_name for output section name in elf_fake_sections, we don't know if the compressed DWARF debug section will be smaller. We may end up with compressed DWARF debug sections which are bigger than the uncompressed ones. This patch delays setting up st_name for output DWARF debug section to _bfd_elf_assign_file_positions_for_non_load which will compress the output debug section. We also postpone placement of shstrtab section after DWARF debug sections have been compressed. The net effect is .shstrtab section is now placed after .symtab and .strtab sections. bfd/ PR ld/18277 * compress.c (bfd_compress_section_contents): Remove the write_compress argument. (bfd_init_section_compress_status): Updated. (bfd_compress_section): Likewise. * elf.c (_bfd_elf_set_reloc_sh_name): New. (_bfd_elf_init_reloc_shdr): Add delay_st_name_p. Set sh_name to (unsigned int) -1 if delay_st_name_p is TRUE. Use _bfd_elf_set_reloc_sh_name. (elf_fake_sections): Don't rename DWARF debug section for linker output if it will be compressed. Instead, set delay_st_name_p to TRUE and pass it to _bfd_elf_init_reloc_shdr. (assign_section_numbers): Call _bfd_elf_strtab_addref only if sh_name != (unsigned int) -1. Don't finalize nor assign shstrtab section here. Delay setting output section names to _bfd_elf_write_object_contents. (_bfd_elf_compute_section_file_positions): Update comments on sh_offset for shstrtab section. (assign_file_positions_for_non_load_sections): Set sh_offset to -1 for shstrtab section. (assign_file_positions_except_relocs): Likewise. (_bfd_elf_assign_file_positions_for_non_load): Set up sh_name when compressing DWARF debug sections. Place shstrtab section after DWARF debug sections have been compressed. (_bfd_elf_write_object_contents): Setting sh_name for output sections. ld/testsuite/ PR ld/18277 * ld-elf/compressed1d.d: New. * ld-elf/compressed1e.d: Likewise.
2015-04-23Don't change compressed input debug section namesH.J. Lu2-0/+8
Change compressed input debug section name for objdump is very confusing. But we need to change it for linker so that linker will consider the input section as a debug section. This patch delays section rename to elf_fake_sections for objcopy and avoids it for objdump. bfd/ PR binutils/18209 * bfd.c (bfd): Add is_linker_input. * elf.c (convert_debug_to_zdebug): New. (convert_zdebug_to_debug): Likewise. (_bfd_elf_make_section_from_shdr): Don't convert .debug_* to .zdebug_* here. Use convert_zdebug_to_debug. Set SEC_ELF_RENAME. (_bfd_elf_init_reloc_shdr): Pass a pointer to section name instead of a pointer to section. (elf_fake_sections): Rename the section name if SEC_ELF_RENAME is set. * section.c (SEC_ELF_RENAME): New. * bfd-in2.h: Regenerated. binutils/ PR binutils/18209 * objcopy.c (setup_section): Copy compress status. binutils/testsuite/ PR binutils/18209 * binutils-all/compress.exp: Replace dw2-3.W with dw2-3gabi.W on zlib-gabi output. * binutils-all/dw2-1.W: Convert section names to .zdebug_*. * binutils-all/dw2-3.W: Likewise. * binutils-all/objdump.W: Likewise. * binutils-all/dw2-3gabi.W: New file. ld/ PR binutils/18209 * ldfile.c (ldfile_try_open_bfd): Set is_linker_input to 1.
2015-04-23Accept odd result in ld-powerpc/tocnovar testcaseAlan Modra2-1/+2
I didn't commit this with the relro and powerpc .TOC. changes, thinking that something should be done about the odd result of .shstrtab appearing in PT_GNU_RELRO. On looking at it further, I think that changing readelf would be wrong, so let's just accept the results. Real binaries will always have other sections past .got, so PT_GNU_RELRO won't finish past the end of loaded sections. * ld-powerpc/tocnovar.d: Adjust.
2015-04-23Align .TOC. for PowerPC64Alan Modra28-132/+164
This change, with prerequisite 0e5fabeb, provides a toc base aligned to 256 bytes rather than 8 bytes. This is necessary for a minor gcc optimisation, allowing use of d-form instructions to correctly access toc-relative items larger than 8 bytes. bfd/ * elf64-ppc.c (TOC_BASE_ALIGN): Define. (ppc64_elf_next_toc_section): Align multi-got toc base. (ppc64_elf_set_toc): Likewise initial toc base and .TOC. symbol. ld/ * emulparams/elf64ppc.sh (GOT): Align. ld/testsuite/ * ld-powerpc/ambiguousv1b.d: Update for aligned .got. * ld-powerpc/defsym.d: Likewise. * ld-powerpc/elfv2-2exe.d: Likewise. * ld-powerpc/elfv2exe.d: Likewise. * ld-powerpc/elfv2so.d: Likewise. * ld-powerpc/relbrlt.d: Likewise. * ld-powerpc/tls.g: Likewise. * ld-powerpc/tlsexe.d: Likewise. * ld-powerpc/tlsexe.g: Likewise. * ld-powerpc/tlsexe.r: Likewise. * ld-powerpc/tlsexetoc.d: Likewise. * ld-powerpc/tlsexetoc.g: Likewise. * ld-powerpc/tlsexetoc.r: Likewise. * ld-powerpc/tlsso.d: Likewise. * ld-powerpc/tlsso.g: Likewise. * ld-powerpc/tlsso.r: Likewise. * ld-powerpc/tlstoc.g: Likewise. * ld-powerpc/tlstocso.d: Likewise. * ld-powerpc/tlstocso.g: Likewise. * ld-powerpc/tlstocso.r: Likewise. * ld-powerpc/tocopt.d: Likewise. * ld-powerpc/tocopt2.d: Likewise. * ld-powerpc/tocopt3.d: Likewise. * ld-powerpc/tocopt4.d: Likewise. * ld-powerpc/tocopt5.d: Likewise.
2015-04-22Rewrite relro adjusting codeAlan Modra6-42/+50
The linker tries to put the end of the last section in the relro segment exactly on a page boundary, because the relro segment itself must end on a page boundary. If for any reason this can't be done, padding is inserted. Since the end of the relro segment is typically between .got and .got.plt, padding effectively increases the size of the GOT. This isn't nice for targets and code models with limited GOT addressing. The problem with the current code is that it doesn't cope very well with aligned sections in the relro segment. When making .got aligned to a 256 byte boundary for PowerPC64, I found that often the initial alignment attempt failed and the fallback attempt to be less than adequate. This is a particular problem for PowerPC64 since the distance between .got and .plt affects the size of plt call stubs, leading to "stubs don't match calculated size" errors. So this rewrite takes a direct approach to calculating a new relro base. Starting from the last section in the segment, we calculate where it must start to position its end on the boundary, or as near as possible considering alignment requirements. The new start then becomes the goal for the previous section to end, and so on for all sections. This of course ignores the possibility that user scripts will place . = ALIGN(xxx); in the relro segment, or provide section address expressions. In those cases we might fail, but the old code probably did too, and a fallback is provided. ld/ * ldexp.h (struct ldexp_control): Delete dataseg.min_base. Add data_seg.relro_offset. * ldexp.c (fold_binary <DATA_SEGMENT_ALIGN>): Don't set min_base. (fold_binary <DATA_SEGMENT_RELRO_END>): Do set relro_offset. * ldlang.c (lang_size_sections): Rewrite code adjusting relro segment base to line up last section on page boundary. ld/testsuite/ * ld-x86-64/pr18176.d: Update.
2015-04-22i386: Allow copy relocs for building PIEH.J. Lu15-0/+218
This patch allows copy relocs for R_386_GOTOFF relocations in PIE. For extern int glob_a; int foo () { return glob_a; } compiler now can optimize it from call __x86.get_pc_thunk.ax addl $_GLOBAL_OFFSET_TABLE_, %eax movl glob_a@GOT(%eax), %eax movl (%eax), %eax ret to call __x86.get_pc_thunk.ax addl $_GLOBAL_OFFSET_TABLE_, %eax movl glob_a@GOTOFF(%eax), %eax ret bfd/ PR ld/18289 * elf32-i386.c (elf_i386_link_hash_entry): Add gotoff_ref. (elf_i386_link_hash_newfunc): Initialize gotoff_ref to 0. (elf_i386_create_dynamic_sections): Always allow copy relocs for building executables. (elf_i386_copy_indirect_symbol): Also copy gotoff_ref. (elf_i386_check_relocs): Set gotoff_ref for R_386_GOTOFF. (elf_i386_adjust_dynamic_symbol): Also allocate copy relocs for PIE and R_386_GOTOFF. (elf_i386_relocate_section): Allow R_386_GOTOFF in executable. ld/testsuite/ PR ld/18289 * ld-i386/copyreloc-lib.c: New file. * ld-i386/copyreloc-main.S: Likewise. * ld-i386/copyreloc-main.out: Likewise. * ld-i386/copyreloc-main1.rd: Likewise. * ld-i386/copyreloc-main2.rd: Likewise. * ld-i386/dummy.c: Likewise. * ld-i386/pr17689.out: Likewise. * ld-i386/pr17689.rd: Likewise. * ld-i386/pr17689a.c: Likewise. * ld-i386/pr17689b.S: Likewise. * ld-i386/pr17827.rd: Likewise. * ld-i386/pr17827ver.rd: Likewise. * ld-i386/i386.exp: Run copyreloc tests.
2015-04-20Don't hardcode offset of .shstrtab sectionH.J. Lu27-26/+55
There is no requirement on placement of section name section, .shstrtab. This patch removes hardcoded offsets of .shstrtab sections. binutils/testsuite/ * binutils-all/i386/compressed-1b.d: Don't hardcode offset of .shstrtab section. * binutils-all/i386/compressed-1c.d: Likewise. * binutils-all/readelf.s-64: Likewise. * binutils-all/x86-64/compressed-1b.d: Likewise. * binutils-all/x86-64/compressed-1c.d: Likewise. gas/testsuite/ * gas/i386/ilp32/x86-64-unwind.d: Don't hardcode offset of .shstrtab section. * gas/i386/x86-64-unwind.d: Likewise. * gas/ia64/alias-ilp32.d: Likewise. * gas/ia64/alias.d: Likewise. * gas/ia64/group-1.d: Likewise. * gas/ia64/group-2.d: Likewise. * gas/ia64/secname-ilp32.d: Likewise. * gas/ia64/secname.d: Likewise. * gas/ia64/unwind-ilp32.d: Likewise. * gas/ia64/unwind.d: Likewise. * gas/mmix/bspec-1.d: Likewise. * gas/mmix/byte-1.d: Likewise. * gas/mmix/loc-1.d: Likewise. * gas/mmix/loc-2.d: Likewise. * gas/mmix/loc-3.d: Likewise. * gas/mmix/loc-4.d: Likewise. * gas/mmix/loc-5.d: Likewise. * gas/tic6x/scomm-directive-4.d: Likewise. ld/testsuite/ * ld-mmix/bspec1.d: Don't hardcode offset of .shstrtab section. * ld-mmix/bspec2.d: Likewise. * ld-mmix/local1.d: Likewise. * ld-mmix/local3.d: Likewise. * ld-mmix/local5.d: Likewise. * ld-mmix/local7.d: Likewise. * ld-mmix/undef-3.d: Likewise. * ld-sh/sh64/crangerel1.rd: Likewise. * ld-sh/sh64/crangerel2.rd: Likewise. * ld-tic6x/common.d: Likewise. * ld-tic6x/shlib-1.rd: Likewise. * ld-tic6x/shlib-1b.rd: Likewise. * ld-tic6x/shlib-1r.rd: Likewise. * ld-tic6x/shlib-1rb.rd: Likewise. * ld-tic6x/shlib-app-1.rd: 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. * ld-x86-64/ilp32-4.d: Likewise. * ld-x86-64/split-by-file-nacl.rd: Likewise. * ld-x86-64/split-by-file.rd: Likewise.
2015-04-15Mention --compress-debug-sections=[none|zlib|zlib-gnu|zlib-gabi]H.J. Lu2-0/+8
binutils/ * NEWS: Mention --compress-debug-sections=[none|zlib|zlib-gnu|zlib-gabi]. gas/ * NEWS: Mention --compress-debug-sections=[none|zlib|zlib-gnu|zlib-gabi]. ld/ * NEWS: Mention --compress-debug-sections=[none|zlib|zlib-gnu|zlib-gabi].
2015-04-14Add --compress-debug-sections=[none|zlib|zlib-gnu|zlib-gabi]H.J. Lu13-1/+253
This patch adds --compress-debug-sections=[none|zlib|zlib-gnu|zlib-gabi] to ld for ELF targets to support generating compressed DWARF debug sections. We always generate .zdebug_* section since section names have been finalized and they can't be changed easily when compression is being performed. bfd/ * bfd-in.h (compressed_debug_section_type): New. * compress.c (bfd_compress_section_contents): Add an argument for linker write compression and always generate .zdebug_* section when linking. (bfd_init_section_compress_status): Pass FALSE to bfd_compress_section_contents. (bfd_compress_section): New function. * elf.c (elf_fake_sections): For linking, set SEC_ELF_COMPRESS on DWARF debug sections if COMPRESS_DEBUG is set and rename section if COMPRESS_DEBUG_GABI_ZLIB isn't set. (assign_file_positions_for_non_load_sections): Set sh_offset to -1 if SEC_ELF_COMPRESS is set. (assign_file_positions_except_relocs): Likwise. (_bfd_elf_assign_file_positions_for_relocs): Renamed to ... (_bfd_elf_assign_file_positions_for_non_load): This. Change return time to bfd_boolean. Compress the section if SEC_ELF_COMPRESS is set. (_bfd_elf_write_object_contents): Updated. (_bfd_elf_set_section_contents): Write section contents to the buffer if SEC_ELF_COMPRESS is set. * merge.c: Include "elf-bfd.h". (sec_merge_emit): Add arguments for contents and offset. Write to contents with offset if contents isn't NULL. (_bfd_write_merged_section): Write section contents to the buffer if SEC_ELF_COMPRESS is set. Pass contents and output_offset to sec_merge_emit. * elflink.c (bfd_elf_final_link): Allocate the buffer for output section contents if SEC_ELF_COMPRESS is set. * section.c (SEC_ELF_COMPRESS): New. * bfd-in2.h: Regenerated. gas/ * as.h (compressed_debug_section_type): Removed. include/ * bfdlink.h (bfd_link_info): Add compress_debug. ld/ * ld.texinfo: Document --compress-debug-sections=. * ldmain.c (main): Set BFD_COMPRESS on output_bfd if COMPRESS_DEBUG is set. Set BFD_COMPRESS_GABI on output_bfd for COMPRESS_DEBUG_GABI_ZLIB. * lexsup.c (elf_static_list_options): Add --compress-debug-sections=. * emultempl/elf32.em (OPTION_COMPRESS_DEBUG): New. (xtra_long): Add "compress-debug-sections". (gld${EMULATION_NAME}_handle_option): Handle OPTION_COMPRESS_DEBUG. ld/testsuite/ * ld-elf/compress.exp (build_tests): Add tests for --compress-debug-sections=. (run_tests): Likewise. Add additonal tests for --compress-debug-sections=. * ld-elf/gabiend.rt: New file. * ld-elf/gabinormal.rt: Likewise. * ld-elf/gnubegin.rS: Likewise. * ld-elf/gnunormal.rS: Likewise. * ld-elf/zlibbegin.rS: Likewise. * ld-elf/zlibnormal.rS: Likewise.
2015-04-15xfail pr18223 test for tic6xAlan Modra2-0/+5
Fails due to warning: generating a shared library containing non-PIC/PID code * ld-gc/pr18223.d: xfail tic6x.
2015-04-14Add -z noextern-protected-data to ld for ELF/x86H.J. Lu18-2/+79
Address of protected data defined in the shared library may be external, i.e., due to copy relocation. By default, linker backend checks if relocations against protected data symbols are valid for building shared library and issues an error if relocation isn't allowed. The new option override linker backend default. When -z noextern-protected-data is used, updates on protected data symbols by another module won't be visibile to the resulting shared library. This option is specific to ELF/i386 and ELF/x86-64. bfd/ PR ld/pr17709 * elflink.c (_bfd_elf_adjust_dynamic_copy): Check info->extern_protected_data when warning copy relocs against protected symbols. (_bfd_elf_symbol_refs_local_p): Check info->extern_protected_data when checking protected non-function symbols. include/ PR ld/pr17709 * bfdlink.h (bfd_link_info): Add extern_protected_data. ld/ PR ld/pr17709 * ld.texinfo: Document "-z noextern-protected-data". * ldmain.c (main): Initialize link_info.extern_protected_data to -1. * lexsup.c (elf_shlib_list_options): Add "-z [no]extern-protected-data". * emulparams/elf32_x86_64.sh: Source extern_protected_data.sh. * emulparams/elf_i386.sh: Likewise. * emulparams/elf_i386_be.sh: Likewise. * emulparams/elf_i386_chaos.sh: Likewise. * emulparams/elf_i386_ldso.sh: Likewise. * emulparams/elf_i386_vxworks.sh: Likewise. * emulparams/elf_k1om.sh: Likewise. * emulparams/elf_l1om.sh: Likewise. * emulparams/elf_x86_64.sh: Source extern_protected_data.sh. (PARSE_AND_LIST_OPTIONS): Renamed to ... (PARSE_AND_LIST_OPTIONS_BNDPLT): This. (PARSE_AND_LIST_ARGS_CASE_Z): Renamed to ... (PARSE_AND_LIST_ARGS_CASE_Z_BNDPLT): This. (PARSE_AND_LIST_OPTIONS): Append $PARSE_AND_LIST_OPTIONS_BNDPLT. (PARSE_AND_LIST_ARGS_CASE_Z): Append $PARSE_AND_LIST_ARGS_CASE_Z_BNDPLT. * emulparams/extern_protected_data.sh: New file. ld/testsuite/ PR ld/pr17709 * ld-i386/i386.exp: Run protected6b. * ld-i386/protected6b.d: New file. * ld-x86-64/protected6b.d: Likewise. * ld-x86-64/x86-64.exp: Run protected6b.
2015-04-11Remove an extra ';'H.J. Lu2-1/+5
* plugin.c (plugin_load_plugins): Removed an extra ';'.
2015-04-11Replace SYMBOLIC_BIND with SYMBOL_REFERENCES_LOCALH.J. Lu9-2/+41
When checking R_386_GOTOFF/R_X86_64_GOTOFF64 for building shared library, we should check SYMBOL_REFERENCES_LOCAL instead of SYMBOLIC_BIND to cover more cases. bfd/ * elf32-i386.c (elf_i386_relocate_section): Replace SYMBOLIC_BIND with SYMBOL_REFERENCES_LOCAL when checking R_386_GOTOFF against protected data symbol when building shared library. * elf64-x86-64.c (elf_x86_64_relocate_section): Check R_X86_64_GOTOFF64 against undefined symbol and replace SYMBOLIC_BIND with SYMBOL_REFERENCES_LOCAL when checking R_X86_64_GOTOFF64 against protected data symbol when building shared library. ld/testsuite/ * ld-i386/i386.exp: Run protected6a. * ld-i386/protected6.d: Renamed to ... * ld-i386/protected6a.d: This. * ld-x86-64/hidden4.d: New file. * ld-x86-64/hidden4.s: Likewise. * ld-x86-64/hidden5.d: Likewise. * ld-x86-64/hidden5.s: Likewise. * ld-x86-64/protected6.d: Renamed to ... * ld-x86-64/protected6a.d: This. * ld-x86-64/x86-64.exp: Run hidden4, hidden5, protected6a, protected7a and protected7b.
2015-04-10Check GOTOFF reloc against protected data on x86H.J. Lu10-0/+72
R_386_GOTOFF/R_X86_64_GOTOFF64 relocation shouldn't be used against protected data symbol on x86 since with copy relocation, address of protected data defined in the shared library may be external. This patch will break building shared libraries with protected data symbols using GCCs older than GCC 5 without the bug fix for https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65248 GCC backport request should be made in the GCC bug report above. bfd/ PR ld/pr17709 * elf32-i386.c (elf_i386_relocate_section): Also check R_386_GOTOFF against protected data symbol when building shared library. * elf64-x86-64.c (elf_x86_64_relocate_section): Also check R_X86_64_GOTOFF64 against protected data symbol when building shared library. ld/testsuite/ PR ld/pr17709 * ld-i386/protected6.d: New file. * ld-i386/protected6.s: Likewise. * ld-x86-64/protected6.d: Likewise. * ld-x86-64/protected6.s: Likewise. * ld-x86-64/protected7.d: Likewise. * ld-x86-64/protected7.s: Likewise. * ld-x86-64/protected7a.d: Likewise. * ld-x86-64/protected7b.d: Likewise.
2015-04-10Add extern_protected_data and set it for x86H.J. Lu15-4/+77
Re-apply: commit ca3fe95e469b9daec153caa2c90665f5daaec2b5 With copy relocation, address of protected data defined in the shared library may be external. This patch adds extern_protected_data and changes _bfd_elf_symbol_refs_local_p to return false for protected data if extern_protected_data is true. This patch will break building shared libraries with protected data symbols using GCCs older than GCC 5 without the bug fix for https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65248 GCC backport request should be made in the GCC bug report above. To get correct run-time behavior on Linux, glibc 2.22 or above are required, which have the bug fix for https://sourceware.org/bugzilla/show_bug.cgi?id=17711 Backports for glibc 2.21, 2.20, 2.19 and 2.18 are on hjl/pr17711/2.21, hjl/pr17711/2.20, hjl/pr17711/2.19 and hjl/pr17711/2.18 branches, respectively, at https://sourceware.org/git/?p=glibc.git;a=summary bfd/ PR ld/pr15228 PR ld/pr17709 * elf-bfd.h (elf_backend_data): Add extern_protected_data. * elf32-i386.c (elf_backend_extern_protected_data): New. Defined to 1. * elf64-x86-64.c (elf_backend_extern_protected_data): Likewise. * elflink.c (_bfd_elf_adjust_dynamic_copy): Don't error on copy relocs against protected symbols if extern_protected_data is true. (_bfd_elf_symbol_refs_local_p): Don't return true on protected non-function symbols if extern_protected_data is true. * elfxx-target.h (elf_backend_extern_protected_data): New. Default to 0. (elfNN_bed): Initialize extern_protected_data with elf_backend_extern_protected_data. ld/testsuite/ PR ld/pr15228 PR ld/pr17709 * ld-i386/i386.exp (i386tests): Add a test for PR ld/17709. * ld-i386/pr17709-nacl.rd: New file. * ld-i386/pr17709.rd: Likewise. * ld-i386/pr17709a.s: Likewise. * ld-i386/pr17709b.s: Likewise. * ld-i386/protected3.d: Updated. * ld-i386/protected3.s: Likewise. * ld-x86-64/pr17709-nacl.rd: New file. * ld-x86-64/pr17709.rd: Likewise. * ld-x86-64/pr17709a.s: Likewise. * ld-x86-64/pr17709b.s: Likewise. * ld-x86-64/protected3.d: Updated. * ld-x86-64/protected3.s: Likewise. * ld-x86-64/x86-64.exp (x86_64tests): Add a test for PR ld/17709.
2015-04-10Add a testcase for PR ld/18223H.J. Lu4-0/+21
PR ld/18223 * ld-gc/gc.exp: Run pr18223. * ld-gc/pr18223.d: New file. * ld-gc/pr18223.s: Likewise.
2015-04-10Revert "Add extern_protected_data and set it for x86"Alan Modra15-58/+24
This reverts commit ca3fe95e469b9daec153caa2c90665f5daaec2b5.
2015-04-10Correct setting of elf_list_optionsAlan Modra3-14/+17
* configure.ac: Set elf_list_options etc. in proper case. * configure: Regenerate.
2015-04-10Add documentation about the interation of the ARM assembler's -EB option and ↵Nick Clifton2-2/+10
the linker's --be8 option. PR binutils/18198 * ld.texinfo (--be8): Add a note about the interaction of this option with the assembler's -EB option. * doc/c-arm.texi (ARM Options): Add a note about the interaction of the -EB option with the linker's --be8 option.
2015-04-10Mark _init and _fini for --gc-sectionsAlan Modra2-0/+21
gold marks _init and _fini via symbol, ld marks them via section (default scripts set .init and .fini section KEEP). This makes it possible for people to write their own _init and not bother to put the function into the right section. PR ld/18223 * ldlang.c (lang_process): Add _init and _fini to gc_sym_list.
2015-04-09Remove BNDPLT and add PARSE_AND_LIST_ARGS_CASE_ZH.J. Lu3-16/+24
* emulparams/elf_x86_64.sh (BNDPLT): Removed. (PARSE_AND_LIST_OPTIONS): New. (PARSE_AND_LIST_ARGS_CASE_Z): Likewise. * emultempl/elf32.em (gld${EMULATION_NAME}_handle_option): Remove BNDPLT check. Handle PARSE_AND_LIST_ARGS_CASE_Z. (gld${EMULATION_NAME}_list_options): Remove BNDPLT check.
2015-04-09Update French translation of ld strings.Nick Clifton2-889/+822
* po/fr.po: Updated French translation.
2015-04-08Enable ELF ld_list_options for --enable-targets=allH.J. Lu3-0/+14
When --enable-targets=all is used with non-ELF target, we should enable ELF ld_list_options. * configure.ac (elf_list_options): Set to TRUE for --enable-targets=all. (elf_shlib_list_options): Likewise. (elf_plt_unwind_list_options): Likewise. * configure: Regenerated.
2015-04-08Skip empty EMULATION_NAMEH.J. Lu2-3/+8
* emulparams/elf32bmipn32-defs.sh: Skip empty EMULATION_NAME.
2015-04-08Add SHF_COMPRESSED support to gas and objcopyH.J. Lu5-2/+64
This patch adds --compress-debug-sections={none|zlib|zlib-gnu|zlib-gabi} options to gas and objcopy for ELF files. They control how DWARF debug sections are compressed. --compress-debug-sections=none is equivalent to --nocompress-debug-sections. --compress-debug-sections=zlib and --compress-debug-sections=zlib-gnu are equivalent to --compress-debug-sections. --compress-debug-sections=zlib-gabi compresses DWARF debug sections with SHF_COMPRESSED from the ELF ABI. No linker changes are required to support SHF_COMPRESSED. bfd/ * archive.c (_bfd_get_elt_at_filepos): Also copy BFD_COMPRESS_GABI bit. * bfd.c (bfd::flags): Increase size to 18 bits. (BFD_COMPRESS_GABI): New. (BFD_FLAGS_SAVED): Add BFD_COMPRESS_GABI. (BFD_FLAGS_FOR_BFD_USE_MASK): Likewise. (bfd_update_compression_header): New fuction. (bfd_check_compression_header): Likewise. (bfd_get_compression_header_size): Likewise. (bfd_is_section_compressed_with_header): Likewise. * compress.c (MAX_COMPRESSION_HEADER_SIZE): New. (bfd_compress_section_contents): Return the uncompressed size if the full section contents is compressed successfully. Support converting from/to .zdebug* sections. (bfd_get_full_section_contents): Call bfd_get_compression_header_size to get compression header size. (bfd_is_section_compressed): Renamed to ... (bfd_is_section_compressed_with_header): This. Add a pointer argument to return compression header size. (bfd_is_section_compressed): Use it. (bfd_init_section_decompress_status): Call bfd_get_compression_header_size to get compression header size. Return FALSE if uncompressed section size is 0. * elf.c (_bfd_elf_make_section_from_shdr): Support converting from/to .zdebug* sections. * bfd-in2.h: Regenerated. binutils/ * objcopy.c (do_debug_sections): Add compress_zlib, compress_gnu_zlib and compress_gabi_zlib. (copy_options): Use optional_argument on compress-debug-sections. (copy_usage): Update --compress-debug-sections. (copy_file): Handle compress_zlib, compress_gnu_zlib and compress_gabi_zlib. (copy_main): Handle --compress-debug-sections={none|zlib|zlib-gnu|zlib-gabi}. * doc/binutils.texi: Document --compress-debug-sections={none|zlib|zlib-gnu|zlib-gabi}. binutils/testsuite/ * compress.exp: Add tests for --compress-debug-sections={none|zlib|zlib-gnu|zlib-gabi}. * binutils-all/dw2-3.rS: New file. * binutils-all/dw2-3.rt: Likewise. * binutils-all/libdw2-compressedgabi.out: Likewise. gas/ * as.c (show_usage): Update --compress-debug-sections. (std_longopts): Use optional_argument on compress-debug-sections. (parse_args): Handle --compress-debug-sections={none|zlib|zlib-gnu|zlib-gabi}. * as.h (compressed_debug_section_type): New. (flag_compress_debug): Change type to compressed_debug_section_type. --compress-debug-sections={none|zlib|zlib-gnu|zlib-gabi}. * write.c (compress_debug): Set BFD_COMPRESS_GABI for --compress-debug-sections=zlib-gabi. Call bfd_get_compression_header_size to get compression header size. Don't rename section name for --compress-debug-sections=zlib-gabi. * config/tc-i386.c (compressed_debug_section_type): Set to COMPRESS_DEBUG_ZLIB. * doc/as.texinfo: Document --compress-debug-sections={none|zlib|zlib-gnu|zlib-gabi}. gas/testsuite/ * gas/i386/dw2-compressed-1.d: New file. * gas/i386/dw2-compressed-2.d: Likewise. * gas/i386/dw2-compressed-3.d: Likewise. * gas/i386/x86-64-dw2-compressed-2.d: Likewise. * gas/i386/i386.exp: Run dw2-compressed-2, dw2-compressed-1, dw2-compressed-3 and x86-64-dw2-compressed-2. ld/testsuite/ * ld-elf/compress.exp: Add a test for --compress-debug-sections=zlib-gabi. (build_tests): Add 2 tests for --compress-debug-sections=zlib-gabi. (run_tests): Likewise. Verify linker output with zlib-gabi compressed debug input. * ld-elf/compressed1a.d: New file. * ld-elf/compressed1b.d: Likewise. * ld-elf/compressed1c.d: Likewise.
2015-04-08Add ld_list_optionsH.J. Lu8-119/+195
This patch adds ld_list_options for ELF targets to avoid duplicated outputs from ld --help. * Makefile.am (ELF_CLFAGS): New. (AM_CFLAGS): Add $(ELF_CLFAGS). * configure.ac (elf_list_options): New. AC_SUBST. (elf_shlib_list_options): Likewise. (elf_plt_unwind_list_options): Likewise. * lexsup.c (elf_shlib_list_options): New. (elf_static_list_options): Likewise. (elf_plt_unwind_list_options): Likewise. (ld_list_options): Likewise. (help): Call ld_list_options. * Makefile.in: Regenerated. * configure: Likewise. * emulparams/plt_unwind.sh (PLT_UNWIND): New. (PARSE_AND_LIST_OPTIONS): Removed. * emultempl/elf32.em (gld_list_options): New. (gld${EMULATION_NAME}_list_options): Define only if BNDPLT or PARSE_AND_LIST_OPTIONS is defined. (ld_${EMULATION_NAME}_emulation): Replace gld${EMULATION_NAME}_list_options with ${gld_list_options.
2015-04-07Add new linker option: --warn-orphan which generates warning messages when ↵Nick Clifton10-0/+67
orphan sections are detected. ld * ld.h (struct ld_config_type): Add new field: warn_orphan. * ldlex.h (enum option_values): Add OPTION_WARN_ORPHAN and OPTION_NO_WARN_ORPHAN. * lexsup.c (ld_options): Add --warn-orphan and --no-warn-orphan. (parse_args): Handle the new options. * ldemul.c (ldemul_place_orphan): If requested, generate a warning message when an orphan section is placed in the output file. * ld.texinfo: Document the new option. * NEWS: Mention the new feature. tests * ld-elf/orphan-5.l: New test - checks the linker's output with --warn-orphan enabled. * ld-elf/elf.exp: Run the new test.
2015-04-07Modify get_reloc_section for targets that map .got.plt to .gotAlan Modra11-9/+23
Fixes tic6x testsuite failures due to .rela.plt having a zero sh_info. I considered passing link_info to get_reloc_section so we could directly return the .got.plt output section, but we need the fallback to name lookup anyway for objcopy. bfd/ * elf.c (_bfd_elf_get_reloc_section): Allow for .got.plt being mapped to output .got section. ld/testsuite/ * ld-arm/tls-gdesc-nlazy.g: Adjust for readelf note. * ld-tic6x/shlib-1.rd: Expect corrected .rela.plt sh_info. * ld-tic6x/shlib-1b.rd: Likewise. * ld-tic6x/shlib-1r.rd: Likewise. * ld-tic6x/shlib-1rb.rd: Likewise. * ld-tic6x/shlib-app-1.rd: 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.
2015-04-07Cast shift expressionAlan Modra2-1/+6
PR ld/18176 * ldlang.c (lang_size_sections): Cast shift expression.
2015-04-07PowerPC non-PIC to PIC editing for protected var accessAlan Modra2-3/+18
This is a linker-only solution to the incompatibility between shared library protected visibility variables and using .dynbss and copy relocs for non-PIC access to shared library variables. bfd/ * elf32-ppc.c (struct ppc_elf_link_hash_entry): Add has_addr16_ha and has_addr16_lo. Make has_sda_refs a bitfield. (ppc_elf_check_relocs): Set new flags. (ppc_elf_link_hash_table_create): Update default_params. (ppc_elf_adjust_dynamic_symbol): Clear protected_def in cases where we won't be making .dynbss entries or editing code. Set params->pic_fixup when we'll edit code for protected var access. (allocate_dynrelocs): Allocate got entry for edited code and discard dyn_relocs. (struct ppc_elf_relax_info): Add picfixup_size. (ppc_elf_relax_section): Rename struct one_fixup to struct one_branch_fixup. Rename fixups to branch_fixups. Size space for pic fixups. (ppc_elf_relocate_section): Edit non-PIC accessing protected visibility variables to PIC. Don't emit dyn_relocs for code we've edited. * elf32-ppc.h (struct ppc_elf_params): Add pic_fixup. ld/ * emultempl/ppc32elf.em: Handle --no-pic-fixup. (params): Init new field. (ppc_before_allocation): Enable relaxation for pic_fixup.
2015-04-06Remove is_zlib_supportedH.J. Lu3-11/+7
Since zlib is always supported, there is no need for is_zlib_supported. binutils/testsuite/ * binutils-all/compress.exp: Remove is_zlib_supported check. * binutils-all/objdump.exp: Likewise. * binutils-all/readelf.exp (readelf_compressed_wa_test): Likewise. * lib/utils-lib.exp (run_dump_test): Likewise. * lib/binutils-common.exp (is_zlib_supported): Removed. gas/testsuite/ * lib/gas-defs.exp (run_dump_test): Remove is_zlib_supported check. ld/testsuite/ * ld-elf/compress.exp: Remove is_zlib_supported check. Fail if --compress-debug-sections doesn't work. * lib/ld-lib.exp (run_dump_test): Remove is_zlib_supported check.
2015-04-02Add support for configuring an aarch64-freebsd target.Andrew Turner6-0/+71
ld * Makefile.am: Add FreeBSD aarch64 files. * Makefile.in: Regenerate. * configure.tgt: Add aarch64-*-freebsd* target triple. * emulparams/aarch64fbsd.sh: New file. * emulparams/aarch64fbsdb.sh: New file. bfd * config.bfd: Add aarch64-*-freebsd* target triple.
2015-04-01Work around a GCC uninitialized warning bugH.J. Lu2-0/+10
* emultempl/elf32.em (gld${EMULATION_NAME}_before_allocation): Work around a GCC uninitialized warning bug fixed in GCC 4.6.
2015-04-01[AArch64] Workaround for Cortex A53 erratum 843419Marcus Shawcroft6-1/+179
Some early revisions of the Cortex-A53 have an erratum (843419). The details of the erratum are quite complex and involve dynamic conditions. For the purposes of the workaround we have simplified the static conditions to an ADRP in the last two instructions of a 4KByte page, followed within four instructions by a load/store dependent on the ADRP. This patch adds support to conservatively scan for and workaround Cortex A53 erratum 843419. There are two different workaround strategies used. The first is to rewrite ADRP instructions which form part of an erratum sequence with an ADR instruction. In situations where the ADR provides insufficient offset the dependent load or store instruction from the sequence is moved to a stub section and branches are inserted from the original sequence to the relocated instruction and back again. Stub section sizes are rounded up to a multiple of 4096 in order to ensure that the act of inserting work around stubs does not create more errata sequences. Workaround stubs are always inserted into the stub section associated with the input section containing the erratum sequence. This ensures that the fully relocated form of the veneered load store instruction is available at the point in time when the stub section is written.
2015-04-01Add a testcase for PR ld/18176H.J. Lu6-0/+110
PR ld/18176 * ld-x86-64/pr18176.d: New file. * ld-x86-64/pr18176.s: Likewise. * ld-x86-64/pr18176.t: Likewise. * ld-x86-64/x86-64.exp: Run pr18176.