tools/objtool: tolerate STT_NOTYPE symbols at end of section
PATCH 1/1 tools/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.
--- tools/objtool/check.c | 9 +++++++++ 1 file changed, 9 insertions(+)
tools/objtool/check.c +9 -0
@@ -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 ;
Signature · 1 line
2.37.2
Le 20/12/2022 à 11:13, Nicholas Piggin a écrit :
Quoted 8 lines
Hand-written asm often contains non-function symbols in executable sections.
_endsymbols for finding the size of instruction blocks for runtime processing is one such usage.
optprobe_template_endis one example that causes the warning:objtool:
optprobe_template_end(): can't find starting instruction
Quoted 7 lines
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_NOTYPEsymbols instead of bailing out because an instruction can't be found. While we're here, add a more descriptive warning forSTT_FUNCsymbols found at the end of a section.
There's a patch to solve this already as far as I understand. They seem different.
See
https://patchwork.ozlabs.org/project/linuxppc-dev/patch/[email protected]/
Quoted 26 lines
Signed-off-by Nicholas Piggin <[email protected]>--- tools/objtool/check.c | 9 +++++++++ 1 file changed, 9 insertions(+)tools/objtool/check.c +9
-0@@ -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 ;
[tip: core/urgent] objtool: Tolerate STT_NOTYPE symbols at end of section
In reply to Nicholas PigginThe following commit has been merged into the core/urgent branch of tip:
The following commit has been merged into the core/urgent branch of tip:
Commit-ID: cad90e5381d840cf2296aaac9b3eff71a30b7c5b Gitweb: https://git.kernel.org/tip/cad90e5381d840cf2296aaac9b3eff71a30b7c5b Author: Nicholas Piggin <[email protected]> AuthorDate: Tue, 20 Dec 2022 20:13:23 +10:00 Committer: Ingo Molnar <[email protected]> CommitterDate: Mon, 09 Jan 2023 17:53:46 +01:00
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. ]
--- tools/objtool/check.c | 9 +++++++++ 1 file changed, 9 insertions(+)
tools/objtool/check.c +9 -0
@@ -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 ;