aboutsummaryrefslogtreecommitdiff
path: root/ld/testsuite/ld-mips-elf
AgeCommit message (Collapse)AuthorFilesLines
2024-01-04Update year range in copyright notice of binutils filesAlan Modra4-4/+4
Adds two new external authors to etc/update-copyright.py to cover bfd/ax_tls.m4, and adds gprofng to dirs handled automatically, then updates copyright messages as follows: 1) Update cgen/utils.scm emitted copyrights. 2) Run "etc/update-copyright.py --this-year" with an extra external author I haven't committed, 'Kalray SA.', to cover gas testsuite files (which should have their copyright message removed). 3) Build with --enable-maintainer-mode --enable-cgen-maint=yes. 4) Check out */po/*.pot which we don't update frequently.
2023-12-11R_MICROMIPS_GPREL7_S2Alan Modra2-2/+2
This reloc is meant for the 16-bit LWGP instruction, 0x6400/0xfc00 match/mask encoding in `micromips_opcodes'. It is correctly specified to operate on a half-word by the howtos in elf32-mips.c, elfn32-mips.c and elf64-mips.c, but is incorrectly subject to shuffle/unshuffle in code like _bfd_mips_elf32_gprel16_reloc. Current behaviour when applying the reloc to .byte 0x11,0x22,0x33,0x44 is to apply the reloc to byte 0x22 when big-endian, and to byte 0x33 when little-endian. Big-endian behaviour is unchanged after this patch and little-endian correctly applies the reloc to byte 0x11. The patch also corrects REL addend extraction from section contents, and overflow checking. gold had all of the bfd problems with this reloc and additionally did not apply the rightshift by two. bfd/ * elfxx-mips.c (micromips_reloc_shuffle_p): Return false for R_MICROMIPS_GPREL7_S2. (mips_elf_calculate_relocation): Correct sign extension and overflow calculation for R_MICROMIPS_GPREL7_S2. (_bfd_mips_elf_relocate_section): Update small-data overflow message. gold/ * mips.cc (Mips_relocate_functions::should_shuffle_micromips_reloc): Return false for R_MICROMIPS_GPREL7_S2. (Mips_relocate_functions::mips_reloc_unshuffle): Update comment. (Mips_relocate_functions::relgprel): Remove R_MICROMIPS_GPREL7_S2 handling. (Mips_relocate_functions::relgprel7): New function. (Target_mips::Relocate::relocate): Adjust to suit. ld/ * testsuite/ld-mips-elf/reloc-4.d: Adjust expected error. * testsuite/ld-mips-elf/reloc-5.d: Likewise.
2023-07-28MIPS: Support `-gnuabi64' target triplet suffix for 64-bit Linux targetsYunQiang Su3-7/+18
Make the n64 ABI the default for 64-bit Linux targets specified with `-gnuabi64' suffix included in the target triplet, for configurations such as the Debian mips64el and mips64r6el ports. Adjust testsuite configuration accordingly. There are the following regressions with the new target triplet: mips64-linux-gnuabi64 +FAIL: readelf -S bintest mips64-linux-gnuabi64 +FAIL: MIPS reloc estimation 1 mips64el-linux-gnuabi64 +FAIL: readelf -S bintest mips64el-linux-gnuabi64 +FAIL: MIPS reloc estimation 1 The `readelf' issue comes from a difference in section headers produced that the `binutils/testsuite/binutils-all/readelf.s-64' pattern template does not match. While there has been a precedent it does not appear to me that there is a clear advantage from adding more and more variations to the template rather than forking the existing template into multiple ones for a more exact match. So this is best deferred to a separate discussion. The MIPS reloc estimation issue is an actual bug in `objdump', which discards a number of trailing entries from output here for n64 composed relocations: DYNAMIC RELOCATION RECORDS OFFSET TYPE VALUE 0000000000000000 R_MIPS_NONE *ABS* 0000000000000000 R_MIPS_NONE *ABS* and consequently `ld/testsuite/ld-mips-elf/reloc-estimate-1.d' does not match even though ELF output produced is correct according to `readelf': Relocation section '.rel.dyn' at offset 0x10400 contains 2 entries: Offset Info Type Sym. Value Sym. Name 000000000000 000000000000 R_MIPS_NONE Type2: R_MIPS_NONE Type3: R_MIPS_NONE 000000010000 000300001203 R_MIPS_REL32 0000000000010010 foo@@V2 Type2: R_MIPS_64 Type3: R_MIPS_NONE As a genuine bug this has to be handled separately. Co-Authored by: Maciej W. Rozycki <macro@orcam.me.uk> bfd/ * config.bfd: Add `mips64*el-*-linux*-gnuabi64' and `mips64*-*-linux*-gnuabi64' targets. binutils/ * testsuite/binutils-all/mips/mips.exp: Handle `*-*-*-gnuabi64' targets. * testsuite/binutils-all/objcopy.exp: Handle `mips64*-*-*-gnuabi64' targets. * testsuite/binutils-all/remove-relocs-01.d: Likewise. * testsuite/binutils-all/remove-relocs-04.d: Likewise. * testsuite/binutils-all/remove-relocs-05.d: Likewise. * testsuite/binutils-all/remove-relocs-06.d: Likewise. gas/ * configure.ac: Handle `mips64*-linux-gnuabi64' targets. * configure: Regenerate. * testsuite/gas/mips/compact-eh-eb-7.d: Handle `mips64*-*-*-gnuabi64' targets. * testsuite/gas/mips/compact-eh-el-7.d: Likewise. ld/ * configure.tgt: Add `mips64*el-*-linux-gnuabi64' and `mips64*-*-linux-gnuabi64' targets. * testsuite/ld-undefined/undefined.exp: Handle `mips64*-*-*-gnuabi64' targets. * testsuite/ld-mips-elf/attr-gnu-4-10.d: Likewise. * testsuite/ld-mips-elf/compact-eh6.d: Likewise. * testsuite/ld-mips-elf/mips-elf.exp: Handle `*-*-*-gnuabi64' targets.
2023-07-28testsuite: Handle composed R_MIPS_NONE relocationsYunQiang Su1-0/+4
MIPS n64 ABI has a peculiarity where all relocations are composed of three, with subsequent relocation types set to R_MIPS_NONE if further calculation is not required. Example output produced by `readelf' and `objdump' for such relocations is: Offset Info Type Sym. Value Sym. Name + Addend 000000000000 000800000002 R_MIPS_32 0000000000000000 foo + 0 Type2: R_MIPS_NONE Type3: R_MIPS_NONE and: OFFSET TYPE VALUE 0000000000000000 R_MIPS_32 foo 0000000000000000 R_MIPS_NONE *ABS* 0000000000000000 R_MIPS_NONE *ABS* respectively. The presence of these extra R_MIPS_NONE entries is not relevant for generic or even some MIPS tests, so optionally match them with the respective dump patterns, also discarding `xfail' annotation for MIPS/OpenBSD targets from gas/elf/missing-build-notes.d, removing these regressions: mips64-openbsd -FAIL: readelf -r bintest mips64-openbsd -FAIL: forward expression mips64-openbsd -FAIL: assignment tests mips64-openbsd -FAIL: gas/all/none mips64-openbsd -XFAIL: gas/elf/missing-build-notes mips64-openbsd -FAIL: macro test 2 mips64-openbsd -FAIL: macro irp mips64-openbsd -FAIL: macro rept mips64-openbsd -FAIL: nested irp/irpc/rept mips64-openbsd -FAIL: macro vararg mips64-openbsd -FAIL: mips jalx mips64-openbsd -FAIL: ST Microelectronics Loongson-2F workarounds of Jump Instruction issue mips64el-openbsd -FAIL: readelf -r bintest mips64el-openbsd -FAIL: forward expression mips64el-openbsd -FAIL: assignment tests mips64el-openbsd -FAIL: gas/all/none mips64el-openbsd -XFAIL: gas/elf/missing-build-notes mips64el-openbsd -FAIL: macro test 2 mips64el-openbsd -FAIL: macro irp mips64el-openbsd -FAIL: macro rept mips64el-openbsd -FAIL: nested irp/irpc/rept mips64el-openbsd -FAIL: macro vararg mips64el-openbsd -FAIL: mips jalx mips64el-openbsd -FAIL: ST Microelectronics Loongson-2F workarounds of Jump Instruction issue Co-Authored-By: Maciej W. Rozycki <macro@orcam.me.uk> binutils/ * testsuite/binutils-all/readelf.r-64: Optionally match extra R_MIPS_NONE pairs. gas/ * testsuite/gas/all/assign.d: Optionally match extra R_MIPS_NONE pairs. * testsuite/gas/all/fwdexp.d: Likewise. * testsuite/gas/all/none.d: Likewise. * testsuite/gas/macros/irp.d: Likewise. * testsuite/gas/macros/repeat.d: Likewise. * testsuite/gas/macros/rept.d: Likewise. * testsuite/gas/macros/test2.d: Likewise. * testsuite/gas/macros/vararg.d: Likewise. * testsuite/gas/mips/compact-eh-eb-1.d: Likewise. * testsuite/gas/mips/compact-eh-eb-2.d: Likewise. * testsuite/gas/mips/compact-eh-eb-3.d: Likewise. * testsuite/gas/mips/compact-eh-eb-4.d: Likewise. * testsuite/gas/mips/compact-eh-eb-5.d: Likewise. * testsuite/gas/mips/compact-eh-eb-6.d: Likewise. * testsuite/gas/mips/compact-eh-el-1.d: Likewise. * testsuite/gas/mips/compact-eh-el-2.d: Likewise. * testsuite/gas/mips/compact-eh-el-3.d: Likewise. * testsuite/gas/mips/compact-eh-el-4.d: Likewise. * testsuite/gas/mips/compact-eh-el-5.d: Likewise. * testsuite/gas/mips/compact-eh-el-6.d: Likewise. * testsuite/gas/mips/loongson-2f-3.d: Likewise. * testsuite/gas/mips/mips-jalx.d: Likewise. * testsuite/gas/elf/missing-build-notes.d: Likewise. Remove the `xfail' tag. ld/ * testsuite/ld-mips-elf/reloc-estimate-1.d: Optionally match extra R_MIPS_NONE pairs.
2023-07-28MIPS/testsuite: Handle 64-bit addressesYunQiang Su3-8/+8
Several MIPS test cases are suitable for the n64 ABI if not for the extra leading zeros or spaces in addresses not handled by dump patterns. Match the characters then, removing these regressions: mips64-openbsd -FAIL: .set arch=FOO mips64-openbsd -FAIL: ST Microelectronics Loongson-2F workarounds of nop issue mips64-openbsd -FAIL: MIPS DSP ASE for MIPS64 mips64-openbsd -FAIL: gas/mips/align2 mips64-openbsd -FAIL: gas/mips/align2-el mips64-openbsd -FAIL: Locally-resolvable PC-relative code references mips64-openbsd -FAIL: MIPS jalx-1 mips64-openbsd -FAIL: JAL overflow 2 mips64el-openbsd -FAIL: .set arch=FOO mips64el-openbsd -FAIL: ST Microelectronics Loongson-2F workarounds of nop issue mips64el-openbsd -FAIL: MIPS DSP ASE for MIPS64 mips64el-openbsd -FAIL: gas/mips/align2 mips64el-openbsd -FAIL: gas/mips/align2-el mips64el-openbsd -FAIL: Locally-resolvable PC-relative code references mips64el-openbsd -FAIL: MIPS jalx-1 mips64el-openbsd -FAIL: JAL overflow 2 Co-Authored-By: Maciej W. Rozycki <macro@orcam.me.uk> gas/ * testsuite/gas/mips/align2-el.d: Match extra leading zeros with addresses. * testsuite/gas/mips/align2.d: Likewise. * testsuite/gas/mips/compact-eh-eb-1.d: Likewise. * testsuite/gas/mips/compact-eh-eb-2.d: Likewise. * testsuite/gas/mips/compact-eh-eb-3.d: Likewise. * testsuite/gas/mips/compact-eh-eb-4.d: Likewise. * testsuite/gas/mips/compact-eh-eb-5.d: Likewise. * testsuite/gas/mips/compact-eh-eb-6.d: Likewise. * testsuite/gas/mips/compact-eh-el-1.d: Likewise. * testsuite/gas/mips/compact-eh-el-2.d: Likewise. * testsuite/gas/mips/compact-eh-el-3.d: Likewise. * testsuite/gas/mips/compact-eh-el-4.d: Likewise. * testsuite/gas/mips/compact-eh-el-5.d: Likewise. * testsuite/gas/mips/compact-eh-el-6.d: Likewise. * testsuite/gas/mips/loongson-2f-2.d: Likewise. * testsuite/gas/mips/loongson-2f-3.d: Likewise. * testsuite/gas/mips/mips-jalx.d: Likewise. * testsuite/gas/mips/mips64-dsp.d: Likewise. * testsuite/gas/mips/pcrel-1.d: Likewise. * testsuite/gas/mips/set-arch.d: Likewise. ld/ * testsuite/ld-mips-elf/jaloverflow-2.d: Match extra leading zeros and spaces with addresses as appropriate. * testsuite/ld-mips-elf/jalx-1.d: Likewise. * testsuite/ld-mips-elf/reloc-estimate-1.d: Likewise.
2023-07-28testsuite: Also discard the `.MIPS.options' sectionYunQiang Su1-1/+1
Also discard the `.MIPS.options' section, used with n64 MIPS binaries, along with similar other MIPS sections (`.reginfo', `.MIPS.abiflags') not relevant for the test cases concerned, fixing these regressions: mips64-openbsd -FAIL: ld-elf/group3a mips64-openbsd -FAIL: ld-elf/group3b mips64-openbsd -FAIL: Place orphan sections (map file check) mips64-openbsd -FAIL: ld-elf/orphan-region mips64-openbsd -FAIL: ld-elf/orphan mips64-openbsd -FAIL: overlay size (map file check) mips64-openbsd -FAIL: overlay size mips64el-openbsd -FAIL: ld-elf/group3a mips64el-openbsd -FAIL: ld-elf/group3b mips64el-openbsd -FAIL: Place orphan sections (map file check) mips64el-openbsd -FAIL: ld-elf/orphan-region mips64el-openbsd -FAIL: ld-elf/orphan mips64el-openbsd -FAIL: overlay size (map file check) mips64el-openbsd -FAIL: overlay size Co-Authored-By: Maciej W. Rozycki <macro@orcam.me.uk> binutils/ * testsuite/binutils-all/strip-3.d: Add `-R .MIPS.options' to the `strip' tag. ld/ * testsuite/ld-elf/group.ld: Also discard `.MIPS.options'. * testsuite/ld-elf/orphan-region.ld: Likewise. * testsuite/ld-elf/orphan.ld: Likewise. * testsuite/ld-mips-elf/got-page-1.ld: Likewise. * testsuite/ld-scripts/overlay-size.t: Likewise.
2023-07-28MIPS/LD/testsuite: Fix MIPS16 interlinking test IRIX 6 regressionsMaciej W. Rozycki1-1/+2
IRIX 6 does not have MIPS16 stub section support in its n32 linker scripts, causing such input sections to be propagated to the respective output sections rather than `.text', causing dump pattern mismatches. Expect IRIX 6 to fail with n32 testing then, removing this regression: mips-sgi-irix6 -FAIL: MIPS16 interlinking for local functions 1 (n32) We may choose to update IRIX 6 n32 linker scripts sometime, as it seems a harmless change. ld/ * testsuite/ld-mips-elf/mips-elf.exp: Expect IRIX 6 to fail with n32 `mips16-local-stubs-1' testing.
2023-07-28MIPS/LD/testsuite: Fix MIPS16 interlinking test n64 regressionsYunQiang Su3-2/+4
The MIPS16 interlinking test for local functions expects to be assembled with 32-bit addressing, otherwise causing assembly warnings: .../ld/testsuite/ld-mips-elf/mips16-local-stubs-1.s: Assembler messages: .../ld/testsuite/ld-mips-elf/mips16-local-stubs-1.s:16: Warning: la used to load 64-bit address; recommend using dla instead Use the per-ABI framework then to run the test explicitly for o32 and n32 ABIs only, replacing the `-mips4' option from the `as' tag with `.module mips4' pseudo-op within the source itself so as to avoid assembly errors: Assembler messages: Error: -mips4 conflicts with the other architecture options, which imply -mips3 with n32 testing for some targets, and ultimately removing these regressions: mips64-openbsd -FAIL: MIPS16 interlinking for local functions 1 mips64el-openbsd -FAIL: MIPS16 interlinking for local functions 1 Co-Authored-By: Maciej W. Rozycki <macro@orcam.me.uk> ld/ * testsuite/ld-mips-elf/mips16-local-stubs-1.d: Remove `-mips4' from the `as' tag. * testsuite/ld-mips-elf/mips16-local-stubs-1.s: Add `.module mips4'. * testsuite/ld-mips-elf/mips-elf.exp: Run `mips16-local-stubs-1' for o32 and n32 ABIs only.
2023-07-28MIPS/LD/testsuite: Run `got-dump-1' for o32/n32 ABIsMaciej W. Rozycki1-1/+2
The `got-dump-1' test case uses 32-bit addressing, so it makes no sense to run it with the n64 ABI. And there is a corresponding `got-dump-2' test already for the n64 ABI. Use the per-ABI framework then to run the `got-dump-1' test explicitly for o32 and n32 ABIs only. ld/ * testsuite/ld-mips-elf/mips-elf.exp: Run `got-dump-1' for o32 and n32 ABIs only.
2023-07-28MIPS/LD/testsuite: Fix `attr-gnu-4-10' failures with OpenBSD targetsMaciej W. Rozycki1-0/+1
OpenBSD targets produce ELF64 files while the pattern dump expects ELF32 output and specific header sizes. Disable it for `mips64*-*-openbsd*' for these targets then, removing these failures: mips64-openbsd -FAIL: ld-mips-elf/attr-gnu-4-10 mips64el-openbsd -FAIL: ld-mips-elf/attr-gnu-4-10 ld/ * testsuite/ld-mips-elf/attr-gnu-4-10.d: Add `notarget' tag with `mips64*-*-openbsd*'.
2023-07-28MIPS/LD/testsuite: Fix `attr-gnu-4-10' failures with IRIX targetsMaciej W. Rozycki1-0/+1
IRIX targets do not enable the production of a `.pdr' section in GAS by default, which causes a failure with the `attr-gnu-4-10' test case due to a difference resulting in the number and indices of sections produced in linker output. As the presence or absence of this section is not relevant to this test case, just enable it unconditionally, fixing these regressions: mips-sgi-irix5 -FAIL: ld-mips-elf/attr-gnu-4-10 mips-sgi-irix6 -FAIL: ld-mips-elf/attr-gnu-4-10 ld/ * testsuite/ld-mips-elf/attr-gnu-4-10.d: Add `as' tag with `-mpdr'.
2023-07-28MIPS/LD/testsuite: Fix JALR relaxation test failure with IRIX 6Maciej W. Rozycki4-10/+9
The `mips-sgi-irix6' target only supports IRIX linker emulations, but most JALR relaxation tests request the relevant traditional emulation instead, causing a link failure: ./ld-new: unrecognised emulation mode: elf32btsmipn32 Supported emulations: elf32bmipn32 elf32bsmip elf64bmip This is clearly an omission from the conversion to use the per-ABI framework made with commit 78da84f99405 ("MIPS/LD/testsuite: Correct mips-elf.exp test ABI/emul/endian arrangement"). These tests are also endianness agnostic, which was missed in the conversion as well. Remove the unnecessary explicit ABI and endianness options then and rely on the per-ABI framework to get things right, removing this regression: mips-sgi-irix6 -FAIL: MIPS relax-jalr-shared n32 ld/ * testsuite/ld-mips-elf/relax-jalr-n32-shared.d: Remove flags related to ABI and endianness selection from the `as' and `ld' tags. * testsuite/ld-mips-elf/relax-jalr-n64.d: Likewise. * testsuite/ld-mips-elf/relax-jalr-n64-shared.d: Likewise. * testsuite/ld-mips-elf/mips-elf.exp: Remove `as' and `ld' tag additions from the invocation of JALR relaxation tests.
2023-07-28MIPS/LD/testsuite: Fix unaligned JALX failures with OpenBSD targetsMaciej W. Rozycki9-16/+24
There are only n64 linker emulations included with `mips64*-*-openbsd*' targets, however the unaligned JALX tests insist on running across all targets and force the n32 ABI, causing link errors with the targets concerned, e.g.: ./ld-new: tmpdir/unaligned-jalx-0.o: ABI is incompatible with that of the selected emulation ./ld-new: failed to merge target specific data of file tmpdir/unaligned-jalx-0.o ./ld-new: tmpdir/unaligned-insn.o: ABI is incompatible with that of the selected emulation ./ld-new: failed to merge target specific data of file tmpdir/unaligned-insn.o Convert the tests then to use the per-ABI framework and run them for the o32 and n32 ABIs, removing these regressions: mips64-openbsd -FAIL: MIPS JALX to unaligned symbol 0 mips64-openbsd -FAIL: MIPS JALX to unaligned symbol 1 mips64-openbsd -FAIL: MIPS JALX to unaligned symbol 2 mips64-openbsd -FAIL: MIPS JALX to unaligned symbol 3 mips64-openbsd -FAIL: MIPS16 JALX to unaligned symbol 0 mips64-openbsd -FAIL: MIPS16 JALX to unaligned symbol 1 mips64-openbsd -FAIL: microMIPS JALX to unaligned symbol 0 mips64-openbsd -FAIL: microMIPS JALX to unaligned symbol 1 mips64el-openbsd -FAIL: MIPS JALX to unaligned symbol 0 mips64el-openbsd -FAIL: MIPS JALX to unaligned symbol 1 mips64el-openbsd -FAIL: MIPS JALX to unaligned symbol 2 mips64el-openbsd -FAIL: MIPS JALX to unaligned symbol 3 mips64el-openbsd -FAIL: MIPS16 JALX to unaligned symbol 0 mips64el-openbsd -FAIL: MIPS16 JALX to unaligned symbol 1 mips64el-openbsd -FAIL: microMIPS JALX to unaligned symbol 0 mips64el-openbsd -FAIL: microMIPS JALX to unaligned symbol 1 Similar tests for the n64 ABI can be added separately, using suitable dump patterns. ld/ * testsuite/ld-mips-elf/unaligned-jalx-0.d: Remove `-32' from the `as' tag. * testsuite/ld-mips-elf/unaligned-jalx-1.d: Likewise. * testsuite/ld-mips-elf/unaligned-jalx-2.d: Likewise. * testsuite/ld-mips-elf/unaligned-jalx-3.d: Likewise. * testsuite/ld-mips-elf/unaligned-jalx-mips16-0.d: Likewise. * testsuite/ld-mips-elf/unaligned-jalx-mips16-1.d: Likewise. * testsuite/ld-mips-elf/unaligned-jalx-micromips-0.d: Likewise. * testsuite/ld-mips-elf/unaligned-jalx-micromips-1.d: Likewise. * testsuite/ld-mips-elf/mips-elf.exp: Run unaligned JALX tests with `run_dump_test_o32' and `run_dump_test_n32' rather than `run_dump_test'.
2023-07-28MIPS/LD: Include n64 `.interp' with INITIAL_READONLY_SECTIONSYunQiang Su17-6/+554
In ld/emulparams/elf64bmip-defs.sh there is no explicit handling of the `.interp' section, which causes it to be positioned in output at an odd place. Let's include it with INITIAL_READONLY_SECTIONS, just like o32/n32 do, fixing a regression from commit 5a8e7be242f3 ("INITIAL_READONLY_SECTIONS in elf.sc"), where the handling of n64 was missed due to an unfortunate sequence of events where ld/emulparams/elf64bmip-defs.sh was only added with commit 94bb04b3c611 ("Use .reginfo rather than .MIPS.options in n32 linker scripts") the day before. Add test cases covering section ordering across the three ABIs. This change also fixes ld/pr23658-2: FAIL: Build pr23658-2 Co-Authored-By: Maciej W. Rozycki <macro@orcam.me.uk> ld/ChangeLog: * emulparams/elf64bmip-defs.sh: Include `.interp' with INITIAL_READONLY_SECTIONS. * testsuite/ld-mips-elf/pie-n64.d: Adjust addresses. * testsuite/ld-mips-elf/sections-1-o32.rd: New test. * testsuite/ld-mips-elf/sections-1-o32t.rd: New test. * testsuite/ld-mips-elf/sections-1-n32.rd: New test. * testsuite/ld-mips-elf/sections-1-n32t.rd: New test. * testsuite/ld-mips-elf/sections-1-n32p.rd: New test. * testsuite/ld-mips-elf/sections-1-n64.rd: New test. * testsuite/ld-mips-elf/sections-1-n64t.rd: New test. * testsuite/ld-mips-elf/sections-2-o32.rd: New test. * testsuite/ld-mips-elf/sections-2-o32t.rd: New test. * testsuite/ld-mips-elf/sections-2-n32.rd: New test. * testsuite/ld-mips-elf/sections-2-n32t.rd: New test. * testsuite/ld-mips-elf/sections-2-n32p.rd: New test. * testsuite/ld-mips-elf/sections-2-n64.rd: New test. * testsuite/ld-mips-elf/sections-2-n64t.rd: New test. * testsuite/ld-mips-elf/sections.s: New test source. * testsuite/ld-mips-elf/mips-elf.exp: Run the new tests.
2023-06-15Revert "MIPS: fix r6 testsuites"Maciej W. Rozycki26-208/+150
This reverts commit ffc528aed56b9e2c171137da28690a9bb6861b0b. It was applied unapproved.
2023-06-15Revert "MIPS: fix -gnuabi64 testsuite"Maciej W. Rozycki8-54/+31
This reverts commit cb81e84c72933a7fad10b75b7e270d92d8d65251. It was applied unapproved.
2023-06-15Revert "MIPS: fix some ld testcases with compiler"Maciej W. Rozycki1-1/+1
This reverts commit a0631c1501c113c04891c9a24a9ff5276257f28d. It was applied unapproved.
2023-06-05MIPS: fix some ld testcases with compilerYunQiang Su1-1/+1
1. config/default.exp: use -mabi=32 not for -gnuabi64 xfail_from_runlist: remove an element and mark it xfail. 2. ld-elf/indirect.exp: xfail indirect5a indirect5b indirect6a indirect6b indirect5c indirect5d indirect6c indirect6d 3. ld-elf/pr23658-2: mips output is not common 4. ld-elf/shared.exp: non-run on mips: Build libpr16496b.so 5. ld-elfvers/vers.exp: xfail vers4, vers4b no-run on mips: vers24a, vers24b, vers24c 6. ld-gc/gc.exp: add -KPIC into asflags for pr13683, pr14265, pr19161 7. ld-mips-elf/mips-elf.exp: use noarch for mips16-local-stubs-1, since it use -mips4 8. ld-plugin/lto.exp: no-run on mips/linux: PR ld/12982 add -KPIC into asflags for lto-3r, lto-5r, PR ld/19317 (2) xfail PR ld/15323 (4), PR ld/19317 (3) 9. ld-plugin/plugin.exp: xfail plugin claimfile lost symbol plugin claimfile replace symbol plugin claimfile replace symbol plugin claimfile lost symbol with source plugin claimfile replace symbol with source plugin claimfile resolve symbol with source plugin 2 with source lib load plugin 2 with source plugin 3 with source lib load plugin 3 with source 11. ld-selective/selective.exp: add -fno-PIC, which is needed for -mno-abicalls 12. ld-shared/shared.exp: xfail shared (non PIC), shared (PIC main, non PIC so)
2023-06-05MIPS: fix -gnuabi64 testsuiteYunQiang Su8-31/+54
Test on: mips64-linux-gnuabi64 mips64el-linux-gnuabi64 mipsisa64-linux-gnuabi64 mipsisa64el-linux-gnuabi64 mipsisa64r2-linux-gnuabi64 mipsisa64r2el-linux-gnuabi64 mipsisa64r6-linux-gnuabi64 mipsisa64r6el-linux-gnuabi64
2023-06-05MIPS: fix r6 testsuitesYunQiang Su26-150/+208
Introduce run_dump_test_o32l run_dump_test_n32l run_dump_test_n64l Which use `-march=from-abi` for pre-R6 testcases, like micromips/mips16e etc. For cases doesn't use run_dump_test_*, we use -mips32r2 for micromips32 -mips1 for mips16-32 -march=from-abi for testcases to o32/n32/n64 both/all. Replace `addi` with `addiu` for some cases for both r6 and pre-R6. Introduce some new testcases for r6 with FPXX/FP64. Introduce new testcase: comdat-reloc-r6. Skip `default` in mips_arch_list_matching if triple is mipsisa*, due to: 1)it will cannot match mipsr6@*.d: since mips32rN/mips64rN will always be used, it won't be a problem. 2)some test think -march=mips64rN will alway true for mipsisa64rN, which is not true now. This patch fix testsuite for all r6-default gnu triples: mipsisa32r6-linux-gnu mipsisa32r6el-linux-gnu mips-img-linux-gnu mipsel-img-linux-gnu mipsisa64r6-linux-gnu mipsisa64r6el-linux-gnu
2023-01-01Update year range in copyright notice of binutils filesAlan Modra4-4/+4
The newer update-copyright.py fixes file encoding too, removing cr/lf on binutils/bfdtest2.c and ld/testsuite/ld-cygwin/exe-export.exp, and embedded cr in binutils/testsuite/binutils-all/ar.exp string match.
2022-06-14BFD_RELOC_MIPS_16Alan Modra2-9/+6
MIPS should not be using BFD_RELOC_16 for its R_MIPS_16 relocation, since R_MIPS_16 specifies a 16-bit field in a 32-bit word. BFD_RELOC_16, emitted by generic code to handle fixups on 16-bit data directives, expects fixups to operate on the whole of a 16-bit word. This patch corrects the problem by using BFD_RELOC_MIPS_16, a new bfd reloc that is used to generate R_MIPS_16. BFD_RELOC_16 is handled in md_apply_fix for cases where the fixup can be applied at assembly time. Like BFD_RELOC_8, BFD_RELOC_16 now has no corresponding object file relocation, and thus .half, .hword, .short and .dc.w must be resolved at assembly time. BFD_RELOC_MIPS_REL16 is removed by this patch since it isn't used. PR 3243 PR 26542 * reloc.c (BFD_RELOC_MIPS_16): Rename from BFD_RELOC_MIPS_REL16. * elf32-mips.c (mips_reloc_map): Map BFD_RELOC_MIPS_16 to R_MIPS_16. * elf64-mips.c (mips_reloc_map): Likewise, delete BFD_RELOC_MIPS_REL16. * elfn32-mips.c (mips_reloc_map): Likewise. * libbfd.h: Regenerate. * bfd-in2.h: Regenerate. gas/ * config/tc-mips.c (append_insn): Handle BFD_RELOC_MIPS_16. (macro_build): Likewise. (mips_percent_op <%half>): Generate BFD_RELOC_MIPS_16. (md_apply_fix): Handle BFD_RELOC_16 and BFD_RELOC_MIPS_16 when fx_done. ld/ * testsuite/ld-mips-elf/reloc-local-overflow.d, * testsuite/ld-mips-elf/reloc-local-overflow.s: Rewrite.
2022-05-31Trailing spaces in objdump -r headerAlan Modra11-11/+11
git commit 202be274a4 went a little wild in removing trailing spaces in gas/testsuite/gas/i386/{secidx.d,secrel.d}, causing x86_64-w64-mingw32 +FAIL: i386 secrel reloc x86_64-w64-mingw32 +FAIL: i386 secidx reloc I could have just replaced the trailing space, but let's fix the objdump output instead. Touches lots of testsuite files.
2022-01-02Update year range in copyright notice of binutils filesAlan Modra4-4/+4
The result of running etc/update-copyright.py --this-year, fixing all the files whose mode is changed by the script, plus a build with --enable-maintainer-mode --enable-cgen-maint=yes, then checking out */po/*.pot which we don't update frequently. The copy of cgen was with commit d1dd5fcc38ead reverted as that commit breaks building of bfp opcodes files.
2021-04-21Adjust readelf's output so that section symbols without a name as shown with ↵Nick Clifton2-2/+2
their section name. binutils* readelf.c (print_dynamic_symbol): Print the section name for section symbols without a name of their own. * testsuite/binutils-all/mips/global-local-symtab-sort-n64t.d: Adjust expected output to allow for named section symbols. * testsuite/binutils-all/mips/global-local-symtab-sort-o32t.d: Likewise. * testsuite/binutils-all/readelf.s-64: Likewise. * testsuite/binutils-all/readelf.ss-64-unused: Likewise. * testsuite/binutils-all/readelf.ss-tmips: Likewise. * testsuite/binutils-all/readelf.ss-unused: Likewise. ld * testsuite/ld-aarch64/variant_pcs-now.d: Adjust expected output to allow for named section symbols. * testsuite/ld-aarch64/variant_pcs-r.d: Likewise. * testsuite/ld-aarch64/variant_pcs-shared.d: Likewise. * testsuite/ld-alpha/tlsbin.rd: Likewise. * testsuite/ld-alpha/tlsbinr.rd: Likewise. * testsuite/ld-alpha/tlspic.rd: Likewise. * testsuite/ld-arm/rodata-merge-map.sym: Likewise. * testsuite/ld-arm/script-type.sym: Likewise. * testsuite/ld-cris/libdso-2.d: Likewise. * testsuite/ld-cris/pr16044.d: Likewise. * testsuite/ld-elf/sec64k.exp: Likewise. * testsuite/ld-ia64/tlsbin.rd: Likewise. * testsuite/ld-ia64/tlspic.rd: Likewise. * testsuite/ld-mips-elf/global-local-symtab-sort-n64t.d: Likewise. * testsuite/ld-mips-elf/global-local-symtab-sort-o32t.d: Likewise. * testsuite/ld-mmix/bspec1.d: Likewise. * testsuite/ld-mmix/bspec2.d: Likewise. * testsuite/ld-mmix/local1.d: Likewise. * testsuite/ld-mmix/local3.d: Likewise. * testsuite/ld-mmix/local5.d: Likewise. * testsuite/ld-mmix/local7.d: Likewise. * testsuite/ld-mmix/undef-3.d: Likewise. * testsuite/ld-powerpc/tlsso.r: Likewise. * testsuite/ld-powerpc/tlsso32.r: Likewise. * testsuite/ld-powerpc/tlstocso.r: Likewise. * testsuite/ld-s390/tlsbin.rd: Likewise. * testsuite/ld-s390/tlsbin_64.rd: Likewise. * testsuite/ld-s390/tlspic.rd: Likewise. * testsuite/ld-s390/tlspic_64.rd: Likewise. * testsuite/ld-sparc/gotop32.rd: Likewise. * testsuite/ld-sparc/gotop64.rd: Likewise. * testsuite/ld-sparc/tlssunbin32.rd: Likewise. * testsuite/ld-sparc/tlssunbin64.rd: Likewise. * testsuite/ld-sparc/tlssunnopic32.rd: Likewise. * testsuite/ld-sparc/tlssunnopic64.rd: Likewise. * testsuite/ld-sparc/tlssunpic32.rd: Likewise. * testsuite/ld-sparc/tlssunpic64.rd: Likewise. * testsuite/ld-tic6x/common.d: Likewise. * testsuite/ld-tic6x/shlib-1.rd: Likewise. * testsuite/ld-tic6x/shlib-1b.rd: Likewise. * testsuite/ld-tic6x/shlib-1r.rd: Likewise. * testsuite/ld-tic6x/shlib-1rb.rd: Likewise. * testsuite/ld-tic6x/shlib-app-1.rd: Likewise. * testsuite/ld-tic6x/shlib-app-1b.rd: Likewise. * testsuite/ld-tic6x/shlib-app-1r.rd: Likewise. * testsuite/ld-tic6x/shlib-app-1rb.rd: Likewise. * testsuite/ld-tic6x/shlib-noindex.rd: Likewise. * testsuite/ld-tic6x/static-app-1.rd: Likewise. * testsuite/ld-tic6x/static-app-1b.rd: Likewise. * testsuite/ld-tic6x/static-app-1r.rd: Likewise. * testsuite/ld-tic6x/static-app-1rb.rd: Likewise. gas * testsuite/gas/aarch64/dwarf.d: Adjust expected output to allow for named section symbols. * testsuite/gas/arm/thumbver.d: Likewise. * testsuite/gas/bfin/loop_temps.d: Likewise. * testsuite/gas/elf/section2.e-arc: Likewise. * testsuite/gas/elf/section2.e-arm: Likewise. * testsuite/gas/elf/section2.e-csky: Likewise. * testsuite/gas/elf/section2.e-m32r: Likewise. * testsuite/gas/elf/section2.e-mips: Likewise. * testsuite/gas/elf/section2.e-msp430: Likewise. * testsuite/gas/elf/section2.e-riscv: Likewise. * testsuite/gas/elf/section2.e-rl78: Likewise. * testsuite/gas/elf/section2.e-rx: Likewise. * testsuite/gas/elf/section2.e-score: Likewise. * testsuite/gas/elf/section2.e-tic6x: Likewise. * testsuite/gas/elf/section2.e-unused: Likewise. * testsuite/gas/elf/section2.e-v850: Likewise. * testsuite/gas/elf/section2.e-xtensa: Likewise. * testsuite/gas/ia64/alias-ilp32.d: Likewise. * testsuite/gas/ia64/alias.d: Likewise. * testsuite/gas/ia64/global.d: Likewise. * testsuite/gas/microblaze/relax_size.elf: Likewise. * testsuite/gas/microblaze/relax_size2.elf: Likewise. * testsuite/gas/mips/global-local-symtab-sort-n64t.d: Likewise. * testsuite/gas/mips/global-local-symtab-sort-o32t.d: Likewise. * testsuite/gas/mmix/bspec-1.d: Likewise. * testsuite/gas/mmix/byte-1.d: Likewise. * testsuite/gas/mmix/comment-1.d: Likewise. * testsuite/gas/mmix/loc-1.d: Likewise. * testsuite/gas/mmix/loc-2.d: Likewise. * testsuite/gas/mmix/loc-3.d: Likewise. * testsuite/gas/mmix/loc-4.d: Likewise. * testsuite/gas/mmix/loc-5.d: Likewise. * testsuite/gas/tic6x/scomm-directive-4.d: Likewise.
2021-02-14ld testsuite: change unresolved to unsupported/failAlan Modra1-1/+1
"unresolved" as a test result means runtest returns an error, which can be confusing when there is no apparent error unless you look in .log files. In particular many tests are skipped without reporting an error if no target C compiler is found, but if a target C compiler is found but won't compile a testcase for some reason we used to mark the test as unresolved. Which is no more worthy of an error than when lacking a C compiler entirely. * testsuite/ld-cdtest/cdtest.exp, * testsuite/ld-checks/checks.exp, * testsuite/ld-elf/binutils.exp, * testsuite/ld-elf/compress.exp, * testsuite/ld-elf/dwarf.exp, * testsuite/ld-elf/exclude.exp, * testsuite/ld-elf/frame.exp, * testsuite/ld-elf/indirect.exp, * testsuite/ld-elf/linux-x86.exp, * testsuite/ld-elf/sec-to-seg.exp, * testsuite/ld-elf/tls_common.exp, * testsuite/ld-elfcomm/elfcomm.exp, * testsuite/ld-elfvers/vers.exp, * testsuite/ld-elfvsb/elfvsb.exp, * testsuite/ld-elfweak/elfweak.exp, * testsuite/ld-ifunc/binutils.exp, * testsuite/ld-mips-elf/mips-elf-flags.exp, * testsuite/ld-misc/defsym.exp, * testsuite/ld-mn10300/mn10300.exp, * testsuite/ld-plugin/lto.exp, * testsuite/ld-plugin/plugin.exp, * testsuite/ld-scripts/align.exp, * testsuite/ld-scripts/assert.exp, * testsuite/ld-scripts/crossref.exp, * testsuite/ld-scripts/defined.exp, * testsuite/ld-scripts/extern.exp, * testsuite/ld-scripts/log2.exp, * testsuite/ld-scripts/map-address.exp, * testsuite/ld-scripts/phdrs.exp, * testsuite/ld-scripts/phdrs2.exp, * testsuite/ld-scripts/script.exp, * testsuite/ld-scripts/section-flags.exp, * testsuite/ld-scripts/sizeof.exp, * testsuite/ld-scripts/weak.exp, * testsuite/ld-selective/selective.exp, * testsuite/ld-sh/sh.exp, * testsuite/ld-shared/shared.exp, * testsuite/ld-srec/srec.exp, * testsuite/ld-tic6x/tic6x.exp, * testsuite/ld-undefined/undefined.exp, * testsuite/ld-undefined/weak-undef.exp, * testsuite/lib/ld-lib.exp: Don't use unresolved except after perror. Instead report "unsupported" or "fail".
2021-01-04PR26822, How to prevent a STT_FILE with absolute path in the linked imageAlan Modra4-4/+4
bfd/ PR 26822 * elflink.c (elf_link_input_bfd): Use the file base name in linker generated STT_FILE symbols. ld/ PR 26822 * testsuite/ld-arm/non-contiguous-arm2.d: Adjust STT_FILE symbol match. * testsuite/ld-arm/non-contiguous-arm3.d: Likewise. * testsuite/ld-arm/non-contiguous-arm5.d: Likewise. * testsuite/ld-arm/non-contiguous-arm6.d: Likewise. * testsuite/ld-i386/tlsbin.rd: Likewise. * testsuite/ld-i386/tlsbin2.rd: Likewise. * testsuite/ld-i386/tlsbindesc.rd: Likewise. * testsuite/ld-i386/tlsdesc.rd: Likewise. * testsuite/ld-i386/tlsnopic.rd: Likewise. * testsuite/ld-i386/tlspic.rd: Likewise. * testsuite/ld-i386/tlspic2.rd: Likewise. * testsuite/ld-mips-elf/global-local-symtab-sort-n64.d: Likewise. * testsuite/ld-mips-elf/global-local-symtab-sort-n64t.d: Likewise. * testsuite/ld-mips-elf/global-local-symtab-sort-o32.d: Likewise. * testsuite/ld-mips-elf/global-local-symtab-sort-o32t.d: Likewise. * testsuite/ld-plugin/pr17973.d: Likewise. * testsuite/ld-tic6x/shlib-1.rd: Likewise. * testsuite/ld-tic6x/shlib-1b.rd: Likewise. * testsuite/ld-tic6x/shlib-1r.rd: Likewise. * testsuite/ld-tic6x/shlib-1rb.rd: Likewise. * testsuite/ld-tic6x/shlib-app-1.rd: Likewise. * testsuite/ld-tic6x/shlib-app-1b.rd: Likewise. * testsuite/ld-tic6x/shlib-app-1r.rd: Likewise. * testsuite/ld-tic6x/shlib-app-1rb.rd: Likewise. * testsuite/ld-tic6x/shlib-noindex.rd: Likewise. * testsuite/ld-tic6x/static-app-1.rd: Likewise. * testsuite/ld-tic6x/static-app-1b.rd: Likewise. * testsuite/ld-tic6x/static-app-1r.rd: Likewise. * testsuite/ld-tic6x/static-app-1rb.rd: Likewise. * testsuite/ld-x86-64/tlsbin.rd: Likewise. * testsuite/ld-x86-64/tlsbin2.rd: Likewise. * testsuite/ld-x86-64/tlsbindesc.rd: Likewise. * testsuite/ld-x86-64/tlsdesc.rd: Likewise. * testsuite/ld-x86-64/tlspic.rd: Likewise. * testsuite/ld-x86-64/tlspic2.rd: Likewise. * testsuite/ld-xtensa/tlsbin.rd: Likewise. * testsuite/ld-xtensa/tlspic.rd: Likewise.
2021-01-01Update year range in copyright notice of binutils filesAlan Modra4-4/+4
2020-07-29MIPS: Make the IRIX naming of local section symbols consistentMaciej W. Rozycki10-0/+88
Make the MIPS/IRIX naming of local section symbols consistent between files produced by generic ELF code and ELF linker code, complementing commit 174fd7f95561 ("New bfd elf hook: force naming of local section symbols"), <https://sourceware.org/ml/binutils/2004-02/msg00072.html>. Local section symbols have no names in the standard ELF gABI, however the lack of a name causes problems with IRIX's MIPSpro linker. To work around the issue we give them names, however we do that in generic ELF code only, based on what the `elf_backend_name_local_section_symbols' hook returns if present. That makes objects created by GAS or `objdump' work correctly, however not ones created by `ld -r'. That would not normally cause issues with IRIX systems using GAS and `objdump' only with the MIPSpro linker, however if GNU LD was used for whatever reason in producing objects later fed to IRIX's MIPSpro linker, then things would break. Modify ELF linker code accordingly then, using the same hook. Adjust the `ld-elf/64ksec-r' test accordingly so that it also accepts a section symbol with a name. Also modify the hook itself so that only actual ET_REL objects have names assigned to local section symbols. Other kinds of ELF files are not ever supposed to be relocated with the MIPSpro linker, so we can afford producing more standard output. Add suitable GAS, LD and `objcopy' test cases to the relevant testsuites to keep these tools consistently verified. This change also fixes: FAIL: objcopy executable (pr25662) across MIPS targets using the IRIX compatibility mode. bfd/ * elflink.c (bfd_elf_final_link): Give local symbols a name if so requested. * elfxx-mips.c (_bfd_mips_elf_name_local_section_symbols): Only return TRUE if making ET_REL output. binutils/ * testsuite/binutils-all/mips/global-local-symtab-sort-o32.d: New test. * testsuite/binutils-all/mips/global-local-symtab-sort-o32t.d: New test. * testsuite/binutils-all/mips/global-local-symtab-sort-n32.d: New test. * testsuite/binutils-all/mips/global-local-symtab-sort-n32t.d: New test. * testsuite/binutils-all/mips/global-local-symtab-sort-n64.d: New test. * testsuite/binutils-all/mips/global-local-symtab-sort-n64t.d: New test. * testsuite/binutils-all/mips/global-local-symtab-final-o32.d: New test. * testsuite/binutils-all/mips/global-local-symtab-final-n32.d: New test. * testsuite/binutils-all/mips/global-local-symtab-final-n64.d: New test. * testsuite/binutils-all/mips/mips.exp: Run the new tests. gas/ * testsuite/gas/mips/global-local-symtab-sort-o32.d: New test. * testsuite/gas/mips/global-local-symtab-sort-o32t.d: New test. * testsuite/gas/mips/global-local-symtab-sort-n32.d: New test. * testsuite/gas/mips/global-local-symtab-sort-n32t.d: New test. * testsuite/gas/mips/global-local-symtab-sort-n64.d: New test. * testsuite/gas/mips/global-local-symtab-sort-n64t.d: New test. * testsuite/gas/mips/mips.exp: Run the new tests. ld/ * testsuite/ld-elf/sec64k.exp: Also accept a section symbol with a name. * testsuite/ld-mips-elf/global-local-symtab-sort-o32.d: New test. * testsuite/ld-mips-elf/global-local-symtab-sort-o32t.d: New test. * testsuite/ld-mips-elf/global-local-symtab-sort-n32.d: New test. * testsuite/ld-mips-elf/global-local-symtab-sort-n32t.d: New test. * testsuite/ld-mips-elf/global-local-symtab-sort-n64.d: New test. * testsuite/ld-mips-elf/global-local-symtab-sort-n64t.d: New test. * testsuite/ld-mips-elf/global-local-symtab-final-o32.d: New test. * testsuite/ld-mips-elf/global-local-symtab-final-n32.d: New test. * testsuite/ld-mips-elf/global-local-symtab-final-n64.d: New test. * testsuite/ld-mips-elf/mips-elf.exp: Run the new tests.
2020-07-29MIPS/LD: Set symtab's `sh_info' correctly for IRIX emulationsMaciej W. Rozycki7-0/+50
Correct ELF linker code so as to set the `sh_info' value of the static symbol table section according to the section symbols vs other symbols split where required by the selection of the IRIX compatibility mode for MIPS target. Add a `elf_backend_elfsym_local_is_section' hook for that purpose, returning TRUE if it is only STB_LOCAL/STT_SECTION symbols that are to be considered local for the purpose of this split rather than all STB_LOCAL symbols. We do it already in generic ELF code, and have done it since 1993, with the `elf_backend_sym_is_global' hook, affecting GAS and `objcopy', so these tools produce correct ELF output in the IRIX compatibility mode, however if such output is fed as input to `ld -r', then the linker's output is no longer valid for that mode. The relevant changes to generic ELF code are: commit 062189c6eab72c7ba1bab1cf30fdb27d67a7d668 Author: Ian Lance Taylor <ian@airs.com> Date: Thu Nov 18 17:12:47 1993 +0000 and: commit 6e07e54f1b347f885cc6c021c3fd912c79bdaf55 Author: Ian Lance Taylor <ian@airs.com> Date: Thu Jan 6 20:01:42 1994 +0000 (split across two GIT commits likely due to repository conversion peculiarities). The `elf_backend_sym_is_global' hook however operates on BFD rather than ELF symbols, making it unsuitable for the ELF linker as the linker does not convert any symbol tables processed into the BFD format. Converting the hook to operate on ELF symbols would in principle be possible, but it would still require a considerable rewrite of `bfd_elf_final_link' to adapt to the interface. Therefore, especially given that no new use for the IRIX compatibility mode is expected, minimize changes made to the ELF linker code and just add an entirely new hook, and wire it in the o32 and n32 MIPS backends accordingly; the n64 backend never uses the IRIX compatibility mode. Since we have no coverage here at all add suitable GAS, LD and `objcopy' test cases to the relevant testsuites to keep these tools consistently verified. bfd/ * elf-bfd.h (elf_backend_data): Add `elf_backend_elfsym_local_is_section' member. * elfxx-target.h (elf_backend_elfsym_local_is_section): New macro. (elfNN_bed): Add `elf_backend_elfsym_local_is_section' member. * elflink.c (bfd_elf_final_link): Use it to determine whether set the `.symtab' section's `sh_info' value to the index of the first non-local or non-section symbol. * elf32-mips.c (mips_elf32_elfsym_local_is_section): New function. (elf_backend_elfsym_local_is_section): New macro. * elfn32-mips.c (mips_elf_n32_elfsym_local_is_section): New function. (elf_backend_elfsym_local_is_section): New macro. binutils/ * testsuite/binutils-all/mips/global-local-symtab-o32.d: New test. * testsuite/binutils-all/mips/global-local-symtab-o32t.d: New test. * testsuite/binutils-all/mips/global-local-symtab-n32.d: New test. * testsuite/binutils-all/mips/global-local-symtab-n32t.d: New test. * testsuite/binutils-all/mips/global-local-symtab-n64.d: New test. * testsuite/binutils-all/mips/mips.exp: Run the new tests. gas/ * testsuite/gas/mips/global-local-symtab-o32.d: New test. * testsuite/gas/mips/global-local-symtab-o32t.d: New test. * testsuite/gas/mips/global-local-symtab-n32.d: New test. * testsuite/gas/mips/global-local-symtab-n32t.d: New test. * testsuite/gas/mips/global-local-symtab-n64.d: New test. * testsuite/gas/mips/global-local-symtab.s: New test source. * testsuite/gas/mips/mips.exp: Run the new tests. ld/ * testsuite/ld-mips-elf/global-local-symtab-o32.d: New test. * testsuite/ld-mips-elf/global-local-symtab-o32t.d: New test. * testsuite/ld-mips-elf/global-local-symtab-n32.d: New test. * testsuite/ld-mips-elf/global-local-symtab-n32t.d: New test. * testsuite/ld-mips-elf/global-local-symtab-n64.d: New test. * testsuite/ld-mips-elf/global-local-symtab.ld: New test linker script. * testsuite/ld-mips-elf/mips-elf.exp: Run the new tests.
2020-07-02Change readelf's display of symbol names (when not in --wide mode) so that ↵Nick Clifton1-2/+2
if they are going to be truncated then "[...]" is displayed at the end. Add a comment line option to disable this enhancement and restore the old behaviour. PR 26028 binutils* readelf.c (print_symbol): Handle truncation of symbol names. (options): Add -T/--silent-truncation option. (parse_args): Handle the option. (print_dynamic_symbol): Correct calculation of width available to display symbol name. * doc/binutils.texi: Document the -T option to readelf. * NEWS: Mention the new feature. gas * testsuite/gas/ia64/group-2.d: Add -T option to readelf command line. * testsuite/gas/ia64/unwind.d: Likewise. * testsuite/gas/mmix/bspec-1.d: Likewise. * testsuite/gas/mmix/bspec-2.d: Likewise. * testsuite/gas/mmix/comment-1.d: Likewise. * testsuite/gas/tic6x/scomm-directive-4.d: Likewise. ld * testsuite/ld-powerpc/powerpc.exp: Add -T option to readelf command line when running some tests. * testsuite/ld-arm/arm-elf.exp: Likewise. * testsuite/ld-mips-elf/mips-elf.exp: Likewise. * testsuite/ld-mmix/local1.d: Likewise. * testsuite/ld-mmix/local3.d: Likewise. * testsuite/ld-mmix/local5.d: Likewise. * testsuite/ld-mmix/local7.d: Likewise. * testsuite/ld-powerpc/powerpc.exp: Likewise.
2020-06-20Remove perror from ld_assemble, ld_compile and ld_nmAlan Modra1-2/+2
ERROR should really be reserved for errors in the testsuite framework, not just normal errors from the tools under test. Removing use of perror has been suggested before but without action, over concerns that some test failures might be missed. This patch removes uses of perror in ld_assemble, ld_compile and ld_nm, and updates numerous places that ignored the result of these functions by inappropriately returning an "unresolved" test status. Net result over my large set of targets look good, in some cases improving the diagnostics, eg: i386-msdos -ERROR: tmpdir/script: nm failed i386-msdos -ERROR: tmpdir/script: nm failed i386-msdos -ERROR: tmpdir/script: nm failed i386-msdos -ERROR: tmpdir/script: nm failed i386-msdos +FAIL: script i386-msdos +FAIL: MRI script i386-msdos +FAIL: MEMORY i386-msdos +FAIL: MEMORY with symbols * testsuite/lib/ld-lib.exp (default_ld_compile): Don't perror on a compiler error. (default_ld_assemble): Similarly for an assembler error. (default_ld_nm): Similarly for an nm error. (run_ld_link_tests): Report ld_assemble errors as a fail. (check_as_cfi): Remove now unnecessary perror substitution. * testsuite/ld-elf/exclude.exp: Report ld_nm error return as test fails rather then unresolved. * testsuite/ld-gc/gc.exp: Likewise. * testsuite/ld-scripts/alignof.exp: Likewise. * testsuite/ld-scripts/defined.exp: Likewise. * testsuite/ld-scripts/script.exp: Likewise. * testsuite/ld-scripts/sizeof.exp: Likewise. * testsuite/ld-selective/selective.exp: Likewise. * testsuite/ld-scripts/extern.exp: Likewise. Return on ld_link failure. * testsuite/ld-elfweak/elfweak.exp: Report compiler errors as test unresolved. * testsuite/ld-fastcall/fastcall.exp: Report assember errors as test fails. * testsuite/ld-i386/i386.exp (iamcu_tests): Likewise. * testsuite/ld-ia64/line.exp: Likewise. * testsuite/ld-mep/mep.exp: Likewise. * testsuite/ld-mips-elf/mips-elf-flags.exp: Likewise. * testsuite/ld-nios2/nios2.exp: Likewise. * testsuite/ld-scripts/alignof.exp: Likewise. * testsuite/ld-x86-64/line.exp: Likewise. * testsuite/ld-x86-64/x86-64.exp: Likewise. * testsuite/ld-scripts/log2.exp: Formatting. * testsuite/ld-tic6x/tic6x.exp: Report ld_link errors as a test fail.
2020-06-04tcl global directive outside proc body does nothing (ld)Alan Modra1-1/+0
* testsuite/config/default.exp: Remove global directive outside proc body. * testsuite/ld-bootstrap/bootstrap.exp: Likewise. * testsuite/ld-elf/compress.exp: Likewise. * testsuite/ld-elf/elf.exp: Likewise. * testsuite/ld-elf/exclude.exp: Likewise. * testsuite/ld-elf/frame.exp: Likewise. * testsuite/ld-elf/indirect.exp: Likewise. * testsuite/ld-elf/linux-x86.exp: Likewise. * testsuite/ld-elf/shared.exp: Likewise. * testsuite/ld-elf/tls.exp: Likewise. * testsuite/ld-elf/tls_common.exp: Likewise. * testsuite/ld-elfcomm/elfcomm.exp: Likewise. * testsuite/ld-elfweak/elfweak.exp: Likewise. * testsuite/ld-frv/fdpic.exp: Likewise. * testsuite/ld-frv/tls.exp: Likewise. * testsuite/ld-gc/gc.exp: Likewise. * testsuite/ld-i386/i386.exp: Likewise. * testsuite/ld-i386/no-plt.exp: Likewise. * testsuite/ld-ifunc/ifunc.exp: Likewise. * testsuite/ld-mips-elf/mips-elf-flags.exp: Likewise. * testsuite/ld-nios2/nios2.exp: Likewise. * testsuite/ld-plugin/lto.exp: Likewise. * testsuite/ld-plugin/plugin.exp: Likewise. * testsuite/ld-powerpc/export-class.exp: Likewise. * testsuite/ld-scripts/align.exp: Likewise. * testsuite/ld-scripts/crossref.exp: Likewise. * testsuite/ld-scripts/defined.exp: Likewise. * testsuite/ld-scripts/overlay-size.exp: Likewise. * testsuite/ld-scripts/provide.exp: Likewise. * testsuite/ld-scripts/weak.exp: Likewise. * testsuite/ld-selective/selective.exp: Likewise. * testsuite/ld-sh/rd-sh.exp: Likewise. * testsuite/ld-size/size.exp: Likewise. * testsuite/ld-srec/srec.exp: Likewise. * testsuite/ld-x86-64/mpx.exp: Likewise. * testsuite/ld-x86-64/no-plt.exp: Likewise. * testsuite/ld-x86-64/x86-64.exp: Likewise.
2020-04-14readelf: Consolidate --syms --use-dynamic with --dyn-symsH.J. Lu1-4/+4
When reconstructing dynamic symbol table from the PT_DYNAMIC segment, compute dynamic symbol table size from hash table. For DT_HASH, the number of dynamic symbol table entries equals the number of chains. For DT_GNU_HASH/DT_MIPS_XHASH, only defined symbols with non-STB_LOCAL indings are in hash table. Since DT_GNU_HASH/DT_MIPS_XHASH place all symbols with STB_LOCAL binding before symbols with other bindings and all undefined symbols defined ones in dynamic symbol table, the highest symbol index in DT_GNU_HASH/DT_MIPS_XHASH is the highest dynamic symbol table index. Rewrite print_dynamic_symbol to dump dynamic symbol table for --dyn-syms and --syms --use-dynamic. binutils/ PR binutils/25707 * readelf.c (nbuckets): New. (nchains): Likewise. (buckets): Likewise. (chains): Likewise. (ngnubuckets): Likewise. (gnubuckets): Likewise. (gnuchains): Likewise. (mipsxlat): Likewise. (ngnuchains): Likewise. (gnusymidx): Likewise. (VALID_SYMBOL_NAME): Likewise. (VALID_DYNAMIC_NAME): Use it. (get_dynamic_data): Moved before process_dynamic_section. (get_num_dynamic_syms): New function. (process_dynamic_section): Use DT_SYMTAB, DT_SYMENT, DT_HASH, DT_GNU_HASH and DT_MIPS_XHASH to reconstruct dynamic symbol table. Use DT_STRTAB and DT_STRSZ to reconstruct dynamic string table. (get_symbol_index_type): Don't print "bad section index" when there is no section header. (print_dynamic_symbol): Rewrite. (process_symbol_table): Call print_dynamic_symbol to dump dynamic symbol table. ld/ PR binutils/25707 * testsuite/ld-arm/armthumb-lib.sym: Updated. * testsuite/ld-arm/farcall-mixed-app.sym: Likewise. * testsuite/ld-arm/farcall-mixed-app2.sym: Likewise. * testsuite/ld-arm/fdpic-main-m.sym: Likewise. * testsuite/ld-arm/fdpic-main.sym: Likewise. * testsuite/ld-arm/fdpic-shared-m.sym: Likewise. * testsuite/ld-arm/fdpic-shared.sym: Likewise. * testsuite/ld-arm/mixed-app.sym: Likewise. * testsuite/ld-arm/mixed-lib.sym: Likewise. * testsuite/ld-arm/preempt-app.sym: Likewise. * testsuite/ld-elf/hash.d: Likewise. * testsuite/ld-elf/pr13195.d: Likewise. * testsuite/ld-elfvsb/hidden2.d: Likewise. * testsuite/ld-mips-elf/hash2.d: Likewise.
2020-01-07Re: Prefer object over notype symbols when disassemblingAlan Modra20-35/+3
Reverts unnecessary mips testsuite changes made by commit 660df28acf. * testsuite/ld-mips-elf/eh-frame5.s, * testsuite/ld-mips-elf/ehdr_start-new.s, * testsuite/ld-mips-elf/ehdr_start-o32.s, * testsuite/ld-mips-elf/mips16-call-global-1.s, * testsuite/ld-mips-elf/mips16-intermix-1.s, * testsuite/ld-mips-elf/mips16-pic-1b.s, * testsuite/ld-mips-elf/mips16-pic-4c.s, * testsuite/ld-mips-elf/no-shared-1-n64.s, * testsuite/ld-mips-elf/no-shared-1-o32.s, * testsuite/ld-mips-elf/pic-and-nonpic-1b-micromips.s, * testsuite/ld-mips-elf/pic-and-nonpic-1b.s, * testsuite/ld-mips-elf/pic-and-nonpic-2a.s, * testsuite/ld-mips-elf/pic-and-nonpic-3b.s, * testsuite/ld-mips-elf/pic-and-nonpic-4b.s, * testsuite/ld-mips-elf/pic-and-nonpic-5a.s, * testsuite/ld-mips-elf/pic-and-nonpic-6-n32c.s, * testsuite/ld-mips-elf/pic-and-nonpic-6-n64c.s, * testsuite/ld-mips-elf/pic-and-nonpic-6-o32c.s, * testsuite/ld-mips-elf/pie.s, * testsuite/ld-mips-elf/relax-jalr.s: Revert 2019-12-17 change.
2020-01-01Update year range in copyright notice of binutils filesAlan Modra4-4/+4
2019-12-17Prefer object over notype symbols when disassemblingAlan Modra37-22/+70
Changing objdump disassembly output like this always requires some testsuite changes, with the avr and x64_64 changes simply due to picking up better symbols, the whole point of the patch. The mips changes are due to mips-sgi-irix changing STT_NOTYPE symbols to STT_OBJECT, which objdump now chooses in preference to script symbols. The problem is that objdump looks at the first symbol in the section being disassembled, and if object type, just dumps out bytes rather than disassembling. This results in new failures: FAIL: JAL overflow 2 FAIL: undefined weak symbol overflow FAIL: undefined weak symbol overflow (n32) FAIL: undefined weak symbol overflow (n64) So for mips-sgi-irix function symbols really do need to be function type. I fixed a few more than just the required minimum to avoid the above test fails. binutils/ * objdump.c (compare_section): New static var. (compare_symbols): Sort by current section only. Don't access symbol name out of bounds when checking for file symbols. Sort section symbols and object symbols. (find_symbol_for_address): Remove bogus debugging and section symbol test. (disassemble_data): Move symbol sort from here.. (disassemble_section): ..to here. Set compare_section. ld/ * testsuite/ld-avr/lds-mega.d: Adjust symbols to suit objdump change. * testsuite/ld-avr/lds-tiny.d: Likewise. * testsuite/ld-x86-64/load2.d: Likewise. * testsuite/ld-mips-elf/compact-eh1.s: Give function symbols function type. * testsuite/ld-mips-elf/compact-eh1a.s: Likewise. * testsuite/ld-mips-elf/compact-eh1b.s: Likewise. * testsuite/ld-mips-elf/compact-eh2.s: Likewise. * testsuite/ld-mips-elf/compact-eh3.s: Likewise. * testsuite/ld-mips-elf/compact-eh3a.s: Likewise. * testsuite/ld-mips-elf/eh-frame5.s: Likewise. * testsuite/ld-mips-elf/ehdr_start-new.s: Likewise. * testsuite/ld-mips-elf/ehdr_start-o32.s: Likewise. * testsuite/ld-mips-elf/emit-relocs-1a.s: Likewise. * testsuite/ld-mips-elf/jaloverflow-2.s: Likewise. * testsuite/ld-mips-elf/jaloverflow.s: Likewise. * testsuite/ld-mips-elf/mips16-call-global-1.s: Likewise. * testsuite/ld-mips-elf/mips16-intermix-1.s: Likewise. * testsuite/ld-mips-elf/mips16-pic-1b.s: Likewise. * testsuite/ld-mips-elf/mips16-pic-4c.s: Likewise. * testsuite/ld-mips-elf/no-shared-1-n64.s: Likewise. * testsuite/ld-mips-elf/no-shared-1-o32.s: Likewise. * testsuite/ld-mips-elf/pic-and-nonpic-1b-micromips.s: Likewise. * testsuite/ld-mips-elf/pic-and-nonpic-1b.s: Likewise. * testsuite/ld-mips-elf/pic-and-nonpic-2a.s: Likewise. * testsuite/ld-mips-elf/pic-and-nonpic-3b.s: Likewise. * testsuite/ld-mips-elf/pic-and-nonpic-4b.s: Likewise. * testsuite/ld-mips-elf/pic-and-nonpic-5a.s: Likewise. * testsuite/ld-mips-elf/pic-and-nonpic-6-n32c.s: Likewise. * testsuite/ld-mips-elf/pic-and-nonpic-6-n64c.s: Likewise. * testsuite/ld-mips-elf/pic-and-nonpic-6-o32c.s: Likewise. * testsuite/ld-mips-elf/pie.s: Likewise. * testsuite/ld-mips-elf/relax-jalr.s: Likewise. * testsuite/ld-mips-elf/reloc-1a.s: Likewise. * testsuite/ld-mips-elf/reloc-2a.s: Likewise. * testsuite/ld-mips-elf/reloc-4.s: Likewise. * testsuite/ld-mips-elf/reloc-5.s: Likewise. * testsuite/ld-mips-elf/reloc-6b.s: Likewise. * testsuite/ld-mips-elf/textrel-1.s: Likewise. * testsuite/ld-mips-elf/undefweak-overflow.s: Likewise. * testsuite/ld-mips-elf/undefweak-overflow.d: Adjust.
2019-12-17Accept mips-sgi-irix output in a few ld testsAlan Modra2-9/+13
mips-sgi-irix gas emits STT_OBJECT symbols where other assemblers would use STT_NOTYPE. See mips_frob_symbol in gas/config/tc-mips.c. Also, the section of some dynamic symbols is set to SHN_MIPS_TEXT or SHN_MIPS_DATA. See _bfd_mips_elf_finish_dynamic_symbol in bfd/elfxx-mips.c. These differences are visible in readelf output and cause some tests to fail for no other good reason. The patch fixes the following fails and removes an xfail. FAIL: ld-elf/pr23591 FAIL: PROVIDE_HIDDEN test (auxiliary shared object) FAIL: PR ld/21233 dynamic symbols with section GC (auxiliary shared library) * testsuite/ld-elf/pr21233-l.sd: Accept OBJECT for type and PRC for section of symbols. * testsuite/ld-elf/pr23591.d: Likewise. * testsuite/ld-elf/provide-hidden-s.nd: Likewise. * testsuite/ld-mips-elf/start.s: Make symbols function type. * testsuite/ld-mips-elf/hash2.d: Adjust. Don't xfail irix.
2019-12-06Re: Only give FDE encoding warnings if --eh-frame-hdr was specified.Alan Modra4-4/+4
For mips*-linux targets, fixes the following fails. FAIL: MIPS eh-frame 1, n32 FAIL: MIPS eh-frame 1, n64 FAIL: MIPS eh-frame 2, n32 FAIL: MIPS eh-frame 2, n64 * testsuite/ld-mips-elf/eh-frame1-n32.d: Pass --eh-frame-hdr to ld. * testsuite/ld-mips-elf/eh-frame1-n64.d: Likewise. * testsuite/ld-mips-elf/eh-frame2-n32.d: Likewise. * testsuite/ld-mips-elf/eh-frame2-n64.d: Likewise.
2019-09-11Rename elf32.em to elf.emAlan Modra2-2/+2
* emultempl/elf32.em: Remove "misnamed" comment. Rename to.. * emultempl/elf.em: ..this. * configure.ac (elf_list_options): Adjust TEMPLATE_NAME grep. * emulparams/aarch64cloudabi.sh (TEMPLATE_NAME): Set to elf. * emulparams/aarch64elf.sh: Likewise. * emulparams/aarch64elf32.sh: Likewise. * emulparams/aarch64fbsd.sh: Likewise. * emulparams/aarch64linux.sh: Likewise. * emulparams/aarch64linux32.sh: Likewise. * emulparams/arcelf.sh: Likewise. * emulparams/arcelf_prof.sh: Likewise. * emulparams/arclinux.sh: Likewise. * emulparams/arclinux_prof.sh: Likewise. * emulparams/arcv2elf.sh: Likewise. * emulparams/arcv2elfx.sh: Likewise. * emulparams/armelf.sh: Likewise. * emulparams/armelf_fuchsia.sh: Likewise. * emulparams/armelf_linux.sh: Likewise. * emulparams/armelf_phoenix.sh: Likewise. * emulparams/armnto.sh: Likewise. * emulparams/avr1.sh: Likewise. * emulparams/avr2.sh: Likewise. * emulparams/avr25.sh: Likewise. * emulparams/avr3.sh: Likewise. * emulparams/avr31.sh: Likewise. * emulparams/avr35.sh: Likewise. * emulparams/avr4.sh: Likewise. * emulparams/avr5.sh: Likewise. * emulparams/avr51.sh: Likewise. * emulparams/avr6.sh: Likewise. * emulparams/avrtiny.sh: Likewise. * emulparams/avrxmega1.sh: Likewise. * emulparams/avrxmega2.sh: Likewise. * emulparams/avrxmega3.sh: Likewise. * emulparams/avrxmega4.sh: Likewise. * emulparams/avrxmega5.sh: Likewise. * emulparams/avrxmega6.sh: Likewise. * emulparams/avrxmega7.sh: Likewise. * emulparams/criself.sh: Likewise. * emulparams/crislinux.sh: Likewise. * emulparams/cskyelf.sh: Likewise. * emulparams/d10velf.sh: Likewise. * emulparams/elf32_sparc.sh: Likewise. * emulparams/elf32_spu.sh: Likewise. * emulparams/elf32_tic6x_le.sh: Likewise. * emulparams/elf32_x86_64.sh: Likewise. * emulparams/elf32am33lin.sh: Likewise. * emulparams/elf32bfin.sh: Likewise. * emulparams/elf32bfinfd.sh: Likewise. * emulparams/elf32bmip.sh: Likewise. * emulparams/elf32bmipn32-defs.sh: Likewise. * emulparams/elf32cr16.sh: Likewise. * emulparams/elf32cr16c.sh: Likewise. * emulparams/elf32crx.sh: Likewise. * emulparams/elf32epiphany.sh: Likewise. * emulparams/elf32epiphany_4x4.sh: Likewise. * emulparams/elf32frvfd.sh: Likewise. * emulparams/elf32ip2k.sh: Likewise. * emulparams/elf32lm32.sh: Likewise. * emulparams/elf32lm32fd.sh: Likewise. * emulparams/elf32lriscv-defs.sh: Likewise. * emulparams/elf32m32c.sh: Likewise. * emulparams/elf32mb_linux.sh: Likewise. * emulparams/elf32mbel_linux.sh: Likewise. * emulparams/elf32mcore.sh: Likewise. * emulparams/elf32mep.sh: Likewise. * emulparams/elf32metag.sh: Likewise. * emulparams/elf32microblaze.sh: Likewise. * emulparams/elf32mipswindiss.sh: Likewise. * emulparams/elf32or1k.sh: Likewise. * emulparams/elf32ppccommon.sh: Likewise. * emulparams/elf32rl78.sh: Likewise. * emulparams/elf32rx.sh: Likewise. * emulparams/elf32tilegx.sh: Likewise. * emulparams/elf32tilepro.sh: Likewise. * emulparams/elf32vax.sh: Likewise. * emulparams/elf32visium.sh: Likewise. * emulparams/elf32xc16x.sh: Likewise. * emulparams/elf32xc16xl.sh: Likewise. * emulparams/elf32xc16xs.sh: Likewise. * emulparams/elf32xstormy16.sh: Likewise. * emulparams/elf32xtensa.sh: Likewise. * emulparams/elf64_aix.sh: Likewise. * emulparams/elf64_ia64.sh: Likewise. * emulparams/elf64_s390.sh: Likewise. * emulparams/elf64_sparc.sh: Likewise. * emulparams/elf64alpha.sh: Likewise. * emulparams/elf64bpf.sh: Likewise. * emulparams/elf64hppa.sh: Likewise. * emulparams/elf64mmix.sh: Likewise. * emulparams/elf64rdos.sh: Likewise. * emulparams/elf64tilegx.sh: Likewise. * emulparams/elf_i386.sh: Likewise. * emulparams/elf_i386_be.sh: Likewise. * emulparams/elf_i386_ldso.sh: Likewise. * emulparams/elf_i386_vxworks.sh: Likewise. * emulparams/elf_iamcu.sh: Likewise. * emulparams/elf_k1om.sh: Likewise. * emulparams/elf_l1om.sh: Likewise. * emulparams/elf_s390.sh: Likewise. * emulparams/elf_x86_64.sh: Likewise. * emulparams/h8300elf.sh: Likewise. * emulparams/h8300elf_linux.sh: Likewise. * emulparams/hppa64linux.sh: Likewise. * emulparams/hppaelf.sh: Likewise. * emulparams/hppalinux.sh: Likewise. * emulparams/i386lynx.sh: Likewise. * emulparams/i386moss.sh: Likewise. * emulparams/i386nto.sh: Likewise. * emulparams/m32relf.sh: Likewise. * emulparams/m32relf_linux.sh: Likewise. * emulparams/m68hc11elf.sh: Likewise. * emulparams/m68hc11elfb.sh: Likewise. * emulparams/m68hc12elf.sh: Likewise. * emulparams/m68hc12elfb.sh: Likewise. * emulparams/m68kelf.sh: Likewise. * emulparams/mn10300.sh: Likewise. * emulparams/nds32elf.sh: Likewise. * emulparams/nds32elf16m.sh: Likewise. * emulparams/nds32elf_linux.sh: Likewise. * emulparams/nios2elf.sh: Likewise. * emulparams/nios2linux.sh: Likewise. * emulparams/pruelf.sh: Likewise. * emulparams/score3_elf.sh: Likewise. * emulparams/shelf.sh: Likewise. * emulparams/shelf_nto.sh: Likewise. * emulparams/shelf_vxworks.sh: Likewise. * emulparams/shlelf_linux.sh: Likewise. * emulparams/shlelf_nto.sh: Likewise. * emulparams/v850.sh: Likewise. * emulparams/v850_rh850.sh: Likewise. * ldelf.c: Update comment. * ldelf.h: Likewise. * emultempl/aarch64elf.em: Likewise. * emultempl/alphaelf.em: Likewise. * emultempl/arclinux.em: Likewise. * emultempl/armelf.em: Likewise. * emultempl/avrelf.em: Likewise. * emultempl/bfin.em: Likewise. * emultempl/cr16elf.em: Likewise. * emultempl/crxelf.em: Likewise. * emultempl/cskyelf.em: Likewise. * emultempl/elf-generic.em: Likewise. * emultempl/elf-x86.em: Likewise. * emultempl/epiphanyelf_4x4.em: Likewise. * emultempl/hppaelf.em: Likewise. * emultempl/ia64elf.em: Likewise. * emultempl/m68hc1xelf.em: Likewise. * emultempl/m68kelf.em: Likewise. * emultempl/metagelf.em: Likewise. * emultempl/mmix-elfnmmo.em: Likewise. * emultempl/mmixelf.em: Likewise. * emultempl/mmo.em: Likewise. * emultempl/needrelax.em: Likewise. * emultempl/nios2elf.em: Likewise. * emultempl/ppc32elf.em: Likewise. * emultempl/ppc64elf.em: Likewise. * emultempl/pruelf.em: Likewise. * emultempl/rxelf.em: Likewise. * emultempl/scoreelf.em: Likewise. * emultempl/spuelf.em: Likewise. * emultempl/tic6xdsbt.em: Likewise. * emultempl/v850elf.em: Likewise. * emultempl/vms.em: Likewise. * emultempl/vxworks.em: Likewise. * emultempl/xtensaelf.em: Likewise. * scripttempl/arclinux.sc: Likewise. * scripttempl/armbpabi.sc: Likewise. * scripttempl/elf.sc: Likewise. * scripttempl/elf64bpf.sc: Likewise. * scripttempl/elf64hppa.sc: Likewise. * scripttempl/elf_chaos.sc: Likewise. * scripttempl/elfarc.sc: Likewise. * scripttempl/elfarcv2.sc: Likewise. * scripttempl/elfd10v.sc: Likewise. * scripttempl/elfm68hc11.sc: Likewise. * scripttempl/elfm68hc12.sc: Likewise. * scripttempl/elfm9s12z.sc: Likewise. * scripttempl/elfxgate.sc: Likewise. * scripttempl/elfxtensa.sc: Likewise. * scripttempl/epiphany_4x4.sc: Likewise. * scripttempl/iq2000.sc: Likewise. * scripttempl/mep.sc: Likewise. * scripttempl/nds32elf.sc: Likewise. * scripttempl/v850.sc: Likewise. * scripttempl/v850_rh850.sc: Likewise. * scripttempl/xstormy16.sc: Likewise. * testsuite/ld-arm/arm-dyn.ld: Likewise. * testsuite/ld-arm/arm-lib.ld: Likewise. * testsuite/ld-arm/arm-no-rel-plt.ld: Likewise. * testsuite/ld-arm/fdpic-main.ld: Likewise. * testsuite/ld-arm/fdpic-shared.ld: Likewise. * testsuite/ld-elf/elf.exp: Likewise. * testsuite/ld-elf/orphan-region.d: Likewise. * testsuite/ld-elf/orphan.d: Likewise. * testsuite/ld-elf/pr349.d: Likewise. * testsuite/ld-elf/warn2.d: Likewise. * testsuite/ld-elfvsb/elf-offset.ld: Likewise. * testsuite/ld-mips-elf/mips-dyn.ld: Likewise. * testsuite/ld-mips-elf/mips-lib.ld: Likewise. * testsuite/ld-scripts/dynamic-sections.t: Likewise. * testsuite/ld-shared/elf-offset.ld: Likewise. * configure: Regenerate.
2019-08-09Add support for a MIPS specific .MIPS.xhash section.Mihailo Stojanovic8-17/+49
This patch is a reimplementation of [1] which was submitted in 2015 by Neil Schellenberger. Copyright issue was sorted out [2] last year. It proposed a new section (.gnu.xhash) and related dynamic tag (DT_GNU_XHASH). The new section would be virtually identical to the existing .gnu.hash except for the translation table (xlat) which would contain correct MIPS .dynsym indexes corresponding to the hashvals in chains. This is because MIPS ABI imposes a different ordering on the dynsyms than the one expected by the .gnu.hash section. Another addition would be a leading word (ngnusyms) which would contain the number of entries in the translation table. In this patch, the new section name and dynamic tag are changed to reflect the fact that the section should be treated as MIPS-specific (.MIPS.xhash and DT_MIPS_XHASH). This patch addresses the alignment issue as reported in [3], which is caused by the leading word added to the .MIPS.xhash section. Leading word is removed in this patch, and the number of entries in the translation table is now calculated using DT_MIPS_SYMTABNO dynamic tag (this is addressed by the corresponding glibc patch). Suggestions on coding style in [4] were taken into account. Existing GNU hash testcase was covered, and another one was added in the MIPS part of the testsuite. The other major change is reserving MIPS ABI version 5 for .MIPS.xhash, marking the need of support for .MIPS.xhash in the dynamic linker (again, addressed in the corresponding glibc patch). This is something which I am not sure of, especially after reading [5]. I am confused on whether this ABI version is reserved for IFUNC, or it can be used for this purpose. Already mentioned glibc patch is submitted at: https://sourceware.org/ml/libc-alpha/2019-06/msg00456.html [1] https://sourceware.org/ml/binutils/2015-10/msg00057.html [2] https://sourceware.org/ml/binutils/2018-03/msg00025.html [3] https://sourceware.org/ml/binutils/2016-01/msg00006.html [4] https://sourceware.org/ml/binutils/2016-02/msg00097.html [5] https://sourceware.org/ml/libc-alpha/2016-12/msg00853.html ld * emulparams/elf32bmip.sh: Add .MIPS.xhash section. * emulparams/elf32bmipn32-defs.sh: Add .MIPS.xhash section. * emulparams/elf64bmip-defs.sh: Add .MIPS.xhash section. * emultempl/mipself.em: Remove mips_after_parse function. * testsuite/ld-elf/hash.d: Update comment. * testsuite/ld-mips-elf/hash1.d: New test. * testsuite/ld-mips-elf/hash1.s: Ditto. * testsuite/ld-mips-elf/hash1a.d: Remove. * testsuite/ld-mips-elf/hash1b.d: Ditto. * testsuite/ld-mips-elf/hash1c.d: Ditto * testsuite/ld-mips-elf/hash2.d: New test. * testsuite/ld-mips-elf/mips-elf.exp: New tests. * testsuite/ld-mips-elf/start.s: New test. bfd * elf-bfd.h (struct elf_backend_data): New members. * elflink.c (_bfd_elf_link_create_dynamic_sections): Create .gnu.hash section if necessary. (struct collect_gnu_hash_codes): New member. (elf_gnu_hash_process_symidx): New function name. (elf_renumber_gnu_hash_syms): Ignore local and undefined symbols. Record xlat location for every symbol which should have a .MIPS.xhash entry. (bfd_elf_size_dynamic_sections): Add DT_GNU_HASH dynamic tag to dynamic section if necessary. (GNU_HASH_SECTION_NAME): New define. (bfd_elf_size_dynsym_hash_dynstr): Get .MIPS.xhash section. Update the section size info. * elfxx-mips.c (struct mips_elf_hash_sort_data): New members. (struct mips_elf_link_hash_entry): New member. (mips_elf_link_hash_newfunc): Initialize .MIPS.xhash translation table location. (mips_elf_sort_hash_table): Initialize the pointer to the .MIPS.xhash section. (mips_elf_sort_hash_table_f): Populate the .MIPS.xhash translation table entry with the symbol dynindx. (_bfd_mips_elf_section_from_shdr): Add SHT_MIPS_XHASH. (_bfd_mips_elf_fake_sections): Initialize .MIPS.xhash section info. (_bfd_mips_elf_create_dynamic_sections): Create .MIPS.xhash section. (_bfd_mips_elf_size_dynamic_sections): Add DT_MIPS_XHASH tag to dynamic section. (_bfd_mips_elf_finish_synamic_sections): Add DT_MIPS_XHASH. (_bfd_mips_elf_final_write_processing): Set .MIPS.xhash section sh_link info. (_bfd_mips_elf_get_target_dtag): Get DT_MIPS_XHASH tag. (MIPS_LIBC_ABI_XHASH): New ABI version enum value. (_bfd_mips_post_process_headers): Mark the ABI version as MIPS_LIBC_ABI_XHASH if there exists a .MIPS.xhash section, but not a .hash section. (_bfd_mips_elf_record_xhash_symbol): New function. Record a position in the translation table, associated with the hash entry. * elfxx-mips.h (literal_reloc_p): Define elf_backend_record_xhash_symbol backend hook. * elfxx-target.h: Initialize elf_backend_record_xhash_symbol backend hook. include * elf/mips.h (SHT_GNU_XHASH): New define. (DT_GNU_XHASH): New define. binutils * readelf.c (get_mips_dynamic_type): Return MIPS_XHASH dynamic type. (get_mips_section_type_name): Return MI{S_XHASH name string. (dynamic_section_mips_val): Initialize the .MIPS.xhash dynamic info. (process_symbol_table): Initialize the .MIPS.xhash section pointer. Adjust the readelf output to support the new section. (process_object): Set the .MIPS.xhash dynamic info to zero.
2019-07-13Dynamic TLS section symbolsAlan Modra7-44/+44
It is possible to create shared libraries on PowerPC using -ftls-model=inital-exec or -ftls-model=local-exec. The first is half reasonable, getting you a shared library that can't be dlopen'd but otherwise is reasonable. The second is quite bad. Not only do you lose being able to dlopen, the library also has dynamic text relocations. Worse, the TPREL16_LO, TPREL16_HA and other TPREL16 dynamic relocs emitted were wrong, resulting in wrong values being applied by ld.so. Using the first TLS section symbol in dynamic relocations for local TLS symbols doesn't work. It's wrong because TLS symbols used by TLS relocs have values relative to the TLS segment, whereas the TLS section symbols are addresses. This patch instead uses a symbol index of zero which is used elsewhere by PowerPC on dynamic TLS relocs. It's not strictly ABI compliant to use a non-TLS symbol with TLS relocs but symbol index zero can be interpreted as "no symbol". Not using the first TLS section symbol means it doesn't need to be dynamic. The patch also fixes a further problem with PowerPC32 dynamic TPREL16* relocs, which shouldn't have the symbol value in the addend as we do for non-TLS symbols. bfd/ * elflink.c (_bfd_elf_omit_section_dynsym_default): Don't keep tls_sec. (_bfd_elf_init_1_index_section): Prefer not using TLS sections. (_bfd_elf_init_2_index_sections): Likewise. * elf64-ppc.c (ppc64_elf_relocate_section): When emitting dynamic relocations for local TLS symbols, use STN_UNDEF as the relocation symbol. * elf32-ppc.c (ppc_elf_relocate_section): Likewise, and don't leave TLS symbol value in the addend. ld/ * testsuite/ld-powerpc/tlsso.r: Update. * testsuite/ld-powerpc/tlsso32.g: Update. * testsuite/ld-powerpc/tlsso32.r: Update. * testsuite/ld-powerpc/tlstocso.r: Update. * testsuite/ld-cris/tls-dso-dtpoffd2.d: Update. * testsuite/ld-cris/tls-dso-dtpoffd4.d: Update. * testsuite/ld-cris/tls-dso-tpoffgotcomm1.d: Update. * testsuite/ld-cris/tls-gd-1.d: Update. * testsuite/ld-cris/tls-gd-1h.d: Update. * testsuite/ld-cris/tls-gd-2.d: Update. * testsuite/ld-cris/tls-gd-2h.d: Update. * testsuite/ld-cris/tls-ie-10.d: Update. * testsuite/ld-cris/tls-ie-11.d: Update. * testsuite/ld-cris/tls-ie-8.d: Update. * testsuite/ld-cris/tls-ie-9.d: Update. * testsuite/ld-cris/tls-js1.d: Update. * testsuite/ld-cris/tls-ld-4.d: Update. * testsuite/ld-cris/tls-ld-5.d: Update. * testsuite/ld-cris/tls-ld-6.d: Update. * testsuite/ld-cris/tls-ld-7.d: Update. * testsuite/ld-cris/tls-ldgd-14.d: Update. * testsuite/ld-cris/tls-ldgd-15.d: Update. * testsuite/ld-cris/tls-ldgdx-14.d: Update. * testsuite/ld-cris/tls-ldgdx-15.d: Update. * testsuite/ld-cris/tls-local-54.d: Update. * testsuite/ld-cris/tls-local-60.d: Update. * testsuite/ld-cris/tls-local-61.d: Update. * testsuite/ld-cris/tls-local-63.d: Update. * testsuite/ld-cris/tls-local-64.d: Update. * testsuite/ld-cris/tls-ok-30.d: Update. * testsuite/ld-cris/tls-ok-32.d: Update. * testsuite/ld-cris/tls-ok-34.d: Update. * testsuite/ld-mips-elf/tls-multi-got-1.got: Update. * testsuite/ld-mips-elf/tls-multi-got-1.r: Update. * testsuite/ld-mips-elf/tlsdyn-pie-o32.d: Update. * testsuite/ld-mips-elf/tlsdyn-pie-o32.got: Update. * testsuite/ld-mips-elf/tlslib-o32-hidden.got: Update. * testsuite/ld-mips-elf/tlslib-o32-ver.got: Update. * testsuite/ld-mips-elf/tlslib-o32.got: Update. * testsuite/ld-s390/tlspic.rd: Update. * testsuite/ld-s390/tlspic_64.rd: Update. * testsuite/ld-sparc/tlssunnopic32.rd: Update. * testsuite/ld-sparc/tlssunnopic64.rd: Update. * testsuite/ld-sparc/tlssunpic32.rd: Update. * testsuite/ld-sparc/tlssunpic64.rd: Update.
2019-05-28MIPS/LD: Skip overflow check for %pcrel_hi relocationsFaraz Shahbazker6-11/+63
Overflow checks were removed for all hi16 relocations except PC-relative high relocations per PR ld/16720. Remove overflow checks from %pcrel_hi relocations so that we can correctly handle negative offsets from PC. bfd/ * elfxx-mips.c (mips_elf_calculate_relocation) <R_MIPS_PCHI16>: Remove overflow check. ld/ * testsuite/ld-mips-elf/undefweak-overflow.s: Remove test case for pcrel_hi/pcrel_lo. * testsuite/ld-mips-elf/undefweak-overflow.d: Update to match. * testsuite/ld-mips-elf/reloc-pcrel-r6.s: New test source. * testsuite/ld-mips-elf/reloc-pcrel-r6.d: New test linker script. * testsuite/ld-mips-elf/reloc-pcrel-r6.ld: New test. * testsuite/ld-mips-elf/mips-elf.exp: Run the new test.
2019-05-21MIPS/LD: Reject tprel_hi and tprel_lo relocations in shared libraryFaraz Shahbazker5-4/+43
bfd/ * elfxx-mips.c (_bfd_mips_elf_check_relocs): Generate error for TLS_TPREL_HI16(/LO16) relocations in shared library. ld/ * testsuite/ld-mips-elf/pic-reloc-5.s: Add tests for %tprel_hi and %tprel_lo relocations. * testsuite/ld-mips-elf/pic-reloc-6.s: Likewise. * testsuite/ld-mips-elf/pic-reloc-5.d: Update accordingly. * testsuite/ld-mips-elf/pic-reloc-6.d: Likewise. * testsuite/ld-mips-elf/pic-reloc-tls.ld: New test linker script file.
2019-05-21MIPS/LD: Fix memory fault linking non-PIC object in to shared libraryFaraz Shahbazker7-0/+58
bfd/ * elfxx-mips.c (_bfd_mips_elf_check_relocs): Add NULL pointer checks. Search the RELA table for n64 relocations. ld/ * testsuite/ld-mips-elf/pic-reloc-5.d: New test. * testsuite/ld-mips-elf/pic-reloc-6.d: New test. * testsuite/ld-mips-elf/pic-reloc-7.d: New test. * testsuite/ld-mips-elf/pic-reloc-5.s: New test source. * testsuite/ld-mips-elf/pic-reloc-6.s: New test source. * testsuite/ld-mips-elf/pic-reloc-7.s: New test source. * testsuite/ld-mips-elf/mips-elf.exp: Run the new tests.
2019-05-21[MIPS] Add generation of PLT entries with compact jumps for MIPS R6Matthew Fortune8-0/+183
Add a new option to get the linker to emit PLTs that use compact branches instead of delay slot branches. bfd/ * elfxx-mips.c (LA25_BC): New macro. (mips_elf_link_hash_table)<compact_branches>: New field. (STUB_JALRC): New macro. (mipsr6_o32_exec_plt0_entry_compact): New array. (mipsr6_n32_exec_plt0_entry_compact): Likewise. (mipsr6_n64_exec_plt0_entry_compact): Likewise. (mipsr6_exec_plt_entry_compact): Likewise. (mips_elf_create_la25_stub): Use BC instead of J for stubs when compact_branches is true. (_bfd_mips_elf_finish_dynamic_symbol): Choose the compact PLT for MIPSR6 with compact_branches. Do not reorder the compact branches PLT. Switch the lazy stub for MIPSR6 with compact_branches to use JALRC. (mips_finish_exec_plt): Choose the compact PLT0 for MIPSR6 when compact_branches is true. (_bfd_mips_elf_compact_branches): New function. * elfxx-mips.h (_bfd_mips_elf_compact_branches): New prototype. ld/ * emultempl/mipself.em (compact_branches): New static variable. (mips_create_output_section_statements): Call _bfd_mips_elf_compact_branches. (PARSE_AND_LIST_PROLOGUE): Add OPTION_COMPACT_BRANCHES and OPTION_NO_COMPACT_BRANCHES. (PARSE_AND_LIST_LONGOPTS): Add compact-branches, no-compact-branches. (PARSE_AND_LIST_OPTIONS): Add --compact-branches, --no-compact-branches. (PARSE_AND_LIST_ARGS_CASES): Handle the above. * ld.texinfo: Document --compact-branches, --no-compact-branches. * testsuite/ld-mips-elf/pic-and-nonpic-1-r6.dd: New test. * testsuite/ld-mips-elf/pic-and-nonpic-1-r6.nd: New test. * testsuite/ld-mips-elf/pic-and-nonpic-3a-r6.dd: New test. * testsuite/ld-mips-elf/pic-and-nonpic-3a-r6.gd: New test. * testsuite/ld-mips-elf/pic-and-nonpic-1a-r6.s: New test source. * testsuite/ld-mips-elf/pic-and-nonpic-3a-r6.s: New test source. * testsuite/ld-mips-elf/mips-elf.exp: Run the new tests.
2019-05-20[MIPS] PR gas/14798: Limit IRIX5 specific default typing to IRIX targetsFaraz Shahbazker2-4/+4
On IRIX 5, every global symbol that is not explicitly labelled as being a function is assumed to be an object. There is no reason why IRIX behaviour should extend to all MIPS targets, so limit this to only IRIX targets. gas/ PR 14798 * config/tc-mips.c (s_mips_globl): Only treat symbols that are not explicitly labelled as BSF_OBJECTs for IRIX targets. * testsuite/gas/mips/pr14798.s: New test source. * testsuite/gas/mips/pr14798-irix.d: New test. * testsuite/gas/mips/pr14798.d: Likewise. * testsuite/gas/mips/mips.exp: Run the new tests. binutils/ PR 14798 * testsuite/binutils-all/readelf.ss-mips: Update reference output. * testsuite/binutils-all/readelf.ss-tmips: Likewise. ld/ PR 14798 * testsuite/ld-mips-elf/reloc-6a.s: Specify .text section for global code symbols. * testsuite/ld-mips-elf/reloc-6b.s: Likewise.
2019-04-22Fix M5100 flags test with interAptiv-MR2Matthew Fortune1-1/+2
ld/ * testsuite/ld-mips-elf/mips-elf-flags.exp: Fix expected ASEs for M5100.
2019-01-01Update year range in copyright notice of binutils filesAlan Modra4-4/+4
2018-11-27MIPS/LD: Accept high-part relocations in PIC code with absolute symbolsMaciej W. Rozycki11-0/+93
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.