lkml.org 
[lkml]   [2020]   [Apr]   [22]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
Subject[tip: objtool/urgent] objtool: Fix off-by-one in symbol_by_offset()
The following commit has been merged into the objtool/urgent branch of tip:

Commit-ID: 7f9b34f36cf6b2099f19e679a9e8315c955ef2ee
Gitweb: https://git.kernel.org/tip/7f9b34f36cf6b2099f19e679a9e8315c955ef2ee
Author: Julien Thierry <jthierry@redhat.com>
AuthorDate: Fri, 03 Apr 2020 14:17:30 +01:00
Committer: Peter Zijlstra <peterz@infradead.org>
CommitterDate: Wed, 22 Apr 2020 23:14:46 +02:00

objtool: Fix off-by-one in symbol_by_offset()

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: 2a362ecc3ec9 ("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>
---
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 09ddc8f..c4857fa 100644
--- a/tools/objtool/elf.c
+++ b/tools/objtool/elf.c
@@ -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;
\
 
 \ /
  Last update: 2020-04-23 00:26    [W:0.027 / U:0.212 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site