aboutsummaryrefslogtreecommitdiff
path: root/ld
AgeCommit message (Collapse)AuthorFilesLines
2017-02-27Place read-only data in the text section on AVR Tiny targets.Georg-Johann Lay2-2/+15
PR target/20849 * scripttempl/avrtiny.sc (__RODATA_PM_OFFSET__): New define. (.rodata): New section. (.data): Remove .rodata*.
2017-02-25Testsuite fixes for hppa64-hpuxAlan Modra16-55/+110
HPUX has a different .comm syntax, and anything in the first column is a label. gas/ * testsuite/gas/elf/strtab.s: Don't put directives on first column or continuation with labels not in first column. ld/ * testsuite/ld-elf/elf.exp: Xfail pr20995 tests on hppa64-hpux. Set up HPUX defsym. Run pr14170 tests and build symbol3 objects, defining HPUX where necessary. Define HPUX for implib tests. * testsuite/ld-elf/comm-data4.d: Run for hpux. * testsuite/ld-elf/endsym.d: Likewise. * testsuite/ld-elf/linkoncerdiff.d: Likewise. * testsuite/ld-elf/comm-data4.s: Add alternate .comm when HPUX. * testsuite/ld-elf/comm-data5.s: Likewise. * testsuite/ld-elf/endsym.s: Likewise. * testsuite/ld-elf/pr14170c.s: Likewise. * testsuite/ld-elf/symbol3.s: Likewise. * testsuite/ld-elf/implib.s: Likewise. Don't start directives in first column. * testsuite/ld-elf/linkoncerdiff2.s: Don't use numeric labels. * testsuite/ld-elf/warn3.d: Run for hpux. * testsuite/ld-scripts/rgn-at10.d: Xfail for hpux. * testsuite/ld-scripts/rgn-at11.d: Likewise. * testsuite/ld-scripts/size-2.d: Remove xfail for hpux.
2017-02-24readelf: Fix incorrect "Version definition past end of section" messageMaciej W. Rozycki7-0/+118
Fix a commit 74e1a04b9787 ("More fixes for reading corrupt ELF files.") `readelf --version-info' regression that caused "Version definition past end of section" to be always printed at the end, even with good section data. For example with the `mips-linux' target we get: $ cat ver_def.s .data .globl new_foo .type new_foo, %object new_foo: .symver new_foo, foo@@ver_foo $ cat ver_def.ver { global: *foo*; local: *; }; $ as -o ver_def.o ver_def.s $ ld -e 0 --export-dynamic --version-script=ver_def.ver -o ver_def ver_def.o $ readelf -V ver_def Version symbols section '.gnu.version' contains 4 entries: Addr: 000000000000007e Offset: 0x01007e Link: 2 (.dynsym) 000: 0 (*local*) 2 (ver_foo) 1 (*global*) 2 (ver_foo) Version definition section '.gnu.version_d' contains 2 entries: Addr: 0x0000000000000088 Offset: 0x010088 Link: 3 (.dynstr) 000000: Rev: 1 Flags: BASE Index: 1 Cnt: 1 Name: ver_def 0x001c: Rev: 1 Flags: none Index: 2 Cnt: 1 Name: ver_foo Version definition past end of section $ The cause is the `if (idx + ent.vd_next <= idx)' condition introduced to ensure forward progress, which however always triggers for good version definition section data as the last entry will have its `vd_next' value set to 0. Adjust the condition then, to say `if (idx + ent.vd_next < idx)' instead and to ensure forward progress limit the number of entries processed to the size of the version definition section, removing the problematic message from output quoted above, while ensuring the original PR 17531 test case is still handled gracefully. Add a suitable test case so that we have `readelf --version-info' coverage; due to the lack of infrastructure needed to run the linker in the `binutils' test suite and limited justification to implement it add a new `readelf.exp' script to the `ld' test suite instead, intended to gather any `readelf' test cases that require the linker to be run. If ever we decide to have linker infrastructure added to the `binutils' test suite, then the script can be moved between the test suites. binutils/ * readelf.c (process_version_sections) <SHT_GNU_verdef>: Limit the number of entries processed by the section size. Don't break out of the loop if `ent.vd_next' is 0. ld/ * testsuite/ld-elf/ver_def.d: New test. * testsuite/ld-elf/ver_def.ld: New test linker script. * testsuite/ld-elf/ver_def.ver: New test version script. * testsuite/ld-elf/ver_def.s: New test source. * testsuite/ld-elf/readelf.exp: New test script.
2017-02-23MIPS/BFD: Remove duplicate NewABI JALR relocation handlingMaciej W. Rozycki5-4/+12
Remove separate original NewABI JALR relocation handling, introduced with commit d06471104a83 ("relax jalr $t9 [R_MIPS_JALR symbol] to bal symbol"), <https://sourceware.org/ml/binutils/2003-03/msg00394.html>, and only used by LD with the `--relax' option specified, and rely solely on `mips_elf_perform_relocation' code, which has been introduced with commit 1367d393bb74 ("On the RM9000 convert jal to bal if in range"), <https://www.sourceware.org/ml/binutils/2004-12/msg00088.html> and since made more complete, across all the three ABIs. Also remove the `--relax' option, now irrelevant, from the tests added with the former commit. bfd/ * elfxx-mips.h (_bfd_mips_relax_section): Remove prototype. * elfxx-mips.c (_bfd_mips_relax_section): Remove function. * elf64-mips.c (bfd_elf64_bfd_relax_section): Remove macro. * elfn32-mips.c (bfd_elf32_bfd_relax_section): Likewise. ld/ * testsuite/ld-mips-elf/relax-jalr-n32.d: Remove `--relax' option. * testsuite/ld-mips-elf/relax-jalr-n32-shared.d: Likewise. * testsuite/ld-mips-elf/relax-jalr-n64.d: Likewise. * testsuite/ld-mips-elf/relax-jalr-n64-shared.d: Likewise.
2017-02-23MIPS/BFD: Discard ineligible JALR relocations right awayMaciej W. Rozycki3-1/+32
Discard R_MIPS_JALR and R_MICROMIPS_JALR relocations associated with jumps that cannot be converted to an equivalent branch right away in `mips_elf_calculate_relocation' rather than letting them through to `mips_elf_perform_relocation'. This includes cross-mode jumps which need to flip the ISA bit or jumps to a misaligned location that cannot be encoded with a branch, in addition to preemptible symbol references already handled. Cross-mode jumps are actually already rejected as the conversion is made in `mips_elf_perform_relocation', so in this case this change only saves some processing. Jumps to a misaligned location are however converted, with bits causing misalignment lost, making resulting code functionally different even if the lone effect is avoiding an address error exception with an instruction fetch at the jump destination requested. Add test cases suitable, also including GAS verification to confirm that the JALR relocations explicitly requested have indeed been output in the intermediate objects used. bfd/ * elfxx-mips.c (mips_elf_calculate_relocation) <R_MIPS_JALR> <R_MICROMIPS_JALR>: Discard relocation if `cross_mode_jump_p' or misaligned. gas/ * testsuite/gas/mips/jalr4.d: New test. * testsuite/gas/mips/jalr4-n32.d: New test. * testsuite/gas/mips/jalr4-n64.d: New test. * testsuite/gas/mips/jalr4.s: New test source. * testsuite/gas/mips/mips.exp: Run the new tests. ld/ * testsuite/ld-mips-elf/jalr4.dd: New test. * testsuite/ld-mips-elf/mips-elf.exp: Run the new test.
2017-02-23Correct VLE 16D and SDAREL relocationsAlan Modra3-48/+56
PR 20744 bfd/ * elf32-ppc.c (ppc_elf_howto_raw): Correct dst_mask on all VLE 16D relocations. (ppc_elf_vle_split16): Correct field mask and shift for 16D relocs. (ppc_elf_relocate_section): Correct calculation for VLE SDAREL relocs. ld/ * testsuite/ld-powerpc/vle-reloc-2.s: Use r6 for last insn of each group. * testsuite/ld-powerpc/vle-reloc-2.d: Update for above change and sdarel reloc fix.
2017-02-22PR ld/20828: Move symbol version processing ahead of GC symbol sweepMaciej W. Rozycki9-1/+106
Complement commit b531344c34b0 ("PR ld/20828: Reorder the symbol sweep stage of section GC") and commit 81ff47b3a546 ("PR ld/20828: Fix linker script symbols wrongly forced local with section GC") and move symbol version processing ahead of the symbol sweep stage of section GC, all in `bfd_elf_size_dynamic_sections', so that version symbols created stay in the global scope and are not output as local symbols to the dynamic symbol table in the presence of corresponding symbol definitions pulled from a DSO involved in a link. Consolidate the whole of symbol version processing into a single block from all parts scattered across the function and rearranging the local variables used as necessary, however leaving the setting of dynamic entries associated with the DT_VERDEF, DT_VERDEFNUM, DT_VERNEED and DT_VERNEEDNUM tags and the SEC_EXCLUDE flag for unused `.gnu.version' section in the original places. With the rearrangement of code blocks `Elf_Internal_Verneed *t' would shadow the previous definition of `struct bfd_elf_version_tree *t', so rename the former variable to `vn'. bfd/ PR ld/20828 * elflink.c (bfd_elf_size_dynamic_sections): Move symbol version processing ahead of the call to `elf_gc_sweep_symbol'. ld/ PR ld/20828 * testsuite/ld-elf/pr20828-d.sd: New test. * testsuite/ld-elf/pr20828-e.sd: New test. * testsuite/ld-elf/pr20828-v.od: New test. * testsuite/ld-elf/pr20828-v.ver: New test version script. * testsuite/ld-elf/pr20828-v.ld: New test linker script. * testsuite/ld-elf/pr20828.ld: Add `.gnu.version' and `.gnu.version_d'. * testsuite/ld-elf/shared.exp: Run the new tests.
2017-02-21Fix compile time warning message in linker testsuite test.Nick Clifton2-6/+13
* testsuite/ld-ifunc/pr18808b.c (bar): Fix compile time warning about non-void function returning without a result.
2017-02-21PE ld -r script fixesAlan Modra3-15/+31
PR 15041 * scripttempl/pe.sc: Don't combine sections for ld -r. * scripttempl/pep.sc: Likewise.
2017-02-20fix PR numberAlan Modra1-1/+1
2017-02-20Move .stack before debug sectionsAlan Modra20-157/+98
PR 20199 * emulparams/elf32m32c.sh: Define STACK_ADDR and STACK_SENTINEL rather than using OTHER_SECTIONS. * emulparams/elf32mt.sh: Likewise. * emulparams/elf32rx.sh: Likewise. * emulparams/elf32rl78.sh: Likewise. Use OTHER_SYMBOLS to define __rl78_abs__. * emulparams/shelf.sh: Define STACK_ADDR and STACK_SENTINEL rather than using OTHER_SECTIONS. * emulparams/shelf32.sh: Likewise. Use OTHER_SECTIONS for .cranges. * emulparams/shelf64.sh: Unset OTHER_SECTIONS. * emulparams/shelf_nbsd.sh: Unset STACK_ADDR not OTHER_SECTIONS. * emulparams/shelf_uclinux.sh: Likewise. * emulparams/shlsymbian.sh: Unset STACK_ADDR. Use OTHER_SYMBOLS to define _stack, not OTHER_SECTIONS. * scripttempl/elf.sc: Move STACK, TINY_DATA_SECTION, and TINY_BSS_SECTION before debug sections. Add STACK_SENTINEL. * scripttempl/arclinux.sc: Likewise. * scripttempl/elf64hppa.sc: Likewise. * scripttempl/elfxtensa.sc: Likewise. * scripttempl/nds32elf.sc: Likewise. * scripttempl/armbpabi.sc: Move STACK before debug sections. * scripttempl/elf_chaos.sc: Likewise. * scripttempl/elfarc.sc: Delete STACK. * scripttempl/epiphany_4x4.sc: Delete STACK. Move TINY_DATA_SECTION, TINY_BSS_SECTION, and .stack before debug sections.
2017-02-17Fix documentation of the linker's --pop-state command line option.Nick Clifton2-0/+6
PR ld/20825 * ld.texinfo (Options): Add missing @item entry for --pop-state.
2017-02-17Relax dwarf2 expected error matchAlan Modra2-0/+6
* testsuite/ld-elf/dwarf2.err: Accept other errors between the multiple definition errors.
2017-02-17Relax dwarf3 expected error matchAlan Modra3-4/+9
* testsuite/ld-elf/dwarf2.err: Add missing newline at end. * testsuite/ld-elf/dwarf3.err: Likewise. Allow match without filename.
2017-02-16bfd: Improve lookup of file / line information for errorsAndrew Burgess3-6/+12
When looking up file and line information (used from the linker to report error messages) if no symbol is passed in, then use the symbol list to look for a matching symbol. If a matching symbol is found then use this to look up the file / line information. This should improve errors when looking up file / line information for data sections. Hopefully we should find a matching data symbol, which should, in turn (we hope) match a DW_TAG_variable in the DWARF, this should allow us to give accurate file / line errors for data symbols. As the hope is to find a matching DW_TAG_variable in the DWARF then we ignore section symbols, and prefer global symbols to locals. bfd/ChangeLog: * dwarf2.c (_bfd_dwarf2_find_nearest_line): Perform symbol lookup before trying to fine matching file and line information. ld/ChangeLog: * testsuite/ld-elf/shared.exp: Update expected results. * testsuite/ld-elf/dwarf2.err: Likewise
2017-02-16bfd/dwarf: Improve use of previously loaded dwarf informationAndrew Burgess7-0/+54
When parsing DWARF data in order to report file/line type error messages we perform section placement to make section addresses unique within relocatable object files. Currently, if we reuse previously loaded (and cached) dwarf data then we neglect to perform section placement, the result is that the section addresses will not be unique, and we might, incorrectly associate an address with the wrong debug information, and so report an incorrect file and line number. Further we neglect to check that that bfd for which we are looking up debug information is actually the bfd for which the previous debug information was loaded, it is possible that we will reuse previously loaded debug information for a different bfd. And finally, due to following of gnu_debuglink links in one bfd to another, the process of checking that the cached debug information is valid requires us to track the original bfd in the cached debug information. The original debug information here is either the bfd that we're interested in, not the bfd we finally load the debug information from. bfd/ChangeLog: * dwarf2.c (struct dwarf2_debug): Add orig_bfd member. (_bfd_dwarf2_slurp_debug_info): If stashed debug information does not match current bfd, then reload debug information. Record bfd we're loading debug info for in the stash. If we have debug informatin in the cache then perform section placement before returning. ld/ChangeLog: * testsuite/ld-elf/dwarf.exp (build_tests): Add new tests. * testsuite/ld-elf/dwarf2.err: New file. * testsuite/ld-elf/dwarf2a.c: New file. * testsuite/ld-elf/dwarf2b.c: New file. * testsuite/ld-elf/dwarf3.c: New file. * testsuite/ld-elf/dwarf3.err: New file.
2017-02-16ld: Add additional checking for warnings/errors in testsuiteAndrew Burgess4-16/+84
This commit adds new actions to the run_cc_link_tests mechanism in the linker testsuite. Previously this procedure could take a parameter containing a regular expression that would be matched against warnings from the linker. After this commit the warnings parameter is removed, instead, the actions list can contain the actions 'warning', 'error', 'warning_output', or 'error_output'. The action names are chosen to match the actions already present in the run_dump_test procedure. These new actions allow for the current warning checking, but also allow for checking of errors using a regular expression. More interestingly, the *_output actions allow for the warning/error patterns to be placed in a separate file. The small number of tests that make use of the warning parameter have been updated to the new mechanism. Later commits will make use of the new features added in this commit. ld/ChangeLog: * testsuite/lib/ld-lib.exp (run_cc_link_tests): Add warning, error, warning_output, and error_output actions. Remove separate warnings parameter. * testsuite/ld-elf/shared.exp (build_tests): Updated to use 'warning' action. * testsuite/ld-plugin/lto.exp (lto_link_tests): Likewise.
2017-02-16ld testsuite function pointer comparisons vs. hppaAlan Modra4-5/+12
ld/testsuite/ld-elf/check-ptr-eq.c fails for hppa, since function pointers may point at plabels. It isn't valid to cast two function pointers to void* and then compare the void pointers. * testsuite/ld-elf/check-ptr-eq.c (check_ptr_eq): Change params from void pointers to function pointers. * testsuite/ld-elf/pr18718.c: Update to suit. * testsuite/ld-elf/pr18720a.c: Update to suit.
2017-02-16hppa -z relro againAlan Modra5-8/+16
I misunderstood the hppa alias problem. File offsets of segments need to be such that no page is mapped twice with different permissions. (Which still seems to me like something the kernel could fix, but anyhow, this is not so difficult to achieve in ld.) PR 21000 bfd/ * elf-bfd.h (struct elf_backend_data): Add no_page_alias. * elfxx-target.h (elf_backend_no_page_alias): Define. (elfNN_bed): Init new field. * elf.c (assign_file_positions_for_load_sections): If no_page_alias ensure PT_LOAD segment starts on a new page. * elf32-hppa.c (elf_backend_no_page_alias): Define. ld/ * testsuite/ld-elf/loadaddr1.d: Adjust for hppa file offsets. * testsuite/ld-elf/loadaddr2.d: Likewise. * testsuite/ld-elf/loadaddr3a.d: Likewise. * testsuite/ld-scripts/rgn-at5.d: Likewise.
2017-02-16Fix more powerpc testsuite source errorsAlan Modra3-2/+7
* testsuite/ld-powerpc/vxworks1-lib.s: Correct addi to addic. * testsuite/ld-powerpc/vxworks1-lib.dd: Adjust to suit.
2017-02-15i386: Allow "lea foo@GOT, %reg" in PICH.J. Lu4-0/+72
"lea foo@GOT, %reg" is OK in PIC since it only loads the GOT offset into register, which can be used later with a GOT base register to get the value in the GOT entry. bfd/ PR ld/21168 * elf32-i386.c (elf_i386_relocate_section): Allow "lea foo@GOT, %reg" in PIC. ld/ PR ld/21168 * testsuite/ld-i386/i386.exp: Run pr21168. * testsuite/ld-i386/pr21168a.c: New file. * testsuite/ld-i386/pr21168b.S: Likewise.
2017-02-15Add a test for R_386_GOT32/R_386_GOT32X IFUNC reloc errorH.J. Lu6-0/+56
bfd/ PR ld/20244 * elf32-i386.c (elf_i386_relocate_section): Properly get IFUNC symbol name when reporting R_386_GOT32/R_386_GOT32X relocation error against local IFUNC symbol without a base register for PIC. ld/ PR ld/20244 * testsuite/ld-i386/i386.exp: Run pr20244-4a, pr20244-4b and pr20244-4c. * testsuite/ld-i386/pr20244-4.s: New file. * testsuite/ld-i386/pr20244-4a.d: Likewise. * testsuite/ld-i386/pr20244-4b.d: Likewise. * testsuite/ld-i386/pr20244-4c.d: Likewise.
2017-02-15LD: vfinfo: Make clever formatters consistent WRT function name reportingMaciej W. Rozycki25-548/+35
Remove an inconsistency in linker error message processing causing that it depends on the ability to infer the name of the originating source file whether or not the name of the offending function is repeated by clever formatters for each issue reported within the function. Taking the `ld/testsuite/ld-powerpc/tocopt7.s' test case source as an example and the `powerpc-linux' target we have: $ as -gdwarf2 -o tocopt.o -a64 tocopt.s $ ld -o tocopt -melf64ppc tocopt.o tocopt.o: In function `_start': tocopt.s:35:(.text+0x14): toc optimization is not supported for 0x3fa00000 instruction. tocopt.s:49:(.text+0x34): toc optimization is not supported for 0x3fa00000 instruction. $ vs: $ as -o tocopt.o -a64 tocopt.s $ ld -o tocopt -melf64ppc tocopt.o tocopt.o: In function `_start': (.text+0x14): toc optimization is not supported for 0x3fa00000 instruction. tocopt.o: In function `_start': (.text+0x34): toc optimization is not supported for 0x3fa00000 instruction. $ Similarly with the `mips-linux' target and this source: $ cat jal-global-multi-overflow.s .text .set noreorder .space 0x2000 .align 4 .globl foo .ent foo foo: jal bar nor $0, $0 jal bar nor $0, $0 .end foo .space 0x1ff0 .align 4 .globl bar .ent bar bar: jal foo nor $0, $0 jal foo nor $0, $0 .end bar $ as -o jal-global-multi-overflow.o jal-global-multi-overflow.s $ ld -Ttext 0x1fffd000 -e foo -o jal-global-multi-overflow jal-global-multi-overflow.o jal-global-multi-overflow.o: In function `foo': (.text+0x2000): relocation truncated to fit: R_MIPS_26 against `bar' jal-global-multi-overflow.o: In function `foo': (.text+0x2008): relocation truncated to fit: R_MIPS_26 against `bar' jal-global-multi-overflow.o: In function `bar': (.text+0x4000): relocation truncated to fit: R_MIPS_26 against `foo' jal-global-multi-overflow.o: In function `bar': (.text+0x4008): relocation truncated to fit: R_MIPS_26 against `foo' $ Not only this is inconsistent, but it causes output clutter as well with redundant information. The cause for this is a check in `vfinfo' the intent of which is to print the function heading whenever (among others) the name of the source file has changed, which however does not take into account a situation where the name couldn't have been established both now and previously. Adjust the check then for this situation, yielding: $ as -o tocopt.o -a64 tocopt.s $ ld -o tocopt -melf64ppc tocopt.o tocopt.o: In function `_start': (.text+0x14): toc optimization is not supported for 0x3fa00000 instruction. (.text+0x34): toc optimization is not supported for 0x3fa00000 instruction. $ and: $ as -o jal-global-multi-overflow.o jal-global-multi-overflow.s $ ld -Ttext 0x1fffd000 -e foo -o jal-global-multi-overflow jal-global-multi-overflow.o jal-global-multi-overflow.o: In function `foo': (.text+0x2000): relocation truncated to fit: R_MIPS_26 against `bar' (.text+0x2008): relocation truncated to fit: R_MIPS_26 against `bar' jal-global-multi-overflow.o: In function `bar': (.text+0x4000): relocation truncated to fit: R_MIPS_26 against `foo' (.text+0x4008): relocation truncated to fit: R_MIPS_26 against `foo' $ respectively instead. Adjust the test suite accordingly. ld/ * ldmisc.c (vfinfo): Don't print the function name again either if no source file name has been found both now and previously. * testsuite/ld-cris/tls-err-20x.d: Adjust accordingly. * testsuite/ld-mips-elf/mode-change-error-1.d: Likewise. * testsuite/ld-mips-elf/unaligned-branch.d: Likewise. * testsuite/ld-mips-elf/unaligned-branch-mips16.d: Likewise. * testsuite/ld-mips-elf/unaligned-branch-micromips.d: Likewise. * testsuite/ld-mips-elf/unaligned-branch-r6-1.d: Likewise. * testsuite/ld-mips-elf/unaligned-branch-2.d: Likewise. * testsuite/ld-mips-elf/unaligned-branch-r6-2.d: Likewise. * testsuite/ld-mips-elf/unaligned-branch-ignore-2.d: Likewise. * testsuite/ld-mips-elf/unaligned-branch-ignore-mips16.d: Likewise. * testsuite/ld-mips-elf/unaligned-branch-ignore-micromips.d: Likewise. * testsuite/ld-mips-elf/unaligned-branch-ignore-r6-1.d: Likewise. * testsuite/ld-mips-elf/unaligned-jalx-addend-1.d: Likewise. * testsuite/ld-mips-elf/unaligned-jalx-addend-mips16-1.d: Likewise. * testsuite/ld-mips-elf/unaligned-jalx-addend-micromips-1.d: Likewise. * testsuite/ld-mips-elf/unaligned-jalx-addend-3.d: Likewise. * testsuite/ld-mips-elf/unaligned-jump.d: Likewise. * testsuite/ld-mips-elf/unaligned-jump-mips16.d: Likewise. * testsuite/ld-mips-elf/unaligned-jump-micromips.d: Likewise. * testsuite/ld-mips-elf/unaligned-lwpc-1.d: Likewise. * testsuite/ld-mips-elf/unaligned-ldpc-1.d: Likewise. * testsuite/ld-powerpc/tocopt.out: Likewise. * testsuite/ld-powerpc/tocopt7.out: Likewise.
2017-02-15LD: vfinfo: Remove static NULL initializersMaciej W. Rozycki2-2/+6
Remove static NULL initializers, moving the respective variables from data to BSS and saving some storage space. ld/ * ldmisc.c (vfinfo) <'H'>: Remove static NULL initializers.
2017-02-15Use Windows style directory separators when running sysroot tests under ↵Igor Kudrin2-1/+25
MinGW and Cygwin. * testsuite/ld-scripts/sysroot-prefix.exp (get_base_dir_for_scripts): New function. (run_sysroot_prefix_test): Use get_base_dir_for_scripts.
2017-02-13Don't use "_gp" on RISC-V, use "_global_pointer$" insteadPalmer Dabbelt2-1/+6
"_gp" could conflict with ABI-complient code. While it's probably OK because MIPS uses this name, we figured it'd be good to clean this up before a release with RISC-V in it. ld/ChangeLog: 2017-02-13 Palmer Dabbelt <palmer@dabbelt.com> * emulparams/elf32lriscv-defs.sh (SDATA_START_SYMBOLS): Change _gp to __global_pointer$. bfd/ChangeLog: 2017-02-13 Palmer Dabbelt <palmer@dabbelt.com> * elfnn-riscv.c (riscv_global_pointer_value): Change _gp to __global_pointer$.
2017-02-08ld/arc: Change default linker emulation for nps400Andrew Burgess3-2/+18
If we are configuring for an arc/linux target, and --with-cpu=nps400 is used at configure time then change the default linker emulation to the nps specific version. All of the alternative linker emulations are still available using the -mNAME option for ld. ld/ChangeLog: * configure.tgt (arc*-*-linux*): Change the default linker emulation based on --with-cpu selection. * NEWS: Mention new configuration option.
2017-02-06[ld, testsuite] Don't print to stdout for "readelf -w" to avoid buffer overflowJiong Wang2-4/+9
ld/ * testsuite/ld-elf/compress.exp: Don't print to stdout for all "readelf -w".
2017-02-02CRIS/LD/testsuite: tls-err-20x.d: Fix a typo, s/n/\n/Maciej W. Rozycki2-1/+5
ld/ * testsuite/ld-cris/tls-err-20x.d: Fix a typo, s/n/\n/.
2017-02-02LD/testsuite: ld-lib.exp: Fix a typo, s/regexp/regex/Maciej W. Rozycki2-1/+6
Match `$check_ld(source)' against "regex" rather than "regexp" in reporting, correcting test framework diagnostics, e.g.: tmpdir/undefined.o: In function `foo': (.text+0x0): undefined reference to `bar' failed with: <tmpdir/undefined.o: In function `foo': (.text+0x0): undefined reference to `bar'>, no expected output tmpdir/undefined.o: In function `foo': (.text+0x0): undefined reference to `bar' PASS: MIPS undefined reference (current) vs: tmpdir/undefined.o: In function `foo': (.text+0x0): undefined reference to `bar' failed with: <tmpdir/undefined.o: In function `foo': (.text+0x0): undefined reference to `bar'>, expected: <\A[^\n]*\.o: In function `foo':\n\(\.text\+0x0\): undefined reference to `bar'\Z> tmpdir/undefined.o: In function `foo': (.text+0x0): undefined reference to `bar' PASS: MIPS undefined reference (corrected). No functional change. ld/ * ld/testsuite/lib/ld-lib.exp (run_dump_test): Fix a typo, s/regexp/regex/.
2017-02-02[ld, testsuite] Restrict dl1*main and dl6*main tests on platforms which have ↵Jiong Wang3-39/+94
libdl support ld/ * testsuite/lib/ld-lib.exp (check_libdl_available): New function. * testsuite/ld-elf/shared.exp (run_tests): Split tests which require dlopen support into "dlopen_run_tests". These tests include dl1*main and dl6*main. (dlopen_run_tests): New and only run it when check_libdl_available returns true. XFAIL on *-*-netbsdelf*.
2017-02-01MIPS/LD/testsuite: Correct relocation addends in VxWorks testsMaciej W. Rozycki5-14/+22
Fix commit 171191bac50e ("Add support for STT_IFUNC"), <https://sourceware.org/ml/binutils/2008-12/msg00052.html>, commit e04d7088afe0 ("PR ld/14088: Always display addend as signed hex number"), <https://sourceware.org/ml/binutils/2012-05/msg00123.html> and commit 343dbc36ffae ("Print addend as signed in objdump"), <https://sourceware.org/ml/binutils/2012-05/msg00163.html> regressions: FAIL: VxWorks executable test 1 (dynamic) FAIL: ld-mips-elf/vxworks-forced-local-1 seen with `mips-vxworks' and `mipsel-vxworks' targets and adjust dump patterns according to changes made to the presentation of relocation addends in `readelf -r' and `objdump -r' output. ld/ * testsuite/ld-mips-elf/vxworks-forced-local-1.d: Correct the presentation of relocation addends. * testsuite/ld-mips-elf/vxworks1-lib.rd: Likewise. * testsuite/ld-mips-elf/vxworks1.dd: Likewise. * testsuite/ld-mips-elf/vxworks1.rd: Likewise.
2017-02-01MIPS/LD/testsuite: Fix a `tls-multi-got-1-1.s' build failureMaciej W. Rozycki4-25/+35
Correct a commit ec9ab52c3217 ("gas: consistently emit diagnostics for non-zero data emission to .bss/.struct"), <https://sourceware.org/ml/binutils/2015-12/msg00073.html> regression: .../ld/testsuite/ld-mips-elf/tls-multi-got-1-1.s: Assembler messages: .../ld/testsuite/ld-mips-elf/tls-multi-got-1-1.s:39: Error: attempt to store non-zero value in section `.tbss' ERROR: -EB -march=mips1 -32 -KPIC .../ld/testsuite/ld-mips-elf/tls-multi-got-1-1.s: assembly failed UNRESOLVED: Shared library with multiple GOTs and TLS in MIPS target testing and move `tlsvar_ld' to `.tdata' section, in line with the remaining local dynamic definitions introduced with the set of tests added with commit f4e584bd00f1 ("TLS support for MIPS"), <https://sourceware.org/ml/binutils/2005-02/msg00607.html>. ld/ * testsuite/ld-mips-elf/tls-multi-got-1-1.s: Place `tlsvar_ld' in `.tdata' section. * testsuite/ld-mips-elf/tls-multi-got-1.got: Adjust accordingly. * testsuite/ld-mips-elf/tls-multi-got-1.r: Likewise.
2017-02-01[ld, testsuite] Append $board_cflags in one more place in ld-unique/unique.expJiong Wang2-1/+6
ld/ * testsuite/ld-unique/unique.exp (Could not link a dynamic executable): Append $board_cflags to link commands.
2017-02-01Fix failing print-memory-usage-1 on WindowsSenthil Kumar Selvaraj2-1/+6
ld/ 2017-01-31 Senthil Kumar Selvaraj <senthilkumar.selvaraj@microchip.com> * testsuite/ld-scripts/print-memory-usage-1.l: Relax check for digit in second decimal place.
2017-02-01PR ld/20828: LD/testsuite: Correct indentationMaciej W. Rozycki2-20/+26
ld/ PR ld/20828 * testsuite/ld-elf/shared.exp: Correct PR ld/20828 test indentation.
2017-01-31Fix buffer overflows in ld when printing translated strings.Nick Clifton3-9/+7
ld * ldmain.c (add_archive_element): Eliminate string buffer. * ldlang.c (lang_print_asneeded): Likewise.
2017-01-30MIPS: Add options to control branch ISA checksMaciej W. Rozycki11-3/+383
Complement commit 9d862524f6ae ("MIPS: Verify the ISA mode and alignment of branch and jump targets") and add GAS and LD options to control the checks for invalid branches between ISA modes introduced there, to help with some handwritten code lacking `.insn' annotation for labels used as branch targets and code produced by older versions of GCC which suffers from the issue with branches to code that has been optimized away, addressed with GCC commit 242424 ("MIPS/GCC: Mark trailing labels with `.insn'"), <https://gcc.gnu.org/ml/gcc-patches/2016-11/msg01061.html>. bfd/ * elfxx-mips.h (_bfd_mips_elf_insn32): Rename prototype to... (_bfd_mips_elf_linker_flags): ... this. Add another parameter. * elfxx-mips.c (mips_elf_link_hash_table): Add `ignore_branch_isa' member. (mips_elf_perform_relocation): Do not treat an ISA mode mismatch in branch relocation calculation as an error if `ignore_branch_isa' has been set. (_bfd_mips_elf_insn32): Rename to... (_bfd_mips_elf_linker_flags): ... this. Rename the `on' parameter to `insn32' and add an `ignore_branch_isa' parameter. Handle the new parameter. gas/ * config/tc-mips.c (mips_ignore_branch_isa): New variable. (options): Add OPTION_IGNORE_BRANCH_ISA and OPTION_NO_IGNORE_BRANCH_ISA enum values. (md_longopts): Add "mignore-branch-isa" and "mno-ignore-branch-isa" options. (md_parse_option): Handle OPTION_IGNORE_BRANCH_ISA and OPTION_NO_IGNORE_BRANCH_ISA. (fix_bad_cross_mode_branch_p): Return FALSE if `mips_ignore_branch_isa' has been set. (md_show_usage): Add `-mignore-branch-isa' and `-mno-ignore-branch-isa'. * doc/as.texinfo (Target MIPS options): Add `-mignore-branch-isa' and `-mno-ignore-branch-isa' options. (-mignore-branch-isa, -mno-ignore-branch-isa): New options. * doc/c-mips.texi (MIPS Options): Add `-mignore-branch-isa' and `-mno-ignore-branch-isa' options. * testsuite/gas/mips/branch-local-ignore-2.d: New test. * testsuite/gas/mips/branch-local-ignore-3.d: New test. * testsuite/gas/mips/branch-local-ignore-n32-2.d: New test. * testsuite/gas/mips/branch-local-ignore-n32-3.d: New test. * testsuite/gas/mips/branch-local-ignore-n64-2.d: New test. * testsuite/gas/mips/branch-local-ignore-n64-3.d: New test. * testsuite/gas/mips/mips.exp: Run the new tests. ld/ * emultempl/mipself.em (ignore_branch_isa): New variable. (mips_create_output_section_statements): Rename `_bfd_mips_elf_insn32' called to `_bfd_mips_elf_linker_flags', add `ignore_branch_isa' argument. (PARSE_AND_LIST_PROLOGUE): Add OPTION_IGNORE_BRANCH_ISA and OPTION_NO_IGNORE_BRANCH_ISA enum values. (PARSE_AND_LIST_LONGOPTS): Add "ignore-branch-isa" and "no-ignore-branch-isa" options. (PARSE_AND_LIST_OPTIONS): Add `--ignore-branch-isa' and `--no-ignore-branch-isa'. (PARSE_AND_LIST_ARGS_CASES): Handle OPTION_IGNORE_BRANCH_ISA and OPTION_NO_IGNORE_BRANCH_ISA. * ld.texinfo (Options specific to MIPS targets): Add `--ignore-branch-isa' and `--no-ignore-branch-isa' options. (ld and the MIPS family): Likewise. * testsuite/ld-mips-elf/bal-jalx-pic-ignore.d: New test. * testsuite/ld-mips-elf/bal-jalx-pic-ignore-n32.d: New test. * testsuite/ld-mips-elf/bal-jalx-pic-ignore-n64.d: New test. * testsuite/ld-mips-elf/unaligned-branch-ignore-2.d: New test. * testsuite/ld-mips-elf/unaligned-branch-ignore-r6-1: New test. * testsuite/ld-mips-elf/unaligned-branch-ignore-mips16: New test. * testsuite/ld-mips-elf/unaligned-branch-ignore-micromips: New test. * testsuite/ld-mips-elf/mips-elf.exp: Run the new tests.
2017-01-29Fix another typo in the last ChangeLog entry.Hans-Peter Nilsson1-1/+1
Gah! Though this time I blame autocompletion.
2017-01-29Fix typo in ChangeLogHans-Peter Nilsson1-1/+1
2017-01-29PR binutils/19935Hans-Peter Nilsson1-0/+1
Fix long-standing buglet and fallout from now-default initfini-array. * emulparams/criself.sh (USER_LABEL_PREFIX): Define. (OTHER_READONLY_SECTIONS, ENTRY): Delete now-redunant defines.
2017-01-29Fix long-standing buglet and fallout from now-default initfini-array.Hans-Peter Nilsson2-2/+7
* emulparams/criself.sh (USER_LABEL_PREFIX): Define. (OTHER_READONLY_SECTIONS, ENTRY): Delete now-redunant defines.
2017-01-27[ld, testsuite] XFAIL "pr20995-2", "Build pr20995-2.so" on arm*-*-eabi*Jiong Wang2-1/+12
ld/ * testsuite/ld-elf/elf.exp ("pr20995-2", "Build pr20995-2.so"): XFAIL on arm*-*-eabi*. Some technical discussions about the reason of this XFAIL are available at https://sourceware.org/ml/binutils/2017-01/msg00441.html
2017-01-27Update description of the -plugin option used by the linker, ar and nm.Dilyan Palauzov2-0/+24
PR 20343 ld * ld.texinfo (Options): Extend documentation of the --plugin option. Include a description of where the plugins should be located. binutils* doc/binutils.texi (ar): Extend documentation of the --plugin option. Include a description of where the plugins should be located. (nm): Likewise.
2017-01-27Add Serbian translation for the LD directory.Nick Clifton4-2/+2292
ld * po/sr.po: New Serbian translation. * configure.ac (ALL_LINGUAS): Add sr. * configure: Regenerate.
2017-01-25Move RTEMS target configuration to ELF sectionsSebastian Huber2-24/+28
bfd/ * config.bfd (powerpcle-*-rtems*): Do not mark as removed. (arm-*-rtems*): Move to (arm*-*-eabi*). (i[3-7]86-*-rtems*): Move to (i[3-7]86-*-elf*). (m68-*-rtems*): Move to (m68*-*-elf*). ld/ * configure.tgt (arm-*-rtems*): Move to (arm*-*-eabi*). (bfin-*-rtems*): Move to (bfin*-*-elf*). (i[3-7]86-*-rtems*): Move to (i[3-7]86*-*-elf*). (m68*-*-rtems*): Move to (m68*-*-elf*). (mips*-*-rtems*): Move to (mips*-*-elf*). (or1k*-*-rtems*): Move to (or1k*-*-elf*). (powerpc*-*-rtems*): Move to (powerpc*-*-elf*). (sparc*-*-rtems*): Move to (sparc*-*-elf*). (sparc64*-*-rtems*): Move to (sparc64*-*-elf*).
2017-01-25Remove all RTEMS COFF targetsSebastian Huber2-4/+8
bfd/ * config.bfd (*-*-rtemscoff*): Mark as removed. gas/ * configure.tgt (sh-*-rtemscoff*): Remove. ld/ * configure.tgt (h8300-*-rtemscoff*): Remove. (i960-*-rtems*): Likewise. (m68*-*-rtemscoff*): Likewise. (sh-*-rtemscoff*): Likewise.
2017-01-24Solaris2/LD: Fix anonymous version script acceptance bugMaciej W. Rozycki2-1/+8
Correct a bug in Solaris 2 linker emulation code triggered by a test introduced with commit 81ff47b3a546 ("PR ld/20828: Fix linker script symbols wrongly forced local with section GC") and only create implicit version nodes if versioning is actually introduced with a version script (or VERSION command) rather than only global vs local symbol visibility selected, fixing an: ld: anonymous version tag cannot be combined with other version tags linker error produced whenever a version script (or VERSION command) is used that does not assign symbol versions, such as: { global: foo; bar; local: *; }; and consequently removing a: FAIL: PR ld/20828 dynamic symbols with section GC (version script) test suite failure with the `x86_64-solaris2' target. ld/ * emultempl/solaris2.em (elf_solaris2_before_allocation): Do not add implicit version nodes if an anonymous version tag is being used.
2017-01-24[ld, testsuite] Always assemble those intermeidate .o files used laterJiong Wang2-7/+31
ld/ * testsuite/ld-plugin/lto.exp (lto_link_elf_tests): Move "Compile 7", "Compile 8a", "Compile 8b"... (lto_compile_elf_tests): ...to here. Always run these tests. (lto_run_elf_tests): Move "LTO 7"... (lto_run_elf_shared_tests): ...to here. Restrict these tests on environment where share library is supported.
2017-01-24PowerPC dynamic relocationsAlan Modra4-7/+12
This patch fixes a number of issues with powerpc dynamic relocations. 1) Both ppc and ppc64 were emitting more dynamic symbols and relocations than necessary, due to not supporting static linker resolution of tls_index entries for __tls_get_addr_opt. This meant that any @got@tlsgd or @got@tlsld reloc needed to make their symbols dynamic and generate dptmod and dtprel relocs for the dynamic linker. That would have been passable, but what happened was that practically all @got relocations resulted in their symbols being made dynamic and dynamic relocations emitted against the GOT entries. (Mostly visible on ppc32 executables since ppc64 gcc really only uses @got style relocs for TLS.) 2) The PowerOpen syntax was not supported with __tls_get_addr_opt. DTPMOD/DTPREL relocs on tls_index TOC entries did not use the trick of forcing dynamic symbols and relocations so those entries always resulted in the full __tls_get_addr processing. gcc doesn't use the PowerOpen syntax for TLS, and normally such code would be optimized to TLS IE or LE so the impact of missing this support was minimal. 3) In an executable, relocations against GNU indirect functions always used the value of their PLT stub. While this is correct, it is better in some cases to use a dynamic relocation. An extra dynamic relocation can mean that calls via function pointers need not bounce through the PLT stub at runtime. The patch also tidies the PLT handling code in ppc32 allocate_dynrelocs. Allocating PLT entries after other dynamic relocs allows the PLT loop to omit special handling for undefined weak symbols, and that in turn allows the loop to be simplified. bfd/ * elf32-ppc.c (ppc_elf_adjust_dynamic_symbol): Merge two cases where dynamic relocs are preferable. Allow ifunc too. (ensure_undefweak_dynamic): New function. (allocate_dynrelocs): Use it here. Move plt handling last and don't make symbols dynamic, simplifying loop. Only make undef weak symbols with GOT entries dynamic. Correct condition for GOT relocs. Handle dynamic relocs on ifuncs. Correct comments. Remove goto. (ppc_elf_relocate_section): Correct test for using dynamic symbol on GOT relocs. Rearrange test for emitting GOT relocs to suit. Set up explicit tls_index entries and implicit GOT tls_index entries resolvable at link time for __tls_get_addr_opt. Simplify test to clear mem for prelink. * elf64-ppc.c (allocate_got): Correct condition for GOT relocs. (ensure_undefweak_dynamic): New function. (allocate_dynrelocs): Use it here. Only make undef weak symbols with GOT entries dynamic. Remove unnecessary test of WILL_CALL_FINISH_DYNAMIC_SYMBOL in PLT handling. (ppc64_elf_relocate_section): Correct test for using dynamic symbol on GOT relocs. Rearrange test for emitting GOT relocs to suit. Set up explicit tls_index entries and implicit GOT tls_index entries resolvable at link time for __tls_get_addr_opt. Simplify expression to clear mem for prelink. ld/ * testsuite/ld-powerpc/tlsexe.r: Update for fewer dynamic relocs and symbols. * testsuite/ld-powerpc/tlsexe.d: Likewise. * testsuite/ld-powerpc/tlsexe.g: Likewise.