From: "Rodney M. Bates" <rodney_bates@lcwb.coop>
To: Simon Marchi <simon.marchi@polymtl.ca>,
rodney.m.bates@acm.org, gdb@sourceware.org
Subject: Re: Change in relocation of debug info
Date: Thu, 3 Jun 2021 13:54:36 -0500 [thread overview]
Message-ID: <ea507af6-b9bc-ca1e-26c0-ef8d7930f223@lcwb.coop> (raw)
In-Reply-To: <83239e44-c732-7dad-56b6-b12c98dc6795@polymtl.ca>
On 5/31/21 10:08 AM, Simon Marchi via Gdb wrote:
>> When I link using gcc 5.4:
>>
>> $gcc --version:
>> gcc (Ubuntu 5.4.0-6ubuntu1~16.04.12) 5.4.0 20160609,
>>
>> giving executable named prog I see:
>>
>> $objdump -g prog
>> ...
>> /* file ../src/SetElem.m3 line 11 addr 0x4008ee */
>> ...
>
>> But when linking with gcc 9.3:
>>
>> $gcc --version:
>> gcc (Ubuntu 9.3.0-17ubuntu1~20.04) 9.3.0
>>
>> I see:
>>
>> $objdump -g prog
>> ...
>> /* file ../src/SetElem.m3 line 11 addr 0x9b1 */
>
> It just sounds like your gcc 9.3.0 is producing position-indenpendent
> executables by default, whereas your gcc 5.4.0 did not. In the recent
> years, this has become the norm.
>
> The executable produced by your gcc 5.4.0 is made to always be loaded at
> the same address, so the code at virtual address 0x4008ee in the
> executable will always end up at address 0x4008ee in the virtual address
> space of the process.
>
> With the executable produced by your gcc 9.3.0, the OS / dynamic linker
> will choose a different random base address for the executable
> every time it's loaded (except when address randomization is disabled,
> which GDB tries to do by default, then it will always be the same random
> address). So the virtual address 0x9b1 in the executable will end up at
> <load address> + 0x9b1 in the virtual address space of the process. GDB
> has to account for that: detect the load address of the executable,
> adjust the addresses of the symbols.
>
> This works for DWARF but doesn't seem to work for stabs for some reason
> (based on what you have shown, I didn't try it myself). I don't know
> how difficult it would be to make it work for stabs, but it's unlikely
> that anybody working on GDB will do it, given that stabs is pretty much
> a dead format. You can try if you want though.
>
> An alternative is to instruct your gcc 9.3.0 to produce good old
> position-dependent executables, as your gcc 5.4.0 does. This is done
> using -fno-pie at link time, IIRC.
>
> Simon
>
Thanks. Using -f=no-pie has gotten me going for now. My build process
has been supplying -fPIC for ages, to the older gcc, so I don't fully
understand why it wasn't happening all along, but this works for now.
--
Rodney Bates
rodney.m.bates@acm.org
next prev parent reply other threads:[~2021-06-03 18:55 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-05-30 17:51 Rodney M. Bates
2021-05-31 15:08 ` Simon Marchi
2021-06-03 18:54 ` Rodney M. Bates [this message]
2021-06-03 19:02 ` Simon Marchi
2021-06-03 19:41 ` Rodney M. Bates
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=ea507af6-b9bc-ca1e-26c0-ef8d7930f223@lcwb.coop \
--to=rodney_bates@lcwb.coop \
--cc=gdb@sourceware.org \
--cc=rodney.m.bates@acm.org \
--cc=simon.marchi@polymtl.ca \
/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).