public inbox for glibc-cvs@sourceware.org
help / color / mirror / Atom feed
* [glibc/google/grte/v5-2.27/master] Extend elf/unload8 to test an additional load/unload pattern
@ 2021-07-15 20:00 Stan Shebs
0 siblings, 0 replies; 2+ messages in thread
From: Stan Shebs @ 2021-07-15 20:00 UTC (permalink / raw)
To: glibc-cvs
https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=c783f269d1acc1fab63f58287743181cc6abda29
commit c783f269d1acc1fab63f58287743181cc6abda29
Author: Stan Shebs <stanshebs@google.com>
Date: Thu Jul 15 12:57:50 2021 -0700
Extend elf/unload8 to test an additional load/unload pattern
Diff:
---
elf/Makefile | 2 +-
elf/unload8.c | 41 +++++++++++++++++++++++++++++++++++++++++
elf/unload8mod1.c | 13 +++++++++++++
3 files changed, 55 insertions(+), 1 deletion(-)
diff --git a/elf/Makefile b/elf/Makefile
index 6b2a347ec7..3db837994d 100644
--- a/elf/Makefile
+++ b/elf/Makefile
@@ -655,7 +655,7 @@ $(objpfx)unload6mod2.so: $(libdl)
$(objpfx)unload6mod3.so: $(libdl)
$(objpfx)unload7mod1.so: $(libdl)
$(objpfx)unload7mod2.so: $(objpfx)unload7mod1.so
-$(objpfx)unload8mod1.so: $(objpfx)unload8mod2.so
+$(objpfx)unload8mod1.so: $(objpfx)unload8mod2.so $(libdl)
$(objpfx)unload8mod2.so: $(objpfx)unload8mod3.so
$(objpfx)unload8mod3.so: $(libdl)
$(objpfx)tst-initordera2.so: $(objpfx)tst-initordera1.so
diff --git a/elf/unload8.c b/elf/unload8.c
index f984a38098..363af13d54 100644
--- a/elf/unload8.c
+++ b/elf/unload8.c
@@ -27,7 +27,48 @@ main (void)
}
mod1 ();
+
+ // Additional test to detect when the fastload hash table has bad pointers to
+ // names of unloaded libraries hanging around in it.
+
+ int (*mod1b) (void) = dlsym (h, "mod1b");
+ if (mod1b == NULL)
+ {
+ puts ("dlsym failed");
+ return 1;
+ }
+
+ mod1b ();
+
dlclose (h);
+ void *h2x = dlopen ("$ORIGIN/unload8mod2.so", RTLD_LAZY);
+ if (h2x == NULL)
+ {
+ puts ("dlopen unload8mod2.so failed");
+ return 1;
+ }
+
+
+ void *h2xx = dlopen ("$ORIGIN/unload8mod1x.so", RTLD_LAZY);
+ if (h2xx == NULL)
+ {
+ puts ("dlopen unload8mod1x.so failed");
+ return 1;
+ }
+
+ dlclose (h);
+ dlclose (h2x);
+ dlclose (h2xx);
+
+ void *h3xx = dlopen ("$ORIGIN/unload8mod3.so", RTLD_LAZY);
+ if (h3xx == NULL)
+ {
+ puts ("dlopen unload8mod3.so failed");
+ return 1;
+ }
+
+ dlclose (h3xx);
+
return 0;
}
diff --git a/elf/unload8mod1.c b/elf/unload8mod1.c
index fe7e81c1c3..42a4298b6e 100644
--- a/elf/unload8mod1.c
+++ b/elf/unload8mod1.c
@@ -1,3 +1,5 @@
+#include <dlfcn.h>
+
extern void mod2 (void);
void
@@ -5,3 +7,14 @@ mod1 (void)
{
mod2 ();
}
+
+void
+mod1b (void)
+{
+ void *h = dlopen ("$ORIGIN/unload8mod3.so", RTLD_LAZY);
+ if (h == NULL)
+ {
+ puts ("dlopen unload8mod3.so failed");
+ return 1;
+ }
+}
^ permalink raw reply [flat|nested] 2+ messages in thread
* [glibc/google/grte/v5-2.27/master] Extend elf/unload8 to test an additional load/unload pattern
@ 2021-08-28 0:39 Fangrui Song
0 siblings, 0 replies; 2+ messages in thread
From: Fangrui Song @ 2021-08-28 0:39 UTC (permalink / raw)
To: glibc-cvs
https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=282bbfc364e9f0c5a0b006da377af6828e2048d8
commit 282bbfc364e9f0c5a0b006da377af6828e2048d8
Author: Stan Shebs <stanshebs@google.com>
Date: Thu Jul 15 12:57:50 2021 -0700
Extend elf/unload8 to test an additional load/unload pattern
Diff:
---
elf/Makefile | 2 +-
elf/unload8.c | 41 +++++++++++++++++++++++++++++++++++++++++
elf/unload8mod1.c | 13 +++++++++++++
3 files changed, 55 insertions(+), 1 deletion(-)
diff --git a/elf/Makefile b/elf/Makefile
index 827fe13178..43604e7d84 100644
--- a/elf/Makefile
+++ b/elf/Makefile
@@ -652,7 +652,7 @@ $(objpfx)unload6mod2.so: $(libdl)
$(objpfx)unload6mod3.so: $(libdl)
$(objpfx)unload7mod1.so: $(libdl)
$(objpfx)unload7mod2.so: $(objpfx)unload7mod1.so
-$(objpfx)unload8mod1.so: $(objpfx)unload8mod2.so
+$(objpfx)unload8mod1.so: $(objpfx)unload8mod2.so $(libdl)
$(objpfx)unload8mod2.so: $(objpfx)unload8mod3.so
$(objpfx)unload8mod3.so: $(libdl)
$(objpfx)tst-initordera2.so: $(objpfx)tst-initordera1.so
diff --git a/elf/unload8.c b/elf/unload8.c
index f984a38098..363af13d54 100644
--- a/elf/unload8.c
+++ b/elf/unload8.c
@@ -27,7 +27,48 @@ main (void)
}
mod1 ();
+
+ // Additional test to detect when the fastload hash table has bad pointers to
+ // names of unloaded libraries hanging around in it.
+
+ int (*mod1b) (void) = dlsym (h, "mod1b");
+ if (mod1b == NULL)
+ {
+ puts ("dlsym failed");
+ return 1;
+ }
+
+ mod1b ();
+
dlclose (h);
+ void *h2x = dlopen ("$ORIGIN/unload8mod2.so", RTLD_LAZY);
+ if (h2x == NULL)
+ {
+ puts ("dlopen unload8mod2.so failed");
+ return 1;
+ }
+
+
+ void *h2xx = dlopen ("$ORIGIN/unload8mod1x.so", RTLD_LAZY);
+ if (h2xx == NULL)
+ {
+ puts ("dlopen unload8mod1x.so failed");
+ return 1;
+ }
+
+ dlclose (h);
+ dlclose (h2x);
+ dlclose (h2xx);
+
+ void *h3xx = dlopen ("$ORIGIN/unload8mod3.so", RTLD_LAZY);
+ if (h3xx == NULL)
+ {
+ puts ("dlopen unload8mod3.so failed");
+ return 1;
+ }
+
+ dlclose (h3xx);
+
return 0;
}
diff --git a/elf/unload8mod1.c b/elf/unload8mod1.c
index fe7e81c1c3..42a4298b6e 100644
--- a/elf/unload8mod1.c
+++ b/elf/unload8mod1.c
@@ -1,3 +1,5 @@
+#include <dlfcn.h>
+
extern void mod2 (void);
void
@@ -5,3 +7,14 @@ mod1 (void)
{
mod2 ();
}
+
+void
+mod1b (void)
+{
+ void *h = dlopen ("$ORIGIN/unload8mod3.so", RTLD_LAZY);
+ if (h == NULL)
+ {
+ puts ("dlopen unload8mod3.so failed");
+ return 1;
+ }
+}
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-08-28 0:39 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-15 20:00 [glibc/google/grte/v5-2.27/master] Extend elf/unload8 to test an additional load/unload pattern Stan Shebs
2021-08-28 0:39 Fangrui Song
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).