This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [PATCHv2] Fix float128 IFUNC relocations on ppc64le [BZ #21707]
- From: "H.J. Lu" <hjl dot tools at gmail dot com>
- To: Tulio Magno Quites Machado Filho <tuliom at linux dot vnet dot ibm dot com>
- Cc: GNU C Library <libc-alpha at sourceware dot org>, Florian Weimer <fweimer at redhat dot com>, "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: Sat, 8 Jul 2017 12:30:54 -0700
- Subject: Re: [PATCHv2] Fix float128 IFUNC relocations on ppc64le [BZ #21707]
- Authentication-results: sourceware.org; auth=none
- References: <6cc4b956-0a60-73af-ea6b-08c11cbc2267@redhat.com> <20170708183113.28695-1-tuliom@linux.vnet.ibm.com>
On Sat, Jul 8, 2017 at 11:31 AM, Tulio Magno Quites Machado Filho
<tuliom@linux.vnet.ibm.com> wrote:
> Changes since version 1:
>
> - Added a testcase. This is now validating both statically and
> dynamically linked executables.
> - Fixed an issue in the $(foreach ..) in sysdeps/powerpc/powerpc64le/Makefile.
> - Added a comment to csu/libc-start.c
> - Added a comment to csu/libc-tls.c
>
> -- 8< --
>
> The patch proposed by Peter Bergner [1] to libgc in order to fix
> [BZ #21707] adds a dependency on a symbol provided by the loader,
> forcing the loader to be linked to tests after libgcc was linked.
>
> It also requires to read the thread pointer during IRELA relocations.
>
> Tested on powerpc, powerpc64, powerpc64le, s390x and x86_64.
>
> [1] https://sourceware.org/ml/libc-alpha/2017-06/msg01383.html
>
> 2017-07-08 Tulio Magno Quites Machado Filho <tuliom@linux.vnet.ibm.com>
>
> [BZ #21707]
> * csu/libc-start.c (LIBC_START_MAIN): Perform IREL{,A}
> relocations after initializing the TCB on statically linked
> executables..
> * csu/libc-tls.c (__libc_setup_tls): Add a comment about
> IREL{,A} relocations.
> * elf/Makefile (tests-static-normal): Add tst-tlsifunc-static.
> (tests): Add tst-tlsifunc.
> * elf/tst-tlsifunc.c: New file.
> * elf/tst-tlsifunc-static.c: Likewise.
> * sysdeps/powerpc/powerpc64le/Makefile (f128-loader-link): New
> variable.
> [$(subdir) = math] (test-float128% test-ifloat128%): Force
> linking to the loader after linking to libgcc.
> [$(subdir) = wcsmbs stdlib] (bug-strtod bug-strtod2 bug-strtod2)
> (tst-strtod-round tst-wcstod-round tst-strtod6 tst-strrom)
> (tst-strfrom-locale strfrom-skeleton): Likewise.
> ---
> csu/libc-start.c | 11 +++---
> csu/libc-tls.c | 2 ++
> elf/Makefile | 5 +--
> elf/tst-tlsifunc-static.c | 19 +++++++++++
> elf/tst-tlsifunc.c | 66 ++++++++++++++++++++++++++++++++++++
> sysdeps/powerpc/powerpc64le/Makefile | 10 ++++++
> 6 files changed, 107 insertions(+), 6 deletions(-)
> create mode 100644 elf/tst-tlsifunc-static.c
> create mode 100644 elf/tst-tlsifunc.c
>
> diff --git a/csu/libc-start.c b/csu/libc-start.c
> index c2dd159..84b7f99 100644
> --- a/csu/libc-start.c
> +++ b/csu/libc-start.c
> @@ -188,12 +188,15 @@ LIBC_START_MAIN (int (*main) (int, char **, char ** MAIN_AUXVEC_DECL),
>
> ARCH_INIT_CPU_FEATURES ();
>
> - /* Perform IREL{,A} relocations. */
> - apply_irel ();
> -
> /* The stack guard goes into the TCB, so initialize it early. */
> __libc_setup_tls ();
>
> + /* Perform IREL{,A} relocations.
> + Note: the relocations must happen after TLS initialization so that
> + IFUNC resolvers can benefit from thread-local storage, e.g. powerpc's
> + hwcap and platform fields available in the TCB. */
> + apply_irel ();
> +
> /* Set up the stack checker's canary. */
> uintptr_t stack_chk_guard = _dl_setup_stack_chk_guard (_dl_random);
> # ifdef THREAD_SET_STACK_GUARD
> @@ -224,7 +227,7 @@ LIBC_START_MAIN (int (*main) (int, char **, char ** MAIN_AUXVEC_DECL),
> __pointer_chk_guard_local = pointer_chk_guard;
> # endif
>
> -#endif
> +#endif /* !SHARED */
>
apply_irel should be called as early as possible. If it doesn't work for
powerpc, we should provide a generic version and powerpc can
provide a special one, I oppose changing the order in generic file.
H.J.