On 11/26/2024 03:02 PM, Josh Poimboeuf wrote:
On Fri, Nov 22, 2024 at 12:49:58PM +0800, Tiezhu Yang wrote:
@@ -2107,8 +2112,15 @@ static int add_jump_table(struct objtool_file
*file, struct instruction *insn,
if (reloc != table && reloc == next_table)
break;
+ /* Handle the special cases compiled with Clang on LoongArch */
This comment is not helpful at all. A comment is only needed if the
code is not already obvious. In that case it should describe what is
being done and why.
Will remove it.
+ if (file->elf->ehdr.e_machine == EM_LOONGARCH &&
+ reloc_type(reloc) == R_LARCH_32_PCREL)
+ rodata_entry_size = 4;
+ else
+ rodata_entry_size = 8;
Is this really loongarch-specific or is it only related to the size of
the reloc?
This is related with the reloc type, but it may be wrong to only
check the reloc type to assign the value of rodata_entry_size,
becasue the value of reloc type for different archs may be same,
so it needs to check ehdr.e_machine and relocation type.
Can this be abstracted out to a reloc_size() function like
so?
https://git.kernel.org/pub/scm/linux/kernel/git/jpoimboe/linux.git/tree/tools/objtool/klp-diff.c?h=objtool-diff#n834
maybe it could live in elf.h.
OK, if I understand your comment correctly, this should be an
arch-specific function defined in
tools/objtool/arch/*/include/arch/elf.h, otherwise it also needs to
check ehdr.e_machine
in tools/objtool/include/objtool/elf.h.