2
0
mirror of https://sourceware.org/git/binutils-gdb.git synced 2024-12-21 04:42:53 +08:00
binutils-gdb/ld/testsuite/ld-loongarch-elf/local-ifunc-reloc.d
Xi Ruoyao ae2e4d4035 LoongArch: Fix R_LARCH_IRELATIVE insertion after elf_link_sort_relocs
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.
2022-09-20 17:16:06 +08:00

11 lines
202 B
Makefile

#as:
#ld: -shared -z combreloc
#objdump: -R
.*: +file format .*
DYNAMIC RELOCATION RECORDS
OFFSET +TYPE +VALUE
[[:xdigit:]]+ R_LARCH_IRELATIVE +\*ABS\*\+0x[[:xdigit:]]+
[[:xdigit:]]+ R_LARCH_64 +test