This is the mail archive of the
mailing list for the binutils project.
Re: [committed, PATCH] x86: Properly check building shared library
- From: "H.J. Lu" <hjl dot tools at gmail dot com>
- To: Cary Coutant <ccoutant at gmail dot com>
- Cc: Alan Modra <amodra at gmail dot com>, Binutils <binutils at sourceware dot org>
- Date: Wed, 14 Feb 2018 04:04:11 -0800
- Subject: Re: [committed, PATCH] x86: Properly check building shared library
- Authentication-results: sourceware.org; auth=none
- References: <20180213223129.GA30801@gmail.com> <20180214021119.GI30218@bubble.grove.modra.org> <CAJimCsE1znEvD=18pFaPFZdEruACViYj7Wf39ThS61AyWS0P6w@mail.gmail.com>
On Tue, Feb 13, 2018 at 10:20 PM, Cary Coutant <email@example.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/