]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
objtool: Handle different entry size of rodata
authorTiezhu Yang <yangtiezhu@loongson.cn>
Tue, 11 Feb 2025 11:50:11 +0000 (19:50 +0800)
committerJosh Poimboeuf <jpoimboe@kernel.org>
Wed, 12 Mar 2025 22:43:38 +0000 (15:43 -0700)
In the most cases, the entry size of rodata is 8 bytes because the
relocation type is 64 bit. There are also 32 bit relocation types,
the entry size of rodata should be 4 bytes in this case.

Add an arch-specific function arch_reloc_size() to assign the entry
size of rodata for x86, powerpc and LoongArch.

Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>
Link: https://lore.kernel.org/r/20250211115016.26913-3-yangtiezhu@loongson.cn
Acked-by: Huacai Chen <chenhuacai@loongson.cn>
Signed-off-by: Josh Poimboeuf <jpoimboe@kernel.org>
tools/objtool/arch/loongarch/decode.c
tools/objtool/arch/powerpc/decode.c
tools/objtool/arch/x86/decode.c
tools/objtool/check.c
tools/objtool/include/objtool/arch.h

index 69b66994f2a1557275212bf470b413af299f74f2..b64205b89f6b468252a59f548d6011621ad81010 100644 (file)
@@ -363,3 +363,14 @@ void arch_initial_func_cfi_state(struct cfi_init_state *state)
        state->cfa.base = CFI_SP;
        state->cfa.offset = 0;
 }
+
+unsigned int arch_reloc_size(struct reloc *reloc)
+{
+       switch (reloc_type(reloc)) {
+       case R_LARCH_32:
+       case R_LARCH_32_PCREL:
+               return 4;
+       default:
+               return 8;
+       }
+}
index 53b55690f32041a4c83fcab976fab04ac21474e0..7c0bf24290675922dd9a629db1470e39e7a3f4d0 100644 (file)
@@ -106,3 +106,17 @@ void arch_initial_func_cfi_state(struct cfi_init_state *state)
        state->regs[CFI_RA].base = CFI_CFA;
        state->regs[CFI_RA].offset = 0;
 }
+
+unsigned int arch_reloc_size(struct reloc *reloc)
+{
+       switch (reloc_type(reloc)) {
+       case R_PPC_REL32:
+       case R_PPC_ADDR32:
+       case R_PPC_UADDR32:
+       case R_PPC_PLT32:
+       case R_PPC_PLTREL32:
+               return 4;
+       default:
+               return 8;
+       }
+}
index fe1362c345647e966e7f20969ae0f7720055c66e..fb9691a34d926392003d8b4b1e208f104422a812 100644 (file)
@@ -852,3 +852,16 @@ bool arch_is_embedded_insn(struct symbol *sym)
        return !strcmp(sym->name, "retbleed_return_thunk") ||
               !strcmp(sym->name, "srso_safe_ret");
 }
+
+unsigned int arch_reloc_size(struct reloc *reloc)
+{
+       switch (reloc_type(reloc)) {
+       case R_X86_64_32:
+       case R_X86_64_32S:
+       case R_X86_64_PC32:
+       case R_X86_64_PLT32:
+               return 4;
+       default:
+               return 8;
+       }
+}
index cfab4a1b1f706b7412aa8b3202a163cd84b0f6af..f762d231c747dbb256c6dc6bd1a1d37a384b77d4 100644 (file)
@@ -1969,7 +1969,7 @@ static int add_jump_table(struct objtool_file *file, struct instruction *insn,
                        break;
 
                /* Make sure the table entries are consecutive: */
-               if (prev_offset && reloc_offset(reloc) != prev_offset + 8)
+               if (prev_offset && reloc_offset(reloc) != prev_offset + arch_reloc_size(reloc))
                        break;
 
                sym_offset = reloc->sym->offset + reloc_addend(reloc);
index d63b46a19f39792cc00b7da96b005e8c71a93af9..396f7c6c81c0f824863e658aec91f636803833e1 100644 (file)
@@ -97,4 +97,6 @@ int arch_rewrite_retpolines(struct objtool_file *file);
 
 bool arch_pc_relative_reloc(struct reloc *reloc);
 
+unsigned int arch_reloc_size(struct reloc *reloc);
+
 #endif /* _ARCH_H */