[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 14:05:31 PST 2017


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).

Thanks,
-- 
-- 
Peter
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170223/30a8a36a/attachment.html>


More information about the llvm-commits mailing list