scripts/faddr2line: Fix overlapping text section failures
authorJosh Poimboeuf <jpoimboe@kernel.org>
Thu, 12 May 2022 19:05:27 +0000 (12:05 -0700)
committerJosh Poimboeuf <jpoimboe@kernel.org>
Thu, 12 May 2022 19:07:11 +0000 (12:07 -0700)
commit1d1a0e7c5100d332583e20b40aa8c0a8ed3d7849
tree1ada91ac522b2eb0e689614dc8b48fc646bb6fce
parent21e350233b07619dbfc3ce606ff1fc468fce2d82
scripts/faddr2line: Fix overlapping text section failures

There have been some recent reports of faddr2line failures:

  $ scripts/faddr2line sound/soundcore.ko sound_devnode+0x5/0x35
  bad symbol size: base: 0x0000000000000000 end: 0x0000000000000000

  $ ./scripts/faddr2line vmlinux.o enter_from_user_mode+0x24
  bad symbol size: base: 0x0000000000005fe0 end: 0x0000000000005fe0

The problem is that faddr2line is based on 'nm', which has a major
limitation: it doesn't know how to distinguish between different text
sections.  So if an offset exists in multiple text sections in the
object, it may fail.

Rewrite faddr2line to be section-aware, by basing it on readelf.

Fixes: 67326666e2d4 ("scripts: add script for translating stack dump function offsets")
Reported-by: Kaiwan N Billimoria <kaiwan.billimoria@gmail.com>
Reported-by: Peter Zijlstra <peterz@infradead.org>
Signed-off-by: Josh Poimboeuf <jpoimboe@kernel.org>
Link: https://lore.kernel.org/r/29ff99f86e3da965b6e46c1cc2d72ce6528c17c3.1652382321.git.jpoimboe@kernel.org
scripts/faddr2line