[PATCH v5 01/15] objtool: Fix generic annotation infrastructure cross build

From: Christophe Leroy
Date: Wed Jan 15 2025 - 17:52:14 EST


Cross build for powerpc/32 on x86_64 leads to:

CC init/main.o
init/main.o: warning: objtool: early_randomize_kstack_offset+0xf0: Unknown annotation type: 134217728
init/main.o: warning: objtool: start_kernel+0x4a8: Unknown annotation type: 134217728
init/main.o: warning: objtool: do_one_initcall+0x178: Unknown annotation type: 134217728

Fix byte order.

Fixes: 2116b349e29a ("objtool: Generic annotation infrastructure")
Signed-off-by: Christophe Leroy <christophe.leroy@xxxxxxxxxx>
---
v5: New in v5
---
tools/objtool/check.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/objtool/check.c b/tools/objtool/check.c
index e92c5564d9ca..129c4e2245ae 100644
--- a/tools/objtool/check.c
+++ b/tools/objtool/check.c
@@ -2272,7 +2272,7 @@ static int read_annotate(struct objtool_file *file,
}

for_each_reloc(sec->rsec, reloc) {
- type = *(u32 *)(sec->data->d_buf + (reloc_idx(reloc) * sec->sh.sh_entsize) + 4);
+ type = bswap_if_needed(file->elf, *(u32 *)(sec->data->d_buf + (reloc_idx(reloc) * sec->sh.sh_entsize) + 4));

offset = reloc->sym->offset + reloc_addend(reloc);
insn = find_insn(file, reloc->sym->sec, offset);
--
2.47.0