]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
objtool: Check for missing annotation entries in read_annotate()
authorJosh Poimboeuf <jpoimboe@kernel.org>
Wed, 17 Sep 2025 16:03:31 +0000 (09:03 -0700)
committerJosh Poimboeuf <jpoimboe@kernel.org>
Tue, 14 Oct 2025 21:45:24 +0000 (14:45 -0700)
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>
tools/objtool/check.c

index c2e46f901a5379639d8a30551ab7928321a220b6..49d2db7c7f5b2e71a19c4e21f18fc08ffa04291c 100644 (file)
@@ -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);