Update.
authorUlrich Drepper <drepper@redhat.com>
Wed, 20 Jan 1999 00:34:52 +0000 (00:34 +0000)
committerUlrich Drepper <drepper@redhat.com>
Wed, 20 Jan 1999 00:34:52 +0000 (00:34 +0000)
1999-01-20  Ulrich Drepper  <drepper@cygnus.com>

* elf/Makefile (tests): Add preloadtest.  Add rules to build more test
modules and the preloadtest binary.
* elf/loadtest.c (TEST_ROUNDS): Increase to 1000.
(testobjs): Add more modules.
(tests): Add entries for new modules.
* elf/preloadtest.c: New file.  Test for LD_PRELOAD.
* elf/testobj1.c: Add 'preload' function.
* elf/testobj2.c: Likewise.
* elf/testobj3.c: Likewise.
* elf/testobj4.c: New file.
* elf/testobj5.c: New file.
* elf/testobj6.c: New file.

ChangeLog
elf/Makefile
elf/loadtest.c
elf/preloadtest.c [new file with mode: 0644]
elf/testobj1.c
elf/testobj2.c
elf/testobj3.c
elf/testobj4.c [new file with mode: 0644]
elf/testobj5.c [new file with mode: 0644]
elf/testobj6.c [new file with mode: 0644]

index 86a8b7a..4e99121 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,18 @@
+1999-01-20  Ulrich Drepper  <drepper@cygnus.com>
+
+       * elf/Makefile (tests): Add preloadtest.  Add rules to build more test
+       modules and the preloadtest binary.
+       * elf/loadtest.c (TEST_ROUNDS): Increase to 1000.
+       (testobjs): Add more modules.
+       (tests): Add entries for new modules.
+       * elf/preloadtest.c: New file.  Test for LD_PRELOAD.
+       * elf/testobj1.c: Add 'preload' function.
+       * elf/testobj2.c: Likewise.
+       * elf/testobj3.c: Likewise.
+       * elf/testobj4.c: New file.
+       * elf/testobj5.c: New file.
+       * elf/testobj6.c: New file.
+
 1999-01-19  Ulrich Drepper  <drepper@cygnus.com>
 
        * elf/dl-object.c (_dl_new_object): Micro-optimization.
index f6da5c4..c46c229 100644 (file)
@@ -75,7 +75,7 @@ others                += ldconfig
 install-rootsbin += ldconfig
 endif
 
-tests = loadtest restest1
+tests = loadtest restest1 preloadtest
 
 include ../Rules
 
@@ -214,14 +214,20 @@ $(LINK.o) -shared -o $@ $(sysdep-LDFLAGS) $(config-LDFLAGS)  \
          $(no-whole-archive) $(LDLIBS-$(@F:%.so=%).so)
 endef
 
-modules-names = testobj1 testobj2 testobj3 testobj1_1
+modules-names = testobj1 testobj2 testobj3 testobj4 testobj5 testobj6 \
+               testobj1_1
 test-modules = $(addprefix $(objpfx),$(addsuffix .so,$(modules-names)))
 generated += $(test-modules)
 
+LDLIBS-testobj1.so = -ldl
 $(objpfx)testobj1_1.so: $(objpfx)testobj1.so
 LDLIBS-testobj1_1.so = $(objpfx)testobj1.so
 $(objpfx)testobj2.so: $(objpfx)testobj1.so
-LDLIBS-testobj2.so = $(objpfx)testobj1.so
+LDLIBS-testobj2.so = $(objpfx)testobj1.so -ldl
+LDLIBS-testobj3.so = -ldl
+LDLIBS-testobj4.so = -ldl
+LDLIBS-testobj5.so = -ldl
+LDLIBS-testobj6.so = -ldl
 
 $(test-modules): $(objpfx)%.so: %.c
        $(build-module)
@@ -235,6 +241,10 @@ $(objpfx)restest1: $(objpfx)libdl.so
 LDFLAGS-restest1 = -rdynamic $(objpfx)testobj1.so $(objpfx)testobj1_1.so
 
 $(objpfx)restest1.out: $(test-modules)
+
+$(objpfx)preloadtest.out: $(test-modules)
+LDFLAGS-preloadtest = -rdynamic $(objpfx)testobj6.so
+preloadtest-ENV = LD_PRELOAD=testobj1.so:testobj2.so:testobj3.so:testobj4.so:testobj5.so
 \f
 # muwahaha
 
index 209f420..5b9e116 100644 (file)
@@ -7,7 +7,7 @@
 
 
 /* How many load/unload operations do we do.  */
-#define TEST_ROUNDS    100
+#define TEST_ROUNDS    1000
 
 
 static struct
@@ -21,6 +21,9 @@ static struct
   { "testobj1.so", NULL },
   { "testobj2.so", NULL },
   { "testobj3.so", NULL },
+  { "testobj4.so", NULL },
+  { "testobj5.so", NULL },
+  { "testobj6.so", NULL },
 };
 #define NOBJS  (sizeof (testobjs) / sizeof (testobjs[0]))
 
@@ -47,6 +50,18 @@ static const struct
   { "obj3func1", 2, RTLD_LAZY | RTLD_GLOBAL },
   { "obj3func1", 2, RTLD_NOW },
   { "obj3func2", 2, RTLD_NOW | RTLD_GLOBAL },
+  { "obj4func2", 3, RTLD_LAZY },
+  { "obj4func1", 3, RTLD_LAZY | RTLD_GLOBAL },
+  { "obj4func1", 3, RTLD_NOW },
+  { "obj4func2", 3, RTLD_NOW | RTLD_GLOBAL },
+  { "obj5func2", 4, RTLD_LAZY },
+  { "obj5func1", 4, RTLD_LAZY | RTLD_GLOBAL },
+  { "obj5func1", 4, RTLD_NOW },
+  { "obj5func2", 4, RTLD_NOW | RTLD_GLOBAL },
+  { "obj6func2", 5, RTLD_LAZY },
+  { "obj6func1", 5, RTLD_LAZY | RTLD_GLOBAL },
+  { "obj6func1", 5, RTLD_NOW },
+  { "obj6func2", 5, RTLD_NOW | RTLD_GLOBAL },
 };
 #define NTESTS (sizeof (tests) / sizeof (tests[0]))
 
diff --git a/elf/preloadtest.c b/elf/preloadtest.c
new file mode 100644 (file)
index 0000000..ac27f67
--- /dev/null
@@ -0,0 +1,19 @@
+#include <stdio.h>
+
+extern int preload (int);
+
+int
+main (void)
+{
+  int res = preload (42);
+
+  printf ("preload (42) = %d, %s\n", res, res == 92 ? "ok" : "wrong");
+
+  return res != 92;
+}
+
+int
+foo (int a)
+{
+  return a;
+}
index 9f64d67..b88a8d0 100644 (file)
@@ -1,3 +1,5 @@
+#include <dlfcn.h>
+
 int
 obj1func1 (int a __attribute__ ((unused)))
 {
@@ -9,3 +11,12 @@ obj1func2 (int a)
 {
   return foo (a) + 10;
 }
+
+int
+preload (int a)
+{
+  int (*fp) (int) = dlsym (RTLD_NEXT, "preload");
+  if (fp != NULL)
+    return fp (a) + 10;
+  return 10;
+}
index 5c89d33..ba91fe8 100644 (file)
@@ -1,3 +1,5 @@
+#include <dlfcn.h>
+
 int
 obj2func1 (int a __attribute__ ((unused)))
 {
@@ -9,3 +11,12 @@ obj2func2 (int a)
 {
   return obj1func1 (a) + 10;
 }
+
+int
+preload (int a)
+{
+  int (*fp) (int) = dlsym (RTLD_NEXT, "preload");
+  if (fp != NULL)
+    return fp (a) + 10;
+  return 10;
+}
index 8e3d886..f89b904 100644 (file)
@@ -1,3 +1,5 @@
+#include <dlfcn.h>
+
 int
 obj3func1 (int a __attribute__ ((unused)))
 {
@@ -9,3 +11,12 @@ obj3func2 (int a)
 {
   return foo (a) + 42;
 }
+
+int
+preload (int a)
+{
+  int (*fp) (int) = dlsym (RTLD_NEXT, "preload");
+  if (fp != NULL)
+    return fp (a) + 10;
+  return 10;
+}
diff --git a/elf/testobj4.c b/elf/testobj4.c
new file mode 100644 (file)
index 0000000..38905c8
--- /dev/null
@@ -0,0 +1,22 @@
+#include <dlfcn.h>
+
+int
+obj4func1 (int a __attribute__ ((unused)))
+{
+  return 55;
+}
+
+int
+obj4func2 (int a)
+{
+  return foo (a) + 43;
+}
+
+int
+preload (int a)
+{
+  int (*fp) (int) = dlsym (RTLD_NEXT, "preload");
+  if (fp != NULL)
+    return fp (a) + 10;
+  return 10;
+}
diff --git a/elf/testobj5.c b/elf/testobj5.c
new file mode 100644 (file)
index 0000000..0a2bbe0
--- /dev/null
@@ -0,0 +1,22 @@
+#include <dlfcn.h>
+
+int
+obj5func1 (int a __attribute__ ((unused)))
+{
+  return 66;
+}
+
+int
+obj5func2 (int a)
+{
+  return foo (a) + 44;
+}
+
+int
+preload (int a)
+{
+  int (*fp) (int) = dlsym (RTLD_NEXT, "preload");
+  if (fp != NULL)
+    return fp (a) + 10;
+  return 10;
+}
diff --git a/elf/testobj6.c b/elf/testobj6.c
new file mode 100644 (file)
index 0000000..42bfc8e
--- /dev/null
@@ -0,0 +1,17 @@
+int
+obj6func1 (int a __attribute__ ((unused)))
+{
+  return 77;
+}
+
+int
+obj6func2 (int a)
+{
+  return foo (a) + 46;
+}
+
+int
+preload (int a)
+{
+  return a;
+}