diff mbox series

[RFC,v5,14/57] objtool: Do not look for STT_NOTYPE symbols

Message ID 20200109160300.26150-15-jthierry@redhat.com (mailing list archive)
State New, archived
Headers show
Series objtool: Add support for arm64 | expand

Commit Message

Julien Thierry Jan. 9, 2020, 4:02 p.m. UTC
ELF symbols can have type STT_NOTYPE which have no standard semantics.

Arm64 objects will contain STT_NOTYPE symbols at the beginning of each
section which aren't of any use to generic objtool code. Those symbols
unfortunately overlap with the first function of the section.

Skip symbols with type STT_NOTYPE when looking up symbols.

Suggested-by: Raphael Gault <raphael.gault@arm.com>
Signed-off-by: Julien Thierry <jthierry@redhat.com>
---
 tools/objtool/elf.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Julien Thierry Jan. 13, 2020, 10:20 a.m. UTC | #1
On 1/9/20 4:02 PM, Julien Thierry wrote:
> ELF symbols can have type STT_NOTYPE which have no standard semantics.
> 
> Arm64 objects will contain STT_NOTYPE symbols at the beginning of each
> section which aren't of any use to generic objtool code. Those symbols
> unfortunately overlap with the first function of the section.
> 
> Skip symbols with type STT_NOTYPE when looking up symbols.
> 

Turns out some x86 callable objects have STT_NOTYPE (in the current case 
error_entry in arch/x86/entry/entry_64.S, and it seems to be the case 
for all asm symbols annotated with SYM_CODE_START_LOCAL).

A solution that works both for x86 and arm64 is that if the symbol has 
STT_NOTYPE, continue looking for another symbol at the same offset. If 
none is available, return the STT_NOTYPE symbol.

I'll fix that in next iteration.

> Suggested-by: Raphael Gault <raphael.gault@arm.com>
> Signed-off-by: Julien Thierry <jthierry@redhat.com>
> ---
>   tools/objtool/elf.c | 3 ++-
>   1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/tools/objtool/elf.c b/tools/objtool/elf.c
> index edba4745f25a..c6ac0b771b73 100644
> --- a/tools/objtool/elf.c
> +++ b/tools/objtool/elf.c
> @@ -62,7 +62,8 @@ struct symbol *find_symbol_by_offset(struct section *sec, unsigned long offset)
>   	struct symbol *sym;
>   
>   	list_for_each_entry(sym, &sec->symbol_list, list)
> -		if (sym->type != STT_SECTION &&
> +		if (sym->type != STT_NOTYPE &&
> +		    sym->type != STT_SECTION &&
>   		    sym->offset == offset)
>   			return sym;
>   
>
diff mbox series

Patch

diff --git a/tools/objtool/elf.c b/tools/objtool/elf.c
index edba4745f25a..c6ac0b771b73 100644
--- a/tools/objtool/elf.c
+++ b/tools/objtool/elf.c
@@ -62,7 +62,8 @@  struct symbol *find_symbol_by_offset(struct section *sec, unsigned long offset)
 	struct symbol *sym;
 
 	list_for_each_entry(sym, &sec->symbol_list, list)
-		if (sym->type != STT_SECTION &&
+		if (sym->type != STT_NOTYPE &&
+		    sym->type != STT_SECTION &&
 		    sym->offset == offset)
 			return sym;