Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Ulrich Drepper committed Feb 10, 2002
1 parent 2cef425 commit 87837aa
Show file tree
Hide file tree
Showing 8 changed files with 72 additions and 26 deletions.
17 changes: 15 additions & 2 deletions ChangeLog
@@ -1,7 +1,20 @@
2002-02-10 Ulrich Drepper <drepper@redhat.com>

* 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/tst-tls1.c: Move TLS helper macros to...
* elf/tls-macros.h: ...here. New file.
* elf/tls-macros.hgg: ...here. New file.
* elf/tst-tls2.c: New file.
* elf/Makefile (tests): Add tst-tls2.
(distribute): Add tls-macros.h.
Expand All @@ -27,7 +40,7 @@
* sysdeps/generic/dl-tls.c (_dl_allocate_tls): Correctly terminate
loop to initialize TLS block.

2002-02-08 Richard Henderson <rth@twiddle.net>
2002-02-08 Richard Henderson <rth@redhat.com>

* sysdeps/generic/ldsodefs.h (struct rtld_global): Also include
_dl_cpuclock_offset if HP_SMALL_TIMING_AVAIL.
Expand Down
8 changes: 6 additions & 2 deletions elf/Makefile
Expand Up @@ -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 \
Expand All @@ -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
Expand Down Expand Up @@ -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)) \
Expand Down
24 changes: 14 additions & 10 deletions elf/dl-deps.c
Expand Up @@ -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;

Expand All @@ -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
Expand Down Expand Up @@ -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)); \
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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. */
Expand All @@ -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)
Expand Down
9 changes: 4 additions & 5 deletions elf/dl-open.c
Expand Up @@ -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);
Expand Down Expand Up @@ -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. */
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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;
Expand Down
15 changes: 15 additions & 0 deletions 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;
}
7 changes: 7 additions & 0 deletions elf/nodlopenmod2.c
@@ -0,0 +1,7 @@
extern int a;

int
foo (void)
{
return a;
}
13 changes: 8 additions & 5 deletions elf/rtld.c
Expand Up @@ -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. */
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down
5 changes: 3 additions & 2 deletions sysdeps/generic/ldsodefs.h
Expand Up @@ -462,12 +462,13 @@ extern struct link_map *_dl_map_object_internal (struct link_map *loader,
but before its dependencies. */
extern void _dl_map_object_deps (struct link_map *map,
struct link_map **preloads,
unsigned int npreloads, int trace_mode)
unsigned int npreloads, int trace_mode,
int open_mode)
internal_function;
extern void _dl_map_object_deps_internal (struct link_map *map,
struct link_map **preloads,
unsigned int npreloads,
int trace_mode)
int trace_mode, int open_mode)
internal_function;

/* Cache the locations of MAP's hash table. */
Expand Down

0 comments on commit 87837aa

Please sign in to comment.