This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Use libc_hidden_proto / _def for hidden wchar ifunc symbols.


On 11/13/2017 09:13 PM, H.J. Lu wrote:
On Mon, Nov 13, 2017 at 5:58 AM, H.J. Lu <hjl.tools@gmail.com> wrote:
On Mon, Nov 13, 2017 at 3:55 AM, Florian Weimer <fweimer@redhat.com> wrote:
On 11/13/2017 11:16 AM, Stefan Liebler wrote:

This patch adds the libc_hidden_proto / libc_hidden_def construct.
Then the __GI_* symbols are the default-ifunc-variants which can be called
without PLT.


attribute_hidden and *_hidden_{proto,def} conflict on some architectures.
You need to remove attribute_hidden as part of this change.

That is true.  On i686, a hidden IFUNC function inside libc.so must be compiled
with -fPIC via PLT since EBX must be loaded with GOT first.   This
isn't an issue
for x86-64 since PLT uses PC-relative addressing.  In this case, we
should remove
hidden attribute, instead of using __GI_* symbols, if we sill want to use IFUNC
inside libc.so.


BTW, i386 linker checks invalid PLT usage for IFUNC:

[hjl@gnu-6 tmp]$ cat x.s
.text
.globl bar
.type bar, @function
bar:
jmp foo
.size bar, .-bar
.hidden foo
.type foo, %gnu_indirect_function
.globl foo
foo:
ret
.size foo, .-foo
[hjl@gnu-6 tmp]$ gcc -m32 -c x.s
[hjl@gnu-6 tmp]$ ld -m elf_i386 -shared x.o
ld: x.o: unsupported non-PIC call to IFUNC `foo'
ld: final link failed: Nonrepresentable section on output
[hjl@gnu-6 tmp]$ gcc  -c x.s
[hjl@gnu-6 tmp]$ ld  -shared x.o
[hjl@gnu-6 tmp]$

since i386 uses a different relocation,  R_386_PLT32, for PLT.    We can
catch this issue at link-time.  Can you update 390 linker to do something
similar?  The relevant linker commit is


Thanks for this hint. I've forwarded this mail to Andreas Krebbel. He will have a look into binutils.

commit 74437ea28fb611d4c88077b486fd7c0a8b4c2a25
Author: H.J. Lu <hjl.tools@gmail.com>
Date:   Mon Aug 29 08:12:59 2016 -0700

     i386: Issue an error on non-PIC call to IFUNC in PIC object

     On i386, IFUNC function must be called via PLT.  Since PLT in PIC
     object uses EBX register, R_386_PLT32 relocation must be used to
     call IFUNC function even when IFUNC function is defined locally.
     Linker should issue an error when R_386_PC32 relocation is used
     to call IFUNC function.

     Since PR ld/19784 tests doesn't use PLT relocation to local IFUNC
     function, they are moved to the x86-64 test directory.

     bfd/

             PR ld/14961
             PR ld/20515
             * elf32-i386.c (elf_i386_check_relocs): Issue an error when
             R_386_PC32 relocation is used to call IFUNC function in PIC
             object.




Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]