[committed, PATCH] x86: Properly check building shared library

H.J. Lu hjl.tools@gmail.com
Wed Feb 14 12:04:00 GMT 2018


On Tue, Feb 13, 2018 at 10:20 PM, Cary Coutant <ccoutant@gmail.com> wrote:
>> I'm curious as to why this is necessary, in case other targets need
>> the same treatment.  Normally a PIE is built from position independent
>> code, and thus addresses of functions are loaded from the GOT.  That
>> means there is no need to use any tricks to avoid dynamic text relocs.
>
> I, for one, think it is not necessary, as anywhere it's valid to treat
> the PC32 reloc as if it were a PLT32 reloc, the compiler or assembler
> could (and should) have simply used a PLT32 reloc. I think it's
> dangerous to simply assume that it's always valid to redirect any
> arbitrary PC32 reloc to a PLT entry. There's a reason these are two
> separate relocations.
>
> I also think this is likely to be unique to the x86 architecture.
>

It is normal on x86 for compiler/assembler to generate PC32 reloc and
linker to create PLT which is used as function address when we are
building non-PIE executable.  The issue is PIE.  We can't use PLT in
PIE as function address on i386 since PLT in PIE is EBX relative, which
is module specific.  But PLT on x86-64 is PC relative and PLT in PIE
can be used as function address just like PLT in non-PIE executable/

-- 
H.J.



More information about the Binutils mailing list