mirror of
https://sourceware.org/git/glibc.git
synced 2025-01-05 01:00:14 +00:00
Update.
* elf/Makefile (tests): Add loadfail. Add rules to build failobj.so. * elf/loadfail.c: New file. Test of failing to load object with RTLD_GLOBAL set. * elf/failobj.c: New file. Object which will fail to load.
This commit is contained in:
parent
ad11b5a745
commit
1e26231274
@ -1,5 +1,11 @@
|
|||||||
1999-01-20 Ulrich Drepper <drepper@cygnus.com>
|
1999-01-20 Ulrich Drepper <drepper@cygnus.com>
|
||||||
|
|
||||||
|
* elf/Makefile (tests): Add loadfail.
|
||||||
|
Add rules to build failobj.so.
|
||||||
|
* elf/loadfail.c: New file. Test of failing to load object with
|
||||||
|
RTLD_GLOBAL set.
|
||||||
|
* elf/failobj.c: New file. Object which will fail to load.
|
||||||
|
|
||||||
* elf/dl-close.c (_dl_close): Fix last patch (cnt is unsigned).
|
* elf/dl-close.c (_dl_close): Fix last patch (cnt is unsigned).
|
||||||
|
|
||||||
* elf/dl-close.c: Handle failed loads which would have gone in the
|
* elf/dl-close.c: Handle failed loads which would have gone in the
|
||||||
|
10
elf/Makefile
10
elf/Makefile
@ -75,7 +75,7 @@ others += ldconfig
|
|||||||
install-rootsbin += ldconfig
|
install-rootsbin += ldconfig
|
||||||
endif
|
endif
|
||||||
|
|
||||||
tests = loadtest restest1 preloadtest
|
tests = loadtest restest1 preloadtest loadfail
|
||||||
|
|
||||||
include ../Rules
|
include ../Rules
|
||||||
|
|
||||||
@ -203,7 +203,7 @@ $(objpfx)sprof: $(objpfx)libdl.a
|
|||||||
endif
|
endif
|
||||||
|
|
||||||
modules-names = testobj1 testobj2 testobj3 testobj4 testobj5 testobj6 \
|
modules-names = testobj1 testobj2 testobj3 testobj4 testobj5 testobj6 \
|
||||||
testobj1_1
|
testobj1_1 failobj
|
||||||
test-modules = $(addprefix $(objpfx),$(addsuffix .so,$(modules-names)))
|
test-modules = $(addprefix $(objpfx),$(addsuffix .so,$(modules-names)))
|
||||||
generated += $(test-modules)
|
generated += $(test-modules)
|
||||||
|
|
||||||
@ -216,6 +216,7 @@ LDLIBS-testobj3.so = -ldl
|
|||||||
LDLIBS-testobj4.so = -ldl
|
LDLIBS-testobj4.so = -ldl
|
||||||
LDLIBS-testobj5.so = -ldl
|
LDLIBS-testobj5.so = -ldl
|
||||||
LDLIBS-testobj6.so = -ldl
|
LDLIBS-testobj6.so = -ldl
|
||||||
|
LDLIBS-failobj.so = $(objpfx)testobj6.so
|
||||||
|
|
||||||
$(test-modules): $(objpfx)%.so: %.c
|
$(test-modules): $(objpfx)%.so: %.c
|
||||||
$(build-module)
|
$(build-module)
|
||||||
@ -233,6 +234,11 @@ $(objpfx)restest1.out: $(test-modules)
|
|||||||
$(objpfx)preloadtest.out: $(test-modules)
|
$(objpfx)preloadtest.out: $(test-modules)
|
||||||
LDFLAGS-preloadtest = -rdynamic $(objpfx)testobj6.so
|
LDFLAGS-preloadtest = -rdynamic $(objpfx)testobj6.so
|
||||||
preloadtest-ENV = LD_PRELOAD=testobj1.so:testobj2.so:testobj3.so:testobj4.so:testobj5.so
|
preloadtest-ENV = LD_PRELOAD=testobj1.so:testobj2.so:testobj3.so:testobj4.so:testobj5.so
|
||||||
|
|
||||||
|
$(objpfx)loadfail: $(objpfx)libdl.so
|
||||||
|
LDFLAGS-loadfail = -rdynamic
|
||||||
|
|
||||||
|
$(objpfx)loadfile.out: $(objpfx)failobj.so
|
||||||
|
|
||||||
# muwahaha
|
# muwahaha
|
||||||
|
|
||||||
|
6
elf/failobj.c
Normal file
6
elf/failobj.c
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
/* This function is supposed to not exist. */
|
||||||
|
int
|
||||||
|
foo (int a)
|
||||||
|
{
|
||||||
|
return xyzzy (a);
|
||||||
|
}
|
30
elf/loadfail.c
Normal file
30
elf/loadfail.c
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
#include <dlfcn.h>
|
||||||
|
#include <error.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
int
|
||||||
|
main (void)
|
||||||
|
{
|
||||||
|
void *h;
|
||||||
|
|
||||||
|
if (dlopen ("testobj1.so", RTLD_GLOBAL | RTLD_NOW) == NULL
|
||||||
|
|| dlopen ("testobj1.so", RTLD_GLOBAL | RTLD_NOW) == NULL
|
||||||
|
|| dlopen ("testobj2.so", RTLD_GLOBAL | RTLD_NOW) == NULL
|
||||||
|
|| dlopen ("testobj3.so", RTLD_GLOBAL | RTLD_NOW) == NULL
|
||||||
|
|| dlopen ("testobj4.so", RTLD_GLOBAL | RTLD_NOW) == NULL
|
||||||
|
|| dlopen ("testobj5.so", RTLD_GLOBAL | RTLD_NOW) == NULL)
|
||||||
|
error (EXIT_FAILURE, 0, "failed to load shared object: %s", dlerror ());
|
||||||
|
|
||||||
|
h = dlopen ("failobj.so", RTLD_GLOBAL | RTLD_NOW);
|
||||||
|
|
||||||
|
printf ("h = %p, %s\n", h, h == NULL ? "ok" : "fail");
|
||||||
|
|
||||||
|
return h != NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
foo (int a)
|
||||||
|
{
|
||||||
|
return 10;
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user