aboutsummaryrefslogtreecommitdiff
path: root/ld
AgeCommit message (Collapse)AuthorFilesLines
2019-01-01Update year range in copyright notice of binutils filesAlan Modra330-392/+396
2019-01-01ChangeLog rotationAlan Modra2-4748/+4762
2018-12-31PR24042, Global-buffer-overflow problem in output_rel_findAlan Modra2-8/+20
place_orphan handled ELF SHT_REL/SHT_RELA specially, output_rel_find didn't. This mismatch was a bug and also meant it was possible to craft an object where ld accessed section->name out of bounds. PR 24042 * emultempl/elf32.em (output_rel_find): Drop "sec" param. Add "rela". (gld${EMULATION_NAME}_place_orphan): Use sh_type to calculate "rela" param of output_rel_find when ELF. Tidy uses of elfinput.
2018-12-19x86: Properly handle PLT expression in directiveH.J. Lu6-0/+64
For PLT expressions, we should subtract the PLT relocation size only for jump instructions. Since PLT relocations are PC relative, we only allow "symbol@PLT" in PLT expression. gas/ PR gas/23997 * config/tc-i386.c (x86_cons): Check for invalid PLT expression. (md_apply_fix): Subtract the PLT relocation size only for jump instructions. * testsuite/gas/i386/reloc32.s: Add test for invalid PLT expression. * testsuite/gas/i386/reloc64.s: Likewise. * testsuite/gas/i386/ilp32/reloc64.s: Likewise. * testsuite/gas/i386/reloc32.l: Updated. * testsuite/gas/i386/reloc64.l: Likewise. * testsuite/gas/i386/ilp32/reloc64.l: Likewise. ld/ PR gas/23997 * testsuite/ld-i386/i386.exp: Run PR gas/23997 test. * testsuite/ld-x86-64/x86-64.exp: Likewise. * testsuite/ld-x86-64/pr23997a.s: New file. * testsuite/ld-x86-64/pr23997b.c: Likewise. * testsuite/ld-x86-64/pr23997c.c: Likewise.
2018-12-19Rename PR ld/22842 run-time test to "Run pr22842"H.J. Lu2-1/+6
* testsuite/ld-x86-64/x86-64.exp: Rename PR ld/22842 run-time test to "Run pr22842".
2018-12-14elf: Add PT_GNU_PROPERTY segment typeH.J. Lu28-157/+330
Linkers group input note sections with the same name into one output note section with the same name. One output note section is placed in one PT_NOTE segment. New linkers merge all input .note.gnu.property sections into one output .note.gnu.property section with a single NT_GNU_PROPERTY_TYPE_0 note in a single PT_NOTE segment. Since older linkers treat input .note.gnu.property section as a generic note section and just concatenate all input .note.gnu.property sections into one output .note.gnu.property section without merging them, we may see one or more NT_GNU_PROPERTY_TYPE_0 notes in PT_NOTE segment, which are invalid. GNU_PROPERTY_X86_UINT32_VALID was defined to address this issue such that linker sets the bit for non-relocatable outputs. But it isn't sufficient: 1. It doesn't cover generic properties. 2. When -mx86-used-note=yes is passed to x86 assembler, the GNU_PROPERTY_X86_UINT32_VALID bit is set in GNU_PROPERTY_X86_ISA_1_USED property in object file and older linkers generate invalid NT_GNU_PROPERTY_TYPE_0 notes with the GNU_PROPERTY_X86_UINT32_VALID bit set. I am proposing the following changes: 1. Add PT_GNU_PROPERTY segment type: # define PT_GNU_PROPERTY (PT_LOOS + 0x474e553) which covers .note.gnu.property section. 2. Remove GNU_PROPERTY_X86_UINT32_VALID. bfd/ PR ld/23900 * elf.c (get_program_header_size): Add a PT_GNU_PROPERTY segment for NOTE_GNU_PROPERTY_SECTION_NAME. (_bfd_elf_map_sections_to_segments): Create a PT_GNU_PROPERTY segment for NOTE_GNU_PROPERTY_SECTION_NAME. * elfxx-x86.c (_bfd_elf_link_setup_gnu_properties): Don't set GNU_PROPERTY_X86_UINT32_VALID. binutils/ PR ld/23900 * readelf.c (get_segment_type): Support PT_GNU_PROPERTY. (decode_x86_isa): Don't check GNU_PROPERTY_X86_UINT32_VALID. (decode_x86_feature_1): Likewise. (decode_x86_feature_2): Likewise. (print_gnu_property_note): Remove GNU_PROPERTY_X86_UINT32_VALID check. * testsuite/binutils-all/i386/empty.d: Updated. * testsuite/binutils-all/x86-64/empty-x32.d: Likewise. * testsuite/binutils-all/x86-64/empty.d: Likewise. * testsuite/binutils-all/i386/pr21231b.s: Change GNU_PROPERTY_X86_ISA_1_USED bits to 0x7fffffff. * testsuite/binutils-all/x86-64/pr21231b.s: Likewise. gas/ PR ld/23900 * config/tc-i386.c (x86_cleanup): Don't set GNU_PROPERTY_X86_UINT32_VALID. * testsuite/gas/i386/property-1.s: Change GNU_PROPERTY_X86_ISA_1_USED bits to 0. include/ PR ld/23900 * elf/common.h (PT_GNU_PROPERTY): New. (GNU_PROPERTY_X86_UINT32_VALID): Removed. ld/ PR ld/23900 * testsuite/ld-elf/elf.exp: Run PR ld/23900 test. * testsuite/ld-elf/pr23900-1-32.rd: New file. * testsuite/ld-elf/pr23900-1-64.rd: Likewise. * testsuite/ld-elf/pr23900-1.d: Likewise. * testsuite/ld-elf/pr23900-1.s: Likewise. * testsuite/ld-elf/pr23900-2.s: Likewise. * testsuite/ld-elf/pr23900-2a.d: Likewise. * testsuite/ld-elf/pr23900-2b.d: Likewise. * testsuite/ld-i386/ibt-plt-1.d: Adjusted. * testsuite/ld-i386/ibt-plt-2c.d: Likewise. * testsuite/ld-i386/ibt-plt-2d.d: Likewise. * testsuite/ld-i386/ibt-plt-3d.d: Likewise. * testsuite/ld-x86-64/ibt-plt-1-x32.d: Likewise. * testsuite/ld-x86-64/ibt-plt-1.d: Likewise. * testsuite/ld-x86-64/ibt-plt-2c-x32.d: Likewise. * testsuite/ld-x86-64/ibt-plt-2c.d: Likewise. * testsuite/ld-x86-64/ibt-plt-2d-x32.d: Likewise. * testsuite/ld-x86-64/ibt-plt-2c.d: Likewise. * testsuite/ld-x86-64/ibt-plt-3c-x32.d: Likewise. * testsuite/ld-x86-64/ibt-plt-3c.d: Likewise. * testsuite/ld-x86-64/ibt-plt-3d-x32.d: Likewise. * testsuite/ld-x86-64/ibt-plt-3d.d: Likewise. * testsuite/ld-i386/pr23372c.d: Expect <None> for GNU_PROPERTY_X86_ISA_1_USED. * testsuite/ld-x86-64/pr23372c-x32.d: Likewise. * testsuite/ld-x86-64/pr23372c.d: Likewise. * testsuite/ld-x86-64/pr23372d-x32.d: Likewise. * testsuite/ld-x86-64/pr23372d.d: Likewise. * testsuite/ld-x86-64/property-x86-5a.s: Change GNU_PROPERTY_X86_ISA_1_USED bits to 0. * testsuite/ld-x86-64/property-x86-5b.s: Likewise.
2018-12-11Fix a typo in scripttempl/elf32xc16x.scH.J. Lu2-1/+5
* scripttempl/elf32xc16x.sc: Fix a typo.
2018-12-07Override the previous definition from IR objectH.J. Lu4-0/+23
Mark the previous definition from IR object as undefined so that the generic linker will override it. bfd/ PR ld/23958 * elflink.c (_bfd_elf_add_default_symbol): Override the previous definition from IR object. ld/ PR ld/23958 * testsuite/ld-plugin/lto.exp: Run PR ld/23958 test. * testsuite/ld-plugin/pr23958.c: New file. * testsuite/ld-plugin/pr23958.t: Likewise.
2018-12-07elf: Report property change when merging propertiesH.J. Lu14-2/+57
With merging properties, report property change in linker map file, like Merging program properties Removed property 0xc0010000 to merge /usr/lib/gcc/x86_64-redhat-linux/8/../../../../lib64/crt1.o (0x0) and /usr/lib/gcc/x86_64-redhat-linux/8/../../../../lib64/crti.o (0x0) Removed property 0xc0000002 to merge /usr/lib/gcc/x86_64-redhat-linux/8/../../../../lib64/crt1.o (0x3) and x.o (not found) Removed property 0xc0000000 to merge /usr/lib/gcc/x86_64-redhat-linux/8/../../../../lib64/crt1.o (not found) and /usr/lib64/libc_nonshared.a(elf-init.oS) (0x0) Removed property 0xc0000001 to merge /usr/lib/gcc/x86_64-redhat-linux/8/../../../../lib64/crt1.o (not found) and /usr/lib64/libc_nonshared.a(elf-init.oS) (0x0) bfd/ * elf-properties.c (elf_find_and_remove_property): Add a bfd_boolean argument to indicate if the property should be removed. (elf_merge_gnu_property_list): Updated. Report property change in linker map file. (elf_get_gnu_property_section_size): Skip property_remove properties. (elf_write_gnu_properties): Likewise. (_bfd_elf_link_setup_gnu_properties): Report property merge in linker map file. Pass abfd to elf_merge_gnu_property_list. include/ * bfdlink.h (bfd_link_info): Add has_map_file. ld/ * NEWS: Updated for property change report. * ld.texi: Document property change report. * ldmain.c (main): Set link_info.has_map_file to TRUE when linker map file is used. * testsuite/ld-scripts/rgn-over1.d: Updated. * testsuite/ld-scripts/rgn-over2.d: Likewise. * testsuite/ld-scripts/rgn-over3.d: Likewise. * testsuite/ld-scripts/rgn-over4.d: Likewise. * testsuite/ld-scripts/rgn-over5.d: Likewise. * testsuite/ld-scripts/rgn-over6.d: Likewise. * testsuite/ld-scripts/rgn-over7.d: Likewise. * testsuite/ld-x86-64/property-x86-ibt1a-x32.d: Check linker map file. * testsuite/ld-x86-64/property-x86-ibt1a.d: Likewise. * testsuite/ld-x86-64/property-x86-ibt1a.map: New file.
2018-12-04x86: Don't remove empty GNU_PROPERTY_X86_UINT32_OR_AND propertiesH.J. Lu7-0/+40
For GNU_PROPERTY_X86_COMPAT_ISA_1_USED and GNU_PROPERTY_X86_UINT32_OR_AND properties, a bit in the output pr_data field is set if it is set in any relocatable input pr_data fields and this property is present in all relocatable input files. A missing property implies that its bits have unknown values. When all bits in the the output pr_data field are zero, this property should not be removed from output to indicate it has zero in all bits. bfd/ PR ld/23372 * elfxx-x86.c (_bfd_x86_elf_merge_gnu_properties): Don't remove empty properties for GNU_PROPERTY_X86_COMPAT_ISA_1_USED and GNU_PROPERTY_X86_UINT32_OR_AND. (_bfd_x86_elf_link_fixup_gnu_properties): Likewise. ld/ PR ld/23372 * testsuite/ld-i386/pr23372a.d: Updated. * testsuite/ld-i386/pr23372c.d: Likewise. * testsuite/ld-x86-64/pr23372a-x32.d: Likewise. * testsuite/ld-x86-64/pr23372a.d: Likewise. * testsuite/ld-x86-64/pr23372c-x32.d: Likewise. * testsuite/ld-x86-64/pr23372c.d: Likewise.
2018-12-01x86: Delay setting the iplt section alignmentH.J. Lu10-0/+90
Delay setting its alignment until we know it is non-empty. Otherwise an empty iplt section may change vma and lma of the following sections, which triggers moving dot of the following section backwards, resulting in a warning and section lma not being set properly. It later leads to a "File truncated" error. bfd/ PR ld/23930 * elfxx-x86.c (_bfd_x86_elf_size_dynamic_sections): Update the iplt section alignment if it is non-empty. (_bfd_x86_elf_link_setup_gnu_properties): Set plt.iplt_alignment and delay setting the iplt section alignment. * elfxx-x86.h (elf_x86_plt_layout): Add iplt_alignment. ld/ PR ld/23930 * testsuite/ld-i386/i386.exp: Run pr23930. * testsuite/ld-i386/pr23930.d: New file. * testsuite/ld-x86-64/pr23930-32.t: Likewise. * testsuite/ld-x86-64/pr23930-x32.d: Likewise. * testsuite/ld-x86-64/pr23930.d: Likewise. * testsuite/ld-x86-64/pr23930.t: Likewise. * testsuite/ld-x86-64/pr23930a.s: Likewise. * testsuite/ld-x86-64/pr23930b.s: Likewise. * testsuite/ld-x86-64/x86-64.exp: Run pr23930 and pr23930-x32.
2018-11-30PR23937, powerpc64le local ifunc IRELATIVE relocs are wrongAlan Modra4-0/+82
IFUNC resolvers must always be called via their global entry point. They will be called from ld.so rather than from the local executable. PR 23937 bfd/ * elf64-ppc.c (write_plt_relocs_for_local_syms): Don't add local entry offset for ifuncs. ld/ * testsuite/ld-powerpc/pr23937.d, * testsuite/ld-powerpc/pr23937.s: New test. * testsuite/ld-powerpc/powerpc.exp: Run it.
2018-11-29Document purpose of each ld statement listsThomas Preud'homme3-7/+31
When discovering the statement lists via their header variable statement_list, file_chain and input_file_chain it can be confusing to figure out what they are for. They can point to the same initial statement and the relation between the next field they use is not obvious from the name. This commit adds comment for each of those statement list header to explain what they are for and what next field they use. It also rewrite the comment for the next fields to simply redirect the reader to the list header to avoid duplication of documentation. 2018-11-29 Thomas Preud'homme <thomas.preudhomme@linaro.org> ld/ * ldlang.c (statement_list): Document purpose and what next field it uses. (file_chain): Likewise. (input_file_chain): Likewise. * ldlang.h (lang_statement_header_type): Document statement list header the next pointer correspond to. (lang_statement_header_type): Replace comment for next and next_real_file field to refer the reader to their corresponding statement list header.
2018-11-27MIPS/LD: Accept high-part relocations in PIC code with absolute symbolsMaciej W. Rozycki12-0/+110
Accept R_MIPS_HI16, R_MIPS_HIGHER and R_MIPS_HIGHEST relocations and their compressed counterparts in PIC code where the symbol referred is absolute. Such an operation is meaningful, because an absolute symbol effectively is a constant the calculation of the value of which has been deferred to the static link time, and which is not going to change any further at the dynamic load time. Therefore there is no need ever to refuse the use of these relocations with such symbols, as the resulting run-time value observed by the program will be correct even in PIC code. This is not the case with R_MIPS_26 and its compressed counterparts, because the run-time value calculated by the instructions these relocations are used with depends on the address of the instruction itself, and that can change according to the base address used by the dynamic loader. Therefore these relocations have to continue being rejected in PIC code even with absolute symbols. This allows successful linking of code that relies on previous linker behavior up to commit 861fb55ab50a ("Defer allocation of R_MIPS_REL32 GOT slots"), <https://sourceware.org/ml/binutils/2008-08/msg00096.html>, which introduced the problematic check missing this special exception for absolute symbols. bfd/ * elfxx-mips.c (_bfd_mips_elf_check_relocs) <R_MIPS16_HI16> <R_MIPS_HI16, R_MIPS_HIGHER, R_MIPS_HIGHEST, R_MICROMIPS_HI16> <R_MICROMIPS_HIGHER, R_MICROMIPS_HIGHEST>: Also accept an absolute symbol in PIC code. ld/ * testsuite/ld-mips-elf/pic-reloc-0.d: New test. * testsuite/ld-mips-elf/pic-reloc-1.d: New test. * testsuite/ld-mips-elf/pic-reloc-2.d: New test. * testsuite/ld-mips-elf/pic-reloc-3.d: New test. * testsuite/ld-mips-elf/pic-reloc-4.d: New test. * testsuite/ld-mips-elf/pic-reloc-absolute-hi.ld: New test linker script. * testsuite/ld-mips-elf/pic-reloc-absolute-lo.ld: New test linker script. * testsuite/ld-mips-elf/pic-reloc-ordinary.ld: New test linker script. * testsuite/ld-mips-elf/pic-reloc-j.s: New test source. * testsuite/ld-mips-elf/pic-reloc-lui.s: New test source. * testsuite/ld-mips-elf/mips-elf.exp: Run the new tests.
2018-11-27LD: Convert `%P: %H:' to `%H:' in error messagesMaciej W. Rozycki2-3/+10
Similarly to commit 174d0a74a2e6 ("PowerPC/BFD: Convert `%P: %H:' to `%H:' in error messages") convert linker relocation error messages to use `%H:' rather `%P: %H:', removing inconsistent message composition like: $ cat reloc-j.s .text .globl foo .ent foo foo: j bar j bar .end foo $ cat reloc-j.ld SECTIONS { bar = 0x12345678; .text : { *(.text) } /DISCARD/ : { *(*) } } $ as -o reloc-j.o reloc-j.s $ ld -T reloc-j.ld -o reloc-j reloc-j.o ld: tmpdir/reloc-j.o: in function `foo': (.text+0x0): relocation truncated to fit: R_MIPS_26 against `bar' ld: (.text+0x8): relocation truncated to fit: R_MIPS_26 against `bar' $ where subsequent lines referring to issues within a single function have the name of the linker executable prepended, but the first one does not. As noted with the commit referred this breaks a GNU Coding Standard's requirement that error messages from compilers should look like this: source-file-name:lineno: message also quoted in `vfinfo' code handling these specifiers. Remove the linker name prefix then, making the messages now look like: $ ld -T reloc-j.ld -o reloc-j reloc-j.o tmpdir/reloc-j.o: in function `foo': (.text+0x0): relocation truncated to fit: R_MIPS_26 against `bar' (.text+0x8): relocation truncated to fit: R_MIPS_26 against `bar' $ instead. ld/ * ldmain.c (reloc_overflow): Use `%H:' rather than `%P: %H:' with `einfo'. (reloc_dangerous): Likewise. (unattached_reloc): Likewise.
2018-11-27AArch64: Fix regression in Cortex A53 erratum when PIE. (PR ld/23904)Tamar Christina4-0/+100
The fix for PR ld/22263 causes TLS relocations using ADRP to be relaxed into MOVZ, however this causes issues for the erratum code. The erratum code scans the input sections looking for ADRP instructions and notes their location in the stream. It then later tries to find them again in order to generate the linker stubs. Due to the relaxation it instead finds a MOVZ and hard aborts. Since this relaxation is a valid one, and in which case the erratum no longer applies, it shouldn't abort but instead just continue. This changes the TLS relaxation code such that when it finds an ADRP and it relaxes it, it removes the erratum entry from the work list by changing the stub type into none so the stub is ignored. The entry is not actually removed as removal is a more expensive operation and we have already allocated the memory anyway. The clearing is done for IE->LE and GD->LE relaxations, and a testcase is added for the IE case. The GD case I believe to be impossible to get together with the erratum sequence due to the required BL which would break the sequence. However to cover all basis I have added the guard there as well. build on native hardware and regtested on aarch64-none-elf, aarch64-none-elf (32 bit host), aarch64-none-linux-gnu, aarch64-none-linux-gnu (32 bit host) Cross-compiled and regtested on aarch64-none-linux-gnu, aarch64_be-none-linux-gnu Testcase in PR23940 tested and works as expected now and benchmarks ran on A53 showing no regressions and no issues. bfd/ChangeLog: PR ld/23904 * elfnn-aarch64.c (_bfd_aarch64_adrp_p): Use existing constants. (_bfd_aarch64_erratum_843419_branch_to_stub): Use _bfd_aarch64_adrp_p. (struct erratum_835769_branch_to_stub_clear_data): New. (_bfd_aarch64_erratum_843419_clear_stub): New. (clear_erratum_843419_entry): New. (elfNN_aarch64_tls_relax): Use it. (elfNN_aarch64_relocate_section): Pass input_section. (aarch64_map_one_stub): Handle branch type none as valid. ld/ChangeLog: PR ld/23904 * testsuite/ld-aarch64/aarch64-elf.exp: Add erratum843419_tls_ie. * testsuite/ld-aarch64/erratum843419_tls_ie.d: New test. * testsuite/ld-aarch64/erratum843419_tls_ie.s: New test.
2018-11-16(Another) Updated Spanish translation for the ld subdirectory.Nick Clifton3-40/+38
* po/es.po: Updated Spanish translation.
2018-11-15Updated Spanish translation for the ld subdirectory.Nick Clifton2-85/+63
ld * po/es.po: Updated Spanish translation.
2018-11-12i386: Accept both .plt.got and .plt.sec sectionsH.J. Lu2-1/+6
Glibc commit: commit a15529fda8d132621328c3fe32997a3d9c55aef4 Author: H.J. Lu <hjl.tools@gmail.com> Date: Mon May 14 09:23:55 2018 -0700 i386: Replace PREINIT_FUNCTION@PLT with *%eax in call Since we have loaded address of PREINIT_FUNCTION into %eax, we can avoid extra branch to PLT slot. changed __gmon_start__ relocations in crt1.o from 00000015 0000092b R_386_GOT32X 00000000 __gmon_start__ 0000001e 00000904 R_386_PLT32 00000000 __gmon_start__ to 00000015 00000a2b R_386_GOT32X 00000000 __gmon_start__ As the result, .plt.sec section may be generated instead of .plt.got section, depending on __gmon_start__ relocations. * testsuite/ld-i386/plt-main-ibt.dd: Accept both .plt.got and .plt.sec sections.
2018-11-12Update documentation describing how the linker chooses a start address.Nick Clifton2-1/+7
PR 10865 * ld.texi (Entry Point): Make it clear that the text refers to PE-based systems rather than just a PE system.
2018-11-12Updated Spanish translation for the ld subdirectory.Nick Clifton2-59/+35
ld * po/es.po: Updated Spanish translation.
2018-11-09Updated French translation for the ld subdirectory.Nick Clifton2-3/+7
* po/fr.po: Updated French translation.
2018-11-09[ARC] Update ld tests.Claudiu Zissulescu3-3/+8
ld/ xxxx-xx-xx Claudiu Zissulescu <claziss@synopsys.com> * testsuite/ld-arc/tls_gd-01.d: Update test. * testsuite/ld-arc/arclinux-nps.d: Add cpu option.
2018-11-09Allow for compilers that do not produce aligned .rdat sections in PE format ↵Marc3-0/+9
files. PR 23872 * scripttempl/pep.sc (pe.sc): Ensure rdata_runtime_pseudo_relocs are aligned. * scripttempl/pep.sc (pep.sc): Likewise.
2018-11-06elfedit: Add --enable-x86-feature/--disable-x86-featureH.J. Lu8-0/+91
Add --enable-x86-feature and --disable-x86-feature options to elfedit to set and clear the IBT and SHSTK bits in program property in ELF executables and shared objects. binutils/ * doc/binutils.texi: Document --enable-x86-feature and --disable-x86-feature options for elfedit. * elfedit.c: Include "config.h" and <sys/mman.h>. (enable_x86_features): New. (disable_x86_features): Likewise. (update_gnu_property): Likewise. (elf_x86_feature): Likewise. (process_file): Call update_gnu_property on ET_EXEC or ET_DYN file. (command_line_switch): Add OPTION_ENABLE_X86_FEATURE and OPTION_DISABLE_X86_FEATURE. (options): Add--enable-x86-feature and --disable-x86-feature. (usage): Likewise. (main): Handle OPTION_ENABLE_X86_FEATURE and OPTION_DISABLE_X86_FEATURE. ld/ * testsuite/config/default.exp (ELFEDIT): New. * testsuite/ld-elf/linux-x86.exp (elfedit_test): New proc. Run elfedit tests. * testsuite/ld-elf/x86-feature-1a.rd: New file. * testsuite/ld-elf/x86-feature-1b.rd: Likewise. * testsuite/ld-elf/x86-feature-1c.rd: Likewise. * testsuite/ld-elf/x86-feature-1d.rd: Likewise. * testsuite/ld-elf/x86-feature-1e.rd: Likewise.
2018-11-05Correct ChangeLog entries for PR gas/23854 commitH.J. Lu1-1/+1
commit e60f4d3bdac25f02875afe36b7436bc2dfbbb978 Author: H.J. Lu <hjl.tools@gmail.com> Date: Mon Nov 5 09:01:26 2018 -0800 x86: Disable GOT relaxation with data prefix Since linker GOT relaxation isn't valid for 16-bit GOT access, we should disable GOT relaxation with data prefix.
2018-11-05x86: Disable GOT relaxation with data prefixH.J. Lu7-0/+135
Since linker GOT relaxation isn't valid for 16-bit GOT access, we should disable GOT relaxation with data prefix. gas/ PR gas/r23854 * config/tc-i386.c (output_disp): Disable GOT relaxation with data prefix. * testsuite/gas/i386/mixed-mode-reloc32.d: Updated. ld/ PR gas/r23854 * testsuite/ld-i386/i386.exp: Run pr23854. * testsuite/ld-x86-64/x86-64.exp: Likewwise. * testsuite/ld-i386/pr23854.d: New file. * testsuite/ld-i386/pr23854.s: Likewwise. * testsuite/ld-i386/pr23854.d: Likewwise. * testsuite/ld-x86-64/pr23854.d: Likewwise. * testsuite/ld-x86-64/pr23854.s: Likewwise.
2018-11-01Fix ld action in run_dump_testThomas Preud'homme2-17/+5
run_dump_test proposes an ld action but when trying to make use of it in a gas test it gave me some Tcl error. It turns out that it references the check_shared_lib_support procedure and ld_elf_shared_opt variable both only available in ld-lib.exp. I've thus moved the procedure in binutils-common.exp and defined the variable needed in the various default.exp of testsuite that seem to be using run_dump_test. Since check_shared_lib_support itself references the ld variable not defined in binutils-common I've defined it from LD in run_dump_test and fixed LD and LDFLAGS to be defined as expected by run_dump_test in the various default.exp of testsuite using run_dump_test. 2018-11-01 Thomas Preud'homme <thomas.preudhomme@linaro.org> binutils/ * testsuite/config/default.exp: Define LD, LDFLAGS and ld_elf_shared_opt. * testsuite/lib/binutils-common.exp (check_shared_lib_support): Moved from ld-lib.exp. (run_dump_test): Set ld to $LD. gas/ * testsuite/config/default.exp: Define LD, LDFLAGS and ld_elf_shared_opt. ld/ * testsuite/lib/ld-lib.exp (check_shared_lib_support): Moved to binutils-common.exp.
2018-10-29Report scripts and libraries searched for ld --traceAlan Modra6-14/+27
The idea of this change is to make -t output useful for users wanting to package all the object files involved in linking for a bug report. Something like the following should do the trick. gcc hello.c -save-temps -Wl,-t | xargs realpath | sort | uniq > files tar cJf test.tar.xz `cat files` * ldlang.c (load_symbols): When -t, print file names for script files and archives. * ldmain.c (trace_files): Make an int. (add_archive_element): Print archive elements only with multiple -t options, or when archive is thin. * ldmain.h (trace_files): Update. * ldmisc.c (vfinfo): Don't print both original path and path in sysroot. * lexsup.c (parse_args <t>): Increment trace_files.
2018-10-29Remove some ld --trace outputAlan Modra2-3/+9
This output really belongs in ld --verbose. * ldmain.c (main): Print emulation mode and "deleting executable" for --verbose, not --trace. (add_archive_element): Only print "no new IR symbols" for --verbose.
2018-10-29Simplify --sysroot=/Alan Modra2-9/+17
Prepending '/' to absolute paths doesn't gain us much, and results in the current implementation of --trace emitting silly path-in-sysroot output, eg. /lib/ld-linux-x86-64.so.2 (//lib/ld-linux-x86-64.so.2) * ldmain.c (get_sysroot): Return "" for "--sysroot=/".
2018-10-29ld -r script fixesAlan Modra16-35/+58
For ld -r, we generally set the VMA of sections to zero. This is done to make the output of ld -r most similar to that output by the assembler, which generally has sections starting at VMA zero. In some cases that covers for backend bugs which would mis-handle relocatable object files with non-zero section VMAs. This patch fixes a few sections that didn't have zero VMAs for ld -r. A missing zero on .note.gnu.build-id and .eh_frame_hdr doesn't matter much since these are linker generated symbols only output on final link, but it's good to be consistent. * Makefile.am (ei386beos.c, ei386go32.c): Correct dependencies. * Makefile.in: Regenerate. * scripttempl/elf.sc (.note.gnu.build-id, .eh_frame_hdr): Set address with ${RELOCATING-0}. * scripttempl/arclinux.sc: Likewise. * scripttempl/armbpabi.sc: Likewise. * scripttempl/avr.sc: Likewise. * scripttempl/elf64hppa.sc: Likewise. * scripttempl/elf_chaos.sc: Likewise. * scripttempl/elfarc.sc: Likewise. * scripttempl/elfxtensa.sc: Likewise. * scripttempl/mep.sc: Likewise. * scripttempl/nds32elf.sc: Likewise. * scripttempl/pru.sc: Likewise. * scripttempl/elf32msp430.sc: Likewise, and for other sections. * scripttempl/epiphany_4x4.sc: Similarly.
2018-10-26ELF: update ld man page on `--gc-sections`Christoph Conrads2-3/+9
Commit 91ae256e33 fixes the behavior of ld when `--gc-sections` and `--gc-keep-exported` are both given on the linker command line. This updates the ld documentation to suit. * ld.texi (--gc-sections): Update.
2018-10-24ELF: Hide symbols defined in discarded input sectionsH.J. Lu6-0/+34
When assigning symbol version, we should hide debug symbols defined in discarded sections from IR objects so that they can be removed later. bfd/ PR ld/23818 * elflink.c (_bfd_elf_link_assign_sym_version): Hide symbols defined in discarded input sections. ld/ PR ld/23818 * testsuite/ld-plugin/lto.exp: Run PR ld/23818 test. * testsuite/ld-plugin/pr23818.d: New file. * testsuite/ld-plugin/pr23818.t: Likewise. * testsuite/ld-plugin/pr23818a.c: Likewise. * testsuite/ld-plugin/pr23818b.c: Likewise.
2018-10-23alpha testsuite fixesAlan Modra3-6/+22
Fixes a couple of ERROR results due to .set difference on alpha. * testsuite/ld-elf/shared.exp: Don't build pr19073 test on alpha. * testsuite/ld-elf/pr18720b.c: Don't use .set on alpha.
2018-10-20Relax a -r --gc-sections requirementAlan Modra2-2/+9
A symbol root is not needed if --gc-keep-exported is also given. * ldlang.c (lang_end): Don't error if no --entry or --undefined is given with -r -gc-sections if --gc-keep-exported.
2018-10-15RISC-V: Adjust __global_pointer$ value to reduce code size.Jim Wilson3-2/+21
ld/ * emulparams/elf32lriscv-defs.sh (DATA_START_SYMBOLS): New. (SDATA_START_SYMBOLS): Define __SDATA_BEGIN__. Don't define __global_pointer$. (OTHER_END_SYMBOLS): New. Define __global_pointer$. * testsuite/ld-riscv-elf/pcrel-lo-addend-2.d (#ld): Add --no-relax.
2018-10-15BFD_INIT_MAGICAlan Modra2-1/+8
This patch performs a run-time test that a shared libbfd.so has been compiled with the same size bfd_vma as that of apps using the library. On a 32-bit host it is easily possible to have one libbfd.so compiled to support 64-bit targets (or configured with --enable-64-bit-bfd) while another only supports 32-bit targets. The two libraries will have differently sized bfd_vma types, and if the wrong one is loaded all sorts of weird behaviour might be seen. bfd/ PR 23534 * init.c (BFD_INIT_MAGIC): Define. (bfd_init): Return BFD_INIT_MAGIC. bfd-in2.h: Regenerate. binutils/ PR 23534 * addr2line.c (main): Exit with fatal error if bfd_init returns an unexpected value. * ar.c (main): Likewise. * dlltool.c (identify_dll_for_implib): Likewise. * nm.c (main): Likewise. * objcopy.c (main): Likewise. * objdump.c (main): Likewise. * size.c (main): Likewise. * strings.c (main): Likewise. * windmc.c (main): Likewise. * windres.c (main): Likewise. gas/ PR 23534 * as.c (main): Exit with fatal error if bfd_init returns an unexpected value. ld/ PR 23534 * ldmain.c (main): Exit with fatal error if bfd_init returns an unexpected value.
2018-10-13ELF ld -r scriptsAlan Modra75-660/+791
"ld -r" generally should not combine object file sections with different names. For example, "ld -r" should not combine ".text", ".text.hot" and ".text.cold" into an output ".text" section. An exception needs to be made for linker created sections, for example, branch trampoline sections that might be created even for ld -r. "ld -r" also should not define symbols in linker scripts. Any definitions are likely to conflict with those defined at final link. A MEMORY spec is also not needed for ld -r. * Makefile.am (eelf32btsmip_fbsd.c, eelf32btsmipn32_fbsd.c), (eelf32epiphany.c, eelf32epiphany_4x4.c, eelf32ltsmip_fbsd.c), (eelf32ltsmipn32_fbsd.c, eelf32xc16x.c, eelf32xc16xl.c), (eelf32xc16xs.c, emcorepe.c, enios2elf.c, enios2linux.c), (eelf64btsmip_fbsd.c, eelf64ltsmip_fbsd.c): Correct dependencies. * Makefile.in: Regenerate. * emulparams/aarch64cloudabi.sh, * emulparams/aarch64fbsd.sh, * emulparams/aarch64linux.sh, * emulparams/aarch64linux32.sh, * emulparams/arc-nps.sh, * emulparams/elf32_spu.sh, * emulparams/elf32_tic6x_le.sh, * emulparams/elf32bmip.sh, * emulparams/elf32btsmipn32.sh, * emulparams/elf32lr5900n32.sh, * emulparams/elf32mep.sh, * emulparams/elf32metag.sh, * emulparams/elf64btsmip.sh, * emulparams/shelf_vxworks.sh, * emulparams/shlelf_fd.sh, * scripttempl/DWARF.sc, * scripttempl/alpha.sc, * scripttempl/alphavms.sc, * scripttempl/arclinux.sc, * scripttempl/armbpabi.sc, * scripttempl/avr.sc, * scripttempl/dlx.sc, * scripttempl/elf.sc, * scripttempl/elf32cr16.sc, * scripttempl/elf32cr16c.sc, * scripttempl/elf32crx.sc, * scripttempl/elf32msp430.sc, * scripttempl/elf32msp430_3.sc, * scripttempl/elf32xc16x.sc, * scripttempl/elf32xc16xl.sc, * scripttempl/elf32xc16xs.sc, * scripttempl/elf64hppa.sc, * scripttempl/elf_chaos.sc, * scripttempl/elfarc.sc, * scripttempl/elfarcv2.sc, * scripttempl/elfd10v.sc, * scripttempl/elfd30v.sc, * scripttempl/elfm68hc11.sc, * scripttempl/elfm68hc12.sc, * scripttempl/elfm9s12z.sc, * scripttempl/elfmicroblaze.sc, * scripttempl/elfxgate.sc, * scripttempl/elfxtensa.sc, * scripttempl/epiphany_4x4.sc, * scripttempl/ft32.sc, * scripttempl/hppaelf.sc, * scripttempl/ia64vms.sc, * scripttempl/ip2k.sc, * scripttempl/iq2000.sc, * scripttempl/mep.sc, * scripttempl/mmo.sc, * scripttempl/nds32elf.sc, * scripttempl/pru.sc, * scripttempl/sh.sc, * scripttempl/v850.sc, * scripttempl/v850_rh850.sc, * scripttempl/visium.sc, * scripttempl/xstormy16.sc: Condition various parts of scripts on ${RELOCATABLE} in order to prevent ld -r merging sections or defining symbols. Remove MEMORY and VERSION definitions from ld -r scripts too. * testsuite/ld-elf/group2.d, * testsuite/ld-elf/group4.d, * testsuite/ld-elf/group5.d, * testsuite/ld-elf/group6.d, * testsuite/ld-elf/group7.d, * testsuite/ld-elf/group8a.d, * testsuite/ld-elf/group8b.d, * testsuite/ld-elf/group9a.d, * testsuite/ld-elf/group9b.d, * testsuite/ld-elf/pr17550a.d, * testsuite/ld-elf/pr17550b.d, * testsuite/ld-elf/pr17550d.d: Don't xfail cr16 and crx. * testsuite/ld-elf/init-fini-arrays.d, * testsuite/ld-elf/pr22677.d: Likewise, and dont' xfail mep.
2018-10-08x86: Don't add GNU_PROPERTY_X86_FEATURE_2_NEEDED for -z separate-codeH.J. Lu4-6/+10
With commit 64029e93683a266c38d19789e780f3748bd6a188 Author: Alan Modra <amodra@gmail.com> Date: Fri Oct 5 11:40:54 2018 +0930 Separate header PT_LOAD for -z separate-code there is no need to add a GNU_PROPERTY_X86_ISA_1_USED note to force program header in in non-code PT_LOAD segment when -z separate-code is used. bfd/ PR ld/23428 * elfxx-x86.c (_bfd_x86_elf_link_setup_gnu_properties): Don't add GNU_PROPERTY_X86_FEATURE_2_NEEDED to force program header in non-code PT_LOAD segment. ld/ PR ld/23428 * testsuite/ld-i386/property-x86-4a.d: Updated. * testsuite/ld-x86-64/property-x86-4a-x32.d: Likewise. * testsuite/ld-x86-64/property-x86-4a.d: Likewise.
2018-10-08ELF: Properly group and place orphan note sectionsH.J. Lu5-56/+140
Properly group orphan note sections. When placing orphan note section as the first note section, place it after the section before all note sections. PR ld/23658 * ldlang.c (lang_insert_orphan): Properly group and place orphan note sections. Properly handle orphan note section before all note sections. * testsuite/ld-elf/pr23658-1.d: Renamed to ... * testsuite/ld-elf/pr23658-1a.d: This. Updated. * testsuite/ld-elf/pr23658-1b.d: New test. * testsuite/ld-elf/pr23658-1c.d: Likewise.
2018-10-08Separate header PT_LOAD for -z separate-codeAlan Modra12-20/+19
This patch, along with previous patches in the series, supports putting the ELF file header and program headers in a PT_LOAD without sections. Logic governing whether headers a loaded has changed a little: The primary reason to include headers is now the presence of SIZEOF_HEADERS in a linker script. However, to support scripts that may have reserved space for headers by hand, we continue to add headers whenever the first section address is past the end of headers modulo page size. include/ * bfdlink.h (struct bfd_link_info): Add load_phdrs field. bfd/ * elf-nacl.c (nacl_modify_segment_map): Cope with header PT_LOAD lacking sections. * elf.c (_bfd_elf_map_sections_to_segments): Assume file and program headers are required when info->load_phdrs. Reorganize code handling program headers. Generate a mapping without sections just for file and program headers when -z separate-code would indicate they should be on a different page to the first section. ld/ * ldexp.c (fold_name <SIZEOF_HEADERS>): Set link_info.load_phdrs. * testsuite/ld-elf/loadaddr1.d: Pass -z noseparate-code. * testsuite/ld-elf/loadaddr2.d: Likewise. * testsuite/ld-i386/vxworks2.sd: Adjust expected output. * testsuite/ld-powerpc/vxworks2.sd: Likewise. * testsuite/ld-elf/overlay.d: Remove spu xfail. * testsuite/ld-spu/ovl.lnk: Don't use SIZEOF_HEADERS. * testsuite/ld-tic6x/dsbt-be.ld: Likewise. * testsuite/ld-tic6x/dsbt-inrange.ld: Likewise. * testsuite/ld-tic6x/dsbt-overflow.ld: Likewise. * testsuite/ld-tic6x/dsbt.ld: Likewise.
2018-10-08ld insert_os_after ignoring first assignmentAlan Modra3-5/+15
Some time ago the pr19593 test was xfailed for alpha. This turned out to be the wrong course of action since the test exposed a bug in orphan section placement. On alpha, orphan sections were being inserted before ". = SIZEOF_HEADERS" due to the test having two assignments, and on alpha, an output section statement from -Ttext-segment being passed to ld. * ldlang.c (insert_os_after): Clear ignore_first on assignment to dot, not any assignment. Clear ignore_first on output section statement contents too. * testsuite/ld-elf/pr19539.d: Remove alpha xfail.
2018-10-08No PT_INTERP when .interp is zero sizeAlan Modra2-1/+5
Some targets don't set a default interpreter, resulting in an empty .interp section unless --dynamic-linker is passed to ld. A PT_INTERP without a path is rather useless. The testsuite change fixes a failure on microblaze-linux. bfd/ * elf.c (get_program_header_size): Don't count PT_INTERP if .interp is empty. (_bfd_elf_map_sections_to_segments): Don't create PT_INTERP if .interp is empty. ld/ * testsuite/ld-elf/pr22423.d: Pass --dynamic-linker to ld.
2018-10-05or1k: Add the l.adrp insn and supporting relocationsStafford Horne8-0/+147
This patch adds the new instruction and relocation as per proposal: https://openrisc.io/proposals/ladrp This is to be added to the spec in an upcoming revision. The new instruction l.adrp loads the page offset of the current instruction offset by a 21-bit immediate shifted left 13-bits. This is meant to be used with a 13-bit lower bit page offset. This allows us to free up the got register r16. l.adrp r3, foo l.ori r4, r3, po(foo) l.lbz r5, po(foo)(r3) l.sb po(foo)(r3), r6 The relocations we add are: - BFD_RELOC_OR1K_PLTA26 For PLT jump relocation with PLT entry asm: plta() implemented using l.ardp, meaning no need for r16 (the GOT reg) - BFD_RELOC_OR1K_GOT_PG21 Upper 21-bit Page offset got address asm: got() - BFD_RELOC_OR1K_TLS_GD_PG21 Upper 21-bit Page offset with TLS General asm: tlsgd() Dynamic calculation - BFD_RELOC_OR1K_TLS_LDM_PG21 Upper 21-bit Page offset with TLS local asm: tlsldm() dynamic calculation - BFD_RELOC_OR1K_TLS_IE_PG21 Upper 21-bit Page offset with TLS Initial asm: gottp() Executable calculation - BFD_RELOC_OR1K_PCREL_PG21 Default relocation for disp21 (l.adrp instructions) - BFD_RELOC_OR1K_LO13 low 13-bit page offset relocation asm: po() i.e. mem loads, addi etc - BFD_RELOC_OR1K_SLO13 low 13-bit page offset relocation asm: po() i.e. mem stores, with split immediate - BFD_RELOC_OR1K_GOT_LO13, low 13-bit page offset with GOT calcs asm: gotpo() - BFD_RELOC_OR1K_TLS_GD_LO13 Lower 13-bit offset with TLS GD calcs asm: tlsgdpo() - BFD_RELOC_OR1K_TLS_LDM_LO13 Lower 13-bit offset with TLS LD calcs asm: tlsldmpo() - BFD_RELOC_OR1K_TLS_IE_LO13 Lower 13-bit offset with TLS IE calcs asm: gottppo() bfd/ChangeLog: yyyy-mm-dd Richard Henderson <rth@twiddle.net> * bfd-in2.h: Regenerated. * elf32-or1k.c: (or1k_elf_howto_table): Fix formatting for R_OR1K_PLT26, Add R_OR1K_PCREL_PG21, R_OR1K_GOT_PG21, R_OR1K_TLS_GD_PG21, R_OR1K_TLS_LDM_PG21, R_OR1K_TLS_IE_PG21, R_OR1K_LO13, R_OR1K_GOT_LO13, R_OR1K_TLS_GD_LO13, R_OR1K_TLS_LDM_LO13, R_OR1K_TLS_IE_LO13, R_OR1K_SLO13, R_OR1K_PLTA26. (or1k_reloc_map): Add BFD_RELOC_OR1K_PCREL_PG21, BFD_RELOC_OR1K_GOT_PG21, BFD_RELOC_OR1K_TLS_GD_PG21, BFD_RELOC_OR1K_TLS_LDM_PG21, BFD_RELOC_OR1K_TLS_IE_PG21, BFD_RELOC_OR1K_LO13, BFD_RELOC_OR1K_GOT_LO13, BFD_RELOC_OR1K_TLS_GD_LO13, BFD_RELOC_OR1K_TLS_GD_LO13, BFD_RELOC_OR1K_TLS_LDM_LO13, BFD_RELOC_OR1K_TLS_IE_LO13, BFD_RELOC_OR1K_SLO13, BFD_RELOC_OR1K_PLTA26. (elf_or1k_link_hash_table): Add field saw_plta. (or1k_final_link_relocate): Add value calculations for new relocations. (or1k_elf_relocate_section): Add section relocations for new relocations. (or1k_write_plt_entry): New function. (or1k_elf_finish_dynamic_sections): Add support for PLTA relocations using new l.adrp instruction. Cleanup PLT relocation code generation. * libbfd.h: Regenerated. * reloc.c: Add BFD_RELOC_OR1K_PCREL_PG21, BFD_RELOC_OR1K_LO13, BFD_RELOC_OR1K_SLO13, BFD_RELOC_OR1K_GOT_PG21, BFD_RELOC_OR1K_GOT_LO13, BFD_RELOC_OR1K_PLTA26, BFD_RELOC_OR1K_TLS_GD_PG21, BFD_RELOC_OR1K_TLS_GD_LO13, BFD_RELOC_OR1K_TLS_LDM_PG21, BFD_RELOC_OR1K_TLS_LDM_LO13, BFD_RELOC_OR1K_TLS_IE_PG21, BFD_RELOC_OR1K_TLS_IE_LO13. cpu/ChangeLog: yyyy-mm-dd Richard Henderson <rth@twiddle.net> * or1k.opc (parse_disp26): Add support for plta() relocations. (parse_disp21): New function. (or1k_rclass): New enum. (or1k_rtype): New enum. (or1k_imm16_relocs): Define new PO and SPO relocation mappings. (parse_reloc): Add new po(), gotpo() and gottppo() for LO13 relocations. (parse_imm16): Add support for the new 21bit and 13bit relocations. * or1korbis.cpu (f-disp26): Don't assume SI. (f-disp21): New pc-relative 21-bit 13 shifted to right. (insn-opcode): Add ADRP. (l-adrp): New instruction. gas/ChangeLog: yyyy-mm-dd Richard Henderson <rth@twiddle.net> * config/tc-or1k.c (or1k_apply_fix): Add BFD_RELOC_OR1K_TLS_GD_PG21, BFD_RELOC_OR1K_TLS_GD_LO13, BFD_RELOC_OR1K_TLS_LDM_PG21, BFD_RELOC_OR1K_TLS_LDM_LO13, BFD_RELOC_OR1K_TLS_IE_PG21, BFD_RELOC_OR1K_TLS_IE_LO13. * testsuite/gas/or1k/allinsn.s: Add test for l.adrp. * testsuite/gas/or1k/allinsn.d: Add test results for new instructions. * testsuite/gas/or1k/reloc-1.s: Add tests to generate R_OR1K_PLTA26, R_OR1K_GOT_PG21, R_OR1K_TLS_GD_PG21, R_OR1K_TLS_LDM_PG21, R_OR1K_TLS_IE_PG21, R_OR1K_LO13, R_OR1K_GOT_LO13, R_OR1K_TLS_GD_LO13, R_OR1K_TLD_LDM_LO13, R_OR1K_TLS_IE_LO13, R_OR1K_LO13, R_OR1K_SLO13 relocations. * testsuite/gas/or1k/reloc-1.d: Add relocation results for tests. * testsuite/gas/or1k/reloc-2.s: Add negative tests for store to gotpo(). * testsuite/gas/or1k/reloc-2.l: Add expected error test results. ld/ChangeLog: yyyy-mm-dd Richard Henderson <rth@twiddle.net> * testsuite/ld-or1k/or1k.exp: Add test cases for plt generation. * testsuite/ld-or1k/plt1.dd: New file. * testsuite/ld-or1k/plt1.s: New file. * testsuite/ld-or1k/plt1.x.dd: New file. * testsuite/ld-or1k/plta1.dd: New file. * testsuite/ld-or1k/plta1.s: New file. * testsuite/ld-or1k/pltlib.s: New file. include/ChangeLog: yyyy-mm-dd Richard Henderson <rth@twiddle.net> * elf/or1k.h (elf_or1k_reloc_type): Add R_OR1K_PCREL_PG21, R_OR1K_GOT_PG21, R_OR1K_TLS_GD_PG21, R_OR1K_TLS_LDM_PG21, R_OR1K_TLS_IE_PG21, R_OR1K_LO13, R_OR1K_GOT_LO13, R_OR1K_TLS_GD_LO13, R_OR1K_TLS_LDM_LO13, R_OR1K_TLS_IE_LO13, R_OR1K_SLO13, R_OR1K_PLTA26. opcodes/ChangeLog: yyyy-mm-dd Richard Henderson <rth@twiddle.net> * or1k-asm.c: Regenerated. * or1k-desc.c: Regenerated. * or1k-desc.h: Regenerated. * or1k-dis.c: Regenerated. * or1k-ibld.c: Regenerated. * or1k-opc.c: Regenerated. * or1k-opc.h: Regenerated. * or1k-opinst.c: Regenerated.
2018-10-05or1k: Add relocations for high-signed and low-storesRichard Henderson4-0/+301
This patch adds the following target relocations: - BFD_RELOC_HI16_S High 16-bit relocation, for used with signed asm: ha() lower. - BFD_RELOC_HI16_S_GOTOFF High 16-bit GOT offset relocation for local asm: gotoffha() symbols, for use with signed lower. - BFD_RELOC_OR1K_TLS_IE_AHI16 High 16-bit TLS relocation with initial asm: gottpoffha() executable calculation, for use with signed lower. - BFD_RELOC_OR1K_TLS_LE_AHI16 High 16-bit TLS relocation for local executable asm: tpoffha() variables, for use with signed lower. - BFD_RELOC_OR1K_SLO16 Split lower 16-bit relocation, used with asm: lo() OpenRISC store instructions. - BFD_RELOC_OR1K_GOTOFF_SLO16 Split lower 16-bit GOT offset relocation for asm: gotofflo() local symbols, used with OpenRISC store instructions. - BFD_RELOC_OR1K_TLS_LE_SLO16 Split lower 16-bit relocation for TLS local asm: tpofflo() executable variables, used with OpenRISC store instructions. bfd/ChangeLog: yyyy-mm-dd Richard Henderson <rth@twiddle.net> Stafford Horne <shorne@gmail.com> * bfd-in2.h: Regenerated. * elf32-or1k.c (N_ONES): New macro. (or1k_elf_howto_table): Fix R_OR1K_PLT26 to complain on overflow. Add definitions for R_OR1K_TLS_TPOFF, R_OR1K_TLS_DTPOFF, R_OR1K_TLS_DTPMOD, R_OR1K_AHI16, R_OR1K_GOTOFF_AHI16, R_OR1K_TLS_IE_AHI16, R_OR1K_TLS_LE_AHI16, R_OR1K_SLO16, R_OR1K_GOTOFF_SLO16, R_OR1K_TLS_LE_SLO16. (or1k_reloc_map): Add entries for BFD_RELOC_HI16_S, BFD_RELOC_LO16_GOTOFF, BFD_RELOC_HI16_GOTOFF, BFD_RELOC_HI16_S_GOTOFF, BFD_RELOC_OR1K_TLS_IE_AHI16, BFD_RELOC_OR1K_TLS_LE_AHI16, BFD_RELOC_OR1K_SLO16, BFD_RELOC_OR1K_GOTOFF_SLO16, BFD_RELOC_OR1K_TLS_LE_SLO16. (or1k_reloc_type_lookup): Change search loop to start ad index 0 and also check results before returning. (or1k_reloc_name_lookup): Simplify loop to use R_OR1K_max as index limit. (or1k_final_link_relocate): New function. (or1k_elf_relocate_section): Add support for new AHI and SLO relocations. Use or1k_final_link_relocate instead of generic _bfd_final_link_relocate. (or1k_elf_check_relocs): Add support for new AHI and SLO relocations. * reloc.c: Add new enums for BFD_RELOC_OR1K_SLO16, BFD_RELOC_OR1K_GOTOFF_SLO16, BFD_RELOC_OR1K_TLS_IE_AHI16, BFD_RELOC_OR1K_TLS_IE_AHI16, BFD_RELOC_OR1K_TLS_LE_AHI16, BFD_RELOC_OR1K_TLS_LE_SLO16. Remove unused BFD_RELOC_OR1K_GOTOFF_HI16 and BFD_RELOC_OR1K_GOTOFF_LO16. * libbfd.h: Regenerated. cpu/ChangeLog: yyyy-mm-dd Richard Henderson <rth@twiddle.net> * or1k.opc: Add RTYPE_ enum. (INVALID_STORE_RELOC): New string. (or1k_imm16_relocs): New array array. (parse_reloc): New static function that just does the parsing. (parse_imm16): New static function for generic parsing. (parse_simm16): Change to just call parse_imm16. (parse_simm16_split): New function. (parse_uimm16): Change to call parse_imm16. (parse_uimm16_split): New function. * or1korbis.cpu (simm16-split): Change to use new simm16_split. (uimm16-split): Change to use new uimm16_split. gas/ChangeLog: yyyy-mm-dd Richard Henderson <rth@twiddle.net> * testsuite/gas/or1k/allinsn.d (l_ha): Add result for ha() relocation. * testsuite/gas/or1k/allinsn.s (l_ha): Add test for ha() relocations. * testsuite/gas/or1k/allinsn.exp: Renamed to or1k.exp. * testsuite/gas/or1k/or1k.exp: Add reloc-2 list test. * testsuite/gas/or1k/reloc-1.d: New file. * testsuite/gas/or1k/reloc-1.s: New file. * testsuite/gas/or1k/reloc-2.l: New file. * testsuite/gas/or1k/reloc-2.s: New file. include/ChangeLog: yyyy-mm-dd Richard Henderson <rth@twiddle.net> * elf/or1k.h (elf_or1k_reloc_type): Add R_OR1K_AHI16, R_OR1K_GOTOFF_AHI16, R_OR1K_TLS_IE_AHI16, R_OR1K_TLS_LE_AHI16, R_OR1K_SLO16, R_OR1K_GOTOFF_SLO16, R_OR1K_TLS_LE_SLO16. ld/ChangeLog: yyyy-mm-dd Richard Henderson <rth@twiddle.net> * testsuite/ld-or1k/offsets1.d: New file. * testsuite/ld-or1k/offsets1.s: New file. * testsuite/ld-or1k/or1k.exp: New file. opcodes/ChangeLog: yyyy-mm-dd Richard Henderson <rth@twiddle.net> * or1k-asm.c: Regenerate.
2018-10-04pr23658-1.d: Also xfail ft32-* and xgate-*H.J. Lu2-2/+7
Since ft32-* and xgate-* use generic linker, SHT_NOTE sections aren't grouped nor sorted. PR ld/23658 * testsuite/ld-elf/pr23658-1.d: Also xfail ft32-* and xgate-*.
2018-10-03ELF: Add testcases for PR ld/23658H.J. Lu11-0/+152
Add testcases to verify that all SHT_NOTE sections with the same section alignment are placed in a single PT_NOTE segment. PR ld/23658 * testsuite/ld-elf/pr23658-1.d: New file. * testsuite/ld-elf/pr23658-1a.s: Likewise. * testsuite/ld-elf/pr23658-1b.s: Likewise. * testsuite/ld-elf/pr23658-1c.s: Likewise. * testsuite/ld-elf/pr23658-1d.s: Likewise. * testsuite/ld-elf/pr23658-2.rd: Likewise. * testsuite/ld-elf/pr23658-3.d: Likewise. * testsuite/ld-elf/pr23658-3.s: Likewise. * testsuite/ld-elf/pr23658-3.t: Likewise. * testsuite/ld-elf/shared.exp: Run PR ld/23658 tests.
2018-10-03ELF: Group and sort output note sections by section alignmentsH.J. Lu2-1/+145
To support putting all adjacent SHT_NOTE sections with the same section alignment into a single PT_NOTE segment, lang_insert_orphan must group and sort output note sections by section alignments in both output section list as well as output section statement list. PR ld/23658 * ldlang.c (lang_insert_orphan): Group and sort output note sections by section alignments.
2018-09-25Couple of minor tweaks to the linker testsuite.Eric Botcazou3-1/+15
This gets rid of the couple of linker failures for visium-elf: FAIL: ld-elf/pr14156b FAIL: ld-elf/pr22677 by tweaking the respective testcases. The first tweak is the same as the one made to the sibling testcase ld-elf/pr14156a.d about one year ago and the second tweak adds the usual main/start/_start/__start symbols. ld/ * testsuite/ld-elf/pr14156b.d: Adjust for extra symbols. * testsuite/ld-elf/pr22677.s: Define main/start/_start/__start.