From: John Ogness <john.ogness@linutronix.de>
To: Siddhesh Poyarekar <siddhesh@sourceware.org>, libc-alpha@sourceware.org
Subject: Re: [PATCH] mtrace: Fix output with PIE and ASLR [BZ #22716]
Date: Thu, 22 Jul 2021 16:51:32 +0206 [thread overview]
Message-ID: <877dhis8z7.fsf@jogness.linutronix.de> (raw)
In-Reply-To: <39ec2ae0-c6d8-1738-ff49-52484e446a9e@sourceware.org>
On 2021-07-22, Siddhesh Poyarekar <siddhesh@sourceware.org> wrote:
> 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.
Thank you for the clarification. I forgot about non-pie. But then it
means we are always interested in l_addr. l_map_start is irrelevant.
> 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.
OK, but settings MALLOC_TRACE will cause the memory addresses to be
stored. So it is l_addr that must be subtracted for addr2line.
John Ogness
next prev parent reply other threads:[~2021-07-22 14:45 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
2021-07-22 14:45 ` John Ogness [this message]
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=877dhis8z7.fsf@jogness.linutronix.de \
--to=john.ogness@linutronix.de \
--cc=libc-alpha@sourceware.org \
--cc=siddhesh@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).