Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Update.
	* elf/Makefile: Add no modules for nodelete test.
	* elf/nodelmod3.c: New file.
	* elf/nodelmod4.c: New file.
	* elf/nodelete.c: Also test case where dependency of dlopen() object
	is marked nodelete.

	* elf/nodlopen.c: New file.
	* elf/nodlopenmod.c: New file.
  • Loading branch information
Ulrich Drepper committed Jul 21, 2000
1 parent 2f54c82 commit 2cb8cef
Show file tree
Hide file tree
Showing 7 changed files with 89 additions and 4 deletions.
8 changes: 8 additions & 0 deletions ChangeLog
@@ -1,6 +1,14 @@
2000-07-20 Ulrich Drepper <drepper@redhat.com>

* elf/Makefile: Add no modules for nodelete test.
* elf/nodelmod3.c: New file.
* elf/nodelmod4.c: New file.
* elf/nodelete.c: Also test case where dependency of dlopen() object
is marked nodelete.

* elf/Makefile (tests): Add nodlopen. Add rules to generate nodlopen.
* elf/nodlopen.c: New file.
* elf/nodlopenmod.c: New file.
* include/dlfcn.h: Define __RTLD_DLOPEN.
* elf/dl-load.c (_dl_map_object_from_fd): If DF_1_NOOPEN is set
and this is a dlopen() call, do not load the binary.
Expand Down
7 changes: 5 additions & 2 deletions elf/Makefile
Expand Up @@ -98,7 +98,7 @@ modules-names = testobj1 testobj2 testobj3 testobj4 testobj5 testobj6 \
$(modules-nodelete-$(have-z-nodelete)) \
$(modules-nodlopen-$(have-z-nodlopen))
modules-vis-yes = vismod1 vismod2 vismod3
modules-nodelete-yes = nodelmod1 nodelmod2
modules-nodelete-yes = nodelmod1 nodelmod2 nodelmod3 nodelmod4
modules-nodlopen-yes = nodlopenmod
extra-objs += $(addsuffix .os,$(strip $(modules-names)))

Expand Down Expand Up @@ -242,6 +242,7 @@ $(objpfx)failobj.so: $(objpfx)testobj6.so
$(objpfx)dep1.so: $(objpfx)dep2.so $(objpfx)dep4.so
$(objpfx)dep2.so: $(objpfx)dep3.so $(objpfx)dep4.so
$(objpfx)dep4.so: $(objpfx)dep3.so
$(objpfx)nodelmod3.so: $(objpfx)nodelmod4.so

$(test-modules): $(objpfx)%.so: $(objpfx)%.os
$(build-module)
Expand Down Expand Up @@ -304,8 +305,10 @@ LDFLAGS-noload = -rdynamic
$(objpfx)noload.out: $(objpfx)testobj5.so

LDFLAGS-nodelmod1.so = -Wl,--enable-new-dtags,-z,nodelete
LDFLAGS-nodelmod4.so = -Wl,--enable-new-dtags,-z,nodelete
$(objpfx)nodelete: $(libdl)
$(objpfx)nodelete.out: $(objpfx)nodelmod1.so $(objpfx)nodelmod2.so
$(objpfx)nodelete.out: $(objpfx)nodelmod1.so $(objpfx)nodelmod2.so \
$(objpfx)nodelmod3.so

LDFLAGS-nodlopenmod.so = -Wl,--enable-new-dtags,-z,nodlopen
$(objpfx)nodlopen: $(libdl)
Expand Down
54 changes: 52 additions & 2 deletions elf/nodelete.c
Expand Up @@ -41,7 +41,7 @@ do_test (void)
p = dlopen ("nodelmod1.so", RTLD_LAZY);
if (p == NULL)
{
puts ("failed to load \"nodelmod1.so\"");
printf ("failed to load \"nodelmod1.so\": %s\n", dlerror ());
result = 1;
}
else
Expand Down Expand Up @@ -89,7 +89,7 @@ do_test (void)
p = dlopen ("nodelmod2.so", RTLD_LAZY | RTLD_NODELETE);
if (p == NULL)
{
puts ("failed to load \"nodelmod2.so\"");
printf ("failed to load \"nodelmod2.so\": %s\n", dlerror ());
result = 1;
}
else
Expand Down Expand Up @@ -134,6 +134,56 @@ do_test (void)
}
}

p = dlopen ("nodelmod3.so", RTLD_LAZY);
if (p == NULL)
{
printf ("failed to load \"nodelmod3.so\": %s\n", dlerror ());
result = 1;
}
else
{
int *(*fctp) (void);

puts ("succeeded loading \"nodelmod3.so\"");

fctp = dlsym (p, "addr");
if (fctp == NULL)
{
puts ("failed to get address of \"addr\" in \"nodelmod3.so\"");
result = 1;
}
else
{
int *varp = fctp ();

*varp = -1;

/* Now close the object. */
if (dlclose (p) != 0)
{
puts ("failed to close \"nodelmod3.so\"");
result = 1;
}
else if (! sigsetjmp (jmpbuf, 1))
{
/* Access the variable again. */
if (*varp != -1)
{
puts ("\"var_in_mod4\" value not correct");
result = 1;
}
else
puts ("-z nodelete in dependency succeeded");
}
else
{
/* We caught an segmentation fault. */
puts ("\"nodelmod4.so\" got deleted");
result = 1;
}
}
}

return result;
}

Expand Down
7 changes: 7 additions & 0 deletions elf/nodelmod3.c
@@ -0,0 +1,7 @@
extern int var_in_mod4;

int *
addr (void)
{
return &var_in_mod4;
}
1 change: 1 addition & 0 deletions elf/nodelmod4.c
@@ -0,0 +1 @@
int var_in_mod4 = 99;
15 changes: 15 additions & 0 deletions elf/nodlopen.c
@@ -0,0 +1,15 @@
#include <dlfcn.h>
#include <stdio.h>

int
main (void)
{
if (dlopen ("nodlopenmod.so", RTLD_LAZY) != NULL)
{
puts ("opening \"nodlopenmod.so\" succeeded, FAIL");
return 1;
}

puts ("opening \"nodlopenmod.so\" failed, OK");
return 0;
}
1 change: 1 addition & 0 deletions elf/nodlopenmod.c
@@ -0,0 +1 @@
int a = 42;

0 comments on commit 2cb8cef

Please sign in to comment.