This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [PATCH, 2.27] x86-64: Use IFUNC memcpy and mempcpy in libc.a
- From: "H.J. Lu" <hjl dot tools at gmail dot com>
- To: Florian Weimer <fweimer at redhat dot com>
- Cc: Tulio Magno Quites Machado Filho <tuliom at linux dot vnet dot ibm dot com>, GNU C Library <libc-alpha at sourceware dot org>, "Carlos O'Donell" <carlos at redhat dot com>, "Joseph S. Myers" <joseph at codesourcery dot com>, gftg at linux dot vnet dot ibm dot com
- Date: Wed, 2 Aug 2017 11:36:32 -0700
- Subject: Re: [PATCH, 2.27] x86-64: Use IFUNC memcpy and mempcpy in libc.a
- Authentication-results: sourceware.org; auth=none
- References: <6cc4b956-0a60-73af-ea6b-08c11cbc2267@redhat.com> <20170708183113.28695-1-tuliom@linux.vnet.ibm.com> <CAMe9rOr1YEZKXbaExp83gojA2pBsf8w=0kNB9pMwXMCzH2kA6g@mail.gmail.com> <87eftq1q2e.fsf@linux.vnet.ibm.com> <CAMe9rOoNg=UpL=R8+_M=upmANOi6XoegSMqq6auYL7oFpZk8cg@mail.gmail.com> <20170709145903.GA6521@gmail.com> <CAMe9rOpn9=_rnKHMY=TXuy+NiJndAzSPh0JAsW+Aw6f=ZSy+Jw@mail.gmail.com> <fe51dfed-9c7b-2549-967e-9cef1f0949c4@redhat.com>
On Wed, Aug 2, 2017 at 11:27 AM, Florian Weimer <fweimer@redhat.com> wrote:
> On 08/02/2017 05:53 PM, H.J. Lu wrote:
>> On Sun, Jul 9, 2017 at 7:59 AM, H.J. Lu <hjl.tools@gmail.com> wrote:
>> test-ifloat128%): Force
>>>
>>> FYI, this is the patch I am submitting for glibc 2.27.
>>
>> Any comments or objections?
>
> I have not reviewed if there are any static library initialization
> issues caused by IFUNC use for string functions, but I agree in
> principle that something like this should be possible.
>
The entry point of static executable is
STATIC int
LIBC_START_MAIN (int (*main) (int, char **, char ** MAIN_AUXVEC_DECL),
int argc, char **argv,
#ifdef LIBC_START_MAIN_AUXVEC_ARG
ElfW(auxv_t) *auxvec,
#endif
__typeof (main) init,
void (*fini) (void),
void (*rtld_fini) (void), void *stack_end)
{
/* Result of the 'main' function. */
int result;
__libc_multiple_libcs = &_dl_starting_up && !_dl_starting_up;
#ifndef SHARED
char **ev = &argv[argc + 1];
__environ = ev;
/* Store the lowest stack address. This is done in ld.so if this is
the code for the DSO. */
__libc_stack_end = stack_end;
# ifdef HAVE_AUX_VECTOR
/* First process the auxiliary vector since we need to find the
program header to locate an eventually present PT_TLS entry. */
# ifndef LIBC_START_MAIN_AUXVEC_ARG
ElfW(auxv_t) *auxvec;
{
char **evp = ev;
while (*evp++ != NULL)
;
auxvec = (ElfW(auxv_t) *) evp;
}
# endif
_dl_aux_init (auxvec);
if (GL(dl_phdr) == NULL)
# endif
{
/* Starting from binutils-2.23, the linker will define the
magic symbol __ehdr_start to point to our own ELF header
if it is visible in a segment that also includes the phdrs.
So we can set up _dl_phdr and _dl_phnum even without any
information from auxv. */
extern const ElfW(Ehdr) __ehdr_start
__attribute__ ((weak, visibility ("hidden")));
if (&__ehdr_start != NULL)
{
assert (__ehdr_start.e_phentsize == sizeof *GL(dl_phdr));
GL(dl_phdr) = (const void *) &__ehdr_start + __ehdr_start.e_phoff;
GL(dl_phnum) = __ehdr_start.e_phnum;
}
}
/* Initialize very early so that tunables can use it. */
__libc_init_secure ();
__tunables_init (__environ);
ARCH_INIT_CPU_FEATURES ();
/* Perform IREL{,A} relocations. */
ARCH_SETUP_IREL ();
If there is no memcpy/mempcpy call before ARCH_SETUP_IREL (),
we can use IFUNC memcpy and mempcpy in static executable.
Since the code path up to ARCH_SETUP_IREL () is the same for
all static executables, the static executable tests within glibc are
sufficient to verify that it is safe to do so.
--
H.J.