about summary refs log tree commit diff
path: root/elf/neededtest4.c
diff options
context:
space:
mode:
authorZack Weinberg <zackw@panix.com>2017-06-08 15:39:03 -0400
committerZack Weinberg <zackw@panix.com>2017-06-08 15:39:03 -0400
commit5046dbb4a7eba5eccfd258f92f4735c9ffc8d069 (patch)
tree4470480d904b65cf14ca524f96f79eca818c3eaf /elf/neededtest4.c
parent199fc19d3aaaf57944ef036e15904febe877fc93 (diff)
downloadglibc-zack/build-layout-experiment.tar.gz
glibc-zack/build-layout-experiment.tar.xz
glibc-zack/build-layout-experiment.zip
Prepare for radical source tree reorganization. zack/build-layout-experiment
All top-level files and directories are moved into a temporary storage
directory, REORG.TODO, except for files that will certainly still
exist in their current form at top level when we're done (COPYING,
COPYING.LIB, LICENSES, NEWS, README), all old ChangeLog files (which
are moved to the new directory OldChangeLogs, instead), and the
generated file INSTALL (which is just deleted; in the new order, there
will be no generated files checked into version control).
Diffstat (limited to 'elf/neededtest4.c')
-rw-r--r--elf/neededtest4.c158
1 files changed, 0 insertions, 158 deletions
diff --git a/elf/neededtest4.c b/elf/neededtest4.c
deleted file mode 100644
index 0ae0b7ff47..0000000000
--- a/elf/neededtest4.c
+++ /dev/null
@@ -1,158 +0,0 @@
-#include <dlfcn.h>
-#include <libintl.h>
-#include <link.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#define MAPS ((struct link_map *) _r_debug.r_map)
-
-static int
-check_loaded_objects (const char **loaded)
-{
-  struct link_map *lm;
-  int n;
-  int *found = NULL;
-  int errors = 0;
-
-  for (n = 0; loaded[n]; n++)
-    /* NOTHING */;
-
-  if (n)
-    {
-      found = (int *) alloca (sizeof (int) * n);
-      memset (found, 0, sizeof (int) * n);
-    }
-
-  printf("   Name\n");
-  printf(" --------------------------------------------------------\n");
-  for (lm = MAPS; lm; lm = lm->l_next)
-    {
-      if (lm->l_name && lm->l_name[0])
-	printf(" %s, count = %d\n", lm->l_name, (int) lm->l_direct_opencount);
-      if (lm->l_type == lt_loaded && lm->l_name)
-	{
-	  int match = 0;
-	  for (n = 0; loaded[n] != NULL; n++)
-	    {
-	      if (strcmp (basename (loaded[n]), basename (lm->l_name)) == 0)
-		{
-		  found[n] = 1;
-		  match = 1;
-		  break;
-		}
-	    }
-
-	  if (match == 0)
-	    {
-	      ++errors;
-	      printf ("ERRORS: %s is not unloaded\n", lm->l_name);
-	    }
-	}
-    }
-
-  for (n = 0; loaded[n] != NULL; n++)
-    {
-      if (found[n] == 0)
-	{
-	  ++errors;
-	  printf ("ERRORS: %s is not loaded\n", loaded[n]);
-	}
-    }
-
-  return errors;
-}
-
-extern void c_function (void);
-extern char *dirname (const char *__filename);
-
-int
-main (int argc, char **argv)
-{
-  void *obj;
-  const char *loaded[] = { NULL, NULL, NULL};
-  int errors = 0;
-  void (*f) (void);
-  const char *dir = dirname (argv [0]);
-  char *oldfilename;
-  char *newfilename;
-
-  c_function ();
-
-  printf ("\nThis is what is in memory now:\n");
-  errors += check_loaded_objects (loaded);
-
-  printf( "Loading shared object neededobj6.so\n");
-  obj = dlopen( "neededobj6.so", RTLD_LAZY);
-  if (obj == NULL)
-    {
-      printf ("%s\n", dlerror ());
-      exit (1);
-    }
-  f = dlsym (obj, "a2_function");
-  if (f == NULL)
-    {
-      printf ("%s\n", dlerror ());
-      exit (1);
-    }
-  f ();
-  loaded[0] = "neededobj5.so";
-  loaded[1] = "neededobj6.so";
-  errors += check_loaded_objects (loaded);
-
-  printf ("Closing neededobj6.so\n");
-  dlclose (obj);
-  loaded[0] = NULL;
-  errors += check_loaded_objects (loaded);
-
-  printf ("Rename neededobj5.so\n");
-  oldfilename = alloca (strlen (dir) + 1 + sizeof ("neededobj5.so"));
-  strcpy (oldfilename, dir);
-  strcat (oldfilename, "/");
-  strcat (oldfilename, "neededobj5.so");
-  newfilename = alloca (strlen (oldfilename) + sizeof (".renamed"));
-  strcpy (newfilename, oldfilename);
-  strcat (newfilename, ".renamed");
-  if (rename (oldfilename, newfilename))
-    {
-      perror ("rename");
-      exit (1);
-    }
-
-  printf( "Loading shared object neededobj6.so\n");
-  obj = dlopen( "neededobj6.so", RTLD_LAZY);
-  if (obj == NULL)
-    printf ("%s\n", dlerror ());
-  else
-    {
-      printf ("neededobj6.so should fail to load\n");
-      exit (1);
-    }
-
-  printf( "Loading shared object neededobj1.so\n");
-  obj = dlopen( "neededobj1.so", RTLD_LAZY);
-  if (obj == NULL)
-    {
-      printf ("%s\n", dlerror ());
-      exit (1);
-    }
-  errors += check_loaded_objects (loaded);
-  f = dlsym (obj, "c_function");
-  if (f == NULL)
-    {
-      printf ("%s\n", dlerror ());
-      exit (1);
-    }
-  f ();
-
-  printf ("Restore neededobj5.so\n");
-  if (rename (newfilename, oldfilename))
-    {
-      perror ("rename");
-      exit (1);
-    }
-
-  if (errors != 0)
-    printf ("%d errors found\n", errors);
-  return errors;
-}