[RFC 25/31] objtool: Fix interval tree insertion for zero-length symbols

Josh Poimboeuf
2024-09-03T04:00:42Z

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

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 49528e7835aa..42a657268306 100644
--- a/tools/objtool/elf.c
+++ b/tools/objtool/elf.c
@@ -94,7 +94,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,
--
2.45.2