[PATCH] x86; Allow IFUNC pointer defined in PDE

H.J. Lu hjl.tools@gmail.com
Mon May 14 11:04:00 GMT 2018
On Fri, May 11, 2018 at 2:21 PM, H.J. Lu <hjl.tools@gmail.com> wrote:
> On Fri, May 11, 2018 at 10:50 AM, H.J. Lu <hongjiu.lu@intel.com> wrote:
>> If STT_GNU_IFUNC symbol is defined in position-dependent executable, we
>> should change it to the normal function and set its address to its PLT
>> entry which should be resolved by R_*_IRELATIVE at run-time.  All
>> external references should be resolved to its PLT in executable.
>>
>> The type field is added to elf_x86_link_hash_entry to keep track of the
>> originl symbol file.  elf_x86_allocate_dynrelocs is updated to change
>> IFUNC symbol defined in PDE to FUNC and its address will be changed
>> to its PLT entry by _bfd_x86_elf_link_fixup_ifunc_symbol.
>>
>> Any comments?
>>
>>
>> H.J.
>> ---
>> bfd/
>>
>>         PR ld/23169
>>         * elf-ifunc.c (_bfd_elf_allocate_ifunc_dyn_relocs): Don't issue
>>         an error on IFUNC pointer defined in PDE.
>>         * elf32-i386.c (elf_i386_check_relocs): Copy h->type to
>>         eh->type.
>>         (elf_i386_relocate_section): Check eh->type instead of h->type.
>>         (elf_i386_finish_dynamic_symbol): Pass eh to PLT_LOCAL_IFUNC_P.
>>         Call _bfd_x86_elf_link_fixup_ifunc_symbol.  Check eh->type
>>         instead of h->type.
>>         * elf64-x86-64.c (elf_x86_64_check_relocs): Copy h->type to
>>         eh->type.
>>         (elf_x86_64_relocate_section): Check eh->type instead of h->type.
>>         (elf_x86_64_finish_dynamic_symbol): Pass eh to PLT_LOCAL_IFUNC_P.
>>         Call _bfd_x86_elf_link_fixup_ifunc_symbol.  Check eh->type
>>         instead of h->type.
>>         * elfxx-x86.c (elf_x86_allocate_dynrelocs): Change IFUNC symbol
>>         defined in PDE to FUNC.
>>         (_bfd_x86_elf_link_fixup_ifunc_symbol): New function.
>>         * elfxx-x86.h (PLT_LOCAL_IFUNC_P): Take EH instead of H.
>>         (elf_x86_link_hash_entry): Add type.
>>         (_bfd_x86_elf_link_fixup_ifunc_symbol): New.
>>
>> ld/
>>
>>         PR ld/23169
>>         * testsuite/ld-ifunc/ifunc-9-i386.d: New file.
>>         * testsuite/ld-ifunc/ifunc-9-x86-64.d: Likewise.
>>         * testsuite/ld-ifunc/pr23169a.c: Likewise.
>>         * testsuite/ld-ifunc/pr23169a.rd: Likewise.
>>         * testsuite/ld-ifunc/pr23169b.c: Likewise.
>>         * testsuite/ld-ifunc/pr23169b.c: Likewise.
>>         * testsuite/ld-ifunc/pr23169c.rd: Likewise.
>>         * testsuite/ld-ifunc/pr23169c.rd: Likewise.
>>         * testsuite/ld-ifunc/ifunc-9-x86.d: Removed.
>>         * testsuite/ld-ifunc/ifunc.exp: Run PR ld/23169 tests.
>
> I am going to check in this much simpler patch next week.
>

This is what I checked in.

-- 
H.J.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-x86-Allow-IFUNC-pointer-defined-in-PDE.patch
Type: text/x-patch
Size: 13681 bytes
Desc: not available
URL: <https://sourceware.org/pipermail/binutils/attachments/20180514/d63b0628/attachment.bin>


More information about the Binutils mailing list