Skip to content

Commit cad90e5

Browse files
npigginIngo Molnar
authored andcommitted
objtool: Tolerate STT_NOTYPE symbols at end of section
Hand-written asm often contains non-function symbols in executable sections. _end symbols for finding the size of instruction blocks for runtime processing is one such usage. optprobe_template_end is one example that causes the warning: objtool: optprobe_template_end(): can't find starting instruction This is because the symbol happens to be at the end of the file (and therefore end of a section in the object file). So ignore end-of-section STT_NOTYPE symbols instead of bailing out because an instruction can't be found. While we're here, add a more descriptive warning for STT_FUNC symbols found at the end of a section. [ This also solves a PowerPC regression reported by Sathvika Vasireddy. ] Reported-by: Naveen N. Rao <[email protected]> Reported-by: Sathvika Vasireddy <[email protected]> Signed-off-by: Nicholas Piggin <[email protected]> Signed-off-by: Ingo Molnar <[email protected]> Acked-by: Sathvika Vasireddy <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent b7bfaa7 commit cad90e5

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

tools/objtool/check.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -427,6 +427,15 @@ static int decode_instructions(struct objtool_file *file)
427427
if (func->type != STT_NOTYPE && func->type != STT_FUNC)
428428
continue;
429429

430+
if (func->offset == sec->sh.sh_size) {
431+
/* Heuristic: likely an "end" symbol */
432+
if (func->type == STT_NOTYPE)
433+
continue;
434+
WARN("%s(): STT_FUNC at end of section",
435+
func->name);
436+
return -1;
437+
}
438+
430439
if (func->return_thunk || func->alias != func)
431440
continue;
432441

0 commit comments

Comments
 (0)