aboutsummaryrefslogtreecommitdiff
path: root/ld
AgeCommit message (Collapse)AuthorFilesLines
2016-05-03[AArch64] Also puts value in place for R_AARCH64_RELATIVEJiong Wang9-1/+89
When handling absolute relocations for global symbols bind within the shared object, AArch64 will generate one dynamic RELATIVE relocation, but won't apply the value for this absolution relocations at static linking stage. This is different from AArch64 gold linker and x86-64. This is not a bug as AArch64 is RELA, there is only guarantee that relocation addend is placed in the relocation entry. But some system softwares originally writen for x86-64 might assume AArch64 bfd linker gets the same behavior as x86-64, then they could take advantage of this buy skipping those RELATIVE dynamic relocations if the load address is the same as the static linking address. This patch makes AArch64 BFD linker applies absolution relocations at static linking stage for scenario described above. Meanwhile old AArch64 android loader has a bug (PR19163) which relies on current linker behavior as a workaround, so the same option --no-apply-dynamic-relocs added.
2016-05-03Skip ELF STT_COMMON linker tests if shared libraries are not supported.Senthil Kumar Selvaraj2-0/+13
* testsuite/ld-elfcomm/elfcomm.exp: Check for shared lib support before running STT_COMMON tests.
2016-04-29Download source only on remote hostH.J. Lu3-7/+32
There is no need to download source if we aren't on remote host. Otherwise, each ld test run on local host leaves behind a couple test files. * config/default.exp (NOPIE_CFLAGS): Download source only on remote host. (NOPIE_LDFLAGS): Likewise. * testsuite/lib/ld-lib.exp (check_lto_available): Likewise. (check_lto_fat_available): Likewise. (check_lto_shared_available): Likewise. (check_ifunc_available): Likewise. (check_ifunc_attribute_available): Likewise.
2016-04-27Limit ld-elf/compressed1b.d to Linux/GNU targetsH.J. Lu2-0/+5
Since not all ELF targets use the elf.em emulation to support ld option: --compress-debug-sections=zlib-gnu, limit compressed1b.d to Linux/GNU targets. * testsuite/ld-elf/compressed1b.d: Only run for Linux/GNU targets.
2016-04-27Skip debug sections when estimating distancesH.J. Lu2-4/+13
Skip debug sections when estimating distances between output sections since compressed_size is used to compress debug sections and debug sections aren't excluded from distances between output sections. bfd/ PR ld/20006 * elf64-x86-64.c (elf_x86_64_convert_load): Skip debug sections when estimating distances between output sections. ld/ PR ld/20006 * testsuite/ld-elfvsb/elfvsb.exp (COMPRESS_LDFLAG): New. (visibility_run): Pass COMPRESS_LDFLAG to visibility_test on ELF targets.
2016-04-27Pass --compress-debug-sections=none to ldH.J. Lu3-2/+8
Since ld may generate compressed debug sections by default, pass --compress-debug-sections=none to ld to avoid compressed debug sections. * ld-elf/compressed1b.d: Pass --compress-debug-sections=none to ld. * ld-elf/compressed1c.d: Likewise.
2016-04-27Fix powerpc64 ld testsuite failAlan Modra2-2/+7
PR target/19985 * configure.tgt: Don't use var+=.
2016-04-25Allow powerpc64le-linux-gnu toolchain to support big endian targets as well.Nick Clifton2-2/+11
PR target/19985 * configure.tgt: Include big endian PPC64 emulations with little endian PPC64 targets.
2016-04-25AVR: Allow the start address of the .text section to be set by --section-start.Senthil Kumar Selvaraj2-1/+5
* scripttempl/avrtiny.sc (.text): Do not set LMA to zero.
2016-04-21Always run LTO tests on Linux with GCC 4.9 or newerH.J. Lu1-0/+21
Check for LTO availability will hide LTO bugs in ld. Since GCC 4.9 adds -ffat-lto-objects, we always run LTO tests on Linux with GCC 4.9 or newer. * testsuite/lib/ld-lib.exp (check_lto_available): Return 1 on Linux with GCC 4.9 or newer. (check_lto_fat_available): Likewise. (check_lto_shared_available): Likewise.
2016-04-21Add support for non-ELF targets to check their relocs.Nick Clifton2-5/+12
bfd * aout-adobe.c: Use _bfd_generic_link_check_relocs. * aout-target.h: Likewise. * aout-tic30.c: Likewise. * binary.c: Likewise. * bout.c: Likewise. * coff-alpha.c: Likewise. * coff-rs6000.c: Likewise. * coff64-rs6000.c: Likewise. * coffcode.h: Likewise. * i386msdos.c: Likewise. * i386os9k.c: Likewise. * ieee.c: Likewise. * ihex.c: Likewise. * libbfd-in.h: Likewise. * libecoff.h: Likewise. * mach-o-target.c: Likewise. * mmo.c: Likewise. * nlm-target.h: Likewise. * oasys.c: Likewise. * pef.c: Likewise. * plugin.c: Likewise. * ppcboot.c: Likewise. * som.c: Likewise. * srec.c: Likewise. * tekhex.c: Likewise. * versados.c: Likewise. * vms-alpha.c: Likewise. * xsym.c: Likewise. * elfxx-target.h: Use _bfd_elf_link_check_relocs. * linker.c (bfd_link_check_relocs): New function. (_bfd_generic_link_check_relocs): New function. * targets.c (BFD_JUMP_TABLE_LINK): Add initialization of _bfd_link_check_relocs field. (struct bfd_target)L Add _bfd_link_check_relocs field. * bfd-in2.h: Regenerate. * libbfd.h: Regenerate. ld * ldlang.c (lang_check_relocs): Use bfd_link_check_relocs in prefernce to _bfd_elf_link_check_relocs. Drop test for ELF targets. Do not stop the checks when problems are encountered. include * bfdlink.h: Add prototype for bfd_link_check_relocs.
2016-04-21New NOCROSSREFS_TO testsAlan Modra6-10/+19
Fixes failures on hppa-linux and alpha-linux due to not merging .data.* and .sdata into .data. cross3.t modified too since it is the template for the NOCROSSREFS_TO scripts. * testsuite/ld-scripts/cross3.t: Add commonly used data and text section names to output section statements. * testsuite/ld-scripts/cross4.t: Likewise. * testsuite/ld-scripts/cross5.t: Likewise. * testsuite/ld-scripts/cross6.t: Likewise. * testsuite/ld-scripts/cross7.t: Likewise.
2016-04-20Move ELF relocation check after lang_gc_sectionsH.J. Lu3-14/+31
Move ELF relocation check after lang_gc_sections so that all the reference counting code for plt and got relocs can be removed. This only affects ELF targets which check relocations after opening all input file. * ldlang.c (lang_check_relocs): New function. (lang_process): Call lang_check_relocs after lang_gc_sections. * emultempl/elf32.em (gld${EMULATION_NAME}_before_parse): Don't call _bfd_elf_link_check_relocs here.
2016-04-20Check R_386_NONE/R_X86_64_NONE in eh6.dH.J. Lu2-1/+10
There is no need for run-time relocation when converting pointers in .eh_frame section to DW_EH_PE_pcrel encoding. R_386_NONE and R_X86_64_NONE are expected since the space for run-time relocation has been allocated. This is an optimization. PR ld/19972 * testsuite/ld-elf/eh6.d: Pass -rW to readelf and check for R_386_NONE or R_X86_64_NONE.
2016-04-20Add ld-x86-64/pic1 testH.J. Lu4-0/+12
* testsuite/ld-x86-64/pic1.d: New file. * testsuite/ld-x86-64/pic1.s: Likewise. * testsuite/ld-x86-64/x86-64.exp: Run pic1.
2016-04-20Add ld-x86-64/pie2 testH.J. Lu4-0/+18
* testsuite/ld-x86-64/pie2.d: New file. * testsuite/ld-x86-64/pie2.s: Likewise. * testsuite/ld-x86-64/x86-64.exp: Run pie2.
2016-04-20Check run-time R_X86_64_32 relocation overflowH.J. Lu5-0/+36
Since elf_x86_64_check_relocs is called after opening all input files, we can detect dynamic R_X86_64_32 relocation overflow there. bfd/ PR ld/19969 * elf64-x86-64.c (check_relocs_failed): New. (elf_x86_64_need_pic): Moved before elf_x86_64_check_relocs. Support relocation agaist local symbol. Set check_relocs_failed. (elf_x86_64_check_relocs): Use elf_x86_64_need_pic. Check R_X86_64_32 relocation overflow. (elf_x86_64_relocate_section): Skip if check_relocs failed. Update one elf_x86_64_need_pic and remove one elf_x86_64_need_pic. ld/ PR ld/19969 * testsuite/ld-x86-64/pr19969.d: New file. * testsuite/ld-x86-64/pr19969a.S: Likewise. * testsuite/ld-x86-64/pr19969b.S: Likewise. * testsuite/ld-x86-64/x86-64.exp: Run pr19969 tests.
2016-04-20Check ELF relocs after opening all input filesH.J. Lu10-0/+48
Delaying checking ELF relocations until opening all input files so that symbol information is final when relocations are checked. This is only enabled for x86 targets. bfd/ * elf-bfd.h (_bfd_elf_link_check_relocs): New. * elflink.c (_bfd_elf_link_check_relocs): New function. (elf_link_add_object_symbols): Call _bfd_elf_link_check_relocs if check_relocs_after_open_input is FALSE. include/ * bfdlink.h (bfd_link_info): Add check_relocs_after_open_input. ld/ * emulparams/elf32_x86_64.sh (CHECK_RELOCS_AFTER_OPEN_INPUT): New. * emulparams/elf_i386.sh (CHECK_RELOCS_AFTER_OPEN_INPUT): Likewise. * emulparams/elf_i386_be.sh (CHECK_RELOCS_AFTER_OPEN_INPUT): Likewise. * emulparams/elf_i386_chaos.sh (CHECK_RELOCS_AFTER_OPEN_INPUT): Likewise. * emulparams/elf_i386_ldso.sh (CHECK_RELOCS_AFTER_OPEN_INPUT): Likewise. * emulparams/elf_i386_vxworks.sh (CHECK_RELOCS_AFTER_OPEN_INPUT): Likewise. * emulparams/elf_x86_64.sh (CHECK_RELOCS_AFTER_OPEN_INPUT): Likewise. * emulparams/i386nto.sh (CHECK_RELOCS_AFTER_OPEN_INPUT): Likewise. * emultempl/elf32.em (gld${EMULATION_NAME}_before_parse): Set check_relocs_after_open_input to TRUE if CHECK_RELOCS_AFTER_OPEN_INPUT is yes. (gld${EMULATION_NAME}_after_open): Call _bfd_elf_link_check_relocs on all inputs if check_relocs_after_open_input is TRUE.
2016-04-20Replace .long with .dc.a on my_personality_v0H.J. Lu2-1/+6
We should use .dc.a instead of .long to take address of a symbol. * testsuite/ld-elf/eh6.s: Replace .long with .dc.a on my_personality_v0.
2016-04-20update many old style function definitionsTrevor Saunders2-1/+5
This includes regenerating a bunch of files in opcodes/ with trunk cgen. gprof/ChangeLog: 2016-04-20 Trevor Saunders <tbsaunde+binutils@tbsaunde.org> * basic_blocks.c: Update old style function definitions. * cg_arcs.c: Likewise. * cg_print.c: Likewise. * gen-c-prog.awk: Likewise. * gmon_io.c: Likewise. * hertz.c: Likewise. * hist.c: Likewise. * sym_ids.c: Likewise. bfd/ChangeLog: 2016-04-20 Trevor Saunders <tbsaunde+binutils@tbsaunde.org> * cache.c: Update old style function definitions. * elf32-m68k.c: Likewise. * elf64-mmix.c: Likewise. * stab-syms.c: Likewise. opcodes/ChangeLog: 2016-04-20 Trevor Saunders <tbsaunde+binutils@tbsaunde.org> * alpha-dis.c: Regenerate. * crx-dis.c: Likewise. * disassemble.c: Likewise. * epiphany-opc.c: Likewise. * fr30-opc.c: Likewise. * frv-opc.c: Likewise. * ip2k-opc.c: Likewise. * iq2000-opc.c: Likewise. * lm32-opc.c: Likewise. * lm32-opinst.c: Likewise. * m32c-opc.c: Likewise. * m32r-opc.c: Likewise. * m32r-opinst.c: Likewise. * mep-opc.c: Likewise. * mt-opc.c: Likewise. * or1k-opc.c: Likewise. * or1k-opinst.c: Likewise. * tic80-opc.c: Likewise. * xc16x-opc.c: Likewise. * xstormy16-opc.c: Likewise. ld/ChangeLog: 2016-04-20 Trevor Saunders <tbsaunde+binutils@tbsaunde.org> * emultempl/scoreelf.em: Likewise. binutils/ChangeLog: 2016-04-20 Trevor Saunders <tbsaunde+binutils@tbsaunde.org> * resres.c: Likewise. gas/ChangeLog: 2016-04-20 Trevor Saunders <tbsaunde+binutils@tbsaunde.org> * cgen.c: Likewise. * config/tc-bfin.c: Likewise. * config/tc-ia64.c: Likewise. * config/tc-mep.c: Likewise. * config/tc-metag.c: Likewise. * config/tc-nios2.c: Likewise. * config/tc-rl78.c: Likewise.
2016-04-19Add another testcase for PR ld/19719H.J. Lu4-0/+27
This test checks run-time relocation overflow with GOT relocation and 32-bit relocation against the same symbol. PR ld/19719 * testsuite/ld-x86-64/pr19719.d: New file. * testsuite/ld-x86-64/pr19719.s: Likewise. * testsuite/ld-x86-64/x86-64.exp: Run pr19719.
2016-04-18Add new NOCROSSREFS_TO linker script commandMatthew Fortune13-7/+180
NOCROSSREFS_TO is similar to the existing NOCROSSREFS command but only checks one direction of cross referencing. ld/ChangeLog * ld.texinfo: Document NOCROSSREFS_TO script command. * ldlang.h (struct lang_nocrossrefs): Add onlyfirst field. (lang_add_nocrossref_to): New prototype. * ldcref.c (check_local_sym_xref): Use onlyfirst to only look for symbols defined in the first section. (check_nocrossref): Likewise. * ldgram.y (NOCROSSREFS_TO): New script command. * ldlang.c (lang_add_nocrossref): Set onlyfirst to FALSE. (lang_add_nocrossref_to): New function. * ldlex.l (NOCROSSREFS_TO): New token. * NEWS: Mention NOCROSSREFS_TO. * testsuite/ld-scripts/cross4.t: New file. * testsuite/ld-scripts/cross5.t: Likewise. * testsuite/ld-scripts/cross6.t: Likewise. * testsuite/ld-scripts/cross7.t: Likewise. * testsuite/ld-scripts/crossref.exp: Run 4 new NOCROSSREFS_TO tests.
2016-04-15Regenerate Makefile.in/aclocal.m4 automake 1.11.6H.J. Lu3-83/+164
bfd/ * Makefile.in: Regenerated with automake 1.11.6. * aclocal.m4: Likewise. * doc/Makefile.in: Likewise. binutils/ * Makefile.in: Regenerated with automake 1.11.6. * aclocal.m4: Likewise. * doc/Makefile.in: Likewise. gas/ * Makefile.in: Regenerated with automake 1.11.6. * aclocal.m4: Likewise. * doc/Makefile.in: Likewise. gold/ * Makefile.in: Regenerated with automake 1.11.6. * aclocal.m4: Likewise. * testsuite/Makefile.in: Likewise. gprof/ * Makefile.in: Regenerated with automake 1.11.6. * aclocal.m4: Likewise. ld/ * Makefile.in: Regenerated with automake 1.11.6. * aclocal.m4: Likewise. opcodes/ * Makefile.in: Regenerated with automake 1.11.6. * aclocal.m4: Likewise.
2016-04-14arc/nps400 : New cmem instructions and associated relocationAndrew Burgess6-0/+69
Add support for arc/nps400 cmem instructions, these load and store instructions are hard-wired to access "0x57f00000 + 16-bit-offset". Supporting this relocation required some additions to the arc relocation handling in the bfd library, as well as the standard changes required to add a new relocation type. There's a test of the new instructions in the assembler, and a test of the relocation in the linker. bfd/ChangeLog: * reloc.c: Add BFD_RELOC_ARC_NPS_CMEM16 entry. * bfd-in2.h: Regenerate. * libbfd.h: Regenerate. * elf32-arc.c: Add 'opcode/arc.h' include. (struct arc_relocation_data): Add symbol_name. (arc_special_overflow_checks): New function. (arc_do_relocation): Use arc_special_overflow_checks, reindent as required, add an extra comment. (elf_arc_relocate_section): Setup symbol_name in reloc_data. gas/ChangeLog: * testsuite/gas/arc/nps400-3.d: New file. * testsuite/gas/arc/nps400-3.s: New file. include/ChangeLog: * elf/arc-reloc.def: Add ARC_NPS_CMEM16 reloc. * opcode/arc.h (NPS_CMEM_HIGH_VALUE): Define. ld/ChangeLog: * testsuite/ld-arc/arc.exp: New file. * testsuite/ld-arc/nps-1.s: New file. * testsuite/ld-arc/nps-1a.d: New file. * testsuite/ld-arc/nps-1b.d: New file. * testsuite/ld-arc/nps-1b.err: New file. opcodes/ChangeLog: * arc-nps400-tbl.h: Add xldb, xldw, xld, xstb, xstw, and xst instructions. * arc-opc.c (insert_nps_cmem_uimm16): New function. (extract_nps_cmem_uimm16): New function. (arc_operands): Add NPS_XLDST_UIMM16 operand.
2016-04-14Extend PE matching regexp in PR 19457 test to match cygwin and mingw targets.Nick Clifton2-0/+15
PR 19457 * testsuite/ld-scripts/script.exp (extract_symbol_test): Add exceptions for Mingw and Cygwin.
2016-04-13ld/testsuite: Initialise a variable to prevent tcl errorsAndrew Burgess2-0/+6
In some cases a variable could be left uninitialised and then an attempt made to read this variable, resulting in a tcl error. This commit initialises the variable in all cases. ld/ChangeLog: * testsuite/lib/ld-lib.exp (run_dump_test): Initialise check_ld(terminal).
2016-04-13Update x86-64 tests for --as-neededH.J. Lu2-12/+34
Since compiler may pass --as-needed to ld by default, link .o file before .so file in x86-64 tests. PR ld/19774 * testsuite/ld-x86-64/x86-64.exp: Link tmpdir/pr17689b.o before tmpdir/pr17689.so, fix gotpcrel1 test and add more --as-needed tests.
2016-04-11Properly handle dynamic reloc against normal symbolH.J. Lu9-0/+58
We shouldn't issue an error for read-only segment with dynamic IFUNC relocations when dynamic relocations are against normal symbols. bfd/ PR ld/19939 * elf-bfd.h (_bfd_elf_allocate_ifunc_dyn_relocs): Add a pointer to bfd_boolean. * elf-ifunc.c (_bfd_elf_allocate_ifunc_dyn_relocs): Updated. Set *readonly_dynrelocs_against_ifunc_p to TRUE if dynamic reloc applies to read-only section. * elf32-i386.c (elf_i386_link_hash_table): Add readonly_dynrelocs_against_ifunc. (elf_i386_allocate_dynrelocs): Updated. (elf_i386_size_dynamic_sections): Issue an error for read-only segment with dynamic IFUNC relocations only if readonly_dynrelocs_against_ifunc is TRUE. * elf64-x86-64.c (elf_x86_64_link_hash_table): Add readonly_dynrelocs_against_ifunc. (elf_x86_64_allocate_dynrelocs): Updated. (elf_x86_64_size_dynamic_sections): Issue an error for read-only segment with dynamic IFUNC relocations only if readonly_dynrelocs_against_ifunc is TRUE. * elfnn-aarch64.c (elfNN_aarch64_allocate_ifunc_dynrelocs): Updated. ld/ PR ld/19939 * testsuite/ld-i386/i386.exp: Run PR ld/19939 tests. * testsuite/ld-x86-64/x86-64.exp: Likewise. * testsuite/ld-i386/pr19939.s: New file. * testsuite/ld-i386/pr19939a.d: Likewise. * testsuite/ld-i386/pr19939b.d: Likewise. * testsuite/ld-x86-64/pr19939.s: Likewise. * testsuite/ld-x86-64/pr19939a.d: Likewise. * testsuite/ld-x86-64/pr19939b.d: Likewise.
2016-04-09Adjust default memory size and stack base address for SH simulator.Oleg Endo2-2/+6
ld/ChangeLog: * sh/interp.c (sim_memory_size): Default init to 30. (parse_and_set_memory_size): Adjust upper bound to 31. sim/ChangeLog: * sh/interp.c (sim_memory_size): Default init to 30. (parse_and_set_memory_size): Adjust upper bound to 31.
2016-04-08PR18452, ld allows overlapping sectionsAlan Modra2-19/+34
PR 18452 * ldlang.c (maybe_overlays): Delete. (lang_size_sections_1): Remove code setting maybe_overlays. (lang_check_section_addresses): Instead detect overlays by exact match of section VMAs here. Fix memory leak.
2016-04-08Show sizes in linker map in target machine address unitsDan Gisselquist2-4/+15
* ldlang.c (print_output_section_statement): Show minfo size in target machine address units. (print_reloc_statement): Likewise. (print_padding_statement): Likewise. (print_data_statement): Likewise. Ensure minimum print_dot increment of one address unit.
2016-04-07ld/arc: Make little endian default choice for linker scriptsAndrew Burgess2-3/+8
When building with --enable-targets=all the target string is not set to something that matches the pattern arc*-*, and so the script used to decide if we should build big or little endian linker script currently exits with an error. This commit makes little endian linker script be the default, which will be used when building for all targets, this matches the behaviour from before I made the endianness switchable, when we only ever built little endian linker scripts anyway. ld/ChangeLog: * emulparams/arc-endianness.sh: Make little endian default choice.
2016-04-07Fix typo in name of MSP430 attribute section.Nick Clifton3-2/+8
2016-04-05ld/arc: Fix linker for big-endian arc targetsAndrew Burgess28-93/+65
This aims to bring the linker for big-endian arc targets into line with the linker for (the default) little endian arc targets. The bulk of the changes are to extend the target pattern in the test files from 'arc-*...' to 'arc*-*...' and so match both big and little endian arc targets. In the ld/emulparams/ directory the existing scripts checked for a variable ARC_ENDIAN to switch between big and little endian targets, however, this variable is never set up. So, a new script snippet is introduced which sets up ARC_ENDIAN based on the value of target, this snippet is then included from all of the existing arc scripts. The existing big-endian variants of all the scripts, which existed, but were never used, are deleted in this commit. ld/ChangeLog: * emulparams/arc-endianness.sh: New file. * emulparams/arcebelf.sh: Deleted. * emulparams/arcebelf_prof.sh: Deleted. * emulparams/arceblinux.sh: Deleted. * emulparams/arceblinux_prof.sh: Deleted. * emulparams/arcelf.sh: Include arc-endinness.sh. * emulparams/arcelf_prof.sh: Include arc-endinness.sh. * emulparams/arclinux.sh: Include arc-endinness.sh. * emulparams/arclinux_prof.sh: Include arc-endinness.sh. * emulparams/arcv2elf.sh: Include arc-endinness.sh. * emulparams/arcv2elfx.sh: Include arc-endinness.sh. * testsuite/ld-elf/compressed1d.d: Update pattern for big and little endian arc targets. * testsuite/ld-elf/eh-frame-hdr.d: Likewise. * testsuite/ld-elf/group1.d: Likewise. * testsuite/ld-elf/group3b.d: Likewise. * testsuite/ld-elf/group8a.d: Likewise. * testsuite/ld-elf/group8b.d: Likewise. * testsuite/ld-elf/group9a.d: Likewise. * testsuite/ld-elf/group9b.d: Likewise. * testsuite/ld-elf/linkonce2.d: Likewise. * testsuite/ld-elf/pr12851.d: Likewise. * testsuite/ld-elf/pr12975.d: Likewise. * testsuite/ld-elf/pr13177.d: Likewise. * testsuite/ld-elf/pr13195.d: Likewise. * testsuite/ld-elf/pr17615.d: Likewise. * testsuite/ld-elf/pr19162.d: Likewise. * testsuite/ld-elf/sec64k.exp: Likewise. * testsuite/lib/ld-lib.exp: Likewise.
2016-04-05ELF/LD: Avoid producing hidden and internal dynamic symbolsMaciej W. Rozycki17-10/+166
Always turn hidden and internal symbols which have a dynamic index into local ones. This is required by the the ELF gABI[1]: "A hidden symbol contained in a relocatable object must be either removed or converted to STB_LOCAL binding by the link-editor when the relocatable object is included in an executable file or shared object." "An internal symbol contained in a relocatable object must be either removed or converted to STB_LOCAL binding by the link-editor when the relocatable object is included in an executable file or shared object." The ELF linker usually respects this requirement, however in the case where a dynamic symbol has been preallocated due to a reference of the default export class aka visibility from the object being linked, and then merged with a hidden or internal symbol definition from within the same object, then the original export class is carried over to the output dynamic symbol table, because while merging the generic ELF linker only converts affected dynamic symbols to local when they are defined or referenced by the object being linked and a dynamic object involved in the link both at a time. The dynamic symbol produced confuses then the dynamic loader at the run time -- the hidden or internal export class is ignored and the symbol follows preemption rules as with the default export class. In the MIPS target it happens when `mips_elf_record_global_got_symbol' creates a dynamic symbol when a call relocation is encountered. Additionally if the undefined symbol referred by such a relocation does specify the intended export class, then a local dynamic symbol is created instead, which is harmless and allowed, but useless. Normally no local dynamic symbols are created, except for a single dummy one at the beginning. Correct the problem by removing the extra check for a dynamic symbol being defined or referenced by the object being linked and a dynamic object involved in the link both at a time. The test cases included cover the internal and hidden symbol cases, as well as a protected symbol for a reference, the handling of which is unchanged by this fix. Both cases described above are covered, that is where an internal or hidden dynamic symbol is produced and where a local one is. NB this change affects CRIS results where some symbols in the static table produced in a final link are now converted from STV_HIDDEN to STB_LOCAL. This happens whenever the `elf_backend_hide_symbol' handler is called, so the affected symbols must have been chosen for entering into the dynamic symbol table, except in these test cases no such symbol table is produced. In fully linked binaries the static symbol table is only used for debugging though, so such a change is fine. References: [1] "System V Application Binary Interface - DRAFT - 24 April 2001", The Santa Cruz Operation, Inc., "Symbol Table", <http://www.sco.com/developers/gabi/2001-04-24/ch4.symtab.html> bfd/ PR ld/19908 * elflink.c (elf_link_add_object_symbols): Always turn hidden and internal symbols which have a dynamic index into local ones. ld/ PR ld/19908 * testsuite/ld-cris/tls-e-20.d: Adjust for hidden symbol handling fix. * testsuite/ld-cris/tls-e-20a.d: Likewise. * testsuite/ld-cris/tls-e-21.d: Likewise. * testsuite/ld-cris/tls-e-23.d: Likewise. * testsuite/ld-cris/tls-e-80.d: Likewise. * testsuite/ld-cris/tls-gd-3h.d: Likewise. * testsuite/ld-cris/tls-leie-19.d: Likewise. * testsuite/ld-mips-elf/export-class-ref-lib.sd: New test. * testsuite/ld-mips-elf/export-hidden-ref.sd: New test. * testsuite/ld-mips-elf/export-internal-ref.sd: New test. * testsuite/ld-mips-elf/export-protected-ref.sd: New test. * testsuite/ld-mips-elf/export-class-ref-f0.s: New test source. * testsuite/ld-mips-elf/export-class-ref-f1.s: New test source. * testsuite/ld-mips-elf/export-class-ref-f2.s: New test source. * testsuite/ld-mips-elf/mips-elf.exp: Run the new tests.
2016-04-05[ARC] Fix ld testsuite failures.Claudiu Zissulescu15-12/+38
ld/ 016-04-05 Cupertino Miranda <cmiranda@synopsys.com> * testsuite/ld-discard/extern.d: Removed xfail for ARC. * testsuite/ld-discard/start.d: Likewise. * testsuite/ld-discard/static.d: Likewise. * testsuite/ld-elf/group1.d: Likewise. * testsuite/ld-elf/group3b.d: Likewise. * testsuite/ld-elf/orphan-region.d: Likewise. * testsuite/ld-elf/orphan.d: Likewise. * testsuite/ld-elf/orphan3.d: Likewise. * testsuite/ld-elf/pr349.d: Likewise. * testsuite/ld-elf/warn1.d: Likewise. * testsuite/ld-elf/warn2.d: Likewise. * testsuite/ld-elf/warn3.d: Likewise. * testsuite/ld-scripts/crossref.exp: Add __SDATA_BEGIN__ symbol through linker flags. * testsuite/ld-srec/srec.exp: Set as xfail.
2016-04-04Add missing pr19827-nacl.rd for i386/x86-64 NaClH.J. Lu3-0/+16
PR ld/19827 * testsuite/ld-i386/pr19827-nacl.rd: New file. * testsuite/ld-x86-64/pr19827-nacl.rd: Likewise.
2016-04-04More fixes for COFF/PE lanker garbage collection.Nick Clifton1-0/+10
PR 19803 * emultempl/pe.em (change_undef): New function. Encapsulates duplicated code in pe_fixup_stdcalls and adds the newly defined sym to the gc root list. (pe_fixup_stdcall): Use the new function. * pe-dll.c (process_def_file_and_drectve); Add alias of exported symbol to gc root list.
2016-04-04Ignore DWARF debug information with a version of 0 - assume that it is padding.Nick Clifton2-47/+48
PR 19872 bfd * dwarf2.c (parse_comp_unit): Skip warning about unrecognised version number if the version is zero. bin * dwarf.c (display_debug_aranges): Skip warning about unrecognised version number if the version is zero.
2016-03-31enable -Wwrite-strings for gasTrevor Saunders1-2/+18
We add a new AC_SUBST to warning.m4 so that the test if the warning is supported is centralized, but the warning can be enabled per directory. binutils/ChangeLog: 2016-03-31 Trevor Saunders <tbsaunde+binutils@tbsaunde.org> * configure: Regenerate. gprof/ChangeLog: 2016-03-31 Trevor Saunders <tbsaunde+binutils@tbsaunde.org> * configure: Regenerate. ld/ChangeLog: 2016-03-31 Trevor Saunders <tbsaunde+binutils@tbsaunde.org> * configure: Regenerate. opcodes/ChangeLog: 2016-03-31 Trevor Saunders <tbsaunde+binutils@tbsaunde.org> * configure: Regenerate. bfd/ChangeLog: 2016-03-31 Trevor Saunders <tbsaunde+binutils@tbsaunde.org> * configure: Regenerate. * warning.m4: Add WARN_WRITE_STRINGS AC_SUBST. gold/ChangeLog: 2016-03-31 Trevor Saunders <tbsaunde+binutils@tbsaunde.org> * configure: Regenerate. gas/ChangeLog: 2016-03-31 Trevor Saunders <tbsaunde+binutils@tbsaunde.org> * Makefile.am: Add WARN_WRITE_STRINGS to WARN_CFLAGS. * Makefile.in: Regenerate. * configure: Likewise.
2016-03-31More cases of missing TO_ADDR in ldlang.cAlan Modra2-14/+21
and one extraneous occurrence. * ldlang.c (TO_ADDR, TO_SIZE, opb_shift): Move earlier in file. (lang_insert_orphan): Use TO_ADDR in __stop sym calculation. (print_input_section): Don't use TO_ADDR when printing section size. (lang_size_sections_1): Use TO_ADDR in overlay lma calculation. (lang_size_sections): Use TO_ADDR in relro end calculation.
2016-03-30ld/testing: Fix error and warning checks in run_dump_testAndrew Burgess4-5/+12
The options warning_output and error_output to the run_dump_test function were incorrectly checking the return value from the regexp_diff function, and so, as a result failing tests were showing as a pass. Fixed in this commit. ld/ChangeLog: * testsuite/lib/ld-lib.exp (run_dump_test): Fix check of return value from regexp_diff. * testsuite/ld-elf/orphan-5.l: Fix expected output. * testsuite/ld-elf/orphan-6.l: Likewise.
2016-03-30PR18452, ld allows overlapping sectionsAlan Modra3-46/+116
PR 18452 * ldlang.c (maybe_overlays): New static var. (lang_size_sections_1): Set it here. (struct check_sec): New. (sort_sections_by_lma): Adjust for array of structs. (sort_sections_by_vma): New function. (lang_check_section_addresses): Check both LMA and VMA for overlap. * testsuite/ld-scripts/rgn-over7.d: Adjust.
2016-03-30Missing TO_ADDRAlan Modra2-1/+6
* ldlang.c (lang_size_sections_1): Correct code detecting a backward non-overlapping move.
2016-03-30Use consistent test for .tbss sections in ldlang.cAlan Modra2-12/+15
Some places tested SEC_LOAD, others SEC_HAS_CONTENTS. * ldlang.c (IS_TBSS): New macro, extracted from.. (IGNORE_SECTION): ..here. (lang_size_sections_1): Use IS_TBSS and IGNORE_SECTION. (lang_size_sections, lang_do_assignments_1): Use IS_TBSS.
2016-03-22Improve COFF/PE linker garbage collection by preventing the removal of ↵Nick Clifton6-34/+47
sections containing exported symbols. PR ld/19803 * ldlang.c (lang_add_gc_name): New function. Adds the provided symbol name to the list of gc symbols. (lang_process): Call lang_add_gc_name with entry_symbol_default if entry_symbol.name is NULL. Use lang_add_gc_name to add the init and fini function names. * pe-dll.c (process_def_file_and_drectve): Add exported names to the gc symbol list. * testsuite/ld-pe/pr19803.s: Do not export _testval symbol. * testsuite/ld-pe/pr19803.d: Tweak expected output.
2016-03-22Add -Wstack-usage to the gcc warning flags list, but only if using a ↵Nick Clifton2-1/+23
sufficiently recent version of gcc. bfd * warning.m4 (GCC_WARN_CFLAGS): Only add -Wstack-usage if using a sufficiently recent version of GCC. * configure: Regenerate. others * configure: Regenerate.
2016-03-21Remove use of alloca.Nick Clifton5-28/+48
bfd * warning.m4 (GCC_WARN_CFLAGS): Add -Wstack-usage=262144 * configure: Regenerate. * elf32-m68hc1x.c (elf32_m68hc11_relocate_section): Replace use of alloca with call to xmalloc. * elf32-nds32.c: Likewise. * elf64-hppa.c: Likewise. * elfxx-mips.c: Likewise. * pef.c: Likewise. * pei-x86_64.c: Likewise. * som.c: Likewise. * xsym.c: Likewise. binutils * dlltool.c: Replace use of alloca with call to xmalloc. * dllwrap.c: Likewise. * nlmconv.c: Likewise. * objdump.c: Likewise. * resrc.c: Likewise. * winduni.c: Likewise. * configure: Regenerate. gas * atof-generic.c: Replace use of alloca with call to xmalloc. * cgen.c: Likewise. * dwarf2dbg.c: Likewise. * macro.c: Likewise. * remap.c: Likewise. * stabs.c: Likewise. * symbols.c: Likewise. * config/obj-elf.c: Likewise. * config/tc-aarch64.c: Likewise. * config/tc-arc.c: Likewise. * config/tc-arm.c: Likewise. * config/tc-avr.c: Likewise. * config/tc-ia64.c: Likewise. * config/tc-mips.c: Likewise. * config/tc-msp430.c: Likewise. * config/tc-nds32.c: Likewise. * config/tc-ppc.c: Likewise. * config/tc-sh.c: Likewise. * config/tc-tic30.c: Likewise. * config/tc-tic54x.c: Likewise. * config/tc-xstormy16.c: Likewise. * config/te-vms.c: Likewise. * configure: Regenerate. ld * emultempl/msp430.em: Replace use of alloca with call to xmalloc. * plugin.c: Likewise. * pe-dll.c: Likewise.
2016-03-18Ensure that the .rdata_pseudo_runtime_reloc sections are not discarded by ↵Awson3-2/+9
gabage collection. PR 19531 * scripttempl/pe.sc (.rdata_runtime_pseudo_reloc): Always KEEP this section. * scripttempl/pep.sc (.rdata_runtime_pseudo_reloc): Likewise.
2016-03-18Fix possible failure in the AVR linker tests.Senthil Kumar Selvaraj9-5/+114
* ld-avr/gc-section-debugline.d: Relax regex check for CU.