public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: "H.J. Lu" <hjl.tools@gmail.com>
To: Stefan Liebler <stli@linux.vnet.ibm.com>
Cc: GNU C Library <libc-alpha@sourceware.org>
Subject: Re: [PATCH] Use libc_hidden_proto / _def for hidden wchar ifunc symbols.
Date: Tue, 14 Nov 2017 13:09:00 -0000	[thread overview]
Message-ID: <CAMe9rOqST8NrwA9kZR-Z8z_twR6RecOLxT6g=N4wqYcWF6pKhw@mail.gmail.com> (raw)
In-Reply-To: <b437479a-5279-57a3-9df0-53d21fec0638@linux.vnet.ibm.com>

On Tue, Nov 14, 2017 at 4:45 AM, Stefan Liebler <stli@linux.vnet.ibm.com> wrote:
> 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.

BTW, it will only be possible on binutils master branch where I changed
ELF linker to call check_relocs after we have seen all linker inputs.

>
>> 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.
>>
>>
>



-- 
H.J.

  reply	other threads:[~2017-11-14 13:09 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-13 10:16 Stefan Liebler
2017-11-13 11:55 ` Florian Weimer
2017-11-13 13:58   ` H.J. Lu
2017-11-13 17:12     ` Stefan Liebler
2017-11-13 17:30       ` H.J. Lu
2017-11-14 12:45         ` Stefan Liebler
2017-11-20 15:51         ` Stefan Liebler
2017-11-20 15:59           ` H.J. Lu
2017-11-21  7:48             ` Stefan Liebler
2017-11-13 20:13     ` H.J. Lu
2017-11-14 12:45       ` Stefan Liebler
2017-11-14 13:09         ` H.J. Lu [this message]
2017-11-14 13:12     ` Florian Weimer
2017-11-13 17:12   ` Stefan Liebler

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAMe9rOqST8NrwA9kZR-Z8z_twR6RecOLxT6g=N4wqYcWF6pKhw@mail.gmail.com' \
    --to=hjl.tools@gmail.com \
    --cc=libc-alpha@sourceware.org \
    --cc=stli@linux.vnet.ibm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).