public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: "H.J. Lu" <hjl.tools@gmail.com>
To: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Cc: Szabolcs Nagy <szabolcs.nagy@arm.com>,
	Florian Weimer <fweimer@redhat.com>,
	GNU C Library <libc-alpha@sourceware.org>
Subject: Re: [PATCH v2 5/5] Linux: Consolidate auxiliary vector parsing
Date: Fri, 11 Feb 2022 06:42:48 -0800	[thread overview]
Message-ID: <CAMe9rOqObwU7wtwBUZxhUFZEV4m9ZjOo6sPiPqB9E_WpkEC1pw@mail.gmail.com> (raw)
In-Reply-To: <4d632b0d-191e-064b-d316-7614173561b7@linaro.org>

On Fri, Feb 11, 2022 at 5:49 AM Adhemerval Zanella via Libc-alpha
<libc-alpha@sourceware.org> wrote:
>
>
>
> On 11/02/2022 10:24, Szabolcs Nagy wrote:
> > The 02/11/2022 09:47, Adhemerval Zanella wrote:
> >> On 11/02/2022 09:31, Szabolcs Nagy via Libc-alpha wrote:
> >>> The 02/03/2022 12:08, Florian Weimer via Libc-alpha wrote
> >>>> +  dl_parse_auxv_t auxv_values = { 0, };
> >>>> +  _dl_parse_auxv (av, auxv_values);
> >>>
> >>> this seems to use memset now on aarch64 before irelative
> >>> relocs are resolved in static binaries.
> >>>
> >>> which causes infinite loops in the iplt (i've also seen
> >>> segfaults in the build log).
> >>>
> >>> i wonder what is a clean fix...
> >>>
> >>
> >> Maybe add inhibit_loop_to_libcall to avoid the memset call.
> >
> > does not work for me..
> > happens at -O0 too
> > https://godbolt.org/z/W9r3nffYd
>
> Yeah, this won't help much this situation.  Unless we can make gcc *not*
> emit this memset call, we will need something like:
>
> diff --git a/elf/dl-support.c b/elf/dl-support.c
> index 1977a2be76..49f3fd2a61 100644
> --- a/elf/dl-support.c
> +++ b/elf/dl-support.c
> @@ -19,6 +19,10 @@
>  /* This file defines some things that for the dynamic linker are defined in
>     rtld.c and dl-sysdep.c in ways appropriate to bootstrap dynamic linking.  */
>
> +#ifndef SHARED
> +asm ("memset = __memset_generic");
> +#endif
> +
>  #include <string.h>
>  /* Mark symbols hidden in static PIE for early self relocation to work.
>     Note: string.h may have ifuncs which cannot be hidden on i686.  */
>
>
> $ make -j24 && make test t=elf/tst-tls1-static-non-pie
> [...]
> PASS: elf/tst-tls1-static-non-pie
> original exit status 0
> set bar to 1 (LE)
> get sum of foo and bar (IE) = 1
> get sum of foo and bar (LD or TLSDESC) = 1
> get sum of foo and bar (GD or TLSDESC) = 1
>
>
> I think the best approach would to add a __memset_generic, __memcpy_generic,
> and __memmove_generic on all targets and add a header similar to
> sysdeps/generic/symbol-hacks.h to activate the redirection when required
> (to not pessimize code that would work with the IPTL generated by the
> iFUNC).

I ran into a similar problem on my CET branch.  In my case, it is memcmp.
I added a new header file, <dl-start.h>, to define functions which can be safely
used during ld.so startup:

https://gitlab.com/x86-glibc/glibc/-/commit/2bfa258b114e556ab0be68d6465b5e4fa5504e2e


--
H.J.

  reply	other threads:[~2022-02-11 14:43 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-03 11:08 [PATCH v2 0/5] Linux: Auxiliary vector parsing cleanups Florian Weimer
2022-02-03 11:08 ` [PATCH v2 1/5] elf: Merge dl-sysdep.c into the Linux version Florian Weimer
2022-02-08 20:09   ` Adhemerval Zanella
2022-02-03 11:08 ` [PATCH v2 2/5] Linux: Remove HAVE_AUX_SECURE, HAVE_AUX_XID, HAVE_AUX_PAGESIZE Florian Weimer
2022-02-08 20:11   ` Adhemerval Zanella
2022-02-03 11:08 ` [PATCH v2 3/5] Linux: Remove DL_FIND_ARG_COMPONENTS Florian Weimer
2022-02-08 20:12   ` Adhemerval Zanella
2022-02-03 11:08 ` [PATCH v2 4/5] Linux: Assume that NEED_DL_SYSINFO_DSO is always defined Florian Weimer
2022-02-08 20:13   ` Adhemerval Zanella
2022-02-03 11:08 ` [PATCH v2 5/5] Linux: Consolidate auxiliary vector parsing Florian Weimer
2022-02-08 20:19   ` Adhemerval Zanella
2022-02-08 20:34     ` Florian Weimer
2022-02-08 22:57       ` Adhemerval Zanella
2022-02-10 10:54         ` Florian Weimer
2022-02-10 11:29           ` Adhemerval Zanella
2022-02-10 11:31             ` Florian Weimer
2022-02-10 11:40               ` Adhemerval Zanella
2022-02-10 11:46                 ` Adhemerval Zanella
2022-02-11 12:31   ` Szabolcs Nagy
2022-02-11 12:47     ` Adhemerval Zanella
2022-02-11 13:24       ` Szabolcs Nagy
2022-02-11 13:48         ` Adhemerval Zanella
2022-02-11 14:42           ` H.J. Lu [this message]
2022-02-11 14:56             ` Florian Weimer
2022-02-11 13:49         ` Florian Weimer
2022-02-11 14:17           ` Adhemerval Zanella
2022-02-11 14:29             ` Szabolcs Nagy
2022-02-11 18:15               ` Adhemerval Zanella
2022-02-11 17:32     ` Florian Weimer
2022-02-11 17:49       ` Szabolcs Nagy

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=CAMe9rOqObwU7wtwBUZxhUFZEV4m9ZjOo6sPiPqB9E_WpkEC1pw@mail.gmail.com \
    --to=hjl.tools@gmail.com \
    --cc=adhemerval.zanella@linaro.org \
    --cc=fweimer@redhat.com \
    --cc=libc-alpha@sourceware.org \
    --cc=szabolcs.nagy@arm.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).