]> git.baikalelectronics.ru Git - kernel.git/commit
objtool: Don't add empty symbols to the rbtree
authorJosh Poimboeuf <jpoimboe@redhat.com>
Wed, 6 Jan 2021 00:04:20 +0000 (18:04 -0600)
committerJosh Poimboeuf <jpoimboe@redhat.com>
Wed, 13 Jan 2021 22:56:37 +0000 (16:56 -0600)
commitd08bd6587d5807973780e08c105fdfa849cda00e
treea6d15a482a91cce57a892c957f195687b74c159a
parent23a2b9809c00c14636d193186909bff30026c39d
objtool: Don't add empty symbols to the rbtree

Building with the Clang assembler shows the following warning:

  arch/x86/kernel/ftrace_64.o: warning: objtool: missing symbol for insn at offset 0x16

The Clang assembler strips section symbols.  That ends up giving
objtool's find_func_containing() much more test coverage than normal.
Turns out, find_func_containing() doesn't work so well for overlapping
symbols:

     2: 000000000000000e     0 NOTYPE  LOCAL  DEFAULT    2 fgraph_trace
     3: 000000000000000f     0 NOTYPE  LOCAL  DEFAULT    2 trace
     4: 0000000000000000   165 FUNC    GLOBAL DEFAULT    2 __fentry__
     5: 000000000000000e     0 NOTYPE  GLOBAL DEFAULT    2 ftrace_stub

The zero-length NOTYPE symbols are inside __fentry__(), confusing the
rbtree search for any __fentry__() offset coming after a NOTYPE.

Try to avoid this problem by not adding zero-length symbols to the
rbtree.  They're rare and aren't needed in the rbtree anyway.

One caveat, this actually might not end up being the right fix.
Non-empty overlapping symbols, if they exist, could have the same
problem.  But that would need bigger changes, let's see if we can get
away with the easy fix for now.

Reported-by: Arnd Bergmann <arnd@kernel.org>
Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com>
tools/objtool/elf.c