The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: Josh Poimboeuf <jpoimboe@redhat.com>
To: NeilBrown <neilb@suse.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>,
	Ingo Molnar <mingo@kernel.org>,
	LKML <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] scripts: fix faddr2line to work on last symbol
Date: Thu, 12 Oct 2017 10:55:55 -0500	[thread overview]
Message-ID: <20171012155555.jdryge43krhsjw64@treble> (raw)
In-Reply-To: <8760blnj8j.fsf@notabene.neil.brown.name>

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@suse.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

  reply	other threads:[~2017-10-12 15:55 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-10-12  3:22 [PATCH] scripts: fix faddr2line to work on last symbol NeilBrown
2017-10-12 15:55 ` Josh Poimboeuf [this message]
2017-10-12 19:27   ` Linus Torvalds
2017-10-12 21:40   ` NeilBrown

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20171012155555.jdryge43krhsjw64@treble \
    --to=jpoimboe@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=neilb@suse.com \
    --cc=torvalds@linux-foundation.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox