From: Julien Thierry Date: Fri, 3 Apr 2020 13:17:30 +0000 (+0100) Subject: objtool: Fix off-by-one in symbol_by_offset() X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=5377cae94ae31b089d4a69e7706672501c974f4d;p=linux.git 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 Reviewed-by: Miroslav Benes Signed-off-by: Josh Poimboeuf Signed-off-by: Ingo Molnar --- diff --git a/tools/objtool/elf.c b/tools/objtool/elf.c index 09ddc8f1def3c..c4857fa3f1d18 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;