[PATCH v3 21/64] objtool: Check for missing annotation entries in read_annotate()
From: Josh Poimboeuf
Date: Thu Jun 26 2025 - 20:00:47 EST
Add a sanity check to make sure none of the relocations for the
.discard.annotate_insn section have gone missing.
Signed-off-by: Josh Poimboeuf <jpoimboe@xxxxxxxxxx>
---
tools/objtool/check.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/tools/objtool/check.c b/tools/objtool/check.c
index b5257a959458..fe18f9f5dbef 100644
--- a/tools/objtool/check.c
+++ b/tools/objtool/check.c
@@ -2292,6 +2292,11 @@ static int read_annotate(struct objtool_file *file,
sec->sh.sh_entsize = 8;
}
+ if (sec_num_entries(sec) != sec_num_entries(sec->rsec)) {
+ ERROR("bad .discard.annotate_insn section: missing relocs");
+ return -1;
+ }
+
for_each_reloc(sec->rsec, reloc) {
type = *(u32 *)(sec->data->d_buf + (reloc_idx(reloc) * sec->sh.sh_entsize) + 4);
--
2.49.0