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

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

On Tue, Feb 13, 2018 at 6:11 PM, Alan Modra <amodra@gmail.com> wrote:
> On Tue, Feb 13, 2018 at 02:31:43PM -0800, H.J. Lu wrote:
>> If a symbol is not defined in a regular file, and we are not generating
>> a shared library, then set the symbol to its location in the .plt.  This
>> is required to make function pointers compare as equal between the normal
>> executable and the shared library.
> 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.

This is true in most cases.  However, you can use PC-relative relocation
to compute function address without GOT.  Here is a patch for


with testcases in assembly for i386 and x86-64.  I think you can create
similar testcases for other targets.

I will check it in tomorrow.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-x86-64-Use-PLT-address-for-PC-relative-reloc.patch
Type: text/x-patch
Size: 15021 bytes
Desc: not available
URL: <https://sourceware.org/pipermail/binutils/attachments/20180214/1a714f5f/attachment.bin>

More information about the Binutils mailing list