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

Petr Hosek via llvm-commits llvm-commits at lists.llvm.org
Mon Dec 12 18:22:01 PST 2016

On Mon, Dec 12, 2016 at 5:02 PM Rafael Avila de Espindola <
rafael.espindola at gmail.com> wrote:

> Not sure I follow why you cannot assign to '.'. If that is a limitation
> that we have, that might be what we want to change.

It's not a limitation, linker script input file is an additional input to
the linker which doesn't replace the default linker script. It should only
contains symbol definitions, INPUT, GROUP and VERSION commands (see
more details)

That should fail. That .o file has an ABS symbol, no?

No, because SHN_ABS symbol doesn't mean absolute symbol, it's the
representation for image-relative symbols in ELF. I checked this with
Roland Mcgrath (who also happened to found this bug) and this is verbatim
of what he said. I double checked this with Binutils and it's indeed how
SHN_ABS is interpreted by ld.bfd and ld.gold.

With the patch I have uploaded, lld generates the correct code:

1000:       48 8d 05 f9 ef ff ff    lea    -0x1007(%rip),%rax        # 0

So this is not really a problem with the implementation, it's really the
error message that's incorrect, or more precisely the check is stricter
than it should be (which was pointed out by Roland as well).
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20161213/9696e413/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 4843 bytes
Desc: S/MIME Cryptographic Signature
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20161213/9696e413/attachment.bin>

More information about the llvm-commits mailing list