On Wed, Dec 11, 2024 at 11:16:33AM +0800, Tiezhu Yang wrote:
When compiling on LoongArch, there are some PC relative relocation types
for rodata, it needs to calculate the symbol offset with "S + A - PC" in
this case according to the spec of "ELF for the LoongArch Architecture",
the "PC" is the index of each jump table which is equal with the value
of reloc_offset(reloc) - reloc_offset(table).
I will add the above description to the commit message to make it clear.
I understand how PC-relative addressing works.
The oddity here is that "PC" is the jump table's base address rather
than the entry address.
That has nothing to do with the ELF spec or
even how R_LARCH_32_PCREL is implemented. Rather it seems to be a quirk
related to how loongarch jump table code expects the entries to be.
So the arch_adjust_offset() name seems wrong, as this is specific to
the jump table implementation, rather than relocs in general.
Instead call it arch_jump_table_sym_offset()?