Skip to content

Commit

Permalink
objtool: Fix off-by-one in symbol_by_offset()
Browse files Browse the repository at this point in the history
Sometimes, WARN_FUNC() and other users of symbol_by_offset() will
associate the first instruction of a symbol with the symbol preceding
it.  This is because symbol->offset + symbol->len is already outside of
the symbol's range.

Fixes: 2a362ec ("objtool: Optimize find_symbol_*() and read_symbols()")
Signed-off-by: Julien Thierry <jthierry@redhat.com>
Reviewed-by: Miroslav Benes <mbenes@suse.cz>
Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com>
  • Loading branch information
Julien Thierry authored and Peter Zijlstra committed Apr 22, 2020
1 parent df2b384 commit 7f9b34f
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion tools/objtool/elf.c
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ static int symbol_by_offset(const void *key, const struct rb_node *node)

if (*o < s->offset)
return -1;
if (*o > s->offset + s->len)
if (*o >= s->offset + s->len)
return 1;

return 0;
Expand Down

0 comments on commit 7f9b34f

Please sign in to comment.