diff options
| author | Josh Poimboeuf <jpoimboe@kernel.org> | 2025-09-17 09:03:27 -0700 |
|---|---|---|
| committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2026-01-11 15:21:13 +0100 |
| commit | a8fdcac66666cabe80266d5b5f1e33e9c462ec10 (patch) | |
| tree | 12f9769a4ace73a70959454eb6c2785b23ab3dab /tools/objtool/elf.c | |
| parent | fe6ff6e24ae80577b7ddf5a51587cdf1a4691996 (diff) | |
| download | linux-a8fdcac66666cabe80266d5b5f1e33e9c462ec10.tar.gz linux-a8fdcac66666cabe80266d5b5f1e33e9c462ec10.tar.bz2 linux-a8fdcac66666cabe80266d5b5f1e33e9c462ec10.zip | |
objtool: Fix weak symbol detection
[ Upstream commit 72567c630d32bc31f671977f78228c80937ed80e ]
find_symbol_hole_containing() fails to find a symbol hole (aka stripped
weak symbol) if its section has no symbols before the hole. This breaks
weak symbol detection if -ffunction-sections is enabled.
Fix that by allowing the interval tree to contain section symbols, which
are always at offset zero for a given section.
Fixes a bunch of (-ffunction-sections) warnings like:
vmlinux.o: warning: objtool: .text.__x64_sys_io_setup+0x10: unreachable instruction
Fixes: 4adb23686795 ("objtool: Ignore extra-symbol code")
Acked-by: Petr Mladek <pmladek@suse.com>
Tested-by: Joe Lawrence <joe.lawrence@redhat.com>
Signed-off-by: Josh Poimboeuf <jpoimboe@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'tools/objtool/elf.c')
| -rw-r--r-- | tools/objtool/elf.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/tools/objtool/elf.c b/tools/objtool/elf.c index 081befa4674b..797507a90251 100644 --- a/tools/objtool/elf.c +++ b/tools/objtool/elf.c @@ -110,7 +110,7 @@ struct symbol_hole { }; /* - * Find !section symbol where @offset is after it. + * Find the last symbol before @offset. */ static int symbol_hole_by_offset(const void *key, const struct rb_node *node) { @@ -121,8 +121,7 @@ static int symbol_hole_by_offset(const void *key, const struct rb_node *node) return -1; if (sh->key >= s->offset + s->len) { - if (s->type != STT_SECTION) - sh->sym = s; + sh->sym = s; return 1; } @@ -410,7 +409,8 @@ static void elf_add_symbol(struct elf *elf, struct symbol *sym) sym->len = sym->sym.st_size; __sym_for_each(iter, &sym->sec->symbol_tree, sym->offset, sym->offset) { - if (iter->offset == sym->offset && iter->type == sym->type) + if (iter->offset == sym->offset && iter->type == sym->type && + iter->len == sym->len) iter->alias = sym; } |
