]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commit
LoongArch: Fix resolution of undefined weak hidden/protected symbols
authorXi Ruoyao <xry111@xry111.site>
Wed, 25 Dec 2024 04:41:43 +0000 (12:41 +0800)
committercailulu <cailulu@loongson.cn>
Fri, 27 Dec 2024 09:52:29 +0000 (17:52 +0800)
commitbd94e7cd84c19da4a37dbdbc2d5587db6383f28c
treebd95e91fa2af12e704cf5a79194fd5a4a3c3d7b9
parente65a355022d0dc6b5707310876a72b5693ec0aa5
LoongArch: Fix resolution of undefined weak hidden/protected symbols

An undefined weak hidden/protect symbol should be resolved to runtime
address 0, but we were actually resolving it to link-time address 0.  So
in PIE or DSO the runtime address would be incorrect.

Fix the issue by rewriting pcalau12i to lu12i.w, and pcaddi to addi.w.
The latter does not always work because the immediate field of addi.w is
narrower, report an error in the case the addend is too large.

Signed-off-by: Xi Ruoyao <xry111@xry111.site>
bfd/elfnn-loongarch.c
include/opcode/loongarch.h
ld/testsuite/ld-loongarch-elf/ld-loongarch-elf.exp
ld/testsuite/ld-loongarch-elf/weak-undef-hidden-pie.d [new file with mode: 0644]
ld/testsuite/ld-loongarch-elf/weak-undef-hidden-shared.d [new file with mode: 0644]
ld/testsuite/ld-loongarch-elf/weak-undef-hidden.s [new file with mode: 0644]