diff options
author | Ulrich Drepper <drepper@redhat.com> | 1999-01-20 00:34:52 +0000 |
---|---|---|
committer | Ulrich Drepper <drepper@redhat.com> | 1999-01-20 00:34:52 +0000 |
commit | 3d91edb219b3970ccbc9dd53e24536b25fb41edf (patch) | |
tree | ef522a32e560cd00bb86c895590859f7cbdf9fc6 /elf | |
parent | b25d4ff04dff85bd1d32741cc0a320ee38cfdf51 (diff) | |
download | glibc-3d91edb219b3970ccbc9dd53e24536b25fb41edf.tar glibc-3d91edb219b3970ccbc9dd53e24536b25fb41edf.tar.gz glibc-3d91edb219b3970ccbc9dd53e24536b25fb41edf.tar.bz2 glibc-3d91edb219b3970ccbc9dd53e24536b25fb41edf.zip |
Update.
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.
Diffstat (limited to 'elf')
-rw-r--r-- | elf/Makefile | 16 | ||||
-rw-r--r-- | elf/loadtest.c | 17 | ||||
-rw-r--r-- | elf/preloadtest.c | 19 | ||||
-rw-r--r-- | elf/testobj1.c | 11 | ||||
-rw-r--r-- | elf/testobj2.c | 11 | ||||
-rw-r--r-- | elf/testobj3.c | 11 | ||||
-rw-r--r-- | elf/testobj4.c | 22 | ||||
-rw-r--r-- | elf/testobj5.c | 22 | ||||
-rw-r--r-- | elf/testobj6.c | 17 |
9 files changed, 142 insertions, 4 deletions
diff --git a/elf/Makefile b/elf/Makefile index f6da5c47a0..c46c22933b 100644 --- a/elf/Makefile +++ b/elf/Makefile @@ -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 # muwahaha diff --git a/elf/loadtest.c b/elf/loadtest.c index 209f420141..5b9e116987 100644 --- a/elf/loadtest.c +++ b/elf/loadtest.c @@ -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 index 0000000000..ac27f67150 --- /dev/null +++ b/elf/preloadtest.c @@ -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; +} diff --git a/elf/testobj1.c b/elf/testobj1.c index 9f64d675c4..b88a8d0ce6 100644 --- a/elf/testobj1.c +++ b/elf/testobj1.c @@ -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; +} diff --git a/elf/testobj2.c b/elf/testobj2.c index 5c89d33c8c..ba91fe873d 100644 --- a/elf/testobj2.c +++ b/elf/testobj2.c @@ -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; +} diff --git a/elf/testobj3.c b/elf/testobj3.c index 8e3d8865f7..f89b904cd4 100644 --- a/elf/testobj3.c +++ b/elf/testobj3.c @@ -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 index 0000000000..38905c824a --- /dev/null +++ b/elf/testobj4.c @@ -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 index 0000000000..0a2bbe07db --- /dev/null +++ b/elf/testobj5.c @@ -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 index 0000000000..42bfc8e14b --- /dev/null +++ b/elf/testobj6.c @@ -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; +} |