Skip to content

Commit d08515a

Browse files
author
Nelson Chu
committed
RISC-V: Don't do undefweak relaxations for the linker_def symbols.
I get the following truncated errors recently when running riscv-gnu-toolchain regressions, /scratch/riscv-gnu-toolchain/regression/build/linux-rv32imafdc-ilp32d-medlow/build-glibc-linux-rv32imafdc-ilp32d/libc.a(libc-start.o): in function `elf_irela': /scratch/riscv-gnu-toolchain/glibc/csu/../sysdeps/riscv/dl-irel.h:47:(.text+0x88): relocation truncated to fit: R_RISCV_GPREL_I against symbol `__ehdr_start' defined in .note.ABI-tag section in /scratch/riscv-gnu-toolchain/regression/build/linux-rv32imafdc-ilp32d-medlow/build-glibc-linux-rv32imafdc-ilp32d/elf/sln The linker_def symbols like __ehdr_start that may be undefweak in early stages of linking, including relax stage, but are guaranteed to be defined later. Therefore, it seems like we shouldn't do the undefweak relaxations for these kinds of symbols since they may be defined after relaxations. bfd/ * elfnn-riscv.c (_bfd_riscv_relax_section): Don't do undefweak relaxations for the linker_def symbols.
1 parent 6f85247 commit d08515a

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

bfd/elfnn-riscv.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5123,7 +5123,13 @@ _bfd_riscv_relax_section (bfd *abfd, asection *sec,
51235123
if (h != NULL && h->type == STT_GNU_IFUNC)
51245124
continue;
51255125

5126+
/* Maybe we should check UNDEFWEAK_NO_DYNAMIC_RELOC here? But that
5127+
will break the undefweak relaxation testcases, so just make sure
5128+
we won't do relaxations for linker_def symbols in short-term. */
51265129
if (h->root.type == bfd_link_hash_undefweak
5130+
/* The linker_def symbol like __ehdr_start that may be undefweak
5131+
for now, but will be guaranteed to be defined later. */
5132+
&& !h->root.linker_def
51275133
&& (relax_func == _bfd_riscv_relax_lui
51285134
|| relax_func == _bfd_riscv_relax_pc))
51295135
{

0 commit comments

Comments
 (0)