abe59f
commit 5325233313c66aea13e86f5dd59618e9dd74b510
abe59f
Author: Stefan Liebler <stli@linux.ibm.com>
abe59f
Date:   Thu Apr 7 13:59:48 2022 +0200
abe59f
abe59f
    S390: Fix elf/tst-audit25[ab]
abe59f
    
abe59f
    If glibc is configured with --disable-default-pie and build on
abe59f
    s390 with -O3, the tests elf/tst-audit25a and elf/tst-audit25b are
abe59f
    failing as there are additional la_symbind lines for free and malloc.
abe59f
    It turns out that those belong to the executable. In fact those are
abe59f
    the PLT-stubs. Furthermore la_symbind is also called for calloc and
abe59f
    realloc symbols, but those belong to libc.
abe59f
    
abe59f
    Those functions are not called at all, but dlsym'ed in
abe59f
    elf/dl-minimal.c:
abe59f
    __rtld_malloc_init_real (struct link_map *main_map)
abe59f
    {
abe59f
    ...
abe59f
      void *new_calloc = lookup_malloc_symbol (main_map, "calloc", &version);
abe59f
      void *new_free = lookup_malloc_symbol (main_map, "free", &version);
abe59f
      void *new_malloc = lookup_malloc_symbol (main_map, "malloc", &version);
abe59f
      void *new_realloc = lookup_malloc_symbol (main_map, "realloc", &version);
abe59f
    ...
abe59f
    }
abe59f
    
abe59f
    Therefore, this commit just ignored symbols with LA_SYMB_DLSYM flag.
abe59f
    Reviewed-by: Adheemrval Zanella  <adhemerval.zanella@linaro.org>
abe59f
abe59f
diff --git a/elf/tst-auditmod25.c b/elf/tst-auditmod25.c
abe59f
index 20640a8daf346b5f..0524c5aab17fabba 100644
abe59f
--- a/elf/tst-auditmod25.c
abe59f
+++ b/elf/tst-auditmod25.c
abe59f
@@ -72,7 +72,8 @@ la_symbind32 (Elf32_Sym *sym, unsigned int ndx,
abe59f
 	      unsigned int *flags, const char *symname)
abe59f
 #endif
abe59f
 {
abe59f
-  if (*refcook != -1 && *defcook != -1 && symname[0] != '\0')
abe59f
+  if (*refcook != -1 && *defcook != -1 && symname[0] != '\0'
abe59f
+      && (*flags & LA_SYMB_DLSYM) == 0)
abe59f
     fprintf (stderr, "la_symbind: %s %u\n", symname,
abe59f
 	     *flags & (LA_SYMB_NOPLTENTER | LA_SYMB_NOPLTEXIT) ? 1 : 0);
abe59f
   return sym->st_value;