aboutsummaryrefslogtreecommitdiff
path: root/elf
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2002-02-10 22:40:17 +0000
committerUlrich Drepper <drepper@redhat.com>2002-02-10 22:40:17 +0000
commit87837aace92ced7be739fb7f3c764bb405fb5b2e (patch)
treeedba34cb14159fc0660ac020de1a7989bbf0a87d /elf
parent2cef4257d02ec72a6ca3bef6ce189fe002253bf6 (diff)
downloadglibc-87837aace92ced7be739fb7f3c764bb405fb5b2e.tar
glibc-87837aace92ced7be739fb7f3c764bb405fb5b2e.tar.gz
glibc-87837aace92ced7be739fb7f3c764bb405fb5b2e.tar.bz2
glibc-87837aace92ced7be739fb7f3c764bb405fb5b2e.zip
Update.
* elf/dl-deps.c (struct openaux_args): Add open_mode element. (openaux): Pass open_mode as new last argument to _dl_map_object. (_dl_map_object_deps): Add new argument open_mode. Initialize open_mode element of args variable with it. * elf/dl-open.c (dl_open_worker): Pass __RTLD_DLOPEN flag is set to _dl_map_object_deps. * elf/rtld.c (dl_main): Add zero as last parameter to _dl_map_object_deps call. * sysdeps/generic/ldsodefs.h: Adjust prototype of _dl_map_object_deps. * elf/nodlopen2.c: New file. * elf/nodlopenmod2.c: New file. * elf/Makefile: Add rules to build and run nodlopen2. * elf/tls-macros.hgg: ...here. New file. 2002-02-08 Richard Henderson <rth@redhat.com>
Diffstat (limited to 'elf')
-rw-r--r--elf/Makefile8
-rw-r--r--elf/dl-deps.c24
-rw-r--r--elf/dl-open.c9
-rw-r--r--elf/nodlopen2.c15
-rw-r--r--elf/nodlopenmod2.c7
-rw-r--r--elf/rtld.c13
6 files changed, 54 insertions, 22 deletions
diff --git a/elf/Makefile b/elf/Makefile
index 64ad384189..472dcfd985 100644
--- a/elf/Makefile
+++ b/elf/Makefile
@@ -122,7 +122,7 @@ tests = loadtest restest1 preloadtest loadfail multiload origtest resolvfail \
test-srcs = tst-pathopt
tests-vis-yes = vismain
tests-nodelete-yes = nodelete
-tests-nodlopen-yes = nodlopen
+tests-nodlopen-yes = nodlopen nodlopen2
endif
modules-names = testobj1 testobj2 testobj3 testobj4 testobj5 testobj6 \
testobj1_1 failobj constload2 constload3 unloadmod \
@@ -138,7 +138,7 @@ modules-names = testobj1 testobj2 testobj3 testobj4 testobj5 testobj6 \
reldep6mod0 reldep6mod1 reldep6mod2 reldep6mod3 reldep6mod4
modules-vis-yes = vismod1 vismod2 vismod3
modules-nodelete-yes = nodelmod1 nodelmod2 nodelmod3 nodelmod4
-modules-nodlopen-yes = nodlopenmod
+modules-nodlopen-yes = nodlopenmod nodlopenmod2
extra-objs += $(addsuffix .os,$(strip $(modules-names)))
include ../Rules
@@ -382,6 +382,10 @@ LDFLAGS-nodlopenmod.so = -Wl,--enable-new-dtags,-z,nodlopen
$(objpfx)nodlopen: $(libdl)
$(objpfx)nodlopen.out: $(objpfx)nodlopenmod.so
+$(objpfx)nodlopenmod2.so: $(objpfx)nodlopenmod.so
+$(objpfx)nodlopen2: $(libdl)
+$(objpfx)nodlopen2.out: $(objpfx)nodlopenmod2.so
+
$(objpfx)filtmod1.so: $(objpfx)filtmod1.os $(objpfx)filtmod2.so
$(LINK.o) -shared -o $@ -B$(csu-objpfx) $(LDFLAGS.so) \
-L$(subst :, -L,$(rpath-link)) \
diff --git a/elf/dl-deps.c b/elf/dl-deps.c
index caeadf6dab..e79e8f1b7b 100644
--- a/elf/dl-deps.c
+++ b/elf/dl-deps.c
@@ -47,6 +47,7 @@ struct openaux_args
/* The arguments to openaux. */
struct link_map *map;
int trace_mode;
+ int open_mode;
const char *strtab;
const char *name;
@@ -62,7 +63,7 @@ openaux (void *a)
args->aux = INTUSE(_dl_map_object) (args->map, args->name, 0,
(args->map->l_type == lt_executable
? lt_library : args->map->l_type),
- args->trace_mode, 0);
+ args->trace_mode, args->open_mode);
}
static ptrdiff_t
@@ -107,8 +108,8 @@ struct list
\
/* DST must not appear in SUID/SGID programs. */ \
if (__libc_enable_secure) \
- INTUSE(_dl_signal_error) (0, __str, NULL, \
- N_("DST not allowed in SUID/SGID programs"));\
+ INTUSE(_dl_signal_error) (0, __str, NULL, N_("\
+DST not allowed in SUID/SGID programs")); \
\
__newp = (char *) alloca (DL_DST_REQUIRED (l, __str, strlen (__str), \
__cnt)); \
@@ -141,7 +142,7 @@ void
internal_function
_dl_map_object_deps (struct link_map *map,
struct link_map **preloads, unsigned int npreloads,
- int trace_mode)
+ int trace_mode, int open_mode)
{
struct list known[1 + npreloads + 1];
struct list *runp, *tail;
@@ -225,6 +226,7 @@ _dl_map_object_deps (struct link_map *map,
args.strtab = strtab;
args.map = l;
args.trace_mode = trace_mode;
+ args.open_mode = open_mode;
orig = runp;
for (d = l->l_ld; d->d_tag != DT_NULL; ++d)
@@ -292,14 +294,15 @@ _dl_map_object_deps (struct link_map *map,
if (__builtin_expect (GL(dl_debug_mask) & DL_DEBUG_LIBS,
0))
INTUSE(_dl_debug_printf) ("load auxiliary object=%s"
- " requested by file=%s\n", name,
+ " requested by file=%s\n",
+ name,
l->l_name[0]
? l->l_name : _dl_argv[0]);
/* We must be prepared that the addressed shared
object is not available. */
- err = INTUSE(_dl_catch_error) (&objname, &errstring, openaux,
- &args);
+ err = INTUSE(_dl_catch_error) (&objname, &errstring,
+ openaux, &args);
if (__builtin_expect (errstring != NULL, 0))
{
/* We are not interested in the error message. */
@@ -319,13 +322,14 @@ _dl_map_object_deps (struct link_map *map,
if (__builtin_expect (GL(dl_debug_mask) & DL_DEBUG_LIBS,
0))
INTUSE(_dl_debug_printf) ("load filtered object=%s"
- " requested by file=%s\n", name,
+ " requested by file=%s\n",
+ name,
l->l_name[0]
? l->l_name : _dl_argv[0]);
/* For filter objects the dependency must be available. */
- err = INTUSE(_dl_catch_error) (&objname, &errstring, openaux,
- &args);
+ err = INTUSE(_dl_catch_error) (&objname, &errstring,
+ openaux, &args);
if (__builtin_expect (errstring != NULL, 0))
{
if (err)
diff --git a/elf/dl-open.c b/elf/dl-open.c
index 253f7b93dc..8f30bc009d 100644
--- a/elf/dl-open.c
+++ b/elf/dl-open.c
@@ -158,7 +158,7 @@ dl_open_worker (void *a)
/* Maybe we have to expand a DST. */
dst = strchr (file, '$');
- if (dst != NULL)
+ if (__builtin_expect (dst != NULL, 0))
{
const void *caller = args->caller;
size_t len = strlen (file);
@@ -208,8 +208,7 @@ dl_open_worker (void *a)
}
/* Load the named object. */
- args->map = new = _dl_map_object (NULL, file, 0, lt_loaded, 0,
- mode);
+ args->map = new = _dl_map_object (NULL, file, 0, lt_loaded, 0, mode);
/* If the pointer returned is NULL this means the RTLD_NOLOAD flag is
set and the object is not already loaded. */
@@ -243,7 +242,7 @@ dl_open_worker (void *a)
}
/* Load that object's dependencies. */
- _dl_map_object_deps (new, NULL, 0, 0);
+ _dl_map_object_deps (new, NULL, 0, 0, mode & __RTLD_DLOPEN);
/* So far, so good. Now check the versions. */
for (i = 0; i < new->l_searchlist.r_nlist; ++i)
@@ -413,7 +412,7 @@ _dl_open (const char *file, int mode, const void *caller)
/* Release the lock. */
__libc_lock_unlock_recursive (GL(dl_load_lock));
- if (errstring)
+ if (__builtin_expect (errstring != NULL, 0))
{
/* Some error occurred during loading. */
char *local_errstring;
diff --git a/elf/nodlopen2.c b/elf/nodlopen2.c
new file mode 100644
index 0000000000..a223f36834
--- /dev/null
+++ b/elf/nodlopen2.c
@@ -0,0 +1,15 @@
+#include <dlfcn.h>
+#include <stdio.h>
+
+int
+main (void)
+{
+ if (dlopen ("nodlopenmod2.so", RTLD_LAZY) != NULL)
+ {
+ puts ("opening \"nodlopenmod2.so\" succeeded, FAIL");
+ return 1;
+ }
+
+ puts ("opening \"nodlopenmod2.so\" failed, OK");
+ return 0;
+}
diff --git a/elf/nodlopenmod2.c b/elf/nodlopenmod2.c
new file mode 100644
index 0000000000..ce1bbcc50f
--- /dev/null
+++ b/elf/nodlopenmod2.c
@@ -0,0 +1,7 @@
+extern int a;
+
+int
+foo (void)
+{
+ return a;
+}
diff --git a/elf/rtld.c b/elf/rtld.c
index f87462eda8..6463ed600e 100644
--- a/elf/rtld.c
+++ b/elf/rtld.c
@@ -821,8 +821,9 @@ of this helper program; chances are you did not intend to run this program.\n\
&& (__builtin_expect (! __libc_enable_secure, 1)
|| strchr (p, '/') == NULL))
{
- struct link_map *new_map = INTUSE(_dl_map_object) (GL(dl_loaded), p,
- 1, lt_library,
+ struct link_map *new_map = INTUSE(_dl_map_object) (GL(dl_loaded),
+ p, 1,
+ lt_library,
0, 0);
if (++new_map->l_opencount == 1)
/* It is no duplicate. */
@@ -903,8 +904,9 @@ of this helper program; chances are you did not intend to run this program.\n\
if (problem != NULL)
{
char *p = strndupa (problem, file_size - (problem - file));
- struct link_map *new_map = INTUSE(_dl_map_object) (GL(dl_loaded), p, 1,
- lt_library, 0, 0);
+ struct link_map *new_map = INTUSE(_dl_map_object) (GL(dl_loaded), p,
+ 1, lt_library,
+ 0, 0);
if (++new_map->l_opencount == 1)
/* It is no duplicate. */
++npreloads;
@@ -937,7 +939,8 @@ of this helper program; chances are you did not intend to run this program.\n\
specified some libraries to load, these are inserted before the actual
dependencies in the executable's searchlist for symbol resolution. */
HP_TIMING_NOW (start);
- INTUSE(_dl_map_object_deps) (GL(dl_loaded), preloads, npreloads, mode == trace);
+ INTUSE(_dl_map_object_deps) (GL(dl_loaded), preloads, npreloads,
+ mode == trace, 0);
HP_TIMING_NOW (stop);
HP_TIMING_DIFF (diff, start, stop);
HP_TIMING_ACCUM_NT (load_time, diff);