objtool: Handle PC relative relocation typeFor the most part, an absolute relocation type is used for rodata.In the case of STT_SECTION, reloc->sym->offset is always zero, forthe other symbol typ
objtool: Handle PC relative relocation typeFor the most part, an absolute relocation type is used for rodata.In the case of STT_SECTION, reloc->sym->offset is always zero, forthe other symbol types, reloc_addend(reloc) is always zero, thus itcan use a simple statement "reloc->sym->offset + reloc_addend(reloc)"to obtain the symbol offset for various symbol types.When compiling on LoongArch, there exist PC relative relocation typesfor rodata, it needs to calculate the symbol offset with "S + A - PC"according to the spec of "ELF for the LoongArch Architecture".If there is only one jump table in the rodata, the "PC" is the entryaddress which is equal with the value of reloc_offset(reloc), at thistime, reloc_offset(table) is 0.If there are many jump tables in the rodata, the "PC" is the offsetof the jump table's base address which is equal with the value ofreloc_offset(reloc) - reloc_offset(table).So for LoongArch, if the relocation type is PC relative, it can use astatement "reloc_offset(reloc) - reloc_offset(table)" to get the "PC"value when calculating the symbol offset with "S + A - PC" for one ormany jump tables in the rodata.Add an arch-specific function arch_jump_table_sym_offset() to assignthe symbol offset, for the most part that is an absolute relocation,the default value is "reloc->sym->offset + reloc_addend(reloc)" inthe weak definition, it can be overridden by each architecture thathas different requirements.Link: https://github.com/loongson/la-abi-specs/blob/release/laelf.adocSigned-off-by: Tiezhu Yang <[email protected]>Link: https://lore.kernel.org/r/[email protected]Acked-by: Huacai Chen <[email protected]>Signed-off-by: Josh Poimboeuf <[email protected]>
show more ...
objtool/LoongArch: Enable objtool to be builtAdd the minimal changes to enable objtool build on LoongArch,most of the functions are stubs to only fix the build errorswhen make -C tools/objtool.
objtool/LoongArch: Enable objtool to be builtAdd the minimal changes to enable objtool build on LoongArch,most of the functions are stubs to only fix the build errorswhen make -C tools/objtool.This is similar with commit e52ec98c5ab1 ("objtool/powerpc:Enable objtool to be built on ppc").Co-developed-by: Jinyang He <[email protected]>Signed-off-by: Jinyang He <[email protected]>Co-developed-by: Youling Tang <[email protected]>Signed-off-by: Youling Tang <[email protected]>Signed-off-by: Tiezhu Yang <[email protected]>Signed-off-by: Huacai Chen <[email protected]>