public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] S390: Fix elf/tst-audit25[ab]
@ 2022-04-07 11:59 Stefan Liebler
  2022-04-07 13:36 ` Adhemerval Zanella
  0 siblings, 1 reply; 3+ messages in thread
From: Stefan Liebler @ 2022-04-07 11:59 UTC (permalink / raw)
  To: libc-alpha; +Cc: Stefan Liebler

If glibc is configured with --disable-default-pie and build on
s390 with -O3, the tests elf/tst-audit25a and elf/tst-audit25b are
failing as there are additional la_symbind lines for free and malloc.
It turns out that those belong to the executable. In fact those are
the PLT-stubs. Furthermore la_symbind is also called for calloc and
realloc symbols, but those belong to libc.

Those functions are not called at all, but dlsym'ed in
elf/dl-minimal.c:
__rtld_malloc_init_real (struct link_map *main_map)
{
...
  void *new_calloc = lookup_malloc_symbol (main_map, "calloc", &version);
  void *new_free = lookup_malloc_symbol (main_map, "free", &version);
  void *new_malloc = lookup_malloc_symbol (main_map, "malloc", &version);
  void *new_realloc = lookup_malloc_symbol (main_map, "realloc", &version);
...
}

Therefore, this commit just ignored symbols with LA_SYMB_DLSYM flag.
---
 elf/tst-auditmod25.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/elf/tst-auditmod25.c b/elf/tst-auditmod25.c
index 20640a8daf..0524c5aab1 100644
--- a/elf/tst-auditmod25.c
+++ b/elf/tst-auditmod25.c
@@ -72,7 +72,8 @@ la_symbind32 (Elf32_Sym *sym, unsigned int ndx,
 	      unsigned int *flags, const char *symname)
 #endif
 {
-  if (*refcook != -1 && *defcook != -1 && symname[0] != '\0')
+  if (*refcook != -1 && *defcook != -1 && symname[0] != '\0'
+      && (*flags & LA_SYMB_DLSYM) == 0)
     fprintf (stderr, "la_symbind: %s %u\n", symname,
 	     *flags & (LA_SYMB_NOPLTENTER | LA_SYMB_NOPLTEXIT) ? 1 : 0);
   return sym->st_value;
-- 
2.35.1


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] S390: Fix elf/tst-audit25[ab]
  2022-04-07 11:59 [PATCH] S390: Fix elf/tst-audit25[ab] Stefan Liebler
@ 2022-04-07 13:36 ` Adhemerval Zanella
  2022-04-07 13:51   ` Stefan Liebler
  0 siblings, 1 reply; 3+ messages in thread
From: Adhemerval Zanella @ 2022-04-07 13:36 UTC (permalink / raw)
  To: libc-alpha



On 07/04/2022 08:59, Stefan Liebler via Libc-alpha wrote:
> If glibc is configured with --disable-default-pie and build on
> s390 with -O3, the tests elf/tst-audit25a and elf/tst-audit25b are
> failing as there are additional la_symbind lines for free and malloc.
> It turns out that those belong to the executable. In fact those are
> the PLT-stubs. Furthermore la_symbind is also called for calloc and
> realloc symbols, but those belong to libc.
> 
> Those functions are not called at all, but dlsym'ed in
> elf/dl-minimal.c:
> __rtld_malloc_init_real (struct link_map *main_map)
> {
> ...
>   void *new_calloc = lookup_malloc_symbol (main_map, "calloc", &version);
>   void *new_free = lookup_malloc_symbol (main_map, "free", &version);
>   void *new_malloc = lookup_malloc_symbol (main_map, "malloc", &version);
>   void *new_realloc = lookup_malloc_symbol (main_map, "realloc", &version);
> ...
> }
> 
> Therefore, this commit just ignored symbols with LA_SYMB_DLSYM flag.

LGTM, thank.  Why don't we see in other configuration and/or architecture?
What s390 is doing different here?

Reviewed-by: Adheemrval Zanella  <adhemerval.zanella@linaro.org>

> ---
>  elf/tst-auditmod25.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/elf/tst-auditmod25.c b/elf/tst-auditmod25.c
> index 20640a8daf..0524c5aab1 100644
> --- a/elf/tst-auditmod25.c
> +++ b/elf/tst-auditmod25.c
> @@ -72,7 +72,8 @@ la_symbind32 (Elf32_Sym *sym, unsigned int ndx,
>  	      unsigned int *flags, const char *symname)
>  #endif
>  {
> -  if (*refcook != -1 && *defcook != -1 && symname[0] != '\0')
> +  if (*refcook != -1 && *defcook != -1 && symname[0] != '\0'
> +      && (*flags & LA_SYMB_DLSYM) == 0)
>      fprintf (stderr, "la_symbind: %s %u\n", symname,
>  	     *flags & (LA_SYMB_NOPLTENTER | LA_SYMB_NOPLTEXIT) ? 1 : 0);
>    return sym->st_value;

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] S390: Fix elf/tst-audit25[ab]
  2022-04-07 13:36 ` Adhemerval Zanella
@ 2022-04-07 13:51   ` Stefan Liebler
  0 siblings, 0 replies; 3+ messages in thread
From: Stefan Liebler @ 2022-04-07 13:51 UTC (permalink / raw)
  To: libc-alpha

On 07/04/2022 15:36, Adhemerval Zanella via Libc-alpha wrote:
> 
> 
> On 07/04/2022 08:59, Stefan Liebler via Libc-alpha wrote:
>> If glibc is configured with --disable-default-pie and build on
>> s390 with -O3, the tests elf/tst-audit25a and elf/tst-audit25b are
>> failing as there are additional la_symbind lines for free and malloc.
>> It turns out that those belong to the executable. In fact those are
>> the PLT-stubs. Furthermore la_symbind is also called for calloc and
>> realloc symbols, but those belong to libc.
>>
>> Those functions are not called at all, but dlsym'ed in
>> elf/dl-minimal.c:
>> __rtld_malloc_init_real (struct link_map *main_map)
>> {
>> ...
>>   void *new_calloc = lookup_malloc_symbol (main_map, "calloc", &version);
>>   void *new_free = lookup_malloc_symbol (main_map, "free", &version);
>>   void *new_malloc = lookup_malloc_symbol (main_map, "malloc", &version);
>>   void *new_realloc = lookup_malloc_symbol (main_map, "realloc", &version);
>> ...
>> }
>>
>> Therefore, this commit just ignored symbols with LA_SYMB_DLSYM flag.
> 
> LGTM, thank.  Why don't we see in other configuration and/or architecture?
> What s390 is doing different here?
> 
> Reviewed-by: Adheemrval Zanella  <adhemerval.zanella@linaro.org>
> 

Thanks.
Then I'll commit the patch.

You are right I have not seen it on x86_64. Perhaps it triggers
something in s390x-code in ld regarding -Bsymbolic and
pointer-equality-reasons. But this is only a guess.

Thanks,
Stefan

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-04-07 13:51 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-07 11:59 [PATCH] S390: Fix elf/tst-audit25[ab] Stefan Liebler
2022-04-07 13:36 ` Adhemerval Zanella
2022-04-07 13:51   ` Stefan Liebler

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