mirror of
https://gitee.com/open-loongarch/linux-6.12.git
synced 2026-10-25 12:37:11 +08:00
objtool: Handle PC relative relocation type
When compiling with Clang on LoongArch, there exists 32 bit PC relative relocation type, it needs to get the offset with "S + A - PC" according to the spec of "ELF for the LoongArch Architecture". This is preparation for later patch on LoongArch, there is no effect for the other archs with this patch. Link: https://github.com/loongson/la-abi-specs/blob/release/laelf.adoc Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn> Signed-off-by: Huacai Chen <chenhuacai@loongson.cn> Signed-off-by: michael <michael5hzg@gmail.com> Signed-off-by: maoxiaochuan <maoxiaochuan@loongson.cn>
This commit is contained in:
committed by
maoxiaochuan
parent
606869223f
commit
e5a48eeb78
@@ -2126,6 +2126,11 @@ static int add_jump_table(struct objtool_file *file, struct instruction *insn,
|
||||
if (reloc->sym->type == STT_SECTION) {
|
||||
/* Addend field in the relocation entry associated with the symbol */
|
||||
offset = reloc_addend(reloc);
|
||||
/* Handle the special cases compiled with Clang on LoongArch */
|
||||
if (file->elf->ehdr.e_machine == EM_LOONGARCH &&
|
||||
reloc_type(reloc) == R_LARCH_32_PCREL)
|
||||
offset = reloc->sym->offset + reloc_addend(reloc) -
|
||||
(reloc_offset(reloc) - reloc_offset(table));
|
||||
} else {
|
||||
/* The address of the symbol in the relocation entry */
|
||||
offset = reloc->sym->offset;
|
||||
|
||||
Reference in New Issue
Block a user