aboutsummaryrefslogtreecommitdiff
path: root/ld
AgeCommit message (Collapse)AuthorFilesLines
2023-08-14ld: fix relocatable, retain7a target pattens for HPPASam James2-2/+2
Fix issue reported by Dave and Alan. Put back the old pattern for hppa-*-linux* and add hppa[12]*-*-linux* to cover Gentoo's hppa1.1 and hppa2.0 without including hppa64 inadvertently like I did before. ld/ PR 30733 PR 30734 * ld/testsuite/ld-elf/relocatable.d: Use better pattern to exclude hppa64 but include hppa1.1, hppa2.0. * ld/testsuite/ld-elf/retain7a.d: Ditto. Fixes: 0e339f6b4f2df25ed351cb94dc7fe16868626f49 Fixes: e3b66187192ce6840df283c00f6395bb0ff15cf5 Signed-off-by: Sam James <sam@gentoo.org>
2023-08-12regen configAlan Modra1-30/+86
This regenerates config files changed by the previous 44 commits. Note that subject lines in these commits mostly match the gcc git originating commit.
2023-08-11warn unused result for bfd IO functionsAlan Modra2-32/+56
This patch fixes all the warnings I found in bfd, binutils and ld, plus some bitrotted COFF_GO32 code that tried to allocate -168ul bytes. When the malloc fail was reported these testsuite fails resulted: i386-go32 +FAIL: go32 stub i386-go32 +ERROR: tcl error sourcing /home/alan/src/binutils-gdb/ld/testsuite/ld-i386/i386.exp. i386-go32 +ERROR: couldn't open "tmpdir/go32stub": no such file or directory i386-go32 +FAIL: ld-scripts/sane1 i386-go32 +FAIL: ld-scripts/assign-loc i386-go32 +FAIL: ld-scripts/pr18963 This does result in some warnings in gdb which are fixed in a followup patch. bfd/ * bfdio.c (bfd_read, bfd_write): Add ATTRIBUTE_WARN_UNUSED_RESULT. (bfd_tell, bfd_stat, bfd_seek, bfd_mmap): Likewise. * bfd-in2.h: Regenerate. * coff-rs6000.c (xcoff_write_armap_big) Don't ignore bfd_write return value. (xcoff_generate_rtinit): Likewise. Also free data_buffer and string_table before returning. * coff64-rs6000.c (xcoff64_generate_rtinit): Likewise. * coff-stgo32.c (go32exe_check_format): Don't ignore bfd_seek return value. * coffcode.h (coff_apply_checksum): Don't ignore bfd_write return. (coff_write_object_contents <COFF_GO32>): Likewise, and bfd_malloc. Fix bitrotted code to look for first section with non-zero filepos. * elf64-ia64-vms.c (elf64_vms_write_shdrs_and_ehdr): Don't ignore bfd_seek or bfd_write return values. * pef.c (bfd_pef_scan_section): Likewise. (bfd_pef_read_header, bfd_pef_xlib_read_header): Likewise. * vms-misc.c (_bfd_vms_output_end): Likewise. Return status. * vms.h (_bfd_vms_output_end): Update prototype. * vms-alpha.c: Pass _bfd_vms_output_end status up call chains. * wasm-module.c (wasm_compute_custom_section_file_position): Don't ignore bfd_seek or bfd_write return values. (wasm_compute_section_file_positions): Likewise. * xsym.c (bfd_sym_scan): Don't ignore bfd_seek return value. (bfd_sym_read_name_table): Likewise. binutils/ * ar.c (print_contents, extract_file): Don't ignore bfd_seek return value. ld/ * pdb.c (create_section_contrib_substream): Don't ignore bfd_seek return value. (create_section_header_stream): Likewise. * pe-dll.c (pe_get16, pe_get32): Add fail param to return results from bfd_seek and bfd_read. (pe_implied_import_dll): Handle these fails, and other bfd_seek and bfd_read return values.
2023-08-09Rename bfd_bread and bfd_bwriteAlan Modra5-70/+70
These were renamed from bfd_read and bfd_write back in 2001 when they lost an unnecessary parameter. Rename them back, and get rid of a few casts that are only needed without prototyped functions (K&R C).
2023-08-09Add ld makefile dependenciesAlan Modra2-3/+6
* Makefile.am (EXTRA_ld_new_SOURCES): Add pep-dll-aarch64.c and pep-dll-x86_64.c. * Makefile.in: Regenerate.
2023-08-08ld: Fix retain7a.d XFAIL/notarget entry for hppaSam James1-1/+1
PR 30733 * ld/testsuite/ld-elf/retain7a.d: Fix XFAIL entry for hppa to match hppa{1.1,2.0}*, like hppa2.0-unknown-linux-gnu which Gentoo uses. Signed-off-by: Sam James <sam@gentoo.org>
2023-08-08ld: Fix relocatable.d XFAIL/notarget entry for hppaSam James1-1/+1
PR 30734 * ld/testsuite/ld-elf/relocatable.d: Fix notarget entry for hppa to match hppa{1.1,2.0}*, like hppa2.0-unknown-linux-gnu which Gentoo uses. Signed-off-by: Sam James <sam@gentoo.org>
2023-08-04PR30697, ppc32 mix of local-dynamic and global-dynamic TLSAlan Modra3-0/+30
This fixes miscounting of dynamic relocations on GOT entries when a) there are both local-dynamic and global-dynamic tls accesss for a given symbol, and b) the symbol is global with non-default visibility, and c) the __tls_get_addr calls aren't optimised away. PR 30697 bfd/ * elf32-ppc.c (allocate_dynrelocs): Correct local-dynamic reloc count. ld/ * testsuite/ld-powerpc/tls32ldgd.d, * testsuite/ld-powerpc/tls32ldgd.s: New test. * testsuite/ld-powerpc/powerpc.exp: Run it.
2023-08-03ld: sprintf sanitizer null destination pointerAlan Modra9-25/+42
* configure.ac (stpcpy): AC_CHECK_DECLS. * sysdep.h (stpcpy): Add fallback declaraion. * config.in: Regenerate. * configure: Regenerate. * emultempl/pe.em (open_dynamic_archive): Use stpcpy rather than sprintf plus strlen. * emultempl/pep.em (open_dynamic_archive): Likewise. * emultempl/xtensaelf.em (elf_xtensa_before_allocation): Use auto rather than malloc'd buffer. Use sprintf count. * ldelf.c (ldelf_search_needed): Use memcpy in place of sprintf. * pe-dll.c (pe_process_import_defs): Use string already formed for alias match rather than recreating.
2023-08-02Revert "2.41 Release sources"Sam James88-2162/+2125
This reverts commit 675b9d612cc59446e84e2c6d89b45500cb603a8d. See https://sourceware.org/pipermail/binutils/2023-August/128761.html.
2023-08-022.41 Release sourcesbinutils-2_41-releaseNick Clifton88-2125/+2162
2023-08-02Don't declare xmalloc and others in ldmisc.hAlan Modra7-7/+10
* ldmisc.h (xmalloc, xrealloc, xexit, yyerror): Don't declare. * emultempl/pdp11.em: Include libiberty.h. * emultempl/ticoff.em: Likewise. * emultempl/vms.em: Likewise. * ldctor.c: Likewise. * ldelfgen.c: Likewise. * ldgram.y: Likewise. (yyerror): Prototype and make static.
2023-08-02Regen ld/configureAlan Modra1-1/+1
For commit 3d05c80b5dc4.
2023-08-01ld: Fix test failures with --enable-textrel-check=errorSam James8-8/+8
2023-07-31ld: fix typo in --enable-warn-rwx-segments helpSam James1-1/+1
2023-07-28MIPS: Support `-gnuabi64' target triplet suffix for 64-bit Linux targetsYunQiang Su5-8/+30
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 Su5-5/+5
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 Su18-7/+559
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-07-28Revert "MIPS: support mips*64 as CPU and gnuabi64 as ABI"Maciej W. Rozycki1-10/+2
This reverts commit 32f1c80375ebe8ad25d9805ee5889f0006c51e59. It had two unrelated changes lumped together, one of which changed the meaning of the `mipsisa64*-*-linux*' target triplets, which was not properly evaluated.
2023-07-28ldscripts/empty-address vs. xcoffAlan Modra5-2/+5
The empty-address tests check that if a section is removed by ld due to being empty then properties of that section don't affect following addresses. The xcoff backend doesn't remove the empty .data section created by empty-address-2* and empty-address-3* for some reason, and therefore fails the test. * testsuite/ld-scripts/empty-address-1.d: Accept more symbols. * testsuite/ld-scripts/empty-address-2a.d: xfail for xcoff. * testsuite/ld-scripts/empty-address-2b.d: Likewise. * testsuite/ld-scripts/empty-address-3a.d: Likewise. * testsuite/ld-scripts/empty-address-3b.d: Likewise.
2023-07-27/DISCARD/ in ld testsuiteAlan Modra35-35/+35
The canonical form to discard all sections not mentioned earlier in the script is /DISCARD/ : { *(*) } not /DISCARD/ : { *(.*) } ".*" happens to work with the usual section names starting with a dot, but let's not promote something not quite right.
2023-07-24objcopy embeds the current time and ignores SOURCE_DATE_EPOCH making the ↵Johannes Schauer Marin Rodrigues3-1/+24
output unreproducible. bfd * peXXigen.c (_bfd_XXi_only_swap_filehdr_out): If inserting a timestamp, use the value held in the SOURCE_DATE_EPOCH environment variable, if it is defined. binutils * doc/binutils.texi (objcopy): Document change in behaviour of objcopy's --preserve-dates command line option. ld * pe-dll.c (fill_edata): If inserting a timestamp, use the value held in the SOURCE_DATE_EPOCH environment variable, if it is defined. * ld.texi (--insert-timestamp): Document change in behaviour.
2023-07-24LoongArch: ld: Simplify inserting IRELATIVE relocations to .rela.dynmengqinggang1-1/+1
In LoongArch, the R_LARCH_IRELATIVE relocations for local ifunc symbols are in .rela.dyn. Before, this is done by loongarch_elf_finish_dynamic_sections. But this function is called after elf_link_sort_relocs, it need to find a null slot to insert IRELATIVE relocation. Now, it is processed by elf_loongarch_output_arch_local_syms before elf_link_sort_relocs, just need to call loongarch_elf_append_rela to insert IRELATIVE relocation. bfd/ChangeLog: * elfnn-loongarch.c (elfNN_allocate_local_ifunc_dynrelocs): Return type change to int. (loongarch_elf_size_dynamic_sections): Delete (void *). (loongarch_elf_finish_dynamic_symbol): Use loongarch_elf_append_rela insert IRELATIVE relocation to .rela.dyn. (elfNN_loongarch_finish_local_dynamic_symbol): Return type change to int. (loongarch_elf_finish_dynamic_sections): Delete process of local ifunc symbols. (elf_backend_output_arch_local_syms): New. ld/ChangeLog: * testsuite/ld-loongarch-elf/local-ifunc-reloc.d: Regenerated.
2023-07-21DesCGENization of the BPF binutils portJose E. Marchesi4-7/+7
CGEN is cool, but the BPF architecture is simply too bizarre for it. The weird way of BPF to handle endianness in instruction encoding, the weird C-like alternative assembly syntax, the weird abuse of multi-byte (or infra-byte) instruction fields as opcodes, the unusual presence of opcodes beyond the first 32-bits of some instructions, are all examples of what makes it a PITA to continue using CGEN for this port. The bpf.cpu file is becoming so complex and so nested with p-macros that it is very difficult to read, and quite challenging to update. Also, every time we are forced to change something in CGEN to accommodate BPF requirements (which is often) we have to do extensive testing to make sure we do not break any other target using CGEN. This is getting un-maintenable. So I have decided to bite the bullet and revamp/rewrite the port so it no longer uses CGEN. Overall, this involved: * To remove the cpu/bpf.{cpu,opc} descriptions. * To remove the CGEN generated files. * To replace the CGEN generated opcodes table with a new hand-written opcodes table for BPF. * To replace the CGEN generated disassembler wih a new disassembler that uses the new opcodes. * To replace the CGEN generated assembler with a new assembler that uses the new opcodes. * To replace the CGEN generated simulator with a new simulator that uses the new opcodes. [This is pushed in GDB in another patch.] * To adapt the build systems to the new situation. Additionally, this patch introduces some extensions and improvements: * A new BPF relocation BPF_RELOC_BPF_DISP16 plus corresponding ELF relocation R_BPF_GNU_64_16 are added to the BPF BFD port. These relocations are used for section-relative 16-bit offsets used in load/store instructions. * The disassembler now has support for the "pseudo-c" assembly syntax of BPF. What dialect to use when disassembling is controlled by a command line option. * The disassembler now has support for dumping instruction immediates in either octal, hexadecimal or decimal. The used output base is controlled by a new command-line option. * The GAS BPF test suite has been re-structured and expanded in order to test the disassembler pseudoc syntax support. Minor bugs have been also fixed there. The assembler generic tests that were disabled for bpf-*-* targets due to the previous implementation of pseudoc syntax are now re-enabled. Additional tests have been added to test the new features of the assembler. .dump files are no longer used. * The linker BPF test suite has been adapted to the command line options used by the new disassembler. The result is very satisfactory. This patchs adds 3448 lines of code and removes 10542 lines of code. Tested in: * Target bpf-unknown-none with 64-bit little-endian host and 32-bit little-endian host. * Target x86-64-linux-gnu with --enable-targets=all Note that I have not tested in a big-endian host yet. I will do so once this lands upstream so I can use the GCC compiler farm. I have not included ChangeLog entries in this patch: these would be massive and not very useful, considering this is pretty much a rewrite of the port. I beg the indulgence of the global maintainers.
2023-07-18PR 30632 - ld segfaults if linker script includes a STARTUP line.Pter Chubb1-3/+9
2023-07-17Also support '^=' in linker script expressionsMichael Matz4-3/+7
this requires also changes in ldgram.y and ldexp.c, unlike accepting '^' only. But let's do this anyway, if only for symmetry.
2023-07-17PR10957, Missing option to really print section+offsetAlan Modra15-23/+23
Many of the reloc error messages have already been converted from using %C to using %H in ld.bfd, to print section+offset as well as file/line/function. This catches a few remaining, and changes gold to do the same. PR 10957 bfd/ * elf32-sh.c (sh_elf_relocate_section): Use %H in error messages. gold/ * object.cc (Relocate_info::location): Always report section+offset. * testsuite/debug_msg.sh: Adjust to suit. * testsuite/x32_overflow_pc32.sh: Likewise. * testsuite/x86_64_overflow_pc32.sh: Likewise. ld/ * emultempl/pe.em (read_addend): Use %H in error message. * emultempl/pep.em (read_addend): Likewise. * ldcref.c (check_reloc_refs): Likewise. * ldmain.c (warning_find_reloc, undefined_symbol): Likewise. * pe-dll.c (pe_create_import_fixup): Likewise. * testsuite/ld-cris/undef2.d: Adjust expected output to suit. * testsuite/ld-cris/undef3.d: Likewise. * testsuite/ld-elf/shared.exp: Likewise. * testsuite/ld-i386/compressed1.d: Likewise. * testsuite/ld-ia64/line.exp: Likewise. * testsuite/ld-plugin/lto.exp: Likewise. * testsuite/ld-undefined/undefined.exp: Likewise. * testsuite/ld-x86-64/compressed1.d: Likewise. * testsuite/ld-x86-64/line.exp: Likewise. * testsuite/ld-x86-64/pr27587.err: Likewise.
2023-07-17Support NEXT_SECTION in ALIGNOF and SIZEOFAlan Modra19-98/+149
This patch is aimed at making __bss_start properly aligned with the first of any bss-style sections following. Most of the work here involves keeping track of the last output section seen when processing the linker script. You can almost align __bss_start properly by using ${RELOCATING+. = ALIGN(${DATA_SDATA-${NO_SMALL_DATA-ALIGNOF(.${SBSS_NAME}) != 0 ? ALIGNOF(.${SBSS_NAME}) : }}${BSS_PLT+ALIGNOF(.plt) != 0 ? ALIGNOF(.plt) : }ALIGNOF(.${BSS_NAME}));} and changing every place that defines NO_SMALL_DATA to use " ", but having two .plt sections (marked SPECIAL) on some backends foils that idea. The problem is that you only want to pick up the following .plt, not the one preceeding __bss_start in the data segment if the backend decides that is the proper .plt section. Perhaps that could be fixed too, but I decided instead to extend the linker script a little. THIS_SECTION and PREV_SECTION could easily be added too. * ld.texi (ALIGNOF, SIZEOF): Update and mention NEXT_SECTION. * ldexp.c (output_section_find): New function. (fold_name <ALIGNOF, SIZEOF>): Use output_section_find. (exp_fold_tree): Add os parameter. Adjust all calls. (exp_fold_tree_no_dot, exp_get_vma, exp_get_power): Likewise. * ldexp.h (struct ldexp_control): Add last_os. (exp_fold_tree, exp_fold_tree_no_dot): Update prototypes. (exp_get_vma, exp_get_power): Likewise. * ldlang.c: Pass last output section to expression folder calls throughout file. (open_input_bfds): Add os parameter to track last os seen. (lang_size_sections_1): Rename output_section_statement param to current_os. Track last os. (lang_do_assignments_1): Track last os. * scripttempl/arclinux.sc: Align to ALIGNOF NEXT_SECTION before defining __bss_start. * scripttempl/elf.sc: Likewise. * scripttempl/elf64bpf.sc: Likewise. * scripttempl/elf64hppa.sc: Likewise. * scripttempl/elf_chaos.sc: Likewise. * scripttempl/elfarc.sc: Likewise. * scripttempl/elfd10v.sc: Likewise. * scripttempl/elfxtensa.sc: Likewise. * scripttempl/epiphany_4x4.sc: Likewise. * scripttempl/iq2000.sc: Likewise. * scripttempl/mep.sc: Likewise. * scripttempl/nds32elf.sc: Likewise. * scripttempl/xstormy16.sc: Likewise. * testsuite/ld-x86-64/pe-x86-64-5.od: Update expected __bss_start. * testsuite/ld-x86-64/pe-x86-64-5.rd: Likewise.
2023-07-15Re: Let '^' through the lexerTobias Burnus1-1/+1
Fix "make pdf".
2023-07-13Let '^' through the lexerMichael Matz2-16/+21
so that the (existing) code in parser and expression evaluator actually get to see it and handle it as XOR. Also adjust docu to match what's there.
2023-07-12.noinit and .persistent for msp430Alan Modra1-14/+11
Similar to the previous patch, but also tidy a few more sections. * scripttempl/elf32msp430.sc (.text, .rodata, .data, .bss, .noinit), (.persistent): Align the section rather than aligning inside.
2023-07-12.noinit and .persistent alignmentAlan Modra1-4/+2
It's more elegant to make the section match up with its "_start" symbol. We could align by setting the address of the section (by using ALIGN before the colon), but this way we also set sh_addralign to at least $ALIGNMENT. * scripttempl/elf.sc (.noinit, .persistent): Align the output section rather than using ". = ALIGN();" at the beginning. Set address to zero when not a final link.
2023-07-12Re: Align linkerscript symbols according to ABIAlan Modra1-1/+2
Align dot before symbols defined outside of output sections. Before _end is already aligned. * scripttempl/elf.sc (def_symbol): Tidy excess space. (_edata): Align before emitting symbol when SYMBOL_ABI_ALIGNMENT.
2023-07-11ld/PDB: fix off-by-1 in add_globals_ref()Jan Beulich1-1/+1
Copying one too many bytes can corrupt memory, detected/reported by glibc on a 32-bit distro.
2023-07-07ld: fix build with old glibc / gccJan Beulich1-2/+2
"rename" conflicts with a function of that name, which gcc from that same timeframe then complains about. Use a name matching that of struct input_remap's respective field.
2023-07-07Udated Freach and Romainian translations for various sub-directoriesNick Clifton1-2220/+2877
2023-07-06ld: fix plugin tests for MIPS PICYunQiang Su10-0/+10
On MIPS, for PIC objects, symbols may reference 2 times: once from the caller, and once from GOT. Thus ld may complains 2 times about "undefined reference". So we add a new "#?" line to every effected testsuite.
2023-07-06Use run_host_cmd to run $CC and other no-section-header test fixesAlan Modra7-54/+54
We should be using run_host_cmd everywhere we invoke a compiler in the ld testsuite, if we want to use ld/ld-new just built. run_host_cmd properly inserts $gcc_B_opt in cases where a user wants to test binutils with a newly built compiler, ie. when $CC specifies -B itself. Also, it is not good practice to exclude tests when non-native except of course those tests that run a target binary. Compiling and linking often shows up problems. * testsuite/ld-elf/no-section-header.exp (binutils_run_test): Use run_host_cmd to invoke $CC_FOR_TARGET. Run all tests non-native too, except for attempting to run the binaries. Run tests for ELF in general, not just linux. * testsuite/ld-elf/pr25617-1-no-sec-hdr.rd: Allow localentry symbol decoration, and support either sorting of symbols. * testsuite/ld-elf/pr25617-1a-no-sec-hdr.rd: Likewise. * testsuite/ld-elf/pr25617-1a-sec-hdr.rd: Likewise. * testsuite/ld-elf/pr25617-1a-no-sec-hdr.nd: Accept D function syms. * testsuite/ld-elf/start-shared-noheader-sysv.rd: Accept mips-sgi-irix symbol output. * testsuite/ld-elf/start-shared-noheader.nd: Likewise.
2023-07-06Re: Stop the linker's --dependency-file option from including temporary lto ↵Alan Modra1-0/+2
files. PR 30568 * ldfile.c (ldfile_try_open_bfd): Fix build failure when !BFD_SUPPORTS_PLUGINS.
2023-07-06ld: Use run_host_cmd_yesno in indirect.exp instead of catch execYunQiang Su1-4/+1
Catch "exec $CC_FOR_TARGET" won't use the gas/ld that we just build, and in fact run_host_cmd_yesno is a better choice for it. ld/ChangeLog: * testsuite/ld-elf/indirect.exp: use run_host_cmd_yesno instead of handwrite catch exec $CC_FOR_TARGET.
2023-07-06ld: Use [list ] syntax to define run_tests in indirect.expYunQiang Su1-62/+62
Currently, the var run_tests is defined by syntax {{}}, while in this case, variables cannot be used. Thus $NOPIE_CFLAGS and $NOPIE_LDFLAGS are passed to cmd as names instead of values: gcc ... $NOPIE_CFLAGS -c .../indirect5a.c -o tmpdir/indirect5a.o Let's use [list [list ]] syntax instead. ld/ChangeLog: * testsuite/ld-elf/indirect.exp(run_tests): use [list [list]] syntax instead of {{}}.