From: Josh Poimboeuf <jpoimboe@redhat.com>
To: Kaiwan N Billimoria <kaiwan.billimoria@gmail.com>
Cc: Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
Chi-Thanh Hoang <chithanh.hoang@gmail.com>
Subject: Re: Issue using faddr2line on kernel modules
Date: Mon, 17 Jan 2022 11:48:36 -0800 [thread overview]
Message-ID: <20220117194836.vj2rxr3wocrtdx7k@treble> (raw)
In-Reply-To: <CAPDLWs_iSrbXwfKa6CQ0f6H6GE4U88uRhaFgabRjMmSuSEpsiA@mail.gmail.com>
On Mon, Jan 17, 2022 at 10:27:14AM +0530, Kaiwan N Billimoria wrote:
> Hi there,
>
> Am researching using the cool faddr2line script to help debug Oops'es
> from kernel modules..
> I find it works just fine when used against the unstripped vmlinux
> with debug symbols.
>
> My use case is for a kernel module which Oopses, though. Here's my scenario:
> I built a module on a custom debug kernel (5.10.60) with most debug
> options enabled...
> KASLR is enabled by default as well.
>
> A test kernel module Oopses on my x86_64 guest running this kernel with:
> RIP: 0010:do_the_work+0x15b/0x174 [oops_tryv2]
>
> So, i try this:
>
> $ <...>/linux-5.10.60/scripts/faddr2line ./oops_tryv2.ko do_the_work+0x15b/0x174
> bad symbol size: base: 0x0000000000000000 end: 0x0000000000000000
> $
>
> (It works fine with addr2line though!).
> Now I think I've traced the faddr2line script's failure to locate
> anything down to this:
> ...
> done < <(${NM} -n $objfile | awk -v fn=$func -v end=$file_end '$3 ==
> fn { found=1; line =$0; start=$1; next } found == 1 { found=0;
> print line, "0x"$1 } END {if (found == 1) print line, end; }')
>
> The nm output is:
> $ nm -n ./oops_tryv2.ko |grep -i do_the_work
> 0000000000000000 t do_the_work
> $
>
> nm shows the text addr as 0x0; this is obviously incorrect (same 0x0
> with objdump -d on the module).
> Am I missing something? Any suggestions as to what I can try, to get
> faddr2line working?
Hi Kaiwan,
Thanks for reporting this issue. The module text address of 0x0 is not
necessarily incorrect, as the address is relative the the module, where
all text usually starts at zero.
I was able to recreate this problem using a module which only has a
single function in .text. Does this fix it?
diff --git a/scripts/faddr2line b/scripts/faddr2line
index 6c6439f69a72..cd6e812b9d06 100755
--- a/scripts/faddr2line
+++ b/scripts/faddr2line
@@ -111,21 +111,11 @@ __faddr2line() {
# Go through each of the object's symbols which match the func name.
# In rare cases there might be duplicates.
- file_end=$(${SIZE} -Ax $objfile | awk '$1 == ".text" {print $2}')
while read symbol; do
local fields=($symbol)
local sym_base=0x${fields[0]}
- local sym_type=${fields[1]}
- local sym_end=${fields[3]}
-
- # calculate the size
- local sym_size=$(($sym_end - $sym_base))
- if [[ -z $sym_size ]] || [[ $sym_size -le 0 ]]; then
- warn "bad symbol size: base: $sym_base end: $sym_end"
- DONE=1
- return
- fi
- sym_size=0x$(printf %x $sym_size)
+ local sym_size=0x${fields[1]}
+ local sym_type=${fields[2]}
# calculate the address
local addr=$(($sym_base + $offset))
@@ -189,7 +179,7 @@ __faddr2line() {
DONE=1
- done < <(${NM} -n $objfile | awk -v fn=$func -v end=$file_end '$3 == fn { found=1; line=$0; start=$1; next } found == 1 { found=0; print line, "0x"$1 } END {if (found == 1) print line, end; }')
+ done < <(${NM} -nS $objfile | awk -v fn=$func '$4 == fn')
}
[[ $# -lt 2 ]] && usage
next prev parent reply other threads:[~2022-01-17 19:48 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-01-17 4:57 Kaiwan N Billimoria
2022-01-17 19:48 ` Josh Poimboeuf [this message]
2022-01-17 20:27 ` Josh Poimboeuf
2022-01-18 2:40 ` Kaiwan N Billimoria
2022-01-18 17:52 ` Josh Poimboeuf
2022-01-19 3:57 ` Kaiwan N Billimoria
2022-01-19 21:21 ` Josh Poimboeuf
2022-01-19 23:43 ` Josh Poimboeuf
2022-01-20 5:14 ` Kaiwan N Billimoria
2022-01-20 17:17 ` Josh Poimboeuf
2022-01-20 20:05 ` Kaiwan N Billimoria
2022-01-27 11:24 ` Kaiwan N Billimoria
2022-02-06 20:28 ` Josh Poimboeuf
2022-02-07 2:23 ` Kaiwan N Billimoria
2022-02-11 3:31 ` Kaiwan N Billimoria
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=20220117194836.vj2rxr3wocrtdx7k@treble \
--to=jpoimboe@redhat.com \
--cc=chithanh.hoang@gmail.com \
--cc=kaiwan.billimoria@gmail.com \
--cc=linux-kernel@vger.kernel.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
all inboxes | Powered by JetHome®