public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] powerpc: Use the correct flag for 32-bit known libraries
@ 2021-10-22 21:12 Lucas A. M. Magalhaes
  2021-10-25 18:22 ` Florian Weimer
  2021-11-04 18:10 ` [PATCH] powerpc: Use FLAG_ELF_LIBC6 for 32-bit known libraries Lucas A. M. Magalhaes
  0 siblings, 2 replies; 15+ messages in thread
From: Lucas A. M. Magalhaes @ 2021-10-22 21:12 UTC (permalink / raw)
  To: libc-alpha; +Cc: tuliom

In systems with more versions of the known libraries, i.e. on IBM
Advance Toolchain, ldconfig will order them incorrectly on ld.cache.

The issue only occurs with 32-bit libraries that don't depend on libc or
libm. That's because process_elf32_file check if the elf depends on one
of the libraries at known_libs to select the elf flag. For example, as
libc.so.6 don't depend on itself or on libm it will be flagged as
FLAG_ELF instead of FLAG_LIBC6 as expected.

This commit fixes this by checking if a appropriate flag was set by
process_elf32_file. If not it will search on known_libs and use the flag
in there.
---
 sysdeps/unix/sysv/linux/powerpc/readelflib.c | 21 +++++++++++++++++---
 1 file changed, 18 insertions(+), 3 deletions(-)

diff --git a/sysdeps/unix/sysv/linux/powerpc/readelflib.c b/sysdeps/unix/sysv/linux/powerpc/readelflib.c
index 51f8a9496a..94da21c407 100644
--- a/sysdeps/unix/sysv/linux/powerpc/readelflib.c
+++ b/sysdeps/unix/sysv/linux/powerpc/readelflib.c
@@ -33,11 +33,26 @@ process_elf_file (const char *file_name, const char *lib, int *flag,
 		  char **soname, void *file_contents, size_t file_length)
 {
   ElfW(Ehdr) *elf_header = (ElfW(Ehdr) *) file_contents;
-  int ret;
+  int ret, j;
 
   if (elf_header->e_ident [EI_CLASS] == ELFCLASS32)
-    return process_elf32_file (file_name, lib, flag, osversion, isa_level,
-			       soname, file_contents, file_length);
+    {
+      ret = process_elf32_file (file_name, lib, flag, osversion, isa_level,
+                                soname, file_contents, file_length);
+      /* Use the apropriate flag for known_libs instead of FLAG_ELF.  */
+      if (*flag == FLAG_ELF)
+        {
+          for (j = 0;
+               j < sizeof (known_libs) / sizeof (known_libs [0]);
+               ++j)
+            if (strcmp (lib, known_libs [j].soname) == 0)
+              {
+                *flag = known_libs [j].flag;
+                break;
+              }
+        }
+      return ret;
+    }
   else
     {
       ret = process_elf64_file (file_name, lib, flag, osversion, isa_level,
-- 
2.31.1


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

* Re: [PATCH] powerpc: Use the correct flag for 32-bit known libraries
  2021-10-22 21:12 [PATCH] powerpc: Use the correct flag for 32-bit known libraries Lucas A. M. Magalhaes
@ 2021-10-25 18:22 ` Florian Weimer
  2021-12-22 15:31   ` [RFC] Remove special flags of libc.5.so and libc.4.so Lucas A. M. Magalhaes
  2021-11-04 18:10 ` [PATCH] powerpc: Use FLAG_ELF_LIBC6 for 32-bit known libraries Lucas A. M. Magalhaes
  1 sibling, 1 reply; 15+ messages in thread
From: Florian Weimer @ 2021-10-25 18:22 UTC (permalink / raw)
  To: Lucas A. M. Magalhaes via Libc-alpha; +Cc: Lucas A. M. Magalhaes, tuliom

* Lucas A. M. Magalhaes via Libc-alpha:

> In systems with more versions of the known libraries, i.e. on IBM
> Advance Toolchain, ldconfig will order them incorrectly on ld.cache.
>
> The issue only occurs with 32-bit libraries that don't depend on libc or
> libm. That's because process_elf32_file check if the elf depends on one
> of the libraries at known_libs to select the elf flag. For example, as
> libc.so.6 don't depend on itself or on libm it will be flagged as
> FLAG_ELF instead of FLAG_LIBC6 as expected.

FLAG_ELF_LIBC6 instead of FLAG_LIBC6.

I have not looked at this patch in detail.  I would prefer if we removed
unified cache support for libc.so.4, libc.so.5 and always wrote
FLAG_ELF_LIBC6 to the cache instead.  The older Linux libcs have been
obsolete for more than twenty years.  I do not know how much work this
would be, so if someone can review your patch and it can go in, that's
fine with me.

Thanks,
Florian


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

* [PATCH] powerpc: Use FLAG_ELF_LIBC6 for 32-bit known libraries
  2021-10-22 21:12 [PATCH] powerpc: Use the correct flag for 32-bit known libraries Lucas A. M. Magalhaes
  2021-10-25 18:22 ` Florian Weimer
@ 2021-11-04 18:10 ` Lucas A. M. Magalhaes
  2021-12-03 12:40   ` Lucas A. M. Magalhaes
                     ` (3 more replies)
  1 sibling, 4 replies; 15+ messages in thread
From: Lucas A. M. Magalhaes @ 2021-11-04 18:10 UTC (permalink / raw)
  To: libc-alpha; +Cc: tuliom, fweimer

In systems with more versions of the known libraries, i.e. on IBM
Advance Toolchain, ldconfig will order them incorrectly on ld.cache.

The issue only occurs with 32-bit libraries that don't depend on libc or
libm. That's because process_elf32_file check if the elf depends on one
of the libraries at known_libs to select the elf flag. For example, as
libc.so.6 don't depend on itself or on libm it will be flagged as
FLAG_ELF instead of FLAG_ELF_LIBC6 as expected.

This commit fixes this by checking if a appropriate flag was set by
process_elf32_file. If not it will search on known_libs and use the flag
in there.
---
 sysdeps/unix/sysv/linux/powerpc/readelflib.c | 21 +++++++++++++++++---
 1 file changed, 18 insertions(+), 3 deletions(-)

diff --git a/sysdeps/unix/sysv/linux/powerpc/readelflib.c b/sysdeps/unix/sysv/linux/powerpc/readelflib.c
index 51f8a9496a..94da21c407 100644
--- a/sysdeps/unix/sysv/linux/powerpc/readelflib.c
+++ b/sysdeps/unix/sysv/linux/powerpc/readelflib.c
@@ -33,11 +33,26 @@ process_elf_file (const char *file_name, const char *lib, int *flag,
 		  char **soname, void *file_contents, size_t file_length)
 {
   ElfW(Ehdr) *elf_header = (ElfW(Ehdr) *) file_contents;
-  int ret;
+  int ret, j;
 
   if (elf_header->e_ident [EI_CLASS] == ELFCLASS32)
-    return process_elf32_file (file_name, lib, flag, osversion, isa_level,
-			       soname, file_contents, file_length);
+    {
+      ret = process_elf32_file (file_name, lib, flag, osversion, isa_level,
+                                soname, file_contents, file_length);
+      /* Use the apropriate flag for known_libs instead of FLAG_ELF.  */
+      if (*flag == FLAG_ELF)
+        {
+          for (j = 0;
+               j < sizeof (known_libs) / sizeof (known_libs [0]);
+               ++j)
+            if (strcmp (lib, known_libs [j].soname) == 0)
+              {
+                *flag = known_libs [j].flag;
+                break;
+              }
+        }
+      return ret;
+    }
   else
     {
       ret = process_elf64_file (file_name, lib, flag, osversion, isa_level,
-- 
2.31.1


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

* Re: [PATCH] powerpc: Use FLAG_ELF_LIBC6 for 32-bit known libraries
  2021-11-04 18:10 ` [PATCH] powerpc: Use FLAG_ELF_LIBC6 for 32-bit known libraries Lucas A. M. Magalhaes
@ 2021-12-03 12:40   ` Lucas A. M. Magalhaes
  2021-12-03 14:17   ` Florian Weimer
                     ` (2 subsequent siblings)
  3 siblings, 0 replies; 15+ messages in thread
From: Lucas A. M. Magalhaes @ 2021-12-03 12:40 UTC (permalink / raw)
  To: Lucas A. M. Magalhaes via Libc-alpha; +Cc: tuliom

Ping.

Quoting Lucas A. M. Magalhaes via Libc-alpha (2021-11-04 15:10:39)
> In systems with more versions of the known libraries, i.e. on IBM
> Advance Toolchain, ldconfig will order them incorrectly on ld.cache.
> 
> The issue only occurs with 32-bit libraries that don't depend on libc or
> libm. That's because process_elf32_file check if the elf depends on one
> of the libraries at known_libs to select the elf flag. For example, as
> libc.so.6 don't depend on itself or on libm it will be flagged as
> FLAG_ELF instead of FLAG_ELF_LIBC6 as expected.
> 
> This commit fixes this by checking if a appropriate flag was set by
> process_elf32_file. If not it will search on known_libs and use the flag
> in there.
> ---
>  sysdeps/unix/sysv/linux/powerpc/readelflib.c | 21 +++++++++++++++++---
>  1 file changed, 18 insertions(+), 3 deletions(-)
> 
> diff --git a/sysdeps/unix/sysv/linux/powerpc/readelflib.c b/sysdeps/unix/sysv/linux/powerpc/readelflib.c
> index 51f8a9496a..94da21c407 100644
> --- a/sysdeps/unix/sysv/linux/powerpc/readelflib.c
> +++ b/sysdeps/unix/sysv/linux/powerpc/readelflib.c
> @@ -33,11 +33,26 @@ process_elf_file (const char *file_name, const char *lib, int *flag,
>                   char **soname, void *file_contents, size_t file_length)
>  {
>    ElfW(Ehdr) *elf_header = (ElfW(Ehdr) *) file_contents;
> -  int ret;
> +  int ret, j;
>  
>    if (elf_header->e_ident [EI_CLASS] == ELFCLASS32)
> -    return process_elf32_file (file_name, lib, flag, osversion, isa_level,
> -                              soname, file_contents, file_length);
> +    {
> +      ret = process_elf32_file (file_name, lib, flag, osversion, isa_level,
> +                                soname, file_contents, file_length);
> +      /* Use the apropriate flag for known_libs instead of FLAG_ELF.  */
> +      if (*flag == FLAG_ELF)
> +        {
> +          for (j = 0;
> +               j < sizeof (known_libs) / sizeof (known_libs [0]);
> +               ++j)
> +            if (strcmp (lib, known_libs [j].soname) == 0)
> +              {
> +                *flag = known_libs [j].flag;
> +                break;
> +              }
> +        }
> +      return ret;
> +    }
>    else
>      {
>        ret = process_elf64_file (file_name, lib, flag, osversion, isa_level,
> -- 
> 2.31.1
>

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

* Re: [PATCH] powerpc: Use FLAG_ELF_LIBC6 for 32-bit known libraries
  2021-11-04 18:10 ` [PATCH] powerpc: Use FLAG_ELF_LIBC6 for 32-bit known libraries Lucas A. M. Magalhaes
  2021-12-03 12:40   ` Lucas A. M. Magalhaes
@ 2021-12-03 14:17   ` Florian Weimer
  2021-12-03 14:51   ` Adhemerval Zanella
  2022-02-23 22:09   ` Raoni Fassina Firmino
  3 siblings, 0 replies; 15+ messages in thread
From: Florian Weimer @ 2021-12-03 14:17 UTC (permalink / raw)
  To: Lucas A. M. Magalhaes; +Cc: libc-alpha, tuliom

* Lucas A. M. Magalhaes:

> In systems with more versions of the known libraries, i.e. on IBM
> Advance Toolchain, ldconfig will order them incorrectly on ld.cache.
>
> The issue only occurs with 32-bit libraries that don't depend on libc or
> libm. That's because process_elf32_file check if the elf depends on one
> of the libraries at known_libs to select the elf flag. For example, as
> libc.so.6 don't depend on itself or on libm it will be flagged as
> FLAG_ELF instead of FLAG_ELF_LIBC6 as expected.
>
> This commit fixes this by checking if a appropriate flag was set by
> process_elf32_file. If not it will search on known_libs and use the flag
> in there.

I would like to defer review of this patch to the POWER maintainers, sorry.
(I just spotted a typo in the first version.)

Thanks,
Florian


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

* Re: [PATCH] powerpc: Use FLAG_ELF_LIBC6 for 32-bit known libraries
  2021-11-04 18:10 ` [PATCH] powerpc: Use FLAG_ELF_LIBC6 for 32-bit known libraries Lucas A. M. Magalhaes
  2021-12-03 12:40   ` Lucas A. M. Magalhaes
  2021-12-03 14:17   ` Florian Weimer
@ 2021-12-03 14:51   ` Adhemerval Zanella
  2022-03-02 19:30     ` Raoni Fassina Firmino
  2022-02-23 22:09   ` Raoni Fassina Firmino
  3 siblings, 1 reply; 15+ messages in thread
From: Adhemerval Zanella @ 2021-12-03 14:51 UTC (permalink / raw)
  To: Lucas A. M. Magalhaes, libc-alpha; +Cc: fweimer, tuliom



On 04/11/2021 15:10, Lucas A. M. Magalhaes via Libc-alpha wrote:
> In systems with more versions of the known libraries, i.e. on IBM
> Advance Toolchain, ldconfig will order them incorrectly on ld.cache.
> 
> The issue only occurs with 32-bit libraries that don't depend on libc or
> libm. That's because process_elf32_file check if the elf depends on one
> of the libraries at known_libs to select the elf flag. For example, as
> libc.so.6 don't depend on itself or on libm it will be flagged as
> FLAG_ELF instead of FLAG_ELF_LIBC6 as expected.

Wouldn't be simpler to check if the DT_SONAME matches any on 'known_libs' after
dynamic section parsing and set the appropriated flag on generic 'process_file'? 

(also powerpc SYSDEP_KNOWN_LIBRARY_NAMES seems redundant).

> 
> This commit fixes this by checking if a appropriate flag was set by
> process_elf32_file. If not it will search on known_libs and use the flag
> in there.
> ---
>  sysdeps/unix/sysv/linux/powerpc/readelflib.c | 21 +++++++++++++++++---
>  1 file changed, 18 insertions(+), 3 deletions(-)
> 
> diff --git a/sysdeps/unix/sysv/linux/powerpc/readelflib.c b/sysdeps/unix/sysv/linux/powerpc/readelflib.c
> index 51f8a9496a..94da21c407 100644
> --- a/sysdeps/unix/sysv/linux/powerpc/readelflib.c
> +++ b/sysdeps/unix/sysv/linux/powerpc/readelflib.c
> @@ -33,11 +33,26 @@ process_elf_file (const char *file_name, const char *lib, int *flag,
>  		  char **soname, void *file_contents, size_t file_length)
>  {
>    ElfW(Ehdr) *elf_header = (ElfW(Ehdr) *) file_contents;
> -  int ret;
> +  int ret, j;
>  
>    if (elf_header->e_ident [EI_CLASS] == ELFCLASS32)
> -    return process_elf32_file (file_name, lib, flag, osversion, isa_level,
> -			       soname, file_contents, file_length);
> +    {
> +      ret = process_elf32_file (file_name, lib, flag, osversion, isa_level,
> +                                soname, file_contents, file_length);
> +      /* Use the apropriate flag for known_libs instead of FLAG_ELF.  */
> +      if (*flag == FLAG_ELF)
> +        {
> +          for (j = 0;
> +               j < sizeof (known_libs) / sizeof (known_libs [0]);
> +               ++j)
> +            if (strcmp (lib, known_libs [j].soname) == 0)
> +              {
> +                *flag = known_libs [j].flag;
> +                break;
> +              }
> +        }
> +      return ret;
> +    }
>    else
>      {
>        ret = process_elf64_file (file_name, lib, flag, osversion, isa_level,
> 

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

* [RFC] Remove special flags of libc.5.so and libc.4.so
  2021-10-25 18:22 ` Florian Weimer
@ 2021-12-22 15:31   ` Lucas A. M. Magalhaes
  2022-01-10 19:21     ` Lucas A. M. Magalhaes
                       ` (2 more replies)
  0 siblings, 3 replies; 15+ messages in thread
From: Lucas A. M. Magalhaes @ 2021-12-22 15:31 UTC (permalink / raw)
  To: libc-alpha; +Cc: fweimer, tuliom

I've tested it in a AT build and was able to build and link programs as
expected. For other archs I try with build-many-glibcs.py, all
succeeded.

Any other suggestions on how to test this?

Florian am I missing something? Should we add a restriction to cache
just new libc6.so compatible libraries?

-- 8< --

The older libcs version are obsolete for over twenty years now. This
commit removes special flags of libc.5.so and libc.4.so.. It assume that
all libraries cached are libc.6.so compatible and wrote FLAG_ELF_LIBC6.

Tested on x86_64, powerpc, powerpc64 and powerpc64le.
Tested with build-many-glibcs.py for the other affected architectures.
---
 elf/cache.c                                |  6 +--
 elf/ldconfig.c                             | 33 +---------------
 elf/readelflib.c                           | 46 +++-------------------
 elf/readlib.c                              | 25 +-----------
 sysdeps/unix/sysv/linux/arc/ldconfig.h     |  8 ----
 sysdeps/unix/sysv/linux/arm/ldconfig.h     |  7 ----
 sysdeps/unix/sysv/linux/csky/ldconfig.h    |  6 ---
 sysdeps/unix/sysv/linux/ia64/ldconfig.h    |  6 ---
 sysdeps/unix/sysv/linux/powerpc/ldconfig.h |  8 ----
 sysdeps/unix/sysv/linux/riscv/ldconfig.h   | 17 --------
 sysdeps/unix/sysv/linux/s390/ldconfig.h    |  7 ----
 sysdeps/unix/sysv/linux/x86_64/ldconfig.h  |  8 ----
 12 files changed, 11 insertions(+), 166 deletions(-)

diff --git a/elf/cache.c b/elf/cache.c
index 1c0dc5ee87..387dd11a05 100644
--- a/elf/cache.c
+++ b/elf/cache.c
@@ -158,6 +158,7 @@ struct cache_entry
 /* List of all cache entries.  */
 static struct cache_entry *entries;
 
+/* libc4, ELF and libc5 are unsupported */
 static const char *flag_descr[] =
 { "libc4", "ELF", "libc5", "libc6"};
 
@@ -169,14 +170,11 @@ print_entry (const char *lib, int flag, unsigned int osversion,
   printf ("\t%s (", lib);
   switch (flag & FLAG_TYPE_MASK)
     {
-    case FLAG_LIBC4:
-    case FLAG_ELF:
-    case FLAG_ELF_LIBC5:
     case FLAG_ELF_LIBC6:
       fputs (flag_descr[flag & FLAG_TYPE_MASK], stdout);
       break;
     default:
-      fputs (_("unknown"), stdout);
+      fputs (_("Unknown or unsupported flag"), stdout);
       break;
     }
   switch (flag & FLAG_REQUIRED_MASK)
diff --git a/elf/ldconfig.c b/elf/ldconfig.c
index 101d56ac8e..d64b134781 100644
--- a/elf/ldconfig.c
+++ b/elf/ldconfig.c
@@ -65,19 +65,6 @@
 
 #define PACKAGE _libc_intl_domainname
 
-static const struct
-{
-  const char *name;
-  int flag;
-} lib_types[] =
-{
-  {"libc4", FLAG_LIBC4},
-  {"libc5", FLAG_ELF_LIBC5},
-  {"libc6", FLAG_ELF_LIBC6},
-  {"glibc2", FLAG_ELF_LIBC6}
-};
-
-
 /* List of directories to handle.  */
 struct dir_entry
 {
@@ -471,25 +458,7 @@ add_dir_1 (const char *line, const char *from_file, int from_line)
 
   /* Search for an '=' sign.  */
   entry->path = xstrdup (line);
-  char *equal_sign = strchr (entry->path, '=');
-  if (equal_sign)
-    {
-      *equal_sign = '\0';
-      ++equal_sign;
-      entry->flag = FLAG_ANY;
-      for (i = 0; i < sizeof (lib_types) / sizeof (lib_types[0]); ++i)
-	if (strcmp (equal_sign, lib_types[i].name) == 0)
-	  {
-	    entry->flag = lib_types[i].flag;
-	    break;
-	  }
-      if (entry->flag == FLAG_ANY)
-	error (0, 0, _("%s is not a known library type"), equal_sign);
-    }
-  else
-    {
-      entry->flag = FLAG_ANY;
-    }
+  entry->flag = FLAG_ELF_LIBC6;
 
   /* Canonify path: for now only remove leading and trailing
      whitespace and the trailing slashes.  */
diff --git a/elf/readelflib.c b/elf/readelflib.c
index 10b10b6080..801c5587ab 100644
--- a/elf/readelflib.c
+++ b/elf/readelflib.c
@@ -44,7 +44,6 @@ process_elf_file (const char *file_name, const char *lib, int *flag,
 		  char **soname, void *file_contents, size_t file_length)
 {
   int i;
-  unsigned int j;
   unsigned int dynamic_addr;
   size_t dynamic_size;
   char *program_interpreter;
@@ -82,9 +81,8 @@ process_elf_file (const char *file_name, const char *lib, int *flag,
   elf_pheader = (ElfW(Phdr) *) (elf_header->e_phoff + file_contents);
   check_ptr (elf_pheader);
 
-  /* The library is an elf library, now search for soname and
-     libc5/libc6.  */
-  *flag = FLAG_ELF;
+  /* The library is an elf library   */
+  *flag = FLAG_ELF_LIBC6;
 
   /* The default ISA level is 0.  */
   *isa_level = 0;
@@ -111,16 +109,6 @@ process_elf_file (const char *file_name, const char *lib, int *flag,
 	  program_interpreter = (char *) (file_contents + segment->p_offset);
 	  check_ptr (program_interpreter);
 
-	  /* Check if this is enough to classify the binary.  */
-	  for (j = 0; j < sizeof (interpreters) / sizeof (interpreters [0]);
-	       ++j)
-	    if (strcmp (program_interpreter, interpreters[j].soname) == 0)
-	      {
-		*flag = interpreters[j].flag;
-		break;
-	      }
-	  break;
-
 	case PT_NOTE:
 	  if (!*osversion && segment->p_filesz >= 32 && segment->p_align >= 4)
 	    {
@@ -291,38 +279,16 @@ done:
   if (dynamic_strings == NULL)
     return 1;
 
-  /* Now read the DT_NEEDED and DT_SONAME entries.  */
+  /* Now read the DT_SONAME entries.  */
   for (dyn_entry = dynamic_segment; dyn_entry->d_tag != DT_NULL;
        ++dyn_entry)
     {
-      if (dyn_entry->d_tag == DT_NEEDED || dyn_entry->d_tag == DT_SONAME)
+      if (dyn_entry->d_tag == DT_SONAME)
 	{
 	  char *name = dynamic_strings + dyn_entry->d_un.d_val;
 	  check_ptr (name);
-
-	  if (dyn_entry->d_tag == DT_NEEDED)
-	    {
-
-	      if (*flag == FLAG_ELF)
-		{
-		  /* Check if this is enough to classify the binary.  */
-		  for (j = 0;
-		       j < sizeof (known_libs) / sizeof (known_libs [0]);
-		       ++j)
-		    if (strcmp (name, known_libs [j].soname) == 0)
-		      {
-			*flag = known_libs [j].flag;
-			break;
-		      }
-		}
-	    }
-
-	  else if (dyn_entry->d_tag == DT_SONAME)
-	    *soname = xstrdup (name);
-
-	  /* Do we have everything we need?  */
-	  if (*soname && *flag != FLAG_ELF)
-	    return 0;
+          *soname = xstrdup (name);
+          return 0;
 	}
     }
 
diff --git a/elf/readlib.c b/elf/readlib.c
index 64b20d7804..9164c1cda7 100644
--- a/elf/readlib.c
+++ b/elf/readlib.c
@@ -43,24 +43,6 @@ struct known_names
   int flag;
 };
 
-static struct known_names interpreters[] =
-{
-  { "/lib/" LD_SO, FLAG_ELF_LIBC6 },
-#ifdef SYSDEP_KNOWN_INTERPRETER_NAMES
-  SYSDEP_KNOWN_INTERPRETER_NAMES
-#endif
-};
-
-static struct known_names known_libs[] =
-{
-  { LIBC_SO, FLAG_ELF_LIBC6 },
-  { LIBM_SO, FLAG_ELF_LIBC6 },
-#ifdef SYSDEP_KNOWN_LIBRARY_NAMES
-  SYSDEP_KNOWN_LIBRARY_NAMES
-#endif
-};
-
-
 /* Check if string corresponds to a GDB Python file.  */
 static bool
 is_gdb_python_file (const char *name)
@@ -84,7 +66,8 @@ process_file (const char *real_file_name, const char *file_name,
   struct exec *aout_header;
 
   ret = 0;
-  *flag = FLAG_ANY;
+  /* Just set FLAG_ELF_LIBC6 as old formats are not supported anymore.  */
+  *flag = FLAG_ELF_LIBC6;
   *soname = NULL;
 
   file = fopen (real_file_name, "rb");
@@ -151,7 +134,6 @@ process_file (const char *real_file_name, const char *file_name,
 	    *dot = '\0';
 	}
       *soname = copy;
-      *flag = FLAG_LIBC4;
       goto done;
     }
 
@@ -192,9 +174,6 @@ implicit_soname (const char *lib, int flag)
 {
   char *soname = xstrdup (lib);
 
-  if ((flag & FLAG_TYPE_MASK) != FLAG_LIBC4)
-    return soname;
-
   /* Aout files don't have a soname, just return the name
      including the major number.  */
   char *major = strstr (soname, ".so.");
diff --git a/sysdeps/unix/sysv/linux/arc/ldconfig.h b/sysdeps/unix/sysv/linux/arc/ldconfig.h
index 8c776fca9e..02ed826283 100644
--- a/sysdeps/unix/sysv/linux/arc/ldconfig.h
+++ b/sysdeps/unix/sysv/linux/arc/ldconfig.h
@@ -17,11 +17,3 @@
    <https://www.gnu.org/licenses/>.  */
 
 #include <sysdeps/generic/ldconfig.h>
-
-#define SYSDEP_KNOWN_INTERPRETER_NAMES 		\
-  { "/lib/ld-linux-arc.so.2", FLAG_ELF_LIBC6 },	\
-  { "/lib/ld-linux-arceb.so.2", FLAG_ELF_LIBC6 },
-
-#define SYSDEP_KNOWN_LIBRARY_NAMES 	\
-  { "libc.so.6", FLAG_ELF_LIBC6 },	\
-  { "libm.so.6", FLAG_ELF_LIBC6 },
diff --git a/sysdeps/unix/sysv/linux/arm/ldconfig.h b/sysdeps/unix/sysv/linux/arm/ldconfig.h
index d839470cfe..b3fa8ceebe 100644
--- a/sysdeps/unix/sysv/linux/arm/ldconfig.h
+++ b/sysdeps/unix/sysv/linux/arm/ldconfig.h
@@ -16,10 +16,3 @@
    <https://www.gnu.org/licenses/>.  */
 
 #include <sysdeps/generic/ldconfig.h>
-
-#define SYSDEP_KNOWN_INTERPRETER_NAMES \
-  { "/lib/ld-linux.so.3", FLAG_ELF_LIBC6 }, \
-  { "/lib/ld-linux-armhf.so.3", FLAG_ELF_LIBC6 },
-#define SYSDEP_KNOWN_LIBRARY_NAMES \
-  { "libc.so.6", FLAG_ELF_LIBC6 },	\
-  { "libm.so.6", FLAG_ELF_LIBC6 },
diff --git a/sysdeps/unix/sysv/linux/csky/ldconfig.h b/sysdeps/unix/sysv/linux/csky/ldconfig.h
index eeda37e4a8..6861f71327 100644
--- a/sysdeps/unix/sysv/linux/csky/ldconfig.h
+++ b/sysdeps/unix/sysv/linux/csky/ldconfig.h
@@ -26,9 +26,3 @@
 #else
 # define LD_SO_ABI "cskyv2"
 #endif
-
-#define SYSDEP_KNOWN_INTERPRETER_NAMES	\
-  { LD_SO_PREFIX LD_SO_ABI LD_SO_SUFFIX, FLAG_ELF_LIBC6 },
-#define SYSDEP_KNOWN_LIBRARY_NAMES	\
-  { "libc.so.6", FLAG_ELF_LIBC6 },	\
-  { "libm.so.6", FLAG_ELF_LIBC6 },
diff --git a/sysdeps/unix/sysv/linux/ia64/ldconfig.h b/sysdeps/unix/sysv/linux/ia64/ldconfig.h
index 53685659ed..b3fa8ceebe 100644
--- a/sysdeps/unix/sysv/linux/ia64/ldconfig.h
+++ b/sysdeps/unix/sysv/linux/ia64/ldconfig.h
@@ -16,9 +16,3 @@
    <https://www.gnu.org/licenses/>.  */
 
 #include <sysdeps/generic/ldconfig.h>
-
-#define SYSDEP_KNOWN_INTERPRETER_NAMES \
-  { "/lib/ld-linux.so.2", FLAG_ELF_LIBC6 },
-#define SYSDEP_KNOWN_LIBRARY_NAMES \
-  { "libc.so.6", FLAG_ELF_LIBC6 },	\
-  { "libm.so.6", FLAG_ELF_LIBC6 },
diff --git a/sysdeps/unix/sysv/linux/powerpc/ldconfig.h b/sysdeps/unix/sysv/linux/powerpc/ldconfig.h
index 09d75b3dec..d0935d541b 100644
--- a/sysdeps/unix/sysv/linux/powerpc/ldconfig.h
+++ b/sysdeps/unix/sysv/linux/powerpc/ldconfig.h
@@ -17,11 +17,3 @@
    <https://www.gnu.org/licenses/>.  */
 
 #include <sysdeps/generic/ldconfig.h>
-
-#define SYSDEP_KNOWN_INTERPRETER_NAMES \
-  { "/lib/ld.so.1", FLAG_ELF_LIBC6 },	\
-  { "/lib64/ld64.so.1", FLAG_ELF_LIBC6 }, \
-  { "/lib64/ld64.so.2", FLAG_ELF_LIBC6 },
-#define SYSDEP_KNOWN_LIBRARY_NAMES \
-  { "libc.so.6", FLAG_ELF_LIBC6 },	\
-  { "libm.so.6", FLAG_ELF_LIBC6 },
diff --git a/sysdeps/unix/sysv/linux/riscv/ldconfig.h b/sysdeps/unix/sysv/linux/riscv/ldconfig.h
index e6e7d271ad..24aae5155a 100644
--- a/sysdeps/unix/sysv/linux/riscv/ldconfig.h
+++ b/sysdeps/unix/sysv/linux/riscv/ldconfig.h
@@ -17,20 +17,3 @@
    <https://www.gnu.org/licenses/>.  */
 
 #include <sysdeps/generic/ldconfig.h>
-
-#define LD_SO_PREFIX "/lib/ld-linux-"
-#define LD_SO_SUFFIX ".so.1"
-
-#if __riscv_xlen == 64
-# define LD_SO_ABI "riscv64-lp64"
-#else
-# define LD_SO_ABI "riscv32-ilp32"
-#endif
-
-#define SYSDEP_KNOWN_INTERPRETER_NAMES				\
-  { LD_SO_PREFIX LD_SO_ABI "d" LD_SO_SUFFIX, FLAG_ELF_LIBC6 },	\
-  { LD_SO_PREFIX LD_SO_ABI     LD_SO_SUFFIX, FLAG_ELF_LIBC6 },
-
-#define SYSDEP_KNOWN_LIBRARY_NAMES	\
-  { "libc.so.6", FLAG_ELF_LIBC6 },	\
-  { "libm.so.6", FLAG_ELF_LIBC6 },
diff --git a/sysdeps/unix/sysv/linux/s390/ldconfig.h b/sysdeps/unix/sysv/linux/s390/ldconfig.h
index 83086ce843..b3fa8ceebe 100644
--- a/sysdeps/unix/sysv/linux/s390/ldconfig.h
+++ b/sysdeps/unix/sysv/linux/s390/ldconfig.h
@@ -16,10 +16,3 @@
    <https://www.gnu.org/licenses/>.  */
 
 #include <sysdeps/generic/ldconfig.h>
-
-#define SYSDEP_KNOWN_INTERPRETER_NAMES \
-  { "/lib/ld.so.1", FLAG_ELF_LIBC6 },	\
-  { "/lib/ld64.so.1", FLAG_ELF_LIBC6 },
-#define SYSDEP_KNOWN_LIBRARY_NAMES \
-  { "libc.so.6", FLAG_ELF_LIBC6 },	\
-  { "libm.so.6", FLAG_ELF_LIBC6 },
diff --git a/sysdeps/unix/sysv/linux/x86_64/ldconfig.h b/sysdeps/unix/sysv/linux/x86_64/ldconfig.h
index 1089668f09..b3fa8ceebe 100644
--- a/sysdeps/unix/sysv/linux/x86_64/ldconfig.h
+++ b/sysdeps/unix/sysv/linux/x86_64/ldconfig.h
@@ -16,11 +16,3 @@
    <https://www.gnu.org/licenses/>.  */
 
 #include <sysdeps/generic/ldconfig.h>
-
-#define SYSDEP_KNOWN_INTERPRETER_NAMES \
-  { "/lib/ld-linux.so.2", FLAG_ELF_LIBC6 }, \
-  { "/libx32/ld-linux-x32.so.2", FLAG_ELF_LIBC6 }, \
-  { "/lib64/ld-linux-x86-64.so.2", FLAG_ELF_LIBC6 },
-#define SYSDEP_KNOWN_LIBRARY_NAMES \
-  { "libc.so.6", FLAG_ELF_LIBC6 },	\
-  { "libm.so.6", FLAG_ELF_LIBC6 },
-- 
2.31.1


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

* Re: [RFC] Remove special flags of libc.5.so and libc.4.so
  2021-12-22 15:31   ` [RFC] Remove special flags of libc.5.so and libc.4.so Lucas A. M. Magalhaes
@ 2022-01-10 19:21     ` Lucas A. M. Magalhaes
  2022-01-11 19:22     ` Adhemerval Zanella
  2022-02-23 22:17     ` Raoni Fassina Firmino
  2 siblings, 0 replies; 15+ messages in thread
From: Lucas A. M. Magalhaes @ 2022-01-10 19:21 UTC (permalink / raw)
  To: Lucas A. M. Magalhaes via Libc-alpha; +Cc: fweimer, tuliom

Ping.

Quoting Lucas A. M. Magalhaes via Libc-alpha (2021-12-22 12:31:51)
> I've tested it in a AT build and was able to build and link programs as
> expected. For other archs I try with build-many-glibcs.py, all
> succeeded.
> 
> Any other suggestions on how to test this?
> 
> Florian am I missing something? Should we add a restriction to cache
> just new libc6.so compatible libraries?
> 
> -- 8< --
> 
> The older libcs version are obsolete for over twenty years now. This
> commit removes special flags of libc.5.so and libc.4.so.. It assume that
> all libraries cached are libc.6.so compatible and wrote FLAG_ELF_LIBC6.
> 
> Tested on x86_64, powerpc, powerpc64 and powerpc64le.
> Tested with build-many-glibcs.py for the other affected architectures.
> ---
>  elf/cache.c                                |  6 +--
>  elf/ldconfig.c                             | 33 +---------------
>  elf/readelflib.c                           | 46 +++-------------------
>  elf/readlib.c                              | 25 +-----------
>  sysdeps/unix/sysv/linux/arc/ldconfig.h     |  8 ----
>  sysdeps/unix/sysv/linux/arm/ldconfig.h     |  7 ----
>  sysdeps/unix/sysv/linux/csky/ldconfig.h    |  6 ---
>  sysdeps/unix/sysv/linux/ia64/ldconfig.h    |  6 ---
>  sysdeps/unix/sysv/linux/powerpc/ldconfig.h |  8 ----
>  sysdeps/unix/sysv/linux/riscv/ldconfig.h   | 17 --------
>  sysdeps/unix/sysv/linux/s390/ldconfig.h    |  7 ----
>  sysdeps/unix/sysv/linux/x86_64/ldconfig.h  |  8 ----
>  12 files changed, 11 insertions(+), 166 deletions(-)
> 
> diff --git a/elf/cache.c b/elf/cache.c
> index 1c0dc5ee87..387dd11a05 100644
> --- a/elf/cache.c
> +++ b/elf/cache.c
> @@ -158,6 +158,7 @@ struct cache_entry
>  /* List of all cache entries.  */
>  static struct cache_entry *entries;
>  
> +/* libc4, ELF and libc5 are unsupported */
>  static const char *flag_descr[] =
>  { "libc4", "ELF", "libc5", "libc6"};
>  
> @@ -169,14 +170,11 @@ print_entry (const char *lib, int flag, unsigned int osversion,
>    printf ("\t%s (", lib);
>    switch (flag & FLAG_TYPE_MASK)
>      {
> -    case FLAG_LIBC4:
> -    case FLAG_ELF:
> -    case FLAG_ELF_LIBC5:
>      case FLAG_ELF_LIBC6:
>        fputs (flag_descr[flag & FLAG_TYPE_MASK], stdout);
>        break;
>      default:
> -      fputs (_("unknown"), stdout);
> +      fputs (_("Unknown or unsupported flag"), stdout);
>        break;
>      }
>    switch (flag & FLAG_REQUIRED_MASK)
> diff --git a/elf/ldconfig.c b/elf/ldconfig.c
> index 101d56ac8e..d64b134781 100644
> --- a/elf/ldconfig.c
> +++ b/elf/ldconfig.c
> @@ -65,19 +65,6 @@
>  
>  #define PACKAGE _libc_intl_domainname
>  
> -static const struct
> -{
> -  const char *name;
> -  int flag;
> -} lib_types[] =
> -{
> -  {"libc4", FLAG_LIBC4},
> -  {"libc5", FLAG_ELF_LIBC5},
> -  {"libc6", FLAG_ELF_LIBC6},
> -  {"glibc2", FLAG_ELF_LIBC6}
> -};
> -
> -
>  /* List of directories to handle.  */
>  struct dir_entry
>  {
> @@ -471,25 +458,7 @@ add_dir_1 (const char *line, const char *from_file, int from_line)
>  
>    /* Search for an '=' sign.  */
>    entry->path = xstrdup (line);
> -  char *equal_sign = strchr (entry->path, '=');
> -  if (equal_sign)
> -    {
> -      *equal_sign = '\0';
> -      ++equal_sign;
> -      entry->flag = FLAG_ANY;
> -      for (i = 0; i < sizeof (lib_types) / sizeof (lib_types[0]); ++i)
> -       if (strcmp (equal_sign, lib_types[i].name) == 0)
> -         {
> -           entry->flag = lib_types[i].flag;
> -           break;
> -         }
> -      if (entry->flag == FLAG_ANY)
> -       error (0, 0, _("%s is not a known library type"), equal_sign);
> -    }
> -  else
> -    {
> -      entry->flag = FLAG_ANY;
> -    }
> +  entry->flag = FLAG_ELF_LIBC6;
>  
>    /* Canonify path: for now only remove leading and trailing
>       whitespace and the trailing slashes.  */
> diff --git a/elf/readelflib.c b/elf/readelflib.c
> index 10b10b6080..801c5587ab 100644
> --- a/elf/readelflib.c
> +++ b/elf/readelflib.c
> @@ -44,7 +44,6 @@ process_elf_file (const char *file_name, const char *lib, int *flag,
>                   char **soname, void *file_contents, size_t file_length)
>  {
>    int i;
> -  unsigned int j;
>    unsigned int dynamic_addr;
>    size_t dynamic_size;
>    char *program_interpreter;
> @@ -82,9 +81,8 @@ process_elf_file (const char *file_name, const char *lib, int *flag,
>    elf_pheader = (ElfW(Phdr) *) (elf_header->e_phoff + file_contents);
>    check_ptr (elf_pheader);
>  
> -  /* The library is an elf library, now search for soname and
> -     libc5/libc6.  */
> -  *flag = FLAG_ELF;
> +  /* The library is an elf library   */
> +  *flag = FLAG_ELF_LIBC6;
>  
>    /* The default ISA level is 0.  */
>    *isa_level = 0;
> @@ -111,16 +109,6 @@ process_elf_file (const char *file_name, const char *lib, int *flag,
>           program_interpreter = (char *) (file_contents + segment->p_offset);
>           check_ptr (program_interpreter);
>  
> -         /* Check if this is enough to classify the binary.  */
> -         for (j = 0; j < sizeof (interpreters) / sizeof (interpreters [0]);
> -              ++j)
> -           if (strcmp (program_interpreter, interpreters[j].soname) == 0)
> -             {
> -               *flag = interpreters[j].flag;
> -               break;
> -             }
> -         break;
> -
>         case PT_NOTE:
>           if (!*osversion && segment->p_filesz >= 32 && segment->p_align >= 4)
>             {
> @@ -291,38 +279,16 @@ done:
>    if (dynamic_strings == NULL)
>      return 1;
>  
> -  /* Now read the DT_NEEDED and DT_SONAME entries.  */
> +  /* Now read the DT_SONAME entries.  */
>    for (dyn_entry = dynamic_segment; dyn_entry->d_tag != DT_NULL;
>         ++dyn_entry)
>      {
> -      if (dyn_entry->d_tag == DT_NEEDED || dyn_entry->d_tag == DT_SONAME)
> +      if (dyn_entry->d_tag == DT_SONAME)
>         {
>           char *name = dynamic_strings + dyn_entry->d_un.d_val;
>           check_ptr (name);
> -
> -         if (dyn_entry->d_tag == DT_NEEDED)
> -           {
> -
> -             if (*flag == FLAG_ELF)
> -               {
> -                 /* Check if this is enough to classify the binary.  */
> -                 for (j = 0;
> -                      j < sizeof (known_libs) / sizeof (known_libs [0]);
> -                      ++j)
> -                   if (strcmp (name, known_libs [j].soname) == 0)
> -                     {
> -                       *flag = known_libs [j].flag;
> -                       break;
> -                     }
> -               }
> -           }
> -
> -         else if (dyn_entry->d_tag == DT_SONAME)
> -           *soname = xstrdup (name);
> -
> -         /* Do we have everything we need?  */
> -         if (*soname && *flag != FLAG_ELF)
> -           return 0;
> +          *soname = xstrdup (name);
> +          return 0;
>         }
>      }
>  
> diff --git a/elf/readlib.c b/elf/readlib.c
> index 64b20d7804..9164c1cda7 100644
> --- a/elf/readlib.c
> +++ b/elf/readlib.c
> @@ -43,24 +43,6 @@ struct known_names
>    int flag;
>  };
>  
> -static struct known_names interpreters[] =
> -{
> -  { "/lib/" LD_SO, FLAG_ELF_LIBC6 },
> -#ifdef SYSDEP_KNOWN_INTERPRETER_NAMES
> -  SYSDEP_KNOWN_INTERPRETER_NAMES
> -#endif
> -};
> -
> -static struct known_names known_libs[] =
> -{
> -  { LIBC_SO, FLAG_ELF_LIBC6 },
> -  { LIBM_SO, FLAG_ELF_LIBC6 },
> -#ifdef SYSDEP_KNOWN_LIBRARY_NAMES
> -  SYSDEP_KNOWN_LIBRARY_NAMES
> -#endif
> -};
> -
> -
>  /* Check if string corresponds to a GDB Python file.  */
>  static bool
>  is_gdb_python_file (const char *name)
> @@ -84,7 +66,8 @@ process_file (const char *real_file_name, const char *file_name,
>    struct exec *aout_header;
>  
>    ret = 0;
> -  *flag = FLAG_ANY;
> +  /* Just set FLAG_ELF_LIBC6 as old formats are not supported anymore.  */
> +  *flag = FLAG_ELF_LIBC6;
>    *soname = NULL;
>  
>    file = fopen (real_file_name, "rb");
> @@ -151,7 +134,6 @@ process_file (const char *real_file_name, const char *file_name,
>             *dot = '\0';
>         }
>        *soname = copy;
> -      *flag = FLAG_LIBC4;
>        goto done;
>      }
>  
> @@ -192,9 +174,6 @@ implicit_soname (const char *lib, int flag)
>  {
>    char *soname = xstrdup (lib);
>  
> -  if ((flag & FLAG_TYPE_MASK) != FLAG_LIBC4)
> -    return soname;
> -
>    /* Aout files don't have a soname, just return the name
>       including the major number.  */
>    char *major = strstr (soname, ".so.");
> diff --git a/sysdeps/unix/sysv/linux/arc/ldconfig.h b/sysdeps/unix/sysv/linux/arc/ldconfig.h
> index 8c776fca9e..02ed826283 100644
> --- a/sysdeps/unix/sysv/linux/arc/ldconfig.h
> +++ b/sysdeps/unix/sysv/linux/arc/ldconfig.h
> @@ -17,11 +17,3 @@
>     <https://www.gnu.org/licenses/>.  */
>  
>  #include <sysdeps/generic/ldconfig.h>
> -
> -#define SYSDEP_KNOWN_INTERPRETER_NAMES                 \
> -  { "/lib/ld-linux-arc.so.2", FLAG_ELF_LIBC6 },        \
> -  { "/lib/ld-linux-arceb.so.2", FLAG_ELF_LIBC6 },
> -
> -#define SYSDEP_KNOWN_LIBRARY_NAMES     \
> -  { "libc.so.6", FLAG_ELF_LIBC6 },     \
> -  { "libm.so.6", FLAG_ELF_LIBC6 },
> diff --git a/sysdeps/unix/sysv/linux/arm/ldconfig.h b/sysdeps/unix/sysv/linux/arm/ldconfig.h
> index d839470cfe..b3fa8ceebe 100644
> --- a/sysdeps/unix/sysv/linux/arm/ldconfig.h
> +++ b/sysdeps/unix/sysv/linux/arm/ldconfig.h
> @@ -16,10 +16,3 @@
>     <https://www.gnu.org/licenses/>.  */
>  
>  #include <sysdeps/generic/ldconfig.h>
> -
> -#define SYSDEP_KNOWN_INTERPRETER_NAMES \
> -  { "/lib/ld-linux.so.3", FLAG_ELF_LIBC6 }, \
> -  { "/lib/ld-linux-armhf.so.3", FLAG_ELF_LIBC6 },
> -#define SYSDEP_KNOWN_LIBRARY_NAMES \
> -  { "libc.so.6", FLAG_ELF_LIBC6 },     \
> -  { "libm.so.6", FLAG_ELF_LIBC6 },
> diff --git a/sysdeps/unix/sysv/linux/csky/ldconfig.h b/sysdeps/unix/sysv/linux/csky/ldconfig.h
> index eeda37e4a8..6861f71327 100644
> --- a/sysdeps/unix/sysv/linux/csky/ldconfig.h
> +++ b/sysdeps/unix/sysv/linux/csky/ldconfig.h
> @@ -26,9 +26,3 @@
>  #else
>  # define LD_SO_ABI "cskyv2"
>  #endif
> -
> -#define SYSDEP_KNOWN_INTERPRETER_NAMES \
> -  { LD_SO_PREFIX LD_SO_ABI LD_SO_SUFFIX, FLAG_ELF_LIBC6 },
> -#define SYSDEP_KNOWN_LIBRARY_NAMES     \
> -  { "libc.so.6", FLAG_ELF_LIBC6 },     \
> -  { "libm.so.6", FLAG_ELF_LIBC6 },
> diff --git a/sysdeps/unix/sysv/linux/ia64/ldconfig.h b/sysdeps/unix/sysv/linux/ia64/ldconfig.h
> index 53685659ed..b3fa8ceebe 100644
> --- a/sysdeps/unix/sysv/linux/ia64/ldconfig.h
> +++ b/sysdeps/unix/sysv/linux/ia64/ldconfig.h
> @@ -16,9 +16,3 @@
>     <https://www.gnu.org/licenses/>.  */
>  
>  #include <sysdeps/generic/ldconfig.h>
> -
> -#define SYSDEP_KNOWN_INTERPRETER_NAMES \
> -  { "/lib/ld-linux.so.2", FLAG_ELF_LIBC6 },
> -#define SYSDEP_KNOWN_LIBRARY_NAMES \
> -  { "libc.so.6", FLAG_ELF_LIBC6 },     \
> -  { "libm.so.6", FLAG_ELF_LIBC6 },
> diff --git a/sysdeps/unix/sysv/linux/powerpc/ldconfig.h b/sysdeps/unix/sysv/linux/powerpc/ldconfig.h
> index 09d75b3dec..d0935d541b 100644
> --- a/sysdeps/unix/sysv/linux/powerpc/ldconfig.h
> +++ b/sysdeps/unix/sysv/linux/powerpc/ldconfig.h
> @@ -17,11 +17,3 @@
>     <https://www.gnu.org/licenses/>.  */
>  
>  #include <sysdeps/generic/ldconfig.h>
> -
> -#define SYSDEP_KNOWN_INTERPRETER_NAMES \
> -  { "/lib/ld.so.1", FLAG_ELF_LIBC6 },  \
> -  { "/lib64/ld64.so.1", FLAG_ELF_LIBC6 }, \
> -  { "/lib64/ld64.so.2", FLAG_ELF_LIBC6 },
> -#define SYSDEP_KNOWN_LIBRARY_NAMES \
> -  { "libc.so.6", FLAG_ELF_LIBC6 },     \
> -  { "libm.so.6", FLAG_ELF_LIBC6 },
> diff --git a/sysdeps/unix/sysv/linux/riscv/ldconfig.h b/sysdeps/unix/sysv/linux/riscv/ldconfig.h
> index e6e7d271ad..24aae5155a 100644
> --- a/sysdeps/unix/sysv/linux/riscv/ldconfig.h
> +++ b/sysdeps/unix/sysv/linux/riscv/ldconfig.h
> @@ -17,20 +17,3 @@
>     <https://www.gnu.org/licenses/>.  */
>  
>  #include <sysdeps/generic/ldconfig.h>
> -
> -#define LD_SO_PREFIX "/lib/ld-linux-"
> -#define LD_SO_SUFFIX ".so.1"
> -
> -#if __riscv_xlen == 64
> -# define LD_SO_ABI "riscv64-lp64"
> -#else
> -# define LD_SO_ABI "riscv32-ilp32"
> -#endif
> -
> -#define SYSDEP_KNOWN_INTERPRETER_NAMES                         \
> -  { LD_SO_PREFIX LD_SO_ABI "d" LD_SO_SUFFIX, FLAG_ELF_LIBC6 }, \
> -  { LD_SO_PREFIX LD_SO_ABI     LD_SO_SUFFIX, FLAG_ELF_LIBC6 },
> -
> -#define SYSDEP_KNOWN_LIBRARY_NAMES     \
> -  { "libc.so.6", FLAG_ELF_LIBC6 },     \
> -  { "libm.so.6", FLAG_ELF_LIBC6 },
> diff --git a/sysdeps/unix/sysv/linux/s390/ldconfig.h b/sysdeps/unix/sysv/linux/s390/ldconfig.h
> index 83086ce843..b3fa8ceebe 100644
> --- a/sysdeps/unix/sysv/linux/s390/ldconfig.h
> +++ b/sysdeps/unix/sysv/linux/s390/ldconfig.h
> @@ -16,10 +16,3 @@
>     <https://www.gnu.org/licenses/>.  */
>  
>  #include <sysdeps/generic/ldconfig.h>
> -
> -#define SYSDEP_KNOWN_INTERPRETER_NAMES \
> -  { "/lib/ld.so.1", FLAG_ELF_LIBC6 },  \
> -  { "/lib/ld64.so.1", FLAG_ELF_LIBC6 },
> -#define SYSDEP_KNOWN_LIBRARY_NAMES \
> -  { "libc.so.6", FLAG_ELF_LIBC6 },     \
> -  { "libm.so.6", FLAG_ELF_LIBC6 },
> diff --git a/sysdeps/unix/sysv/linux/x86_64/ldconfig.h b/sysdeps/unix/sysv/linux/x86_64/ldconfig.h
> index 1089668f09..b3fa8ceebe 100644
> --- a/sysdeps/unix/sysv/linux/x86_64/ldconfig.h
> +++ b/sysdeps/unix/sysv/linux/x86_64/ldconfig.h
> @@ -16,11 +16,3 @@
>     <https://www.gnu.org/licenses/>.  */
>  
>  #include <sysdeps/generic/ldconfig.h>
> -
> -#define SYSDEP_KNOWN_INTERPRETER_NAMES \
> -  { "/lib/ld-linux.so.2", FLAG_ELF_LIBC6 }, \
> -  { "/libx32/ld-linux-x32.so.2", FLAG_ELF_LIBC6 }, \
> -  { "/lib64/ld-linux-x86-64.so.2", FLAG_ELF_LIBC6 },
> -#define SYSDEP_KNOWN_LIBRARY_NAMES \
> -  { "libc.so.6", FLAG_ELF_LIBC6 },     \
> -  { "libm.so.6", FLAG_ELF_LIBC6 },
> -- 
> 2.31.1
>

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

* Re: [RFC] Remove special flags of libc.5.so and libc.4.so
  2021-12-22 15:31   ` [RFC] Remove special flags of libc.5.so and libc.4.so Lucas A. M. Magalhaes
  2022-01-10 19:21     ` Lucas A. M. Magalhaes
@ 2022-01-11 19:22     ` Adhemerval Zanella
  2022-03-02 19:37       ` Raoni Fassina Firmino
  2022-02-23 22:17     ` Raoni Fassina Firmino
  2 siblings, 1 reply; 15+ messages in thread
From: Adhemerval Zanella @ 2022-01-11 19:22 UTC (permalink / raw)
  To: Lucas A. M. Magalhaes, libc-alpha; +Cc: fweimer, tuliom



On 22/12/2021 12:31, Lucas A. M. Magalhaes via Libc-alpha wrote:
> I've tested it in a AT build and was able to build and link programs as
> expected. For other archs I try with build-many-glibcs.py, all
> succeeded.
> 
> Any other suggestions on how to test this?
> 
> Florian am I missing something? Should we add a restriction to cache
> just new libc6.so compatible libraries?
> 
> -- 8< --
> 
> The older libcs version are obsolete for over twenty years now. This
> commit removes special flags of libc.5.so and libc.4.so.. It assume that
> all libraries cached are libc.6.so compatible and wrote FLAG_ELF_LIBC6.
> 
> Tested on x86_64, powerpc, powerpc64 and powerpc64le.
> Tested with build-many-glibcs.py for the other affected architectures.

I think it makes sense to stop support libc.4 and libc.5 and assume
FLAG_ELF_LIBC6 by ldconfig.

I also think it should be safe to just get rid of the arch-specific
SYSDEP_KNOWN_INTERPRETER_NAMES, at least in theory it should not be
used by the cache (so there is not need to actually classify it).

> ---
>  elf/cache.c                                |  6 +--
>  elf/ldconfig.c                             | 33 +---------------
>  elf/readelflib.c                           | 46 +++-------------------
>  elf/readlib.c                              | 25 +-----------
>  sysdeps/unix/sysv/linux/arc/ldconfig.h     |  8 ----
>  sysdeps/unix/sysv/linux/arm/ldconfig.h     |  7 ----
>  sysdeps/unix/sysv/linux/csky/ldconfig.h    |  6 ---
>  sysdeps/unix/sysv/linux/ia64/ldconfig.h    |  6 ---
>  sysdeps/unix/sysv/linux/powerpc/ldconfig.h |  8 ----
>  sysdeps/unix/sysv/linux/riscv/ldconfig.h   | 17 --------
>  sysdeps/unix/sysv/linux/s390/ldconfig.h    |  7 ----
>  sysdeps/unix/sysv/linux/x86_64/ldconfig.h  |  8 ----
>  12 files changed, 11 insertions(+), 166 deletions(-)
> 
> diff --git a/elf/cache.c b/elf/cache.c
> index 1c0dc5ee87..387dd11a05 100644
> --- a/elf/cache.c
> +++ b/elf/cache.c
> @@ -158,6 +158,7 @@ struct cache_entry
>  /* List of all cache entries.  */
>  static struct cache_entry *entries;
>  
> +/* libc4, ELF and libc5 are unsupported */
>  static const char *flag_descr[] =
>  { "libc4", "ELF", "libc5", "libc6"};
>  
> @@ -169,14 +170,11 @@ print_entry (const char *lib, int flag, unsigned int osversion,
>    printf ("\t%s (", lib);
>    switch (flag & FLAG_TYPE_MASK)
>      {
> -    case FLAG_LIBC4:
> -    case FLAG_ELF:
> -    case FLAG_ELF_LIBC5:
>      case FLAG_ELF_LIBC6:
>        fputs (flag_descr[flag & FLAG_TYPE_MASK], stdout);
>        break;
>      default:
> -      fputs (_("unknown"), stdout);
> +      fputs (_("Unknown or unsupported flag"), stdout);
>        break;
>      }
>    switch (flag & FLAG_REQUIRED_MASK)
> diff --git a/elf/ldconfig.c b/elf/ldconfig.c
> index 101d56ac8e..d64b134781 100644
> --- a/elf/ldconfig.c
> +++ b/elf/ldconfig.c
> @@ -65,19 +65,6 @@
>  
>  #define PACKAGE _libc_intl_domainname
>  
> -static const struct
> -{
> -  const char *name;
> -  int flag;
> -} lib_types[] =
> -{
> -  {"libc4", FLAG_LIBC4},
> -  {"libc5", FLAG_ELF_LIBC5},
> -  {"libc6", FLAG_ELF_LIBC6},
> -  {"glibc2", FLAG_ELF_LIBC6}
> -};
> -
> -
>  /* List of directories to handle.  */
>  struct dir_entry
>  {
> @@ -471,25 +458,7 @@ add_dir_1 (const char *line, const char *from_file, int from_line)
>  
>    /* Search for an '=' sign.  */
>    entry->path = xstrdup (line);
> -  char *equal_sign = strchr (entry->path, '=');
> -  if (equal_sign)
> -    {
> -      *equal_sign = '\0';
> -      ++equal_sign;
> -      entry->flag = FLAG_ANY;
> -      for (i = 0; i < sizeof (lib_types) / sizeof (lib_types[0]); ++i)
> -	if (strcmp (equal_sign, lib_types[i].name) == 0)
> -	  {
> -	    entry->flag = lib_types[i].flag;
> -	    break;
> -	  }
> -      if (entry->flag == FLAG_ANY)
> -	error (0, 0, _("%s is not a known library type"), equal_sign);
> -    }
> -  else
> -    {
> -      entry->flag = FLAG_ANY;
> -    }
> +  entry->flag = FLAG_ELF_LIBC6;
>  
>    /* Canonify path: for now only remove leading and trailing
>       whitespace and the trailing slashes.  */
> diff --git a/elf/readelflib.c b/elf/readelflib.c
> index 10b10b6080..801c5587ab 100644
> --- a/elf/readelflib.c
> +++ b/elf/readelflib.c
> @@ -44,7 +44,6 @@ process_elf_file (const char *file_name, const char *lib, int *flag,
>  		  char **soname, void *file_contents, size_t file_length)
>  {
>    int i;
> -  unsigned int j;
>    unsigned int dynamic_addr;
>    size_t dynamic_size;
>    char *program_interpreter;
> @@ -82,9 +81,8 @@ process_elf_file (const char *file_name, const char *lib, int *flag,
>    elf_pheader = (ElfW(Phdr) *) (elf_header->e_phoff + file_contents);
>    check_ptr (elf_pheader);
>  
> -  /* The library is an elf library, now search for soname and
> -     libc5/libc6.  */
> -  *flag = FLAG_ELF;
> +  /* The library is an elf library   */
> +  *flag = FLAG_ELF_LIBC6;
>  
>    /* The default ISA level is 0.  */
>    *isa_level = 0;
> @@ -111,16 +109,6 @@ process_elf_file (const char *file_name, const char *lib, int *flag,
>  	  program_interpreter = (char *) (file_contents + segment->p_offset);
>  	  check_ptr (program_interpreter);
>  
> -	  /* Check if this is enough to classify the binary.  */
> -	  for (j = 0; j < sizeof (interpreters) / sizeof (interpreters [0]);
> -	       ++j)
> -	    if (strcmp (program_interpreter, interpreters[j].soname) == 0)
> -	      {
> -		*flag = interpreters[j].flag;
> -		break;
> -	      }
> -	  break;
> -
>  	case PT_NOTE:
>  	  if (!*osversion && segment->p_filesz >= 32 && segment->p_align >= 4)
>  	    {
> @@ -291,38 +279,16 @@ done:
>    if (dynamic_strings == NULL)
>      return 1;
>  
> -  /* Now read the DT_NEEDED and DT_SONAME entries.  */
> +  /* Now read the DT_SONAME entries.  */
>    for (dyn_entry = dynamic_segment; dyn_entry->d_tag != DT_NULL;
>         ++dyn_entry)
>      {
> -      if (dyn_entry->d_tag == DT_NEEDED || dyn_entry->d_tag == DT_SONAME)
> +      if (dyn_entry->d_tag == DT_SONAME)
>  	{
>  	  char *name = dynamic_strings + dyn_entry->d_un.d_val;
>  	  check_ptr (name);
> -
> -	  if (dyn_entry->d_tag == DT_NEEDED)
> -	    {
> -
> -	      if (*flag == FLAG_ELF)
> -		{
> -		  /* Check if this is enough to classify the binary.  */
> -		  for (j = 0;
> -		       j < sizeof (known_libs) / sizeof (known_libs [0]);
> -		       ++j)
> -		    if (strcmp (name, known_libs [j].soname) == 0)
> -		      {
> -			*flag = known_libs [j].flag;
> -			break;
> -		      }
> -		}
> -	    }
> -
> -	  else if (dyn_entry->d_tag == DT_SONAME)
> -	    *soname = xstrdup (name);
> -
> -	  /* Do we have everything we need?  */
> -	  if (*soname && *flag != FLAG_ELF)
> -	    return 0;
> +          *soname = xstrdup (name);
> +          return 0;
>  	}
>      }
>  
> diff --git a/elf/readlib.c b/elf/readlib.c
> index 64b20d7804..9164c1cda7 100644
> --- a/elf/readlib.c
> +++ b/elf/readlib.c
> @@ -43,24 +43,6 @@ struct known_names
>    int flag;
>  };
>  
> -static struct known_names interpreters[] =
> -{
> -  { "/lib/" LD_SO, FLAG_ELF_LIBC6 },
> -#ifdef SYSDEP_KNOWN_INTERPRETER_NAMES
> -  SYSDEP_KNOWN_INTERPRETER_NAMES
> -#endif
> -};
> -
> -static struct known_names known_libs[] =
> -{
> -  { LIBC_SO, FLAG_ELF_LIBC6 },
> -  { LIBM_SO, FLAG_ELF_LIBC6 },
> -#ifdef SYSDEP_KNOWN_LIBRARY_NAMES
> -  SYSDEP_KNOWN_LIBRARY_NAMES
> -#endif
> -};
> -
> -
>  /* Check if string corresponds to a GDB Python file.  */
>  static bool
>  is_gdb_python_file (const char *name)
> @@ -84,7 +66,8 @@ process_file (const char *real_file_name, const char *file_name,
>    struct exec *aout_header;
>  
>    ret = 0;
> -  *flag = FLAG_ANY;
> +  /* Just set FLAG_ELF_LIBC6 as old formats are not supported anymore.  */
> +  *flag = FLAG_ELF_LIBC6;
>    *soname = NULL;
>  
>    file = fopen (real_file_name, "rb");
> @@ -151,7 +134,6 @@ process_file (const char *real_file_name, const char *file_name,
>  	    *dot = '\0';
>  	}
>        *soname = copy;
> -      *flag = FLAG_LIBC4;
>        goto done;
>      }
>  
> @@ -192,9 +174,6 @@ implicit_soname (const char *lib, int flag)
>  {
>    char *soname = xstrdup (lib);
>  
> -  if ((flag & FLAG_TYPE_MASK) != FLAG_LIBC4)
> -    return soname;
> -
>    /* Aout files don't have a soname, just return the name
>       including the major number.  */
>    char *major = strstr (soname, ".so.");
> diff --git a/sysdeps/unix/sysv/linux/arc/ldconfig.h b/sysdeps/unix/sysv/linux/arc/ldconfig.h
> index 8c776fca9e..02ed826283 100644
> --- a/sysdeps/unix/sysv/linux/arc/ldconfig.h
> +++ b/sysdeps/unix/sysv/linux/arc/ldconfig.h
> @@ -17,11 +17,3 @@
>     <https://www.gnu.org/licenses/>.  */
>  
>  #include <sysdeps/generic/ldconfig.h>
> -
> -#define SYSDEP_KNOWN_INTERPRETER_NAMES 		\
> -  { "/lib/ld-linux-arc.so.2", FLAG_ELF_LIBC6 },	\
> -  { "/lib/ld-linux-arceb.so.2", FLAG_ELF_LIBC6 },
> -
> -#define SYSDEP_KNOWN_LIBRARY_NAMES 	\
> -  { "libc.so.6", FLAG_ELF_LIBC6 },	\
> -  { "libm.so.6", FLAG_ELF_LIBC6 },
> diff --git a/sysdeps/unix/sysv/linux/arm/ldconfig.h b/sysdeps/unix/sysv/linux/arm/ldconfig.h
> index d839470cfe..b3fa8ceebe 100644
> --- a/sysdeps/unix/sysv/linux/arm/ldconfig.h
> +++ b/sysdeps/unix/sysv/linux/arm/ldconfig.h
> @@ -16,10 +16,3 @@
>     <https://www.gnu.org/licenses/>.  */
>  
>  #include <sysdeps/generic/ldconfig.h>
> -
> -#define SYSDEP_KNOWN_INTERPRETER_NAMES \
> -  { "/lib/ld-linux.so.3", FLAG_ELF_LIBC6 }, \
> -  { "/lib/ld-linux-armhf.so.3", FLAG_ELF_LIBC6 },
> -#define SYSDEP_KNOWN_LIBRARY_NAMES \
> -  { "libc.so.6", FLAG_ELF_LIBC6 },	\
> -  { "libm.so.6", FLAG_ELF_LIBC6 },
> diff --git a/sysdeps/unix/sysv/linux/csky/ldconfig.h b/sysdeps/unix/sysv/linux/csky/ldconfig.h
> index eeda37e4a8..6861f71327 100644
> --- a/sysdeps/unix/sysv/linux/csky/ldconfig.h
> +++ b/sysdeps/unix/sysv/linux/csky/ldconfig.h
> @@ -26,9 +26,3 @@
>  #else
>  # define LD_SO_ABI "cskyv2"
>  #endif
> -
> -#define SYSDEP_KNOWN_INTERPRETER_NAMES	\
> -  { LD_SO_PREFIX LD_SO_ABI LD_SO_SUFFIX, FLAG_ELF_LIBC6 },
> -#define SYSDEP_KNOWN_LIBRARY_NAMES	\
> -  { "libc.so.6", FLAG_ELF_LIBC6 },	\
> -  { "libm.so.6", FLAG_ELF_LIBC6 },
> diff --git a/sysdeps/unix/sysv/linux/ia64/ldconfig.h b/sysdeps/unix/sysv/linux/ia64/ldconfig.h
> index 53685659ed..b3fa8ceebe 100644
> --- a/sysdeps/unix/sysv/linux/ia64/ldconfig.h
> +++ b/sysdeps/unix/sysv/linux/ia64/ldconfig.h
> @@ -16,9 +16,3 @@
>     <https://www.gnu.org/licenses/>.  */
>  
>  #include <sysdeps/generic/ldconfig.h>
> -
> -#define SYSDEP_KNOWN_INTERPRETER_NAMES \
> -  { "/lib/ld-linux.so.2", FLAG_ELF_LIBC6 },
> -#define SYSDEP_KNOWN_LIBRARY_NAMES \
> -  { "libc.so.6", FLAG_ELF_LIBC6 },	\
> -  { "libm.so.6", FLAG_ELF_LIBC6 },
> diff --git a/sysdeps/unix/sysv/linux/powerpc/ldconfig.h b/sysdeps/unix/sysv/linux/powerpc/ldconfig.h
> index 09d75b3dec..d0935d541b 100644
> --- a/sysdeps/unix/sysv/linux/powerpc/ldconfig.h
> +++ b/sysdeps/unix/sysv/linux/powerpc/ldconfig.h
> @@ -17,11 +17,3 @@
>     <https://www.gnu.org/licenses/>.  */
>  
>  #include <sysdeps/generic/ldconfig.h>
> -
> -#define SYSDEP_KNOWN_INTERPRETER_NAMES \
> -  { "/lib/ld.so.1", FLAG_ELF_LIBC6 },	\
> -  { "/lib64/ld64.so.1", FLAG_ELF_LIBC6 }, \
> -  { "/lib64/ld64.so.2", FLAG_ELF_LIBC6 },
> -#define SYSDEP_KNOWN_LIBRARY_NAMES \
> -  { "libc.so.6", FLAG_ELF_LIBC6 },	\
> -  { "libm.so.6", FLAG_ELF_LIBC6 },
> diff --git a/sysdeps/unix/sysv/linux/riscv/ldconfig.h b/sysdeps/unix/sysv/linux/riscv/ldconfig.h
> index e6e7d271ad..24aae5155a 100644
> --- a/sysdeps/unix/sysv/linux/riscv/ldconfig.h
> +++ b/sysdeps/unix/sysv/linux/riscv/ldconfig.h
> @@ -17,20 +17,3 @@
>     <https://www.gnu.org/licenses/>.  */
>  
>  #include <sysdeps/generic/ldconfig.h>
> -
> -#define LD_SO_PREFIX "/lib/ld-linux-"
> -#define LD_SO_SUFFIX ".so.1"
> -
> -#if __riscv_xlen == 64
> -# define LD_SO_ABI "riscv64-lp64"
> -#else
> -# define LD_SO_ABI "riscv32-ilp32"
> -#endif
> -
> -#define SYSDEP_KNOWN_INTERPRETER_NAMES				\
> -  { LD_SO_PREFIX LD_SO_ABI "d" LD_SO_SUFFIX, FLAG_ELF_LIBC6 },	\
> -  { LD_SO_PREFIX LD_SO_ABI     LD_SO_SUFFIX, FLAG_ELF_LIBC6 },
> -
> -#define SYSDEP_KNOWN_LIBRARY_NAMES	\
> -  { "libc.so.6", FLAG_ELF_LIBC6 },	\
> -  { "libm.so.6", FLAG_ELF_LIBC6 },
> diff --git a/sysdeps/unix/sysv/linux/s390/ldconfig.h b/sysdeps/unix/sysv/linux/s390/ldconfig.h
> index 83086ce843..b3fa8ceebe 100644
> --- a/sysdeps/unix/sysv/linux/s390/ldconfig.h
> +++ b/sysdeps/unix/sysv/linux/s390/ldconfig.h
> @@ -16,10 +16,3 @@
>     <https://www.gnu.org/licenses/>.  */
>  
>  #include <sysdeps/generic/ldconfig.h>
> -
> -#define SYSDEP_KNOWN_INTERPRETER_NAMES \
> -  { "/lib/ld.so.1", FLAG_ELF_LIBC6 },	\
> -  { "/lib/ld64.so.1", FLAG_ELF_LIBC6 },
> -#define SYSDEP_KNOWN_LIBRARY_NAMES \
> -  { "libc.so.6", FLAG_ELF_LIBC6 },	\
> -  { "libm.so.6", FLAG_ELF_LIBC6 },
> diff --git a/sysdeps/unix/sysv/linux/x86_64/ldconfig.h b/sysdeps/unix/sysv/linux/x86_64/ldconfig.h
> index 1089668f09..b3fa8ceebe 100644
> --- a/sysdeps/unix/sysv/linux/x86_64/ldconfig.h
> +++ b/sysdeps/unix/sysv/linux/x86_64/ldconfig.h
> @@ -16,11 +16,3 @@
>     <https://www.gnu.org/licenses/>.  */
>  
>  #include <sysdeps/generic/ldconfig.h>
> -
> -#define SYSDEP_KNOWN_INTERPRETER_NAMES \
> -  { "/lib/ld-linux.so.2", FLAG_ELF_LIBC6 }, \
> -  { "/libx32/ld-linux-x32.so.2", FLAG_ELF_LIBC6 }, \
> -  { "/lib64/ld-linux-x86-64.so.2", FLAG_ELF_LIBC6 },
> -#define SYSDEP_KNOWN_LIBRARY_NAMES \
> -  { "libc.so.6", FLAG_ELF_LIBC6 },	\
> -  { "libm.so.6", FLAG_ELF_LIBC6 },

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

* Re: [PATCH] powerpc: Use FLAG_ELF_LIBC6 for 32-bit known libraries
  2021-11-04 18:10 ` [PATCH] powerpc: Use FLAG_ELF_LIBC6 for 32-bit known libraries Lucas A. M. Magalhaes
                     ` (2 preceding siblings ...)
  2021-12-03 14:51   ` Adhemerval Zanella
@ 2022-02-23 22:09   ` Raoni Fassina Firmino
  3 siblings, 0 replies; 15+ messages in thread
From: Raoni Fassina Firmino @ 2022-02-23 22:09 UTC (permalink / raw)
  To: Lucas A. M. Magalhaes; +Cc: libc-alpha, fweimer, tuliom

I tested this on top of master without regression in the following
configurations:

powerpc-linux-gnu
powerpc64-linux-gnu  (with -m64 and with m32)
powerpc64le-linux-gnu


I know that Adhemerval raised some points about the approach chosen (I
don't have the knowledge to comment about that right now), but apart
from that this implementation LGTM.


o/
Raoni

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

* Re: [RFC] Remove special flags of libc.5.so and libc.4.so
  2021-12-22 15:31   ` [RFC] Remove special flags of libc.5.so and libc.4.so Lucas A. M. Magalhaes
  2022-01-10 19:21     ` Lucas A. M. Magalhaes
  2022-01-11 19:22     ` Adhemerval Zanella
@ 2022-02-23 22:17     ` Raoni Fassina Firmino
  2 siblings, 0 replies; 15+ messages in thread
From: Raoni Fassina Firmino @ 2022-02-23 22:17 UTC (permalink / raw)
  To: Lucas A. M. Magalhaes; +Cc: libc-alpha, fweimer, tuliom

While testing Lucas previous patch I decided to test this one too, so I
tested this on top of master without regression in the following
configurations:

powerpc-linux-gnu
powerpc64-linux-gnu  (with -m64 and with -m32)
powerpc64le-linux-gnu
ppc64le-redhat-linux
x86_64-linux-gnu  (with -m64 and with -m32 with all the other flags to build 32bits)


o/
Raoni

On Wed, Dec 22, 2021 at 12:31:51PM -0300, AL glibc-alpha wrote:
> I've tested it in a AT build and was able to build and link programs as
> expected. For other archs I try with build-many-glibcs.py, all
> succeeded.
> 
> Any other suggestions on how to test this?
> 
> Florian am I missing something? Should we add a restriction to cache
> just new libc6.so compatible libraries?
> 
> -- 8< --
> 
> The older libcs version are obsolete for over twenty years now. This
> commit removes special flags of libc.5.so and libc.4.so.. It assume that
> all libraries cached are libc.6.so compatible and wrote FLAG_ELF_LIBC6.
> 
> Tested on x86_64, powerpc, powerpc64 and powerpc64le.
> Tested with build-many-glibcs.py for the other affected architectures.
> ---
>  elf/cache.c                                |  6 +--
>  elf/ldconfig.c                             | 33 +---------------
>  elf/readelflib.c                           | 46 +++-------------------
>  elf/readlib.c                              | 25 +-----------
>  sysdeps/unix/sysv/linux/arc/ldconfig.h     |  8 ----
>  sysdeps/unix/sysv/linux/arm/ldconfig.h     |  7 ----
>  sysdeps/unix/sysv/linux/csky/ldconfig.h    |  6 ---
>  sysdeps/unix/sysv/linux/ia64/ldconfig.h    |  6 ---
>  sysdeps/unix/sysv/linux/powerpc/ldconfig.h |  8 ----
>  sysdeps/unix/sysv/linux/riscv/ldconfig.h   | 17 --------
>  sysdeps/unix/sysv/linux/s390/ldconfig.h    |  7 ----
>  sysdeps/unix/sysv/linux/x86_64/ldconfig.h  |  8 ----
>  12 files changed, 11 insertions(+), 166 deletions(-)
> 
> diff --git a/elf/cache.c b/elf/cache.c
> index 1c0dc5ee87..387dd11a05 100644
> --- a/elf/cache.c
> +++ b/elf/cache.c
> @@ -158,6 +158,7 @@ struct cache_entry
>  /* List of all cache entries.  */
>  static struct cache_entry *entries;
>  
> +/* libc4, ELF and libc5 are unsupported */
>  static const char *flag_descr[] =
>  { "libc4", "ELF", "libc5", "libc6"};
>  
> @@ -169,14 +170,11 @@ print_entry (const char *lib, int flag, unsigned int osversion,
>    printf ("\t%s (", lib);
>    switch (flag & FLAG_TYPE_MASK)
>      {
> -    case FLAG_LIBC4:
> -    case FLAG_ELF:
> -    case FLAG_ELF_LIBC5:
>      case FLAG_ELF_LIBC6:
>        fputs (flag_descr[flag & FLAG_TYPE_MASK], stdout);
>        break;
>      default:
> -      fputs (_("unknown"), stdout);
> +      fputs (_("Unknown or unsupported flag"), stdout);
>        break;
>      }
>    switch (flag & FLAG_REQUIRED_MASK)
> diff --git a/elf/ldconfig.c b/elf/ldconfig.c
> index 101d56ac8e..d64b134781 100644
> --- a/elf/ldconfig.c
> +++ b/elf/ldconfig.c
> @@ -65,19 +65,6 @@
>  
>  #define PACKAGE _libc_intl_domainname
>  
> -static const struct
> -{
> -  const char *name;
> -  int flag;
> -} lib_types[] =
> -{
> -  {"libc4", FLAG_LIBC4},
> -  {"libc5", FLAG_ELF_LIBC5},
> -  {"libc6", FLAG_ELF_LIBC6},
> -  {"glibc2", FLAG_ELF_LIBC6}
> -};
> -
> -
>  /* List of directories to handle.  */
>  struct dir_entry
>  {
> @@ -471,25 +458,7 @@ add_dir_1 (const char *line, const char *from_file, int from_line)
>  
>    /* Search for an '=' sign.  */
>    entry->path = xstrdup (line);
> -  char *equal_sign = strchr (entry->path, '=');
> -  if (equal_sign)
> -    {
> -      *equal_sign = '\0';
> -      ++equal_sign;
> -      entry->flag = FLAG_ANY;
> -      for (i = 0; i < sizeof (lib_types) / sizeof (lib_types[0]); ++i)
> -	if (strcmp (equal_sign, lib_types[i].name) == 0)
> -	  {
> -	    entry->flag = lib_types[i].flag;
> -	    break;
> -	  }
> -      if (entry->flag == FLAG_ANY)
> -	error (0, 0, _("%s is not a known library type"), equal_sign);
> -    }
> -  else
> -    {
> -      entry->flag = FLAG_ANY;
> -    }
> +  entry->flag = FLAG_ELF_LIBC6;
>  
>    /* Canonify path: for now only remove leading and trailing
>       whitespace and the trailing slashes.  */
> diff --git a/elf/readelflib.c b/elf/readelflib.c
> index 10b10b6080..801c5587ab 100644
> --- a/elf/readelflib.c
> +++ b/elf/readelflib.c
> @@ -44,7 +44,6 @@ process_elf_file (const char *file_name, const char *lib, int *flag,
>  		  char **soname, void *file_contents, size_t file_length)
>  {
>    int i;
> -  unsigned int j;
>    unsigned int dynamic_addr;
>    size_t dynamic_size;
>    char *program_interpreter;
> @@ -82,9 +81,8 @@ process_elf_file (const char *file_name, const char *lib, int *flag,
>    elf_pheader = (ElfW(Phdr) *) (elf_header->e_phoff + file_contents);
>    check_ptr (elf_pheader);
>  
> -  /* The library is an elf library, now search for soname and
> -     libc5/libc6.  */
> -  *flag = FLAG_ELF;
> +  /* The library is an elf library   */
> +  *flag = FLAG_ELF_LIBC6;
>  
>    /* The default ISA level is 0.  */
>    *isa_level = 0;
> @@ -111,16 +109,6 @@ process_elf_file (const char *file_name, const char *lib, int *flag,
>  	  program_interpreter = (char *) (file_contents + segment->p_offset);
>  	  check_ptr (program_interpreter);
>  
> -	  /* Check if this is enough to classify the binary.  */
> -	  for (j = 0; j < sizeof (interpreters) / sizeof (interpreters [0]);
> -	       ++j)
> -	    if (strcmp (program_interpreter, interpreters[j].soname) == 0)
> -	      {
> -		*flag = interpreters[j].flag;
> -		break;
> -	      }
> -	  break;
> -
>  	case PT_NOTE:
>  	  if (!*osversion && segment->p_filesz >= 32 && segment->p_align >= 4)
>  	    {
> @@ -291,38 +279,16 @@ done:
>    if (dynamic_strings == NULL)
>      return 1;
>  
> -  /* Now read the DT_NEEDED and DT_SONAME entries.  */
> +  /* Now read the DT_SONAME entries.  */
>    for (dyn_entry = dynamic_segment; dyn_entry->d_tag != DT_NULL;
>         ++dyn_entry)
>      {
> -      if (dyn_entry->d_tag == DT_NEEDED || dyn_entry->d_tag == DT_SONAME)
> +      if (dyn_entry->d_tag == DT_SONAME)
>  	{
>  	  char *name = dynamic_strings + dyn_entry->d_un.d_val;
>  	  check_ptr (name);
> -
> -	  if (dyn_entry->d_tag == DT_NEEDED)
> -	    {
> -
> -	      if (*flag == FLAG_ELF)
> -		{
> -		  /* Check if this is enough to classify the binary.  */
> -		  for (j = 0;
> -		       j < sizeof (known_libs) / sizeof (known_libs [0]);
> -		       ++j)
> -		    if (strcmp (name, known_libs [j].soname) == 0)
> -		      {
> -			*flag = known_libs [j].flag;
> -			break;
> -		      }
> -		}
> -	    }
> -
> -	  else if (dyn_entry->d_tag == DT_SONAME)
> -	    *soname = xstrdup (name);
> -
> -	  /* Do we have everything we need?  */
> -	  if (*soname && *flag != FLAG_ELF)
> -	    return 0;
> +          *soname = xstrdup (name);
> +          return 0;
>  	}
>      }
>  
> diff --git a/elf/readlib.c b/elf/readlib.c
> index 64b20d7804..9164c1cda7 100644
> --- a/elf/readlib.c
> +++ b/elf/readlib.c
> @@ -43,24 +43,6 @@ struct known_names
>    int flag;
>  };
>  
> -static struct known_names interpreters[] =
> -{
> -  { "/lib/" LD_SO, FLAG_ELF_LIBC6 },
> -#ifdef SYSDEP_KNOWN_INTERPRETER_NAMES
> -  SYSDEP_KNOWN_INTERPRETER_NAMES
> -#endif
> -};
> -
> -static struct known_names known_libs[] =
> -{
> -  { LIBC_SO, FLAG_ELF_LIBC6 },
> -  { LIBM_SO, FLAG_ELF_LIBC6 },
> -#ifdef SYSDEP_KNOWN_LIBRARY_NAMES
> -  SYSDEP_KNOWN_LIBRARY_NAMES
> -#endif
> -};
> -
> -
>  /* Check if string corresponds to a GDB Python file.  */
>  static bool
>  is_gdb_python_file (const char *name)
> @@ -84,7 +66,8 @@ process_file (const char *real_file_name, const char *file_name,
>    struct exec *aout_header;
>  
>    ret = 0;
> -  *flag = FLAG_ANY;
> +  /* Just set FLAG_ELF_LIBC6 as old formats are not supported anymore.  */
> +  *flag = FLAG_ELF_LIBC6;
>    *soname = NULL;
>  
>    file = fopen (real_file_name, "rb");
> @@ -151,7 +134,6 @@ process_file (const char *real_file_name, const char *file_name,
>  	    *dot = '\0';
>  	}
>        *soname = copy;
> -      *flag = FLAG_LIBC4;
>        goto done;
>      }
>  
> @@ -192,9 +174,6 @@ implicit_soname (const char *lib, int flag)
>  {
>    char *soname = xstrdup (lib);
>  
> -  if ((flag & FLAG_TYPE_MASK) != FLAG_LIBC4)
> -    return soname;
> -
>    /* Aout files don't have a soname, just return the name
>       including the major number.  */
>    char *major = strstr (soname, ".so.");
> diff --git a/sysdeps/unix/sysv/linux/arc/ldconfig.h b/sysdeps/unix/sysv/linux/arc/ldconfig.h
> index 8c776fca9e..02ed826283 100644
> --- a/sysdeps/unix/sysv/linux/arc/ldconfig.h
> +++ b/sysdeps/unix/sysv/linux/arc/ldconfig.h
> @@ -17,11 +17,3 @@
>     <https://www.gnu.org/licenses/>.  */
>  
>  #include <sysdeps/generic/ldconfig.h>
> -
> -#define SYSDEP_KNOWN_INTERPRETER_NAMES 		\
> -  { "/lib/ld-linux-arc.so.2", FLAG_ELF_LIBC6 },	\
> -  { "/lib/ld-linux-arceb.so.2", FLAG_ELF_LIBC6 },
> -
> -#define SYSDEP_KNOWN_LIBRARY_NAMES 	\
> -  { "libc.so.6", FLAG_ELF_LIBC6 },	\
> -  { "libm.so.6", FLAG_ELF_LIBC6 },
> diff --git a/sysdeps/unix/sysv/linux/arm/ldconfig.h b/sysdeps/unix/sysv/linux/arm/ldconfig.h
> index d839470cfe..b3fa8ceebe 100644
> --- a/sysdeps/unix/sysv/linux/arm/ldconfig.h
> +++ b/sysdeps/unix/sysv/linux/arm/ldconfig.h
> @@ -16,10 +16,3 @@
>     <https://www.gnu.org/licenses/>.  */
>  
>  #include <sysdeps/generic/ldconfig.h>
> -
> -#define SYSDEP_KNOWN_INTERPRETER_NAMES \
> -  { "/lib/ld-linux.so.3", FLAG_ELF_LIBC6 }, \
> -  { "/lib/ld-linux-armhf.so.3", FLAG_ELF_LIBC6 },
> -#define SYSDEP_KNOWN_LIBRARY_NAMES \
> -  { "libc.so.6", FLAG_ELF_LIBC6 },	\
> -  { "libm.so.6", FLAG_ELF_LIBC6 },
> diff --git a/sysdeps/unix/sysv/linux/csky/ldconfig.h b/sysdeps/unix/sysv/linux/csky/ldconfig.h
> index eeda37e4a8..6861f71327 100644
> --- a/sysdeps/unix/sysv/linux/csky/ldconfig.h
> +++ b/sysdeps/unix/sysv/linux/csky/ldconfig.h
> @@ -26,9 +26,3 @@
>  #else
>  # define LD_SO_ABI "cskyv2"
>  #endif
> -
> -#define SYSDEP_KNOWN_INTERPRETER_NAMES	\
> -  { LD_SO_PREFIX LD_SO_ABI LD_SO_SUFFIX, FLAG_ELF_LIBC6 },
> -#define SYSDEP_KNOWN_LIBRARY_NAMES	\
> -  { "libc.so.6", FLAG_ELF_LIBC6 },	\
> -  { "libm.so.6", FLAG_ELF_LIBC6 },
> diff --git a/sysdeps/unix/sysv/linux/ia64/ldconfig.h b/sysdeps/unix/sysv/linux/ia64/ldconfig.h
> index 53685659ed..b3fa8ceebe 100644
> --- a/sysdeps/unix/sysv/linux/ia64/ldconfig.h
> +++ b/sysdeps/unix/sysv/linux/ia64/ldconfig.h
> @@ -16,9 +16,3 @@
>     <https://www.gnu.org/licenses/>.  */
>  
>  #include <sysdeps/generic/ldconfig.h>
> -
> -#define SYSDEP_KNOWN_INTERPRETER_NAMES \
> -  { "/lib/ld-linux.so.2", FLAG_ELF_LIBC6 },
> -#define SYSDEP_KNOWN_LIBRARY_NAMES \
> -  { "libc.so.6", FLAG_ELF_LIBC6 },	\
> -  { "libm.so.6", FLAG_ELF_LIBC6 },
> diff --git a/sysdeps/unix/sysv/linux/powerpc/ldconfig.h b/sysdeps/unix/sysv/linux/powerpc/ldconfig.h
> index 09d75b3dec..d0935d541b 100644
> --- a/sysdeps/unix/sysv/linux/powerpc/ldconfig.h
> +++ b/sysdeps/unix/sysv/linux/powerpc/ldconfig.h
> @@ -17,11 +17,3 @@
>     <https://www.gnu.org/licenses/>.  */
>  
>  #include <sysdeps/generic/ldconfig.h>
> -
> -#define SYSDEP_KNOWN_INTERPRETER_NAMES \
> -  { "/lib/ld.so.1", FLAG_ELF_LIBC6 },	\
> -  { "/lib64/ld64.so.1", FLAG_ELF_LIBC6 }, \
> -  { "/lib64/ld64.so.2", FLAG_ELF_LIBC6 },
> -#define SYSDEP_KNOWN_LIBRARY_NAMES \
> -  { "libc.so.6", FLAG_ELF_LIBC6 },	\
> -  { "libm.so.6", FLAG_ELF_LIBC6 },
> diff --git a/sysdeps/unix/sysv/linux/riscv/ldconfig.h b/sysdeps/unix/sysv/linux/riscv/ldconfig.h
> index e6e7d271ad..24aae5155a 100644
> --- a/sysdeps/unix/sysv/linux/riscv/ldconfig.h
> +++ b/sysdeps/unix/sysv/linux/riscv/ldconfig.h
> @@ -17,20 +17,3 @@
>     <https://www.gnu.org/licenses/>.  */
>  
>  #include <sysdeps/generic/ldconfig.h>
> -
> -#define LD_SO_PREFIX "/lib/ld-linux-"
> -#define LD_SO_SUFFIX ".so.1"
> -
> -#if __riscv_xlen == 64
> -# define LD_SO_ABI "riscv64-lp64"
> -#else
> -# define LD_SO_ABI "riscv32-ilp32"
> -#endif
> -
> -#define SYSDEP_KNOWN_INTERPRETER_NAMES				\
> -  { LD_SO_PREFIX LD_SO_ABI "d" LD_SO_SUFFIX, FLAG_ELF_LIBC6 },	\
> -  { LD_SO_PREFIX LD_SO_ABI     LD_SO_SUFFIX, FLAG_ELF_LIBC6 },
> -
> -#define SYSDEP_KNOWN_LIBRARY_NAMES	\
> -  { "libc.so.6", FLAG_ELF_LIBC6 },	\
> -  { "libm.so.6", FLAG_ELF_LIBC6 },
> diff --git a/sysdeps/unix/sysv/linux/s390/ldconfig.h b/sysdeps/unix/sysv/linux/s390/ldconfig.h
> index 83086ce843..b3fa8ceebe 100644
> --- a/sysdeps/unix/sysv/linux/s390/ldconfig.h
> +++ b/sysdeps/unix/sysv/linux/s390/ldconfig.h
> @@ -16,10 +16,3 @@
>     <https://www.gnu.org/licenses/>.  */
>  
>  #include <sysdeps/generic/ldconfig.h>
> -
> -#define SYSDEP_KNOWN_INTERPRETER_NAMES \
> -  { "/lib/ld.so.1", FLAG_ELF_LIBC6 },	\
> -  { "/lib/ld64.so.1", FLAG_ELF_LIBC6 },
> -#define SYSDEP_KNOWN_LIBRARY_NAMES \
> -  { "libc.so.6", FLAG_ELF_LIBC6 },	\
> -  { "libm.so.6", FLAG_ELF_LIBC6 },
> diff --git a/sysdeps/unix/sysv/linux/x86_64/ldconfig.h b/sysdeps/unix/sysv/linux/x86_64/ldconfig.h
> index 1089668f09..b3fa8ceebe 100644
> --- a/sysdeps/unix/sysv/linux/x86_64/ldconfig.h
> +++ b/sysdeps/unix/sysv/linux/x86_64/ldconfig.h
> @@ -16,11 +16,3 @@
>     <https://www.gnu.org/licenses/>.  */
>  
>  #include <sysdeps/generic/ldconfig.h>
> -
> -#define SYSDEP_KNOWN_INTERPRETER_NAMES \
> -  { "/lib/ld-linux.so.2", FLAG_ELF_LIBC6 }, \
> -  { "/libx32/ld-linux-x32.so.2", FLAG_ELF_LIBC6 }, \
> -  { "/lib64/ld-linux-x86-64.so.2", FLAG_ELF_LIBC6 },
> -#define SYSDEP_KNOWN_LIBRARY_NAMES \
> -  { "libc.so.6", FLAG_ELF_LIBC6 },	\
> -  { "libm.so.6", FLAG_ELF_LIBC6 },
> -- 
> 2.31.1
> 

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

* Re: [PATCH] powerpc: Use FLAG_ELF_LIBC6 for 32-bit known libraries
  2021-12-03 14:51   ` Adhemerval Zanella
@ 2022-03-02 19:30     ` Raoni Fassina Firmino
  2022-03-04 18:49       ` Adhemerval Zanella
  0 siblings, 1 reply; 15+ messages in thread
From: Raoni Fassina Firmino @ 2022-03-02 19:30 UTC (permalink / raw)
  To: Adhemerval Zanella; +Cc: Lucas A. M. Magalhaes, libc-alpha, fweimer, tuliom

On Fri, Dec 03, 2021 at 11:51:29AM -0300, AL glibc-alpha wrote:
> 
> 
> On 04/11/2021 15:10, Lucas A. M. Magalhaes via Libc-alpha wrote:
> > In systems with more versions of the known libraries, i.e. on IBM
> > Advance Toolchain, ldconfig will order them incorrectly on ld.cache.
> > 
> > The issue only occurs with 32-bit libraries that don't depend on libc or
> > libm. That's because process_elf32_file check if the elf depends on one
> > of the libraries at known_libs to select the elf flag. For example, as
> > libc.so.6 don't depend on itself or on libm it will be flagged as
> > FLAG_ELF instead of FLAG_ELF_LIBC6 as expected.
> 
> Wouldn't be simpler to check if the DT_SONAME matches any on 'known_libs' after
> dynamic section parsing and set the appropriated flag on generic 'process_file'? 

But then it would touch every architecture, I think since this is only a
problem affecting powerpc (BE 32bits) I don't think it is worth touch
the generic code if will not help any other architecture.


> (also powerpc SYSDEP_KNOWN_LIBRARY_NAMES seems redundant).

Seems to be the same as every other arch except i386. Lookin at Lucas's
RFC for removal of libc.5 and libc.4 compatibility, maybe it being
diferent in i386 is just that it was never really used anymore, and so
never updated.


o/
Raoni

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

* Re: [RFC] Remove special flags of libc.5.so and libc.4.so
  2022-01-11 19:22     ` Adhemerval Zanella
@ 2022-03-02 19:37       ` Raoni Fassina Firmino
  2022-03-04 18:38         ` Adhemerval Zanella
  0 siblings, 1 reply; 15+ messages in thread
From: Raoni Fassina Firmino @ 2022-03-02 19:37 UTC (permalink / raw)
  To: Adhemerval Zanella; +Cc: Lucas A. M. Magalhaes, libc-alpha, fweimer, tuliom

On Tue, Jan 11, 2022 at 04:22:43PM -0300, AL glibc-alpha wrote:
> 
> 
> On 22/12/2021 12:31, Lucas A. M. Magalhaes via Libc-alpha wrote:
> > I've tested it in a AT build and was able to build and link programs as
> > expected. For other archs I try with build-many-glibcs.py, all
> > succeeded.
> > 
> > Any other suggestions on how to test this?
> > 
> > Florian am I missing something? Should we add a restriction to cache
> > just new libc6.so compatible libraries?
> > 
> > -- 8< --
> > 
> > The older libcs version are obsolete for over twenty years now. This
> > commit removes special flags of libc.5.so and libc.4.so.. It assume that
> > all libraries cached are libc.6.so compatible and wrote FLAG_ELF_LIBC6.
> > 
> > Tested on x86_64, powerpc, powerpc64 and powerpc64le.
> > Tested with build-many-glibcs.py for the other affected architectures.
> 
> I think it makes sense to stop support libc.4 and libc.5 and assume
> FLAG_ELF_LIBC6 by ldconfig.
> 
> I also think it should be safe to just get rid of the arch-specific
> SYSDEP_KNOWN_INTERPRETER_NAMES, at least in theory it should not be
> used by the cache (so there is not need to actually classify it).

Lucas's RFC already removed it for a bunch of architectures, only
leaving i386, aarch64 and mips64, and If my grep did not failed me It
seems like the only uses of YSDEP_KNOWN_LIBRARY_NAMES and
SYSDEP_KNOWN_INTERPRETER_NAMES were in known_libs and interpreters
respectively, both removed in the RFC, so it seems that definitions can
be safely removed (in the context of the RFC).

Not sure if there is a need for more opinions or consensus about this
RFC's idea and approach to move forward with a proper patch for review.


o/
Raoni

> 
> > ---
> >  elf/cache.c                                |  6 +--
> >  elf/ldconfig.c                             | 33 +---------------
> >  elf/readelflib.c                           | 46 +++-------------------
> >  elf/readlib.c                              | 25 +-----------
> >  sysdeps/unix/sysv/linux/arc/ldconfig.h     |  8 ----
> >  sysdeps/unix/sysv/linux/arm/ldconfig.h     |  7 ----
> >  sysdeps/unix/sysv/linux/csky/ldconfig.h    |  6 ---
> >  sysdeps/unix/sysv/linux/ia64/ldconfig.h    |  6 ---
> >  sysdeps/unix/sysv/linux/powerpc/ldconfig.h |  8 ----
> >  sysdeps/unix/sysv/linux/riscv/ldconfig.h   | 17 --------
> >  sysdeps/unix/sysv/linux/s390/ldconfig.h    |  7 ----
> >  sysdeps/unix/sysv/linux/x86_64/ldconfig.h  |  8 ----
> >  12 files changed, 11 insertions(+), 166 deletions(-)
> > 
> > diff --git a/elf/cache.c b/elf/cache.c
> > index 1c0dc5ee87..387dd11a05 100644
> > --- a/elf/cache.c
> > +++ b/elf/cache.c
> > @@ -158,6 +158,7 @@ struct cache_entry
> >  /* List of all cache entries.  */
> >  static struct cache_entry *entries;
> >  
> > +/* libc4, ELF and libc5 are unsupported */
> >  static const char *flag_descr[] =
> >  { "libc4", "ELF", "libc5", "libc6"};
> >  
> > @@ -169,14 +170,11 @@ print_entry (const char *lib, int flag, unsigned int osversion,
> >    printf ("\t%s (", lib);
> >    switch (flag & FLAG_TYPE_MASK)
> >      {
> > -    case FLAG_LIBC4:
> > -    case FLAG_ELF:
> > -    case FLAG_ELF_LIBC5:
> >      case FLAG_ELF_LIBC6:
> >        fputs (flag_descr[flag & FLAG_TYPE_MASK], stdout);
> >        break;
> >      default:
> > -      fputs (_("unknown"), stdout);
> > +      fputs (_("Unknown or unsupported flag"), stdout);
> >        break;
> >      }
> >    switch (flag & FLAG_REQUIRED_MASK)
> > diff --git a/elf/ldconfig.c b/elf/ldconfig.c
> > index 101d56ac8e..d64b134781 100644
> > --- a/elf/ldconfig.c
> > +++ b/elf/ldconfig.c
> > @@ -65,19 +65,6 @@
> >  
> >  #define PACKAGE _libc_intl_domainname
> >  
> > -static const struct
> > -{
> > -  const char *name;
> > -  int flag;
> > -} lib_types[] =
> > -{
> > -  {"libc4", FLAG_LIBC4},
> > -  {"libc5", FLAG_ELF_LIBC5},
> > -  {"libc6", FLAG_ELF_LIBC6},
> > -  {"glibc2", FLAG_ELF_LIBC6}
> > -};
> > -
> > -
> >  /* List of directories to handle.  */
> >  struct dir_entry
> >  {
> > @@ -471,25 +458,7 @@ add_dir_1 (const char *line, const char *from_file, int from_line)
> >  
> >    /* Search for an '=' sign.  */
> >    entry->path = xstrdup (line);
> > -  char *equal_sign = strchr (entry->path, '=');
> > -  if (equal_sign)
> > -    {
> > -      *equal_sign = '\0';
> > -      ++equal_sign;
> > -      entry->flag = FLAG_ANY;
> > -      for (i = 0; i < sizeof (lib_types) / sizeof (lib_types[0]); ++i)
> > -	if (strcmp (equal_sign, lib_types[i].name) == 0)
> > -	  {
> > -	    entry->flag = lib_types[i].flag;
> > -	    break;
> > -	  }
> > -      if (entry->flag == FLAG_ANY)
> > -	error (0, 0, _("%s is not a known library type"), equal_sign);
> > -    }
> > -  else
> > -    {
> > -      entry->flag = FLAG_ANY;
> > -    }
> > +  entry->flag = FLAG_ELF_LIBC6;
> >  
> >    /* Canonify path: for now only remove leading and trailing
> >       whitespace and the trailing slashes.  */
> > diff --git a/elf/readelflib.c b/elf/readelflib.c
> > index 10b10b6080..801c5587ab 100644
> > --- a/elf/readelflib.c
> > +++ b/elf/readelflib.c
> > @@ -44,7 +44,6 @@ process_elf_file (const char *file_name, const char *lib, int *flag,
> >  		  char **soname, void *file_contents, size_t file_length)
> >  {
> >    int i;
> > -  unsigned int j;
> >    unsigned int dynamic_addr;
> >    size_t dynamic_size;
> >    char *program_interpreter;
> > @@ -82,9 +81,8 @@ process_elf_file (const char *file_name, const char *lib, int *flag,
> >    elf_pheader = (ElfW(Phdr) *) (elf_header->e_phoff + file_contents);
> >    check_ptr (elf_pheader);
> >  
> > -  /* The library is an elf library, now search for soname and
> > -     libc5/libc6.  */
> > -  *flag = FLAG_ELF;
> > +  /* The library is an elf library   */
> > +  *flag = FLAG_ELF_LIBC6;
> >  
> >    /* The default ISA level is 0.  */
> >    *isa_level = 0;
> > @@ -111,16 +109,6 @@ process_elf_file (const char *file_name, const char *lib, int *flag,
> >  	  program_interpreter = (char *) (file_contents + segment->p_offset);
> >  	  check_ptr (program_interpreter);
> >  
> > -	  /* Check if this is enough to classify the binary.  */
> > -	  for (j = 0; j < sizeof (interpreters) / sizeof (interpreters [0]);
> > -	       ++j)
> > -	    if (strcmp (program_interpreter, interpreters[j].soname) == 0)
> > -	      {
> > -		*flag = interpreters[j].flag;
> > -		break;
> > -	      }
> > -	  break;
> > -
> >  	case PT_NOTE:
> >  	  if (!*osversion && segment->p_filesz >= 32 && segment->p_align >= 4)
> >  	    {
> > @@ -291,38 +279,16 @@ done:
> >    if (dynamic_strings == NULL)
> >      return 1;
> >  
> > -  /* Now read the DT_NEEDED and DT_SONAME entries.  */
> > +  /* Now read the DT_SONAME entries.  */
> >    for (dyn_entry = dynamic_segment; dyn_entry->d_tag != DT_NULL;
> >         ++dyn_entry)
> >      {
> > -      if (dyn_entry->d_tag == DT_NEEDED || dyn_entry->d_tag == DT_SONAME)
> > +      if (dyn_entry->d_tag == DT_SONAME)
> >  	{
> >  	  char *name = dynamic_strings + dyn_entry->d_un.d_val;
> >  	  check_ptr (name);
> > -
> > -	  if (dyn_entry->d_tag == DT_NEEDED)
> > -	    {
> > -
> > -	      if (*flag == FLAG_ELF)
> > -		{
> > -		  /* Check if this is enough to classify the binary.  */
> > -		  for (j = 0;
> > -		       j < sizeof (known_libs) / sizeof (known_libs [0]);
> > -		       ++j)
> > -		    if (strcmp (name, known_libs [j].soname) == 0)
> > -		      {
> > -			*flag = known_libs [j].flag;
> > -			break;
> > -		      }
> > -		}
> > -	    }
> > -
> > -	  else if (dyn_entry->d_tag == DT_SONAME)
> > -	    *soname = xstrdup (name);
> > -
> > -	  /* Do we have everything we need?  */
> > -	  if (*soname && *flag != FLAG_ELF)
> > -	    return 0;
> > +          *soname = xstrdup (name);
> > +          return 0;
> >  	}
> >      }
> >  
> > diff --git a/elf/readlib.c b/elf/readlib.c
> > index 64b20d7804..9164c1cda7 100644
> > --- a/elf/readlib.c
> > +++ b/elf/readlib.c
> > @@ -43,24 +43,6 @@ struct known_names
> >    int flag;
> >  };
> >  
> > -static struct known_names interpreters[] =
> > -{
> > -  { "/lib/" LD_SO, FLAG_ELF_LIBC6 },
> > -#ifdef SYSDEP_KNOWN_INTERPRETER_NAMES
> > -  SYSDEP_KNOWN_INTERPRETER_NAMES
> > -#endif
> > -};
> > -
> > -static struct known_names known_libs[] =
> > -{
> > -  { LIBC_SO, FLAG_ELF_LIBC6 },
> > -  { LIBM_SO, FLAG_ELF_LIBC6 },
> > -#ifdef SYSDEP_KNOWN_LIBRARY_NAMES
> > -  SYSDEP_KNOWN_LIBRARY_NAMES
> > -#endif
> > -};
> > -
> > -
> >  /* Check if string corresponds to a GDB Python file.  */
> >  static bool
> >  is_gdb_python_file (const char *name)
> > @@ -84,7 +66,8 @@ process_file (const char *real_file_name, const char *file_name,
> >    struct exec *aout_header;
> >  
> >    ret = 0;
> > -  *flag = FLAG_ANY;
> > +  /* Just set FLAG_ELF_LIBC6 as old formats are not supported anymore.  */
> > +  *flag = FLAG_ELF_LIBC6;
> >    *soname = NULL;
> >  
> >    file = fopen (real_file_name, "rb");
> > @@ -151,7 +134,6 @@ process_file (const char *real_file_name, const char *file_name,
> >  	    *dot = '\0';
> >  	}
> >        *soname = copy;
> > -      *flag = FLAG_LIBC4;
> >        goto done;
> >      }
> >  
> > @@ -192,9 +174,6 @@ implicit_soname (const char *lib, int flag)
> >  {
> >    char *soname = xstrdup (lib);
> >  
> > -  if ((flag & FLAG_TYPE_MASK) != FLAG_LIBC4)
> > -    return soname;
> > -
> >    /* Aout files don't have a soname, just return the name
> >       including the major number.  */
> >    char *major = strstr (soname, ".so.");
> > diff --git a/sysdeps/unix/sysv/linux/arc/ldconfig.h b/sysdeps/unix/sysv/linux/arc/ldconfig.h
> > index 8c776fca9e..02ed826283 100644
> > --- a/sysdeps/unix/sysv/linux/arc/ldconfig.h
> > +++ b/sysdeps/unix/sysv/linux/arc/ldconfig.h
> > @@ -17,11 +17,3 @@
> >     <https://www.gnu.org/licenses/>.  */
> >  
> >  #include <sysdeps/generic/ldconfig.h>
> > -
> > -#define SYSDEP_KNOWN_INTERPRETER_NAMES 		\
> > -  { "/lib/ld-linux-arc.so.2", FLAG_ELF_LIBC6 },	\
> > -  { "/lib/ld-linux-arceb.so.2", FLAG_ELF_LIBC6 },
> > -
> > -#define SYSDEP_KNOWN_LIBRARY_NAMES 	\
> > -  { "libc.so.6", FLAG_ELF_LIBC6 },	\
> > -  { "libm.so.6", FLAG_ELF_LIBC6 },
> > diff --git a/sysdeps/unix/sysv/linux/arm/ldconfig.h b/sysdeps/unix/sysv/linux/arm/ldconfig.h
> > index d839470cfe..b3fa8ceebe 100644
> > --- a/sysdeps/unix/sysv/linux/arm/ldconfig.h
> > +++ b/sysdeps/unix/sysv/linux/arm/ldconfig.h
> > @@ -16,10 +16,3 @@
> >     <https://www.gnu.org/licenses/>.  */
> >  
> >  #include <sysdeps/generic/ldconfig.h>
> > -
> > -#define SYSDEP_KNOWN_INTERPRETER_NAMES \
> > -  { "/lib/ld-linux.so.3", FLAG_ELF_LIBC6 }, \
> > -  { "/lib/ld-linux-armhf.so.3", FLAG_ELF_LIBC6 },
> > -#define SYSDEP_KNOWN_LIBRARY_NAMES \
> > -  { "libc.so.6", FLAG_ELF_LIBC6 },	\
> > -  { "libm.so.6", FLAG_ELF_LIBC6 },
> > diff --git a/sysdeps/unix/sysv/linux/csky/ldconfig.h b/sysdeps/unix/sysv/linux/csky/ldconfig.h
> > index eeda37e4a8..6861f71327 100644
> > --- a/sysdeps/unix/sysv/linux/csky/ldconfig.h
> > +++ b/sysdeps/unix/sysv/linux/csky/ldconfig.h
> > @@ -26,9 +26,3 @@
> >  #else
> >  # define LD_SO_ABI "cskyv2"
> >  #endif
> > -
> > -#define SYSDEP_KNOWN_INTERPRETER_NAMES	\
> > -  { LD_SO_PREFIX LD_SO_ABI LD_SO_SUFFIX, FLAG_ELF_LIBC6 },
> > -#define SYSDEP_KNOWN_LIBRARY_NAMES	\
> > -  { "libc.so.6", FLAG_ELF_LIBC6 },	\
> > -  { "libm.so.6", FLAG_ELF_LIBC6 },
> > diff --git a/sysdeps/unix/sysv/linux/ia64/ldconfig.h b/sysdeps/unix/sysv/linux/ia64/ldconfig.h
> > index 53685659ed..b3fa8ceebe 100644
> > --- a/sysdeps/unix/sysv/linux/ia64/ldconfig.h
> > +++ b/sysdeps/unix/sysv/linux/ia64/ldconfig.h
> > @@ -16,9 +16,3 @@
> >     <https://www.gnu.org/licenses/>.  */
> >  
> >  #include <sysdeps/generic/ldconfig.h>
> > -
> > -#define SYSDEP_KNOWN_INTERPRETER_NAMES \
> > -  { "/lib/ld-linux.so.2", FLAG_ELF_LIBC6 },
> > -#define SYSDEP_KNOWN_LIBRARY_NAMES \
> > -  { "libc.so.6", FLAG_ELF_LIBC6 },	\
> > -  { "libm.so.6", FLAG_ELF_LIBC6 },
> > diff --git a/sysdeps/unix/sysv/linux/powerpc/ldconfig.h b/sysdeps/unix/sysv/linux/powerpc/ldconfig.h
> > index 09d75b3dec..d0935d541b 100644
> > --- a/sysdeps/unix/sysv/linux/powerpc/ldconfig.h
> > +++ b/sysdeps/unix/sysv/linux/powerpc/ldconfig.h
> > @@ -17,11 +17,3 @@
> >     <https://www.gnu.org/licenses/>.  */
> >  
> >  #include <sysdeps/generic/ldconfig.h>
> > -
> > -#define SYSDEP_KNOWN_INTERPRETER_NAMES \
> > -  { "/lib/ld.so.1", FLAG_ELF_LIBC6 },	\
> > -  { "/lib64/ld64.so.1", FLAG_ELF_LIBC6 }, \
> > -  { "/lib64/ld64.so.2", FLAG_ELF_LIBC6 },
> > -#define SYSDEP_KNOWN_LIBRARY_NAMES \
> > -  { "libc.so.6", FLAG_ELF_LIBC6 },	\
> > -  { "libm.so.6", FLAG_ELF_LIBC6 },
> > diff --git a/sysdeps/unix/sysv/linux/riscv/ldconfig.h b/sysdeps/unix/sysv/linux/riscv/ldconfig.h
> > index e6e7d271ad..24aae5155a 100644
> > --- a/sysdeps/unix/sysv/linux/riscv/ldconfig.h
> > +++ b/sysdeps/unix/sysv/linux/riscv/ldconfig.h
> > @@ -17,20 +17,3 @@
> >     <https://www.gnu.org/licenses/>.  */
> >  
> >  #include <sysdeps/generic/ldconfig.h>
> > -
> > -#define LD_SO_PREFIX "/lib/ld-linux-"
> > -#define LD_SO_SUFFIX ".so.1"
> > -
> > -#if __riscv_xlen == 64
> > -# define LD_SO_ABI "riscv64-lp64"
> > -#else
> > -# define LD_SO_ABI "riscv32-ilp32"
> > -#endif
> > -
> > -#define SYSDEP_KNOWN_INTERPRETER_NAMES				\
> > -  { LD_SO_PREFIX LD_SO_ABI "d" LD_SO_SUFFIX, FLAG_ELF_LIBC6 },	\
> > -  { LD_SO_PREFIX LD_SO_ABI     LD_SO_SUFFIX, FLAG_ELF_LIBC6 },
> > -
> > -#define SYSDEP_KNOWN_LIBRARY_NAMES	\
> > -  { "libc.so.6", FLAG_ELF_LIBC6 },	\
> > -  { "libm.so.6", FLAG_ELF_LIBC6 },
> > diff --git a/sysdeps/unix/sysv/linux/s390/ldconfig.h b/sysdeps/unix/sysv/linux/s390/ldconfig.h
> > index 83086ce843..b3fa8ceebe 100644
> > --- a/sysdeps/unix/sysv/linux/s390/ldconfig.h
> > +++ b/sysdeps/unix/sysv/linux/s390/ldconfig.h
> > @@ -16,10 +16,3 @@
> >     <https://www.gnu.org/licenses/>.  */
> >  
> >  #include <sysdeps/generic/ldconfig.h>
> > -
> > -#define SYSDEP_KNOWN_INTERPRETER_NAMES \
> > -  { "/lib/ld.so.1", FLAG_ELF_LIBC6 },	\
> > -  { "/lib/ld64.so.1", FLAG_ELF_LIBC6 },
> > -#define SYSDEP_KNOWN_LIBRARY_NAMES \
> > -  { "libc.so.6", FLAG_ELF_LIBC6 },	\
> > -  { "libm.so.6", FLAG_ELF_LIBC6 },
> > diff --git a/sysdeps/unix/sysv/linux/x86_64/ldconfig.h b/sysdeps/unix/sysv/linux/x86_64/ldconfig.h
> > index 1089668f09..b3fa8ceebe 100644
> > --- a/sysdeps/unix/sysv/linux/x86_64/ldconfig.h
> > +++ b/sysdeps/unix/sysv/linux/x86_64/ldconfig.h
> > @@ -16,11 +16,3 @@
> >     <https://www.gnu.org/licenses/>.  */
> >  
> >  #include <sysdeps/generic/ldconfig.h>
> > -
> > -#define SYSDEP_KNOWN_INTERPRETER_NAMES \
> > -  { "/lib/ld-linux.so.2", FLAG_ELF_LIBC6 }, \
> > -  { "/libx32/ld-linux-x32.so.2", FLAG_ELF_LIBC6 }, \
> > -  { "/lib64/ld-linux-x86-64.so.2", FLAG_ELF_LIBC6 },
> > -#define SYSDEP_KNOWN_LIBRARY_NAMES \
> > -  { "libc.so.6", FLAG_ELF_LIBC6 },	\
> > -  { "libm.so.6", FLAG_ELF_LIBC6 },

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

* Re: [RFC] Remove special flags of libc.5.so and libc.4.so
  2022-03-02 19:37       ` Raoni Fassina Firmino
@ 2022-03-04 18:38         ` Adhemerval Zanella
  0 siblings, 0 replies; 15+ messages in thread
From: Adhemerval Zanella @ 2022-03-04 18:38 UTC (permalink / raw)
  To: Lucas A. M. Magalhaes, libc-alpha, fweimer, tuliom



On 02/03/2022 16:37, Raoni Fassina Firmino wrote:
> On Tue, Jan 11, 2022 at 04:22:43PM -0300, AL glibc-alpha wrote:
>>
>>
>> On 22/12/2021 12:31, Lucas A. M. Magalhaes via Libc-alpha wrote:
>>> I've tested it in a AT build and was able to build and link programs as
>>> expected. For other archs I try with build-many-glibcs.py, all
>>> succeeded.
>>>
>>> Any other suggestions on how to test this?
>>>
>>> Florian am I missing something? Should we add a restriction to cache
>>> just new libc6.so compatible libraries?
>>>
>>> -- 8< --
>>>
>>> The older libcs version are obsolete for over twenty years now. This
>>> commit removes special flags of libc.5.so and libc.4.so.. It assume that
>>> all libraries cached are libc.6.so compatible and wrote FLAG_ELF_LIBC6.
>>>
>>> Tested on x86_64, powerpc, powerpc64 and powerpc64le.
>>> Tested with build-many-glibcs.py for the other affected architectures.
>>
>> I think it makes sense to stop support libc.4 and libc.5 and assume
>> FLAG_ELF_LIBC6 by ldconfig.
>>
>> I also think it should be safe to just get rid of the arch-specific
>> SYSDEP_KNOWN_INTERPRETER_NAMES, at least in theory it should not be
>> used by the cache (so there is not need to actually classify it).
> 
> Lucas's RFC already removed it for a bunch of architectures, only
> leaving i386, aarch64 and mips64, and If my grep did not failed me It
> seems like the only uses of YSDEP_KNOWN_LIBRARY_NAMES and
> SYSDEP_KNOWN_INTERPRETER_NAMES were in known_libs and interpreters
> respectively, both removed in the RFC, so it seems that definitions can
> be safely removed (in the context of the RFC).
> 
> Not sure if there is a need for more opinions or consensus about this
> RFC's idea and approach to move forward with a proper patch for review.
> 
> 

I think the rationale of the patch is ok, it just need the the
SYSDEP_KNOWN_LIBRARY_NAMES and SYSDEP_KNOWN_INTERPRETER_NAMES
cleanup for aarch64, i386, and mips64.

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

* Re: [PATCH] powerpc: Use FLAG_ELF_LIBC6 for 32-bit known libraries
  2022-03-02 19:30     ` Raoni Fassina Firmino
@ 2022-03-04 18:49       ` Adhemerval Zanella
  0 siblings, 0 replies; 15+ messages in thread
From: Adhemerval Zanella @ 2022-03-04 18:49 UTC (permalink / raw)
  To: Lucas A. M. Magalhaes, libc-alpha, fweimer, tuliom



On 02/03/2022 16:30, Raoni Fassina Firmino wrote:
> On Fri, Dec 03, 2021 at 11:51:29AM -0300, AL glibc-alpha wrote:
>>
>>
>> On 04/11/2021 15:10, Lucas A. M. Magalhaes via Libc-alpha wrote:
>>> In systems with more versions of the known libraries, i.e. on IBM
>>> Advance Toolchain, ldconfig will order them incorrectly on ld.cache.
>>>
>>> The issue only occurs with 32-bit libraries that don't depend on libc or
>>> libm. That's because process_elf32_file check if the elf depends on one
>>> of the libraries at known_libs to select the elf flag. For example, as
>>> libc.so.6 don't depend on itself or on libm it will be flagged as
>>> FLAG_ELF instead of FLAG_ELF_LIBC6 as expected.
>>
>> Wouldn't be simpler to check if the DT_SONAME matches any on 'known_libs' after
>> dynamic section parsing and set the appropriated flag on generic 'process_file'? 
> 
> But then it would touch every architecture, I think since this is only a
> problem affecting powerpc (BE 32bits) I don't think it is worth touch
> the generic code if will not help any other architecture.

Which is not a bad idea, removing arch-specific code and make the ldconfig
have a similar semantic interdependently of the ABI is a good move forward. 

> 
> 
>> (also powerpc SYSDEP_KNOWN_LIBRARY_NAMES seems redundant).
> 
> Seems to be the same as every other arch except i386. Lookin at Lucas's
> RFC for removal of libc.5 and libc.4 compatibility, maybe it being
> diferent in i386 is just that it was never really used anymore, and so
> never updated.

I think it would be better to send this change along the the RPC to
remove libc4/libc5 compatibility.  I am already proposing dropping some 
support for old lib5/aout files [1], which Florian thinks it is ok,
so I take that dropping all support for libc4/libc5 is a way forward.

In fact, with libc4/libc5 removal I think this patch is not really 
required.

[1] https://patchwork.sourceware.org/project/glibc/patch/20220304133801.1868553-4-adhemerval.zanella@linaro.org/

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

end of thread, other threads:[~2022-03-04 18:49 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-22 21:12 [PATCH] powerpc: Use the correct flag for 32-bit known libraries Lucas A. M. Magalhaes
2021-10-25 18:22 ` Florian Weimer
2021-12-22 15:31   ` [RFC] Remove special flags of libc.5.so and libc.4.so Lucas A. M. Magalhaes
2022-01-10 19:21     ` Lucas A. M. Magalhaes
2022-01-11 19:22     ` Adhemerval Zanella
2022-03-02 19:37       ` Raoni Fassina Firmino
2022-03-04 18:38         ` Adhemerval Zanella
2022-02-23 22:17     ` Raoni Fassina Firmino
2021-11-04 18:10 ` [PATCH] powerpc: Use FLAG_ELF_LIBC6 for 32-bit known libraries Lucas A. M. Magalhaes
2021-12-03 12:40   ` Lucas A. M. Magalhaes
2021-12-03 14:17   ` Florian Weimer
2021-12-03 14:51   ` Adhemerval Zanella
2022-03-02 19:30     ` Raoni Fassina Firmino
2022-03-04 18:49       ` Adhemerval Zanella
2022-02-23 22:09   ` Raoni Fassina Firmino

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