[PATCH] D26133: [ELF] Allow relative relocations to absolute symbols in PIC
Petr Hosek via llvm-commits
llvm-commits at lists.llvm.org
Wed Mar 8 19:10:49 PST 2017
I've modified the linker script parser to support ABSOLUTE on the right
hand side, I can upload the patch to Phabricator.
On Wed, Mar 8, 2017 at 6:21 PM Rui Ueyama <ruiu at google.com> wrote:
> On Wed, Mar 8, 2017 at 3:45 PM, Petr Hosek <phosek at google.com> wrote:
>
> On Wed, Mar 8, 2017 at 10:52 AM Cary Coutant <ccoutant at gmail.com> wrote:
>
> No, symbols in an ET_EXEC or ET_DYN object always have
> already-relocated values. The section index is irrelevant other than
> to indicate that the symbol is not absolute or undefined. That's the
> point of the paragraph I quoted from the end of the symbol table
> chapter from the ELF spec. In gold, I try to find a section that
> belongs to the segment that the symbol is associated with, but setting
> st_shndx to 1 would be just as effective.
>
>
> I think this is an issue in LLD. I started experimenting with the solution
> proposed by Peter which is to replace that linker script with:
>
> PROVIDE_HIDDEN(_base = ADDR(.text) - ABSOLUTE(ADDR(.text)));
>
>
> Does this even parse? I believe LLD accepts ABSOLUTE() only immediately
> after an assignment operator.
>
>
> In LLD, this symbol would be processed as a synthetic symbol with value 0
> and .text section, which is correct. The problem is that LLD assumes that
> all synthetic symbols are section relative, so when emitting that symbol,
> LLD would adjust its address by the address of .text, so the final value is
> going to be whatever the .text address is rather than image base.
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170309/7c1bf72f/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/20170309/7c1bf72f/attachment.bin>
More information about the llvm-commits
mailing list