LoongArch: ld: Simplify inserting IRELATIVE relocations to .rela.dyn
authormengqinggang <mengqinggang@loongson.cn>
Tue, 11 Jul 2023 03:21:18 +0000 (11:21 +0800)
committerliuzhensong <liuzhensong@loongson.cn>
Mon, 24 Jul 2023 03:22:42 +0000 (11:22 +0800)
commit3fa45fb168ceb04013d0dbd64d4a09d9cf284f63
treea8ce8d0c9e67ede1b245b8321315f5150b91dfcc
parenta38b0c05b6e9444d94e8a4dd090584a8dcc313ad
LoongArch: ld: Simplify inserting IRELATIVE relocations to .rela.dyn

In LoongArch, the R_LARCH_IRELATIVE relocations for local ifunc symbols are
in .rela.dyn. Before, this is done by loongarch_elf_finish_dynamic_sections.
But this function is called after elf_link_sort_relocs, it need to find a
null slot to insert IRELATIVE relocation.

Now, it is processed by elf_loongarch_output_arch_local_syms before
elf_link_sort_relocs, just need to call loongarch_elf_append_rela to
insert IRELATIVE relocation.

bfd/ChangeLog:

* elfnn-loongarch.c (elfNN_allocate_local_ifunc_dynrelocs): Return
type change to int.
(loongarch_elf_size_dynamic_sections): Delete (void *).
(loongarch_elf_finish_dynamic_symbol): Use loongarch_elf_append_rela
insert IRELATIVE relocation to .rela.dyn.
(elfNN_loongarch_finish_local_dynamic_symbol): Return type change to
int.
(loongarch_elf_finish_dynamic_sections): Delete process of local
ifunc symbols.
(elf_backend_output_arch_local_syms): New.

ld/ChangeLog:

* testsuite/ld-loongarch-elf/local-ifunc-reloc.d: Regenerated.
bfd/elfnn-loongarch.c
ld/testsuite/ld-loongarch-elf/local-ifunc-reloc.d