[tip: objtool/core] objtool: Fix interval tree insertion for zero-length symbols

tip-bot2 for Josh Poimboeuf posted 1 patch 3 months, 3 weeks ago
tools/objtool/elf.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
[tip: objtool/core] objtool: Fix interval tree insertion for zero-length symbols
Posted by tip-bot2 for Josh Poimboeuf 3 months, 3 weeks ago
The following commit has been merged into the objtool/core branch of tip:

Commit-ID:     c2a3e7af31107a2e1dff92b0601d525466dc21b7
Gitweb:        https://git.kernel.org/tip/c2a3e7af31107a2e1dff92b0601d525466dc21b7
Author:        Josh Poimboeuf <jpoimboe@kernel.org>
AuthorDate:    Wed, 17 Sep 2025 09:03:26 -07:00
Committer:     Josh Poimboeuf <jpoimboe@kernel.org>
CommitterDate: Tue, 14 Oct 2025 14:45:23 -07:00

objtool: Fix interval tree insertion for zero-length symbols

Zero-length symbols get inserted in the wrong spot.  Fix that.

Acked-by: Petr Mladek <pmladek@suse.com>
Tested-by: Joe Lawrence <joe.lawrence@redhat.com>
Signed-off-by: Josh Poimboeuf <jpoimboe@kernel.org>
---
 tools/objtool/elf.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/objtool/elf.c b/tools/objtool/elf.c
index a8a78b5..c024937 100644
--- a/tools/objtool/elf.c
+++ b/tools/objtool/elf.c
@@ -92,7 +92,7 @@ static inline unsigned long __sym_start(struct symbol *s)
 
 static inline unsigned long __sym_last(struct symbol *s)
 {
-	return s->offset + s->len - 1;
+	return s->offset + (s->len ? s->len - 1 : 0);
 }
 
 INTERVAL_TREE_DEFINE(struct symbol, node, unsigned long, __subtree_last,