We've discussed this in https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97787 and Richard suggests to report it as a gas bug. $ cat t.s .text foo: .reloc 1f,R_MIPS_JALR,.LTHUNK5.lto_priv.0 1: nop $ mips64el-unknown-linux-gnuabi64-as -64 t.s $ mips64el-unknown-linux-gnuabi64-readelf -s a.out Symbol table '.symtab' contains 10 entries: Num: Value Size Type Bind Vis Ndx Name 0: 0000000000000000 0 NOTYPE LOCAL DEFAULT UND 1: 0000000000000000 0 SECTION LOCAL DEFAULT 1 2: 0000000000000000 0 SECTION LOCAL DEFAULT 3 3: 0000000000000000 0 SECTION LOCAL DEFAULT 4 4: 0000000000000000 0 NOTYPE LOCAL DEFAULT 1 foo 5: 0000000000000000 0 SECTION LOCAL DEFAULT 5 6: 0000000000000000 0 SECTION LOCAL DEFAULT 6 7: 0000000000000000 0 SECTION LOCAL DEFAULT 7 8: 0000000000000000 0 SECTION LOCAL DEFAULT 8 9: 0000000000000000 0 SECTION LOCAL DEFAULT UND $ mips64el-unknown-linux-gnuabi64-objdump -t a.out a.out: file format elf64-tradlittlemips SYMBOL TABLE: 0000000000000000 l d .text 0000000000000000 .text 0000000000000000 l d .data 0000000000000000 .data 0000000000000000 l d .bss 0000000000000000 .bss 0000000000000000 l .text 0000000000000000 foo 0000000000000000 l d .MIPS.options 0000000000000000 .MIPS.options 0000000000000000 l d .MIPS.abiflags 0000000000000000 .MIPS.abiflags 0000000000000000 l d .pdr 0000000000000000 .pdr 0000000000000000 l d .gnu.attributes 0000000000000000 .gnu.attributes 0000000000000000 l d *UND* 0000000000000000 The last "unnamed section" does not make any sense to us.
The master branch has been updated by Alan Modra <amodra@sourceware.org>: https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=68fcee4fa753f6488c9f90610da2f5a5a95d5a1f commit 68fcee4fa753f6488c9f90610da2f5a5a95d5a1f Author: Alan Modra <amodra@gmail.com> Date: Sun Jan 24 12:39:07 2021 +1030 PR27228, .reloc wrong symbol emitted for undefined local symbol Local symbols are of course supposed to be defined by their object file, but in other cases a local symbol is promoted to global by gas if undefined and referenced. This patch stops gas wrongly replacing a local undefined symbol with the undefined section symbol, resulting in a .reloc undefined local symbol being emitted as global. PR 27228 * write.c (resolve_reloc_expr_symbols): Don't assume local symbol is defined.
The binutils-2_36-branch branch has been updated by Alan Modra <amodra@sourceware.org>: https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=1aaad1d55d784670f112954fdecbd0261bfdffd7 commit 1aaad1d55d784670f112954fdecbd0261bfdffd7 Author: Alan Modra <amodra@gmail.com> Date: Sun Jan 24 12:39:07 2021 +1030 PR27228, .reloc wrong symbol emitted for undefined local symbol Local symbols are of course supposed to be defined by their object file, but in other cases a local symbol is promoted to global by gas if undefined and referenced. This patch stops gas wrongly replacing a local undefined symbol with the undefined section symbol, resulting in a .reloc undefined local symbol being emitted as global. PR 27228 * write.c (resolve_reloc_expr_symbols): Don't assume local symbol is defined. (cherry picked from commit 68fcee4fa753f6488c9f90610da2f5a5a95d5a1f)
Fixed for 2.36.
The master branch has been updated by H.J. Lu <hjl@sourceware.org>: https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=eea133e65524218c05bd7a1e93b4fe4241dd8e08 commit eea133e65524218c05bd7a1e93b4fe4241dd8e08 Author: H.J. Lu <hjl.tools@gmail.com> Date: Sun Jan 24 04:14:30 2021 -0800 gas: Add a testcase for PR gas/27228 PR gas/27228 * testsuite/gas/elf/elf.exp: Run pr27228. * testsuite/gas/elf/pr27228.d: New file. * testsuite/gas/elf/pr27228.s: Likewise.
The binutils-2_36-branch branch has been updated by H.J. Lu <hjl@sourceware.org>: https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=8b236dfbac7bdfbb23078c3f8c5f79548c7fee3f commit 8b236dfbac7bdfbb23078c3f8c5f79548c7fee3f Author: H.J. Lu <hjl.tools@gmail.com> Date: Sun Jan 24 04:14:30 2021 -0800 gas: Add a testcase for PR gas/27228 PR gas/27228 * testsuite/gas/elf/elf.exp: Run pr27228. * testsuite/gas/elf/pr27228.d: New file. * testsuite/gas/elf/pr27228.s: Likewise. (cherry picked from commit eea133e65524218c05bd7a1e93b4fe4241dd8e08)