summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJosh Poimboeuf <jpoimboe@kernel.org>2025-09-17 09:03:31 -0700
committerJosh Poimboeuf <jpoimboe@kernel.org>2025-10-14 14:45:24 -0700
commit3e4b5f66cf1a7879a081f5044ff1796aa33cb999 (patch)
tree3a665a4c05203ed2656f28e460dfa2a6c79bd225
parent4cdee7888f42f5573b380ddfa9da43208e759bdc (diff)
objtool: Check for missing annotation entries in read_annotate()
Add a sanity check to make sure none of the relocations for the .discard.annotate_insn section have gone missing. Acked-by: Petr Mladek <pmladek@suse.com> Tested-by: Joe Lawrence <joe.lawrence@redhat.com> Signed-off-by: Josh Poimboeuf <jpoimboe@kernel.org>
-rw-r--r--tools/objtool/check.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/tools/objtool/check.c b/tools/objtool/check.c
index c2e46f901a53..49d2db7c7f5b 100644
--- a/tools/objtool/check.c
+++ b/tools/objtool/check.c
@@ -2293,6 +2293,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);
type = bswap_if_needed(file->elf, type);