[PATCH 2/2] LoongArch: Fix R_LARCH_IRELATIVE insertion after elf_link_sort_relocs
Xi Ruoyao
xry111@xry111.site
Fri Sep 16 20:11:06 GMT 2022
On Thu, 2022-09-15 at 21:03 +0800, liuzhensong wrote:
> It May be unnecessary find the slot in section of .rela.dyn.
>
> The slot of R_LARCH_IRELATIVE is within the scope relplt->contents (the
> space
>
> is calculated in function local_allocate_ifunc_dyn_relocs).
>
> We can find the slot just in relplt->contents(Only for dynamic ifunc. I
> did not test for static ifunc.).
The problem is loongarch_elf_finish_dynamic_symbol runs after
elf_link_sort_relocs. elf_link_sort_relocs basically does:
(pseudo code)
buffer = []
for section in {input of .rela.dyn}
buffer += (section.content) as [RELA]
buffer.sort_by(some_comparator)
buffer = buffer as [byte]
for section in {input of .rela.dyn}
section.content = buffer[..section.content.len()]
buffer = buffer[section.content.len()..]
So a "slot" in relplt->contents can end up elsewhere. You can read the
code of elf_link_sort_relocs to see it...
I can try to write a test case for this, but it's 04:00 AM now so I'd do
it after a sleep...
--
Xi Ruoyao <xry111@xry111.site>
School of Aerospace Science and Technology, Xidian University
More information about the Binutils
mailing list