[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20171012155555.jdryge43krhsjw64@treble>
Date: Thu, 12 Oct 2017 10:55:55 -0500
From: Josh Poimboeuf <jpoimboe@...hat.com>
To: NeilBrown <neilb@...e.com>
Cc: Linus Torvalds <torvalds@...ux-foundation.org>,
Ingo Molnar <mingo@...nel.org>,
LKML <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH] scripts: fix faddr2line to work on last symbol
On Thu, Oct 12, 2017 at 02:22:04PM +1100, NeilBrown wrote:
>
> If faddr2line is given a function name which is the
> last one listed by "nm -n", it will fail because it
> never finds the next symbol.
>
> So teach the awk script to catch that possibility,
> and use 'size' to provide the end point of the last
> function.
>
> Signed-off-by: NeilBrown <neilb@...e.com>
Thanks. I'm assuming you saw this issue with a .o file, and not with
vmlinux? Because on my vmlinux, the last symbol isn't a text symbol.
This patch is mostly ok, but it will only work if the last symbol is in
the .text section (which will probably be true in most cases).
But that makes me realize that this script has even deeper problems with
.o files.
With vmlinux, the symbols have been assigned absolute addresses, so it
makes sense to sort them by address there, and the symbol sorting works
as expected.
But with .o files, they _haven't_ been assigned absolute addresses.
Instead they just have section offsets, which is what nm prints. So
symbols in different sections will be overlaid. For example:
$ nm -n kernel/fork.o |grep "0000000000000000 [tT]"
0000000000000000 t coredump_filter_setup
0000000000000000 T get_task_mm
0000000000000000 t set_ti_thread_flag
0000000000000000 t __setup_coredump_filter_setup
0000000000000000 t __setup_str_coredump_filter_setup
Here coredump_filter_setup() is at offset 0 in .init.text,
set_ti_thread_flag() is at offset 0 in .text.text.unlikely, and
get_task_mm() is at offset 0 in .text. That confuses the script:
$ scripts/faddr2line kernel/fork.o get_task_mm+0x1
bad symbol size: base: 0x0000000000000000 end: 0x0000000000000000
We need to refactor the script a bit to be more section-aware. Instead
of nm, I think it will need to use objdump or readelf, since nm doesn't
seem to have an option for dumping the section name.
After fixing that, we can then fix the issue you found with the last
symbol.
I can give it a shot, though it may be a few weeks (probably
post-Prague).
--
Josh
Powered by blists - more mailing lists