From: Siddhesh Poyarekar <siddhesh@sourceware.org>
To: John Ogness <john.ogness@linutronix.de>, libc-alpha@sourceware.org
Subject: Re: [PATCH] mtrace: Fix output with PIE and ASLR [BZ #22716]
Date: Thu, 22 Jul 2021 20:01:38 +0530 [thread overview]
Message-ID: <39ec2ae0-c6d8-1738-ff49-52484e446a9e@sourceware.org> (raw)
In-Reply-To: <87a6mesai4.fsf@jogness.linutronix.de>
On 7/22/21 7:42 PM, John Ogness wrote:
> AFAIK you are only interested in @l_map_start of the link map. That is
> the first argument.
>
>> $locs{$1} = $2;
>> + $rel{$1} = hex($2) - hex($3);
>
> Subtracting @l_addr from @l_map_start will probably always result in
> 0. Why should @l_addr be interesting for mtrace?
>
l_addr is the difference between the ELF file and that in memory. For
PIC/PIE, the base address in the ELF is set at 0, so l_addr and
l_map_start is the same.
However for non-pie binaries, the base address in the ELF is non-zero,
because of which you'll see the same value in l_map_start as in the ELF,
which makes l_addr 0.
So the (l_addr - l_map_start) is 0 for PIC and PIE, but not for non-pie
executables. Adding that relative offset in the binary for addr2line
will give you the correct symbol in both pic/pie and non-pie cases.
Siddhesh
next prev parent reply other threads:[~2021-07-22 14:31 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-07-22 13:24 Siddhesh Poyarekar
2021-07-22 14:12 ` John Ogness
2021-07-22 14:31 ` Siddhesh Poyarekar [this message]
2021-07-22 14:45 ` John Ogness
2021-07-22 15:17 ` Siddhesh Poyarekar
2021-07-22 15:19 ` Siddhesh Poyarekar
2021-08-11 7:41 ` [PING][PATCH] " Siddhesh Poyarekar
2021-08-12 4:15 ` [PATCH] " DJ Delorie
2021-08-12 4:33 ` Siddhesh Poyarekar
2021-08-12 4:35 ` DJ Delorie
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=39ec2ae0-c6d8-1738-ff49-52484e446a9e@sourceware.org \
--to=siddhesh@sourceware.org \
--cc=john.ogness@linutronix.de \
--cc=libc-alpha@sourceware.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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).