Commit cad90e53 authored by Nicholas Piggin's avatar Nicholas Piggin Committed by Ingo Molnar

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: default avatarNaveen N. Rao <naveen.n.rao@linux.vnet.ibm.com>
Reported-by: default avatarSathvika Vasireddy <sv@linux.ibm.com>
Signed-off-by: default avatarNicholas Piggin <npiggin@gmail.com>
Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
Acked-by: default avatarSathvika Vasireddy <sv@linux.ibm.com>
Link: https://lore.kernel.org/r/20221220101323.3119939-1-npiggin@gmail.com
parent b7bfaa76
......@@ -427,6 +427,15 @@ static int decode_instructions(struct objtool_file *file)
if (func->type != STT_NOTYPE && func->type != STT_FUNC)
continue;
if (func->offset == sec->sh.sh_size) {
/* Heuristic: likely an "end" symbol */
if (func->type == STT_NOTYPE)
continue;
WARN("%s(): STT_FUNC at end of section",
func->name);
return -1;
}
if (func->return_thunk || func->alias != func)
continue;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment