[PATCH 01/15] objtool: Find a destination for jumps beyond the section end
From: Sami Tolvanen
Date: Fri Apr 16 2021 - 16:38:54 EST
With -ffunction-sections, Clang can generate a jump beyond the end of
a section when the section ends in an unreachable instruction. If the
offset matches the section length, use the last instruction as the
jump destination.
Signed-off-by: Sami Tolvanen <samitolvanen@xxxxxxxxxx>
---
tools/objtool/check.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/tools/objtool/check.c b/tools/objtool/check.c
index a0a8ce61cd4d..5fd60e055a5c 100644
--- a/tools/objtool/check.c
+++ b/tools/objtool/check.c
@@ -870,6 +870,10 @@ static int add_jump_destinations(struct objtool_file *file)
}
insn->jump_dest = find_insn(file, dest_sec, dest_off);
+
+ if (!insn->jump_dest && dest_sec->len == dest_off)
+ insn->jump_dest = find_last_insn(file, dest_sec);
+
if (!insn->jump_dest) {
/*
--
2.31.1.368.gbe11c130af-goog