about summary refs log tree commit diff
path: root/elf
diff options
context:
space:
mode:
authorLucas A. M. Magalhaes <lamm@linux.ibm.com>2022-07-14 14:37:22 -0300
committerAdhemerval Zanella <adhemerval.zanella@linaro.org>2022-08-04 09:09:48 -0300
commit8ee878592c4a642937152c8308b8faef86bcfc40 (patch)
treebc02c572bc8c3441d59922be09705b27870e2793 /elf
parent5a57ad23ba73be7aefd2c243489330f5cd8d3ca6 (diff)
downloadglibc-8ee878592c4a642937152c8308b8faef86bcfc40.tar.gz
glibc-8ee878592c4a642937152c8308b8faef86bcfc40.tar.xz
glibc-8ee878592c4a642937152c8308b8faef86bcfc40.zip
Assume only FLAG_ELF_LIBC6 suport
The older libc versions are obsolete for over twenty years now.
This patch removes the special flags for libc5 and libc4 and assumes
that all libraries cached are libc6 compatible and use FLAG_ELF_LIBC6.

Checked with a build for all affected architectures.

Co-authored-by: Adhemerval Zanella  <adhemerval.zanella@linaro.org>
Reviewed-by: Adhemerval Zanella  <adhemerval.zanella@linaro.org>
Diffstat (limited to 'elf')
-rw-r--r--elf/cache.c6
-rw-r--r--elf/ldconfig.c63
-rw-r--r--elf/readelflib.c46
-rw-r--r--elf/readlib.c25
4 files changed, 14 insertions, 126 deletions
diff --git a/elf/cache.c b/elf/cache.c
index 3d7d3a67bf..f5f3ef8c4d 100644
--- a/elf/cache.c
+++ b/elf/cache.c
@@ -157,6 +157,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"};
 
@@ -168,14 +169,11 @@ print_entry (const char *lib, int flag, uint64_t hwcap,
   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 9394ac6438..6f37f38f35 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
 {
@@ -469,27 +456,8 @@ add_dir_1 (const char *line, const char *from_file, int from_line)
   entry->from_file = strdup (from_file);
   entry->from_line = 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.  */
@@ -1054,23 +1022,11 @@ search_dir (const struct dir_entry *entry)
 	  soname = xstrdup (direntry->d_name);
 	}
 
-      if (flag == FLAG_ELF
-	  && (entry->flag == FLAG_ELF_LIBC5
-	      || entry->flag == FLAG_ELF_LIBC6))
-	flag = entry->flag;
-
       /* Some sanity checks to print warnings.  */
       if (opt_verbose)
 	{
-	  if (flag == FLAG_ELF_LIBC5 && entry->flag != FLAG_ELF_LIBC5
-	      && entry->flag != FLAG_ANY)
-	    error (0, 0, _("libc5 library %s in wrong directory"), file_name);
-	  if (flag == FLAG_ELF_LIBC6 && entry->flag != FLAG_ELF_LIBC6
-	      && entry->flag != FLAG_ANY)
+	  if (flag == FLAG_ELF_LIBC6 && entry->flag != FLAG_ELF_LIBC6)
 	    error (0, 0, _("libc6 library %s in wrong directory"), file_name);
-	  if (flag == FLAG_LIBC4 && entry->flag != FLAG_LIBC4
-	      && entry->flag != FLAG_ANY)
-	    error (0, 0, _("libc4 library %s in wrong directory"), file_name);
 	}
 
       /* Add library to list.  */
@@ -1089,19 +1045,8 @@ search_dir (const struct dir_entry *entry)
 		  /* It's newer - add it.  */
 		  /* Flag should be the same - sanity check.  */
 		  if (dlib_ptr->flag != flag)
-		    {
-		      if (dlib_ptr->flag == FLAG_ELF
-			  && (flag == FLAG_ELF_LIBC5 || flag == FLAG_ELF_LIBC6))
-			dlib_ptr->flag = flag;
-		      else if ((dlib_ptr->flag == FLAG_ELF_LIBC5
-				|| dlib_ptr->flag == FLAG_ELF_LIBC6)
-			       && flag == FLAG_ELF)
-			dlib_ptr->flag = flag;
-		      else
-			error (0, 0, _("libraries %s and %s in directory %s have same soname but different type."),
-			       dlib_ptr->name, direntry->d_name,
-			       entry->path);
-		    }
+		    error (0, 0, _("libraries %s and %s in directory %s have same soname but different type."),
+			   dlib_ptr->name, direntry->d_name, entry->path);
 		  free (dlib_ptr->name);
 		  dlib_ptr->name = xstrdup (direntry->d_name);
 		  dlib_ptr->is_link = is_link;
diff --git a/elf/readelflib.c b/elf/readelflib.c
index 771182b5d0..5f43e0230d 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,
 		  size_t file_length)
 {
   int i;
-  unsigned int j;
   unsigned int dynamic_addr;
   size_t dynamic_size;
   char *program_interpreter;
@@ -81,9 +80,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;
@@ -110,16 +108,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_GNU_PROPERTY:
 	  /* The NT_GNU_PROPERTY_TYPE_0 note must be aligned to 4 bytes
 	     in 32-bit objects and to 8 bytes in 64-bit objects.  Skip
@@ -244,38 +232,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 ed42fbd48e..be65e3d0e9 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)
@@ -83,7 +65,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");
@@ -150,7 +133,6 @@ process_file (const char *real_file_name, const char *file_name,
 	    *dot = '\0';
 	}
       *soname = copy;
-      *flag = FLAG_LIBC4;
       goto done;
     }
 
@@ -191,9 +173,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.");