Re: [PATCH v5 02/10] objtool: Handle different entry size of rodata
From: Josh Poimboeuf
Date: Mon Dec 09 2024 - 14:54:20 EST
On Sat, Dec 07, 2024 at 09:59:07AM +0800, Tiezhu Yang wrote:
> +__weak unsigned int arch_reloc_size(struct reloc *reloc)
> +{
> + return 8;
> +}
Instead of making a weak function, each arch should have an explicit
definition of this function, as it's not always 8:
- x86 has R_X86_64_PC32 and R_X86_64_PLT32 which are 4 bytes.
- 32-bit powerpc
- 64-bit powerpc has R_PPC64_REL32
> @@ -1967,8 +1973,10 @@ static int add_jump_table(struct objtool_file *file, struct instruction *insn,
> if (reloc != table && reloc == next_table)
> break;
>
> + entry_size = arch_reloc_size(reloc);
> +
> /* Make sure the table entries are consecutive: */
> - if (prev_offset && reloc_offset(reloc) != prev_offset + 8)
> + if (prev_offset && reloc_offset(reloc) != prev_offset + entry_size)
> break;
No need to use a variable here, just call arch_reloc_size() directly.
--
Josh