Skip to content

Commit 4fab2d7

Browse files
jpoimboeingomolnar
authored andcommitted
objtool: Fix init_module() handling
If IBT is enabled and a module uses the deprecated init_module() magic function name rather than module_init(fn), its ENDBR will get removed, causing an IBT failure during module load. Objtool does print an obscure warning, but then does nothing to either correct it or return an error. Improve the usefulness of the warning and return an error so it will at least fail the build with CONFIG_OBJTOOL_WERROR. Signed-off-by: Josh Poimboeuf <jpoimboe@kernel.org> Signed-off-by: Ingo Molnar <mingo@kernel.org> Cc: Linus Torvalds <torvalds@linux-foundation.org> Link: https://lore.kernel.org/r/366bfdbe92736cde9fb01d5d3eb9b98e9070a1ec.1742852846.git.jpoimboe@kernel.org
1 parent 4759670 commit 4fab2d7

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

tools/objtool/check.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -828,8 +828,11 @@ static int create_ibt_endbr_seal_sections(struct objtool_file *file)
828828
if (opts.module && sym && sym->type == STT_FUNC &&
829829
insn->offset == sym->offset &&
830830
(!strcmp(sym->name, "init_module") ||
831-
!strcmp(sym->name, "cleanup_module")))
832-
WARN("%s(): not an indirect call target", sym->name);
831+
!strcmp(sym->name, "cleanup_module"))) {
832+
WARN("%s(): Magic init_module() function name is deprecated, use module_init(fn) instead",
833+
sym->name);
834+
return -1;
835+
}
833836

834837
if (!elf_init_reloc_text_sym(file->elf, sec,
835838
idx * sizeof(int), idx,

0 commit comments

Comments
 (0)