From: Jan Beulich Date: Fri, 12 Dec 2025 07:06:41 +0000 (+0100) Subject: RISC-V: avoid ld crashes due to bogus use by testcases X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=43720b0cdd2a2171ef7125bb1572e9daf7d88f07;p=thirdparty%2Fbinutils-gdb.git RISC-V: avoid ld crashes due to bogus use by testcases Specifying a little-endian emulation isn't very helpful when the target is big-endian (and hence gas defaults to that). Surely the linker better wouldn't crash when invoked like this, but making sure of this isn't the purpose of any of these tests (afaict). Make assembly output match linker options. With this the ld testsuite completes successfully for me. binutils and gas testsuites still have issues. --- diff --git a/ld/testsuite/ld-riscv-elf/align-small-region.d b/ld/testsuite/ld-riscv-elf/align-small-region.d index 3799129c665..26ab1846c59 100644 --- a/ld/testsuite/ld-riscv-elf/align-small-region.d +++ b/ld/testsuite/ld-riscv-elf/align-small-region.d @@ -1,5 +1,5 @@ #source: align-small-region.s -#as: -march=rv32i +#as: -march=rv32i -mlittle-endian #ld: -melf32lriscv --relax -Talign-small-region.ld --defsym=_start=0x100 #objdump: -d diff --git a/ld/testsuite/ld-riscv-elf/code-model-medany-01.d b/ld/testsuite/ld-riscv-elf/code-model-medany-01.d index 071eee8e5b4..318cceec2a6 100644 --- a/ld/testsuite/ld-riscv-elf/code-model-medany-01.d +++ b/ld/testsuite/ld-riscv-elf/code-model-medany-01.d @@ -1,4 +1,4 @@ #source: code-model.s -#as: -march=rv64i -mabi=lp64 --defsym __medany__=1 +#as: -march=rv64i -mabi=lp64 -mlittle-endian --defsym __medany__=1 #ld: -Tcode-model-01.ld -melf64lriscv --no-relax #error: .*relocation truncated to fit: R_RISCV_GOT_HI20 against symbol `symbolG' diff --git a/ld/testsuite/ld-riscv-elf/code-model-medany-02.d b/ld/testsuite/ld-riscv-elf/code-model-medany-02.d index 017a1dcfda4..235d1ea318c 100644 --- a/ld/testsuite/ld-riscv-elf/code-model-medany-02.d +++ b/ld/testsuite/ld-riscv-elf/code-model-medany-02.d @@ -1,5 +1,5 @@ #source: code-model.s -#as: -march=rv64i -mabi=lp64 --defsym __medany__=1 +#as: -march=rv64i -mabi=lp64 -mlittle-endian --defsym __medany__=1 #ld: -Tcode-model-02.ld -melf64lriscv --no-relax #objdump: -d -Mno-aliases diff --git a/ld/testsuite/ld-riscv-elf/code-model-medany-weakref-01.d b/ld/testsuite/ld-riscv-elf/code-model-medany-weakref-01.d index 0fe5c451393..546d5c188eb 100644 --- a/ld/testsuite/ld-riscv-elf/code-model-medany-weakref-01.d +++ b/ld/testsuite/ld-riscv-elf/code-model-medany-weakref-01.d @@ -1,4 +1,4 @@ #source: code-model.s -#as: -march=rv64i -mabi=lp64 --defsym __medany__=1 --defsym __undefweak__=1 +#as: -march=rv64i -mabi=lp64 -mlittle-endian --defsym __medany__=1 --defsym __undefweak__=1 #ld: -Tcode-model-01.ld -melf64lriscv --no-relax #error: .*relocation truncated to fit: R_RISCV_GOT_HI20 against undefined symbol `symbolW' diff --git a/ld/testsuite/ld-riscv-elf/code-model-medany-weakref-02.d b/ld/testsuite/ld-riscv-elf/code-model-medany-weakref-02.d index 2b3aaae82a8..54d32e4e800 100644 --- a/ld/testsuite/ld-riscv-elf/code-model-medany-weakref-02.d +++ b/ld/testsuite/ld-riscv-elf/code-model-medany-weakref-02.d @@ -1,5 +1,5 @@ #source: code-model.s -#as: -march=rv64i -mabi=lp64 --defsym __medany__=1 --defsym __undefweak__=1 +#as: -march=rv64i -mabi=lp64 -mlittle-endian --defsym __medany__=1 --defsym __undefweak__=1 #ld: -Tcode-model-02.ld -melf64lriscv --no-relax #objdump: -d -Mno-aliases diff --git a/ld/testsuite/ld-riscv-elf/code-model-medlow-01.d b/ld/testsuite/ld-riscv-elf/code-model-medlow-01.d index a92389326ef..d9194573773 100644 --- a/ld/testsuite/ld-riscv-elf/code-model-medlow-01.d +++ b/ld/testsuite/ld-riscv-elf/code-model-medlow-01.d @@ -1,4 +1,4 @@ #source: code-model.s -#as: -march=rv64i -mabi=lp64 --defsym __medlow__=1 +#as: -march=rv64i -mabi=lp64 -mlittle-endian --defsym __medlow__=1 #ld: -Tcode-model-01.ld -melf64lriscv --no-relax #error: .*relocation truncated to fit: R_RISCV_HI20 against `symbolL' diff --git a/ld/testsuite/ld-riscv-elf/code-model-medlow-02.d b/ld/testsuite/ld-riscv-elf/code-model-medlow-02.d index 11688635fe6..de659ee273a 100644 --- a/ld/testsuite/ld-riscv-elf/code-model-medlow-02.d +++ b/ld/testsuite/ld-riscv-elf/code-model-medlow-02.d @@ -1,5 +1,5 @@ #source: code-model.s -#as: -march=rv64i -mabi=lp64 --defsym __medlow__=1 +#as: -march=rv64i -mabi=lp64 -mlittle-endian --defsym __medlow__=1 #ld: -Tcode-model-02.ld -melf64lriscv --no-relax #objdump: -d -Mno-aliases diff --git a/ld/testsuite/ld-riscv-elf/code-model-medlow-weakref-01.d b/ld/testsuite/ld-riscv-elf/code-model-medlow-weakref-01.d index 28f8fe98b2a..52e3f0de37b 100644 --- a/ld/testsuite/ld-riscv-elf/code-model-medlow-weakref-01.d +++ b/ld/testsuite/ld-riscv-elf/code-model-medlow-weakref-01.d @@ -1,5 +1,5 @@ #source: code-model.s -#as: -march=rv64i -mabi=lp64 --defsym __medlow__=1 --defsym __undefweak__=1 +#as: -march=rv64i -mabi=lp64 -mlittle-endian --defsym __medlow__=1 --defsym __undefweak__=1 #ld: -Tcode-model-01.ld -melf64lriscv --no-relax #objdump: -d -Mno-aliases diff --git a/ld/testsuite/ld-riscv-elf/code-model-medlow-weakref-02.d b/ld/testsuite/ld-riscv-elf/code-model-medlow-weakref-02.d index 405b0fe25af..758104ee91e 100644 --- a/ld/testsuite/ld-riscv-elf/code-model-medlow-weakref-02.d +++ b/ld/testsuite/ld-riscv-elf/code-model-medlow-weakref-02.d @@ -1,5 +1,5 @@ #source: code-model.s -#as: -march=rv64i -mabi=lp64 --defsym __medlow__=1 --defsym __undefweak__=1 +#as: -march=rv64i -mabi=lp64 -mlittle-endian --defsym __medlow__=1 --defsym __undefweak__=1 #ld: -Tcode-model-02.ld -melf64lriscv --no-relax #objdump: -d -Mno-aliases diff --git a/ld/testsuite/ld-riscv-elf/code-model-relax-medany-01.d b/ld/testsuite/ld-riscv-elf/code-model-relax-medany-01.d index afa24eff632..e97457d78e0 100644 --- a/ld/testsuite/ld-riscv-elf/code-model-relax-medany-01.d +++ b/ld/testsuite/ld-riscv-elf/code-model-relax-medany-01.d @@ -1,4 +1,4 @@ #source: code-model.s -#as: -march=rv64i -mabi=lp64 --defsym __medany__=1 +#as: -march=rv64i -mabi=lp64 -mlittle-endian --defsym __medany__=1 #ld: -Tcode-model-01.ld -melf64lriscv --relax #error: .*relocation truncated to fit: R_RISCV_GOT_HI20 against symbol `symbolG' diff --git a/ld/testsuite/ld-riscv-elf/code-model-relax-medany-02.d b/ld/testsuite/ld-riscv-elf/code-model-relax-medany-02.d index 7b5b9e99c66..3ab235e7987 100644 --- a/ld/testsuite/ld-riscv-elf/code-model-relax-medany-02.d +++ b/ld/testsuite/ld-riscv-elf/code-model-relax-medany-02.d @@ -1,5 +1,5 @@ #source: code-model.s -#as: -march=rv64i -mabi=lp64 --defsym __medany__=1 +#as: -march=rv64i -mabi=lp64 -mlittle-endian --defsym __medany__=1 #ld: -Tcode-model-02.ld -melf64lriscv --relax #objdump: -d -Mno-aliases diff --git a/ld/testsuite/ld-riscv-elf/code-model-relax-medany-weakref-01.d b/ld/testsuite/ld-riscv-elf/code-model-relax-medany-weakref-01.d index 5b2d1eaf1db..61289a644c8 100644 --- a/ld/testsuite/ld-riscv-elf/code-model-relax-medany-weakref-01.d +++ b/ld/testsuite/ld-riscv-elf/code-model-relax-medany-weakref-01.d @@ -1,4 +1,4 @@ #source: code-model.s -#as: -march=rv64i -mabi=lp64 --defsym __medany__=1 --defsym __undefweak__=1 +#as: -march=rv64i -mabi=lp64 -mlittle-endian --defsym __medany__=1 --defsym __undefweak__=1 #ld: -Tcode-model-01.ld -melf64lriscv --relax #error: .*relocation truncated to fit: R_RISCV_GOT_HI20 against undefined symbol `symbolW' diff --git a/ld/testsuite/ld-riscv-elf/code-model-relax-medany-weakref-02.d b/ld/testsuite/ld-riscv-elf/code-model-relax-medany-weakref-02.d index 783be0c5362..6be00f65c0f 100644 --- a/ld/testsuite/ld-riscv-elf/code-model-relax-medany-weakref-02.d +++ b/ld/testsuite/ld-riscv-elf/code-model-relax-medany-weakref-02.d @@ -1,5 +1,5 @@ #source: code-model.s -#as: -march=rv64i -mabi=lp64 --defsym __medany__=1 --defsym __undefweak__=1 +#as: -march=rv64i -mabi=lp64 -mlittle-endian --defsym __medany__=1 --defsym __undefweak__=1 #ld: -Tcode-model-02.ld -melf64lriscv --relax #objdump: -d -Mno-aliases diff --git a/ld/testsuite/ld-riscv-elf/code-model-relax-medlow-01-norelaxgp.d b/ld/testsuite/ld-riscv-elf/code-model-relax-medlow-01-norelaxgp.d index 8e40cc5f32d..3389860ae9a 100644 --- a/ld/testsuite/ld-riscv-elf/code-model-relax-medlow-01-norelaxgp.d +++ b/ld/testsuite/ld-riscv-elf/code-model-relax-medlow-01-norelaxgp.d @@ -1,4 +1,4 @@ #source: code-model.s -#as: -march=rv64i -mabi=lp64 --defsym __medlow__=1 +#as: -march=rv64i -mabi=lp64 -mlittle-endian --defsym __medlow__=1 #ld: -Tcode-model-01.ld -melf64lriscv --no-relax-gp --relax #error: .*relocation truncated to fit: R_RISCV_HI20 against `symbolL' diff --git a/ld/testsuite/ld-riscv-elf/code-model-relax-medlow-01.d b/ld/testsuite/ld-riscv-elf/code-model-relax-medlow-01.d index eea2f7d6615..4f645f30c0e 100644 --- a/ld/testsuite/ld-riscv-elf/code-model-relax-medlow-01.d +++ b/ld/testsuite/ld-riscv-elf/code-model-relax-medlow-01.d @@ -1,5 +1,5 @@ #source: code-model.s -#as: -march=rv64i -mabi=lp64 --defsym __medlow__=1 +#as: -march=rv64i -mabi=lp64 -mlittle-endian --defsym __medlow__=1 #ld: -Tcode-model-01.ld -melf64lriscv --relax #objdump: -d -Mno-aliases diff --git a/ld/testsuite/ld-riscv-elf/code-model-relax-medlow-02.d b/ld/testsuite/ld-riscv-elf/code-model-relax-medlow-02.d index adc81f5ab20..d9118ad83aa 100644 --- a/ld/testsuite/ld-riscv-elf/code-model-relax-medlow-02.d +++ b/ld/testsuite/ld-riscv-elf/code-model-relax-medlow-02.d @@ -1,5 +1,5 @@ #source: code-model.s -#as: -march=rv64i -mabi=lp64 --defsym __medlow__=1 +#as: -march=rv64i -mabi=lp64 -mlittle-endian --defsym __medlow__=1 #ld: -Tcode-model-02.ld -melf64lriscv --relax #objdump: -d -Mno-aliases diff --git a/ld/testsuite/ld-riscv-elf/code-model-relax-medlow-weakref-01.d b/ld/testsuite/ld-riscv-elf/code-model-relax-medlow-weakref-01.d index b1f22039ee9..d1e693ab933 100644 --- a/ld/testsuite/ld-riscv-elf/code-model-relax-medlow-weakref-01.d +++ b/ld/testsuite/ld-riscv-elf/code-model-relax-medlow-weakref-01.d @@ -1,5 +1,5 @@ #source: code-model.s -#as: -march=rv64i -mabi=lp64 --defsym __medlow__=1 --defsym __undefweak__=1 +#as: -march=rv64i -mabi=lp64 -mlittle-endian --defsym __medlow__=1 --defsym __undefweak__=1 #ld: -Tcode-model-01.ld -melf64lriscv --relax #objdump: -d -Mno-aliases diff --git a/ld/testsuite/ld-riscv-elf/code-model-relax-medlow-weakref-02.d b/ld/testsuite/ld-riscv-elf/code-model-relax-medlow-weakref-02.d index 332046d7c5b..a0348aed78c 100644 --- a/ld/testsuite/ld-riscv-elf/code-model-relax-medlow-weakref-02.d +++ b/ld/testsuite/ld-riscv-elf/code-model-relax-medlow-weakref-02.d @@ -1,5 +1,5 @@ #source: code-model.s -#as: -march=rv64i -mabi=lp64 --defsym __medlow__=1 --defsym __undefweak__=1 +#as: -march=rv64i -mabi=lp64 -mlittle-endian --defsym __medlow__=1 --defsym __undefweak__=1 #ld: -Tcode-model-02.ld -melf64lriscv --relax #objdump: -d -Mno-aliases diff --git a/ld/testsuite/ld-riscv-elf/pcrel-reloc-abs-nopie.d b/ld/testsuite/ld-riscv-elf/pcrel-reloc-abs-nopie.d index 54026388b7a..947c96195fb 100644 --- a/ld/testsuite/ld-riscv-elf/pcrel-reloc-abs-nopie.d +++ b/ld/testsuite/ld-riscv-elf/pcrel-reloc-abs-nopie.d @@ -1,6 +1,6 @@ #source: pcrel-reloc.s #source: pcrel-reloc-abs.s -#as: -march=rv64i -mabi=lp64 +#as: -march=rv64i -mabi=lp64 -mlittle-endian #ld: -melf64lriscv --no-pie --no-relax #objdump: -d diff --git a/ld/testsuite/ld-riscv-elf/pcrel-reloc-abs-pie.d b/ld/testsuite/ld-riscv-elf/pcrel-reloc-abs-pie.d index 7f5eaa321f7..a9f7917adf8 100644 --- a/ld/testsuite/ld-riscv-elf/pcrel-reloc-abs-pie.d +++ b/ld/testsuite/ld-riscv-elf/pcrel-reloc-abs-pie.d @@ -1,5 +1,5 @@ #source: pcrel-reloc.s #source: pcrel-reloc-abs.s -#as: -march=rv64i -mabi=lp64 +#as: -march=rv64i -mabi=lp64 -mlittle-endian #ld: -melf64lriscv --pie --no-relax #error: .*relocation R_RISCV_PCREL_HI20 against absolute symbol `sym' can not be used when making a shared objec.*t diff --git a/ld/testsuite/ld-riscv-elf/pcrel-reloc-rel-nopie.d b/ld/testsuite/ld-riscv-elf/pcrel-reloc-rel-nopie.d index ab2a3774cdd..fdf6a7c8216 100644 --- a/ld/testsuite/ld-riscv-elf/pcrel-reloc-rel-nopie.d +++ b/ld/testsuite/ld-riscv-elf/pcrel-reloc-rel-nopie.d @@ -1,6 +1,6 @@ #source: pcrel-reloc.s #source: pcrel-reloc-rel.s -#as: -march=rv64i -mabi=lp64 +#as: -march=rv64i -mabi=lp64 -mlittle-endian #ld: -melf64lriscv --no-pie --no-relax #objdump: -d diff --git a/ld/testsuite/ld-riscv-elf/pcrel-reloc-rel-pie.d b/ld/testsuite/ld-riscv-elf/pcrel-reloc-rel-pie.d index aec612d4d2c..854d6d384a0 100644 --- a/ld/testsuite/ld-riscv-elf/pcrel-reloc-rel-pie.d +++ b/ld/testsuite/ld-riscv-elf/pcrel-reloc-rel-pie.d @@ -1,6 +1,6 @@ #source: pcrel-reloc.s #source: pcrel-reloc-rel.s -#as: -march=rv64i -mabi=lp64 +#as: -march=rv64i -mabi=lp64 -mlittle-endian #ld: -melf64lriscv --pie --no-relax #objdump: -d diff --git a/ld/testsuite/ld-riscv-elf/property-combine-and-1.d b/ld/testsuite/ld-riscv-elf/property-combine-and-1.d index 571620f848e..a48e93e06a8 100644 --- a/ld/testsuite/ld-riscv-elf/property-combine-and-1.d +++ b/ld/testsuite/ld-riscv-elf/property-combine-and-1.d @@ -1,6 +1,6 @@ #name: RISC-V GNU Property (multiple inputs, combine section) - 1 #source: property1.s #source: property2.s -#as: -march=rv64g +#as: -march=rv64g -mlittle-endian #ld: -shared -melf64lriscv #readelf: -n diff --git a/ld/testsuite/ld-riscv-elf/property-combine-and-2.d b/ld/testsuite/ld-riscv-elf/property-combine-and-2.d index 23482af01af..77706edcd31 100644 --- a/ld/testsuite/ld-riscv-elf/property-combine-and-2.d +++ b/ld/testsuite/ld-riscv-elf/property-combine-and-2.d @@ -1,7 +1,7 @@ #name: RISC-V GNU Property (multiple inputs, combine section) - 2 #source: property1.s #source: property3.s -#as: -march=rv64g +#as: -march=rv64g -mlittle-endian #ld: -shared -melf64lriscv #readelf: -n diff --git a/ld/testsuite/ld-riscv-elf/property-combine-and-3.d b/ld/testsuite/ld-riscv-elf/property-combine-and-3.d index b57a0f76394..4f0c5148034 100644 --- a/ld/testsuite/ld-riscv-elf/property-combine-and-3.d +++ b/ld/testsuite/ld-riscv-elf/property-combine-and-3.d @@ -1,7 +1,7 @@ #name: RISC-V GNU Property (multiple inputs, combine section) - 3 #source: property1.s #source: property4.s -#as: -march=rv64g +#as: -march=rv64g -mlittle-endian #ld: -shared -melf64lriscv #readelf: -n diff --git a/ld/testsuite/ld-riscv-elf/property-zicfilp-unlabeled.d b/ld/testsuite/ld-riscv-elf/property-zicfilp-unlabeled.d index 48d60d6fca0..7f5c0af48c2 100644 --- a/ld/testsuite/ld-riscv-elf/property-zicfilp-unlabeled.d +++ b/ld/testsuite/ld-riscv-elf/property-zicfilp-unlabeled.d @@ -1,6 +1,6 @@ #name: GNU Property (single input, CFI_LP_UNLABELED) #source: property-zicfilp-unlabeled.s -#as: -march=rv64g +#as: -march=rv64g -mlittle-endian #ld: -shared -melf64lriscv #readelf: -n diff --git a/ld/testsuite/ld-riscv-elf/property-zicfiss.d b/ld/testsuite/ld-riscv-elf/property-zicfiss.d index 0dec1a10db0..c94a8ba865a 100644 --- a/ld/testsuite/ld-riscv-elf/property-zicfiss.d +++ b/ld/testsuite/ld-riscv-elf/property-zicfiss.d @@ -1,6 +1,6 @@ #name: GNU Property (single input, CFI_SS) #source: property-zicfiss.s -#as: -march=rv64g +#as: -march=rv64g -mlittle-endian #ld: -shared -melf64lriscv #readelf: -n diff --git a/ld/testsuite/ld-riscv-elf/uleb128.d b/ld/testsuite/ld-riscv-elf/uleb128.d index a921478e988..e5826282663 100644 --- a/ld/testsuite/ld-riscv-elf/uleb128.d +++ b/ld/testsuite/ld-riscv-elf/uleb128.d @@ -1,5 +1,5 @@ #source: uleb128.s -#as: -march=rv32ic +#as: -march=rv32ic -mlittle-endian #ld: -melf32lriscv #objdump: -d diff --git a/ld/testsuite/ld-riscv-elf/zicfilp-unlabeled-plt.d b/ld/testsuite/ld-riscv-elf/zicfilp-unlabeled-plt.d index bb888d163de..b56d5cbe9e6 100644 --- a/ld/testsuite/ld-riscv-elf/zicfilp-unlabeled-plt.d +++ b/ld/testsuite/ld-riscv-elf/zicfilp-unlabeled-plt.d @@ -2,7 +2,7 @@ #source: zicfilp-unlabeled-plt.s #ld: -shared -melf64lriscv #objdump: -dr -j .plt -#as: -march=rv64gc_zicfilp +#as: -march=rv64gc_zicfilp -mlittle-endian [^:]*: *file format elf64-.*riscv