[PATCH] Don't use hidden visibility in libc.a with PIE on i386

H.J. Lu hjl.tools@gmail.com
Thu Oct 5 00:17:00 GMT 2017


On 8/23/17, H.J. Lu <hjl.tools@gmail.com> wrote:
> On Wed, Aug 23, 2017 at 2:23 AM, Florian Weimer <fweimer@redhat.com> wrote:
>> On 08/23/2017 12:44 AM, H.J. Lu wrote:
>>> On i386, when multi-arch is enabled, all external functions must be
>>> called via PIC PLT in PIE, which requires setting up EBX register,
>>> since they may be IFUNC functions.
>>
>> This explanation does not make sense to me.  Could you elaborate further?
>
> When a linker detects a call to a hidden IFUNC function, foo, it will create
> a
> PLT entry and resolve
>
> call foo
>
> to
>
> call foo@PLT
>
> On i386, there are 2 kinds of PLT:
>
> 1. PLT:
>
> 080499a0 <strstr@plt>:
>  80499a0: ff 25 0c 00 22 08     jmp    *0x822000c
>  80499a6: 68 00 00 00 00       push   $0x0
>  80499ab: e9 e0 ff ff ff       jmp    8049990 <.plt>
>
> This is used for non-PIC binary since the address of GOT is fixed.
>
> 2. PIC PLT:
>
> 000178a0 <_Unwind_Find_FDE@plt>:
>    178a0: ff a3 0c 00 00 00     jmp    *0xc(%ebx)
>    178a6: 68 00 00 00 00       push   $0x0
>    178ab: e9 e0 ff ff ff       jmp    17890 <.plt>
>
> This is used for PIC binary since the address of GOT is in EBX.
>
> For non-PIC binary, it is OK to turn
>
> call foo
>
> to
>
> call foo@PLT
>
> since GOT is at the fixed address.  But for PIE, it isn't OK to
> turn
>
> call foo
>
> to
>
> call foo@PLT
>
> since PIE uses PIC PLT and EBX doesn't have the address of
> GOT.
>
>

I am checking it in.

-- 
H.J.



More information about the Libc-alpha mailing list