mirror of
https://sourceware.org/git/binutils-gdb.git
synced 2025-03-07 13:39:43 +08:00
loongarch_elf_finish_dynamic_symbol is called after elf_link_sort_relocs if -z combreloc. elf_link_sort_relocs redistributes the contents of .rela.* sections those would be merged into .rela.dyn, so the slot for R_LARCH_IRELATIVE may be out of relplt->contents now. To make things worse, the boundary check dyn < dyn + relplt->size / sizeof (*dyn) is obviously wrong ("x + 10 < x"? :), causing the issue undetected during the linking process and the resulted executable suddenly crashes at runtime. The issue was found during an attempt to add static-pie support to the toolchain. Fix it by iterating through the inputs of .rela.dyn to find the slot.
29 lines
313 B
ArmAsm
29 lines
313 B
ArmAsm
.text
|
|
.align 2
|
|
|
|
.local ifunc
|
|
.type ifunc, @gnu_indirect_function
|
|
.set ifunc, resolver
|
|
|
|
resolver:
|
|
la.local $a0, impl
|
|
jr $ra
|
|
|
|
impl:
|
|
li.w $a0, 42
|
|
jr $ra
|
|
|
|
.global test
|
|
.type test, @function
|
|
test:
|
|
move $s0, $ra
|
|
bl ifunc
|
|
xori $a0, $a0, 42
|
|
jr $s0
|
|
|
|
.data
|
|
.global ptr
|
|
.type ptr, @object
|
|
ptr:
|
|
.dword test
|