[PATCH] D26133: [ELF] Allow relative relocations to absolute symbols in PIC

Peter Collingbourne via llvm-commits llvm-commits at lists.llvm.org
Thu Feb 23 16:14:25 PST 2017

On Thu, Feb 23, 2017 at 2:05 PM, Peter Collingbourne <peter at pcc.me.uk>

> On Tue, Dec 13, 2016 at 9:29 AM, Rafael Avila de Espindola <
> rafael.espindola at gmail.com> wrote:
>> Peter Collingbourne <peter at pcc.me.uk> writes:
>> > Should this not work for referring to the image base?
>> >
>> > ADDR(.interp) - ABSOLUTE(ADDR(.interp))
>> >
>> > The advantage is that this avoids creating new syntax so is already
>> > somewhat compatible with existing linkers. The downside is that you
>> need to
>> > specify a section, but in practice you can usually choose one that is
>> known
>> > to exist.
>> >
>> > I don't think we currently create a section relative symbol from that,
>> but
>> > that's just a bug we can fix.
>> Yes, that looks better than having a new magic variable.
> Today I discovered that both bfd and gold predefine a symbol named
> __executable_start which resolves to the image base. If we do the same we
> can simply allow users to use that symbol to refer to the image base
> (either directly or in a linker script).

My mistake, this is in fact the start of the executable segment, which does
not correspond to the image base in non-PIC executables.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170223/713d8f79/attachment.html>

More information about the llvm-commits mailing list