aboutsummaryrefslogtreecommitdiff
path: root/elf
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2002-03-01 09:44:29 +0000
committerUlrich Drepper <drepper@redhat.com>2002-03-01 09:44:29 +0000
commite6caf4e12ebb89254977a74b882757e371c5cc16 (patch)
tree294c7931b89d526659023e762272b36ad53744a3 /elf
parent90a77d0a958c5822ad8a2f479c466a6f4d093e74 (diff)
downloadglibc-e6caf4e12ebb89254977a74b882757e371c5cc16.zip
glibc-e6caf4e12ebb89254977a74b882757e371c5cc16.tar.gz
glibc-e6caf4e12ebb89254977a74b882757e371c5cc16.tar.bz2
Update.
2002-03-01 Ulrich Drepper <drepper@redhat.com> * elf/Makefile (dl-routines): Add dl-origin. (elide-routines.os): Add dl-origin. * elf/Versions [ld] (GLIBC_PRIVATE): Add _dl_get_origin. * elf/dl-debug.c (_dl_debug_initialize): Add missing INTUSE around _dl_debug_state. * include/libc-symbols.c: Define attribute_hidden depending on HAVE_VISIBILITY_ATTRIBUTE. Add definition of INTVARDEF. * elf/dl-deps.c: Use INTUSE with __libc_enable_secure. * elf/dl-load.c: Likewise. * elf/rtld.c: Likewise. * include/unistd.h: Declare __libc_enable_secure_internal. * sysdeps/generic/dl-sysdep.c: Use INTVARDEF with __libc_enable_secure. Use INTUSE with __libc_enable_secure. * sysdeps/mach/hurd/dl-sysdep.c: Likewise. * elf/dl-deps.c: Use INTUSE with _dl_out_of_memory. * elf/dl-error.c: Likewise, * sysdeps/generic/ldsodefs.h: Declare _dl_out_of_memory_internal. * elf/dl-dst.h [_RTLD_GLOBAL]: Define _dl_get_origin to use INTUSE. * sysdeps/generic/dl-origin.c: Undefine _dl_get_origin macro before function definition. Use INTDEF with _dl_get_origin. * sysdeps/unix/sysv/linux/dl-origin.c: Likewise. * elf/dl-init.c: Use INTUSE with _dl_starting_up. * elf/rtld.c: Likewise. Use INTVARDEF for _dl_starting_up. * elf/dl-profile.c: Use INTDEF for _dl_mcount. * elf/dl-runtime.c: Use INTUSE with _dl_mcount. * sysdeps/generic/ldsodefs.h: Declare _dl_mcount_internal. * elf/dl-conflict.c: Use rtld_progrname instead of _dl_argv[0]. * elf/dl-deps.c: Likewise. * elf/dl-error.c: Likewise. * elf/dl-fini.c: Likewise. * elf/dl-init.c: Likewise. * elf/dl-load.c: Likewise. * elf/dl-lookup.c: Likewise. * elf/dl-reloc.c: Likewise. * elf/dl-version.c: Likewise. * elf/do-lookup.h: Likewise. * sysdeps/arm/dl-machine.h: Likewise. * sysdeps/cris/dl-machine.h: Likewise. * sysdeps/hppa/dl-machine.h: Likewise. * sysdeps/i386/dl-machine.h: Likewise. * sysdeps/m68k/dl-machine.h: Likewise. * sysdeps/powerpc/dl-machine.h: Likewise. * sysdeps/s390/s390-32/dl-machine.h: Likewise. * sysdeps/s390/s390-64/dl-machine.h: Likewise. * sysdeps/sh/dl-machine.h: Likewise. * sysdeps/sparc/sparc-32/dl-machine.h: Likewise. * sysdeps/sparc/sparc-64/dl-machine.h: Likewise. * sysdeps/x86_64/dl-machine.h: Likewise. * elf/rtld.c: Use INTDEF for _dl_argv. Use rtld_progrname instead of _dl_argv[0]. Use INTUSE with _dl_argv. * sysdeps/generic/dl-sysdep.c: Use INTUSE with _dl_argv. * sysdeps/generic/ldsodefs.h: Define rtld_progname macro.
Diffstat (limited to 'elf')
-rw-r--r--elf/Makefile4
-rw-r--r--elf/Versions1
-rw-r--r--elf/dl-conflict.c2
-rw-r--r--elf/dl-debug.c2
-rw-r--r--elf/dl-deps.c8
-rw-r--r--elf/dl-dst.h5
-rw-r--r--elf/dl-error.c5
-rw-r--r--elf/dl-fini.c3
-rw-r--r--elf/dl-init.c7
-rw-r--r--elf/dl-load.c19
-rw-r--r--elf/dl-lookup.c16
-rw-r--r--elf/dl-profile.c1
-rw-r--r--elf/dl-reloc.c4
-rw-r--r--elf/dl-runtime.c2
-rw-r--r--elf/dl-version.c8
-rw-r--r--elf/do-lookup.h5
-rw-r--r--elf/rtld.c73
17 files changed, 91 insertions, 74 deletions
diff --git a/elf/Makefile b/elf/Makefile
index 4ff6f89..dd4c787 100644
--- a/elf/Makefile
+++ b/elf/Makefile
@@ -29,11 +29,11 @@ routines = $(dl-routines) dl-open dl-close dl-support dl-iteratephdr \
# profiled libraries.
dl-routines = $(addprefix dl-,load cache lookup object reloc deps \
runtime error init fini debug misc \
- version profile conflict tls)
+ version profile conflict tls origin)
all-dl-routines = $(dl-routines) $(sysdep-dl-routines)
# But they are absent from the shared libc, because that code is in ld.so.
elide-routines.os = $(all-dl-routines) dl-support enbl-secure \
- dl-iteratephdr-static
+ dl-iteratephdr-static dl-origin
# ld.so uses those routines, plus some special stuff for being the program
# interpreter and operating independent of libc.
diff --git a/elf/Versions b/elf/Versions
index 37d11d8..477fd2d 100644
--- a/elf/Versions
+++ b/elf/Versions
@@ -50,5 +50,6 @@ ld {
_dl_relocate_object; _dl_signal_error; _dl_start_profile; _dl_starting_up;
_dl_unload_cache;
_rtld_global; _dl_tls_symaddr; _dl_allocate_tls; _dl_deallocate_tls;
+ _dl_get_origin;
}
}
diff --git a/elf/dl-conflict.c b/elf/dl-conflict.c
index bf48acd..07ebfe5 100644
--- a/elf/dl-conflict.c
+++ b/elf/dl-conflict.c
@@ -35,7 +35,7 @@ _dl_resolve_conflicts (struct link_map *l, ElfW(Rela) *conflict,
{
if (__builtin_expect (GL(dl_debug_mask) & DL_DEBUG_RELOC, 0))
_dl_printf ("\nconflict processing: %s\n",
- l->l_name[0] ? l->l_name : _dl_argv[0]);
+ l->l_name[0] ? l->l_name : rtld_progname);
{
/* Do the conflict relocation of the object and library GOT and other
diff --git a/elf/dl-debug.c b/elf/dl-debug.c
index 462a21e..e072b68 100644
--- a/elf/dl-debug.c
+++ b/elf/dl-debug.c
@@ -40,7 +40,7 @@ _dl_debug_initialize (ElfW(Addr) ldbase)
_r_debug.r_version = 1 /* R_DEBUG_VERSION XXX */;
_r_debug.r_ldbase = ldbase;
_r_debug.r_map = GL(dl_loaded);
- _r_debug.r_brk = (ElfW(Addr)) &_dl_debug_state;
+ _r_debug.r_brk = (ElfW(Addr)) &INTUSE(_dl_debug_state);
}
return &_r_debug;
diff --git a/elf/dl-deps.c b/elf/dl-deps.c
index e79e8f1..6dac54a 100644
--- a/elf/dl-deps.c
+++ b/elf/dl-deps.c
@@ -107,7 +107,7 @@ struct list
char *__newp; \
\
/* DST must not appear in SUID/SGID programs. */ \
- if (__libc_enable_secure) \
+ if (INTUSE(__libc_enable_secure)) \
INTUSE(_dl_signal_error) (0, __str, NULL, N_("\
DST not allowed in SUID/SGID programs")); \
\
@@ -297,7 +297,7 @@ _dl_map_object_deps (struct link_map *map,
" requested by file=%s\n",
name,
l->l_name[0]
- ? l->l_name : _dl_argv[0]);
+ ? l->l_name : rtld_progname);
/* We must be prepared that the addressed shared
object is not available. */
@@ -307,7 +307,7 @@ _dl_map_object_deps (struct link_map *map,
{
/* We are not interested in the error message. */
assert (errstring != NULL);
- if (errstring != _dl_out_of_memory)
+ if (errstring != INTUSE(_dl_out_of_memory))
free ((char *) errstring);
/* Simply ignore this error and continue the work. */
@@ -325,7 +325,7 @@ _dl_map_object_deps (struct link_map *map,
" requested by file=%s\n",
name,
l->l_name[0]
- ? l->l_name : _dl_argv[0]);
+ ? l->l_name : rtld_progname);
/* For filter objects the dependency must be available. */
err = INTUSE(_dl_catch_error) (&objname, &errstring,
diff --git a/elf/dl-dst.h b/elf/dl-dst.h
index 615580b..05bdee5 100644
--- a/elf/dl-dst.h
+++ b/elf/dl-dst.h
@@ -62,6 +62,11 @@ extern size_t _dl_dst_count_internal (const char *name, int is_path);
/* Find origin of the executable. */
extern const char *_dl_get_origin (void);
+extern const char *_dl_get_origin_internal (void);
+
+#ifdef _RTLD_LOCAL
+# define _dl_get_origin INTUSE(_dl_get_origin)
+#endif
/* Prototype for used function. */
extern char *_dl_dst_substitute (struct link_map *l, const char *name,
diff --git a/elf/dl-error.c b/elf/dl-error.c
index 71088fb..fbb35d2 100644
--- a/elf/dl-error.c
+++ b/elf/dl-error.c
@@ -49,6 +49,7 @@ __libc_tsd_define (static, DL_ERROR)
variable since we have to avoid freeing it and so have to enable
a pointer comparison. See below and in dlfcn/dlerror.c. */
const char _dl_out_of_memory[] = "out of memory";
+INTVARDEF(_dl_out_of_memory)
/* This points to a function which is called when an continuable error is
@@ -92,7 +93,7 @@ _dl_signal_error (int errcode, const char *objname, const char *occation,
{
/* This is better than nothing. */
lcatch->objname = "";
- lcatch->errstring = _dl_out_of_memory;
+ lcatch->errstring = INTUSE(_dl_out_of_memory);
}
longjmp (lcatch->env, errcode ?: -1);
}
@@ -101,7 +102,7 @@ _dl_signal_error (int errcode, const char *objname, const char *occation,
/* Lossage while resolving the program's own symbols is always fatal. */
char buffer[1024];
_dl_fatal_printf ("%s: %s: %s%s%s%s%s\n",
- _dl_argv[0] ?: "<program name unknown>",
+ rtld_progname ?: "<program name unknown>",
occation ?: N_("error while loading shared libraries"),
objname, *objname ? ": " : "",
errstring, errcode ? ": " : "",
diff --git a/elf/dl-fini.c b/elf/dl-fini.c
index 5beb24b..4e2e66e 100644
--- a/elf/dl-fini.c
+++ b/elf/dl-fini.c
@@ -148,7 +148,8 @@ _dl_fini (void)
/* When debugging print a message first. */
if (__builtin_expect (GL(dl_debug_mask) & DL_DEBUG_IMPCALLS, 0))
INTUSE(_dl_debug_printf) ("\ncalling fini: %s\n\n",
- l->l_name[0] ? l->l_name : _dl_argv[0]);
+ l->l_name[0]
+ ? l->l_name : rtld_progname);
/* First see whether an array is given. */
if (l->l_info[DT_FINI_ARRAY] != NULL)
diff --git a/elf/dl-init.c b/elf/dl-init.c
index a328716..74810fe 100644
--- a/elf/dl-init.c
+++ b/elf/dl-init.c
@@ -26,6 +26,7 @@ typedef void (*init_t) (int, char **, char **);
/* Flag, nonzero during startup phase. */
extern int _dl_starting_up;
+extern int _dl_starting_up_internal attribute_hidden;
static void
@@ -52,7 +53,7 @@ call_init (struct link_map *l, int argc, char **argv, char **env)
/* Print a debug message if wanted. */
if (__builtin_expect (GL(dl_debug_mask) & DL_DEBUG_IMPCALLS, 0))
INTUSE(_dl_debug_printf) ("\ncalling init: %s\n\n",
- l->l_name[0] ? l->l_name : _dl_argv[0]);
+ l->l_name[0] ? l->l_name : rtld_progname);
/* Now run the local constructors. There are two forms of them:
- the one named by DT_INIT
@@ -108,7 +109,7 @@ _dl_init (struct link_map *main_map, int argc, char **argv, char **env)
if (__builtin_expect (GL(dl_debug_mask) & DL_DEBUG_IMPCALLS, 0))
INTUSE(_dl_debug_printf) ("\ncalling preinit: %s\n\n",
main_map->l_name[0]
- ? main_map->l_name : _dl_argv[0]);
+ ? main_map->l_name : rtld_progname);
addrs = (ElfW(Addr) *) (main_map->l_info[DT_PREINIT_ARRAY]->d_un.d_ptr
+ main_map->l_addr);
@@ -142,6 +143,6 @@ _dl_init (struct link_map *main_map, int argc, char **argv, char **env)
INTUSE(_dl_debug_state) ();
/* Finished starting up. */
- _dl_starting_up = 0;
+ INTUSE(_dl_starting_up) = 0;
}
INTDEF (_dl_init)
diff --git a/elf/dl-load.c b/elf/dl-load.c
index 2be2083..b404205 100644
--- a/elf/dl-load.c
+++ b/elf/dl-load.c
@@ -201,7 +201,7 @@ _dl_dst_count (const char *name, int is_path)
is $ORIGIN alone) and it must always appear first in path. */
++name;
if ((len = is_dst (start, name, "ORIGIN", is_path,
- __libc_enable_secure)) != 0
+ INTUSE(__libc_enable_secure))) != 0
|| ((len = is_dst (start, name, "PLATFORM", is_path, 0))
!= 0))
++cnt;
@@ -237,7 +237,7 @@ _dl_dst_substitute (struct link_map *l, const char *name, char *result,
++name;
if ((len = is_dst (start, name, "ORIGIN", is_path,
- __libc_enable_secure)) != 0)
+ INTUSE(__libc_enable_secure))) != 0)
repl = l->l_origin;
else if ((len = is_dst (start, name, "PLATFORM", is_path,
0)) != 0)
@@ -494,7 +494,7 @@ decompose_rpath (struct r_search_path_struct *sps,
/* First see whether we must forget the RUNPATH and RPATH from this
object. */
if (__builtin_expect (GL(dl_inhibit_rpath) != NULL, 0)
- && !__libc_enable_secure)
+ && !INTUSE(__libc_enable_secure))
{
const char *inhp = GL(dl_inhibit_rpath);
@@ -711,7 +711,8 @@ _dl_init_paths (const char *llp)
}
(void) fillin_rpath (llp_tmp, env_path_list.dirs, ":;",
- __libc_enable_secure, "LD_LIBRARY_PATH", NULL);
+ INTUSE(__libc_enable_secure), "LD_LIBRARY_PATH",
+ NULL);
if (env_path_list.dirs[0] == NULL)
{
@@ -1268,7 +1269,7 @@ print_search_path (struct r_search_path_elem **list,
if (name != NULL)
_dl_debug_printf_c ("\t\t(%s from file %s)\n", what,
- name[0] ? name : _dl_argv[0]);
+ name[0] ? name : rtld_progname);
else
_dl_debug_printf_c ("\t\t(%s)\n", what);
}
@@ -1542,7 +1543,7 @@ open_path (const char *name, size_t namelen, int preloaded,
here_any |= this_dir->status[cnt] == existing;
if (fd != -1 && __builtin_expect (preloaded, 0)
- && __libc_enable_secure)
+ && INTUSE(__libc_enable_secure))
{
/* This is an extra security effort to make sure nobody can
preload broken shared objects which are in the trusted
@@ -1649,7 +1650,8 @@ _dl_map_object (struct link_map *loader, const char *name, int preloaded,
if (__builtin_expect (GL(dl_debug_mask) & DL_DEBUG_FILES, 0)
&& loader != NULL)
INTUSE(_dl_debug_printf) ("\nfile=%s; needed by %s\n", name,
- loader->l_name[0] ? loader->l_name : _dl_argv[0]);
+ loader->l_name[0]
+ ? loader->l_name : rtld_progname);
if (strchr (name, '/') == NULL)
{
@@ -1740,7 +1742,8 @@ _dl_map_object (struct link_map *loader, const char *name, int preloaded,
}
if (fd == -1
- && (__builtin_expect (! preloaded, 1) || ! __libc_enable_secure))
+ && (__builtin_expect (! preloaded, 1)
+ || ! INTUSE(__libc_enable_secure)))
{
/* Check the list of libraries in the file /etc/ld.so.cache,
for compatibility with Linux's ldconfig program. */
diff --git a/elf/dl-lookup.c b/elf/dl-lookup.c
index 521f032..f9a229d 100644
--- a/elf/dl-lookup.c
+++ b/elf/dl-lookup.c
@@ -171,9 +171,9 @@ add_dependency (struct link_map *undef_map, struct link_map *map)
if (__builtin_expect (GL(dl_debug_mask) & DL_DEBUG_FILES, 0))
INTUSE(_dl_debug_printf) ("\
\nfile=%s; needed by %s (relocation dependency)\n\n",
- map->l_name[0] ? map->l_name : _dl_argv[0],
+ map->l_name[0] ? map->l_name : rtld_progname,
undef_map->l_name[0]
- ? undef_map->l_name : _dl_argv[0]);
+ ? undef_map->l_name : rtld_progname);
}
else
/* Whoa, that was bad luck. We have to search again. */
@@ -256,7 +256,7 @@ _dl_lookup_symbol (const char *undef_name, struct link_map *undef_map,
/* XXX We cannot translate the messages. */
_dl_signal_cerror (0, (reference_name[0]
? reference_name
- : (_dl_argv[0] ?: "<main program>")),
+ : (rtld_progname ?: "<main program>")),
N_("relocation error"),
make_string (undefined_msg, undef_name));
*ref = NULL;
@@ -419,7 +419,7 @@ _dl_lookup_versioned_symbol (const char *undef_name,
/* XXX We cannot translate the message. */
_dl_signal_cerror (0, (reference_name[0]
? reference_name
- : (_dl_argv[0] ?: "<main program>")),
+ : (rtld_progname ?: "<main program>")),
N_("relocation error"),
make_string ("symbol ", undef_name, ", version ",
version->name,
@@ -443,7 +443,7 @@ _dl_lookup_versioned_symbol (const char *undef_name,
/* XXX We cannot translate the message. */
_dl_signal_cerror (0, (reference_name[0]
? reference_name
- : (_dl_argv[0] ?: "<main program>")), NULL,
+ : (rtld_progname ?: "<main program>")), NULL,
make_string (undefined_msg, undef_name,
", version ",
version->name ?: NULL));
@@ -528,7 +528,7 @@ _dl_lookup_versioned_symbol_skip (const char *undef_name,
/* XXX We cannot translate the messages. */
_dl_signal_cerror (0, (reference_name[0]
? reference_name
- : (_dl_argv[0] ?: "<main program>")),
+ : (rtld_progname ?: "<main program>")),
NULL, buf);
}
*ref = NULL;
@@ -604,9 +604,9 @@ _dl_debug_bindings (const char *undef_name, struct link_map *undef_map,
INTUSE(_dl_debug_printf) ("binding file %s to %s: %s symbol `%s'",
(reference_name[0]
? reference_name
- : (_dl_argv[0] ?: "<main program>")),
+ : (rtld_progname ?: "<main program>")),
value->m->l_name[0]
- ? value->m->l_name : _dl_argv[0],
+ ? value->m->l_name : rtld_progname,
protected ? "protected" : "normal",
undef_name);
if (version)
diff --git a/elf/dl-profile.c b/elf/dl-profile.c
index 05b5c28..489d12b 100644
--- a/elf/dl-profile.c
+++ b/elf/dl-profile.c
@@ -558,3 +558,4 @@ _dl_mcount (ElfW(Addr) frompc, ElfW(Addr) selfpc)
done:
;
}
+INTDEF(_dl_mcount)
diff --git a/elf/dl-reloc.c b/elf/dl-reloc.c
index c9f298a..9e39014 100644
--- a/elf/dl-reloc.c
+++ b/elf/dl-reloc.c
@@ -60,7 +60,7 @@ _dl_relocate_object (struct link_map *l, struct r_scope_elem *scope[],
if (__builtin_expect (GL(dl_debug_mask) & DL_DEBUG_RELOC, 0))
INTUSE(_dl_debug_printf) ("\nrelocation processing: %s%s\n",
- l->l_name[0] ? l->l_name : _dl_argv[0],
+ l->l_name[0] ? l->l_name : rtld_progname,
lazy ? " (lazy)" : "");
/* DT_TEXTREL is now in level 2 and might phase out at some time.
@@ -172,7 +172,7 @@ _dl_relocate_object (struct link_map *l, struct r_scope_elem *scope[],
errstring = N_("%s: profiler found no PLTREL in object %s\n");
fatal:
_dl_fatal_printf (errstring,
- _dl_argv[0] ?: "<program name unknown>",
+ rtld_progname ?: "<program name unknown>",
l->l_name);
}
diff --git a/elf/dl-runtime.c b/elf/dl-runtime.c
index de4639a..3cc8325 100644
--- a/elf/dl-runtime.c
+++ b/elf/dl-runtime.c
@@ -136,7 +136,7 @@ profile_fixup (
#endif
struct link_map *l, ElfW(Word) reloc_offset, ElfW(Addr) retaddr)
{
- void (*mcount_fct) (ElfW(Addr), ElfW(Addr)) = _dl_mcount;
+ void (*mcount_fct) (ElfW(Addr), ElfW(Addr)) = INTUSE(_dl_mcount);
ElfW(Addr) *resultp;
lookup_t result;
ElfW(Addr) value;
diff --git a/elf/dl-version.c b/elf/dl-version.c
index e33cd52..e9553e4 100644
--- a/elf/dl-version.c
+++ b/elf/dl-version.c
@@ -90,7 +90,7 @@ match_symbol (const char *name, ElfW(Word) hash, const char *string,
INTUSE(_dl_debug_printf) ("\
checking for version `%s' in file %s required by file %s\n",
string, map->l_name[0]
- ? map->l_name : _dl_argv[0], name);
+ ? map->l_name : rtld_progname, name);
if (__builtin_expect (map->l_info[VERSYMIDX (DT_VERDEF)] == NULL, 0))
{
@@ -166,7 +166,7 @@ no version information available (required by ", name, ")");
name, ")");
result = 1;
call_cerror:
- _dl_signal_cerror (0, map->l_name[0] ? map->l_name : _dl_argv[0],
+ _dl_signal_cerror (0, map->l_name[0] ? map->l_name : rtld_progname,
NULL, errstring);
return result;
}
@@ -215,7 +215,7 @@ _dl_check_map_versions (struct link_map *map, int verbose, int trace_mode)
" of Verneed record\n");
call_error:
INTUSE(_dl_signal_error) (errval, (*map->l_name
- ? map->l_name : _dl_argv[0]),
+ ? map->l_name : rtld_progname),
NULL, errstring);
}
@@ -240,7 +240,7 @@ _dl_check_map_versions (struct link_map *map, int verbose, int trace_mode)
{
/* Match the symbol. */
result |= match_symbol ((*map->l_name
- ? map->l_name : _dl_argv[0]),
+ ? map->l_name : rtld_progname),
aux->vna_hash,
strtab + aux->vna_name,
needed, verbose,
diff --git a/elf/do-lookup.h b/elf/do-lookup.h
index 3e72902..bbbb4d4 100644
--- a/elf/do-lookup.h
+++ b/elf/do-lookup.h
@@ -61,8 +61,9 @@ FCT (const char *undef_name, unsigned long int hash, const ElfW(Sym) *ref,
/* Print some debugging info if wanted. */
if (__builtin_expect (GL(dl_debug_mask) & DL_DEBUG_SYMBOLS, 0))
- INTUSE(_dl_debug_printf) ("symbol=%s; lookup in file=%s\n", undef_name,
- map->l_name[0] ? map->l_name : _dl_argv[0]);
+ INTUSE(_dl_debug_printf) ("symbol=%s; lookup in file=%s\n",
+ undef_name, (map->l_name[0]
+ ? map->l_name : rtld_progname));
symtab = (const void *) D_PTR (map, l_info[DT_SYMTAB]);
strtab = (const void *) D_PTR (map, l_info[DT_STRTAB]);
diff --git a/elf/rtld.c b/elf/rtld.c
index 12b3cc5..97acf20 100644
--- a/elf/rtld.c
+++ b/elf/rtld.c
@@ -59,7 +59,8 @@ enum mode { normal, list, verify, trace };
static void process_envvars (enum mode *modep);
int _dl_argc;
-char **_dl_argv;
+char **_dl_argv = NULL;
+INTDEF(_dl_argv)
unsigned int _dl_skip_args; /* Nonzero if we were run directly. */
/* Set nonzero during loading and initialization of executable and
@@ -69,7 +70,8 @@ unsigned int _dl_skip_args; /* Nonzero if we were run directly. */
definition seen by libc.so's initializer; that value must be zero,
and will be since that dynamic linker's _dl_start and dl_main will
never be called. */
-int _dl_starting_up;
+int _dl_starting_up = 0;
+INTVARDEF(_dl_starting_up)
/* This is the structure which defines all variables global to ld.so
(except those which cannot be added for some reason). */
@@ -489,7 +491,7 @@ dl_main (const ElfW(Phdr) *phdr,
process_envvars (&mode);
/* Set up a flag which tells we are just starting. */
- _dl_starting_up = 1;
+ INTUSE(_dl_starting_up) = 1;
if (*user_entry == (ElfW(Addr)) ENTRY_POINT)
{
@@ -511,41 +513,43 @@ dl_main (const ElfW(Phdr) *phdr,
rtld_is_main = true;
/* Note the place where the dynamic linker actually came from. */
- GL(dl_rtld_map).l_name = _dl_argv[0];
+ GL(dl_rtld_map).l_name = rtld_progname;
while (_dl_argc > 1)
- if (! strcmp (_dl_argv[1], "--list"))
+ if (! strcmp (INTUSE(_dl_argv)[1], "--list"))
{
mode = list;
GL(dl_lazy) = -1; /* This means do no dependency analysis. */
++_dl_skip_args;
--_dl_argc;
- ++_dl_argv;
+ ++INTUSE(_dl_argv);
}
- else if (! strcmp (_dl_argv[1], "--verify"))
+ else if (! strcmp (INTUSE(_dl_argv)[1], "--verify"))
{
mode = verify;
++_dl_skip_args;
--_dl_argc;
- ++_dl_argv;
+ ++INTUSE(_dl_argv);
}
- else if (! strcmp (_dl_argv[1], "--library-path") && _dl_argc > 2)
+ else if (! strcmp (INTUSE(_dl_argv)[1], "--library-path")
+ && _dl_argc > 2)
{
- library_path = _dl_argv[2];
+ library_path = INTUSE(_dl_argv)[2];
_dl_skip_args += 2;
_dl_argc -= 2;
- _dl_argv += 2;
+ INTUSE(_dl_argv) += 2;
}
- else if (! strcmp (_dl_argv[1], "--inhibit-rpath") && _dl_argc > 2)
+ else if (! strcmp (INTUSE(_dl_argv)[1], "--inhibit-rpath")
+ && _dl_argc > 2)
{
- GL(dl_inhibit_rpath) = _dl_argv[2];
+ GL(dl_inhibit_rpath) = INTUSE(_dl_argv)[2];
_dl_skip_args += 2;
_dl_argc -= 2;
- _dl_argv += 2;
+ INTUSE(_dl_argv) += 2;
}
else
break;
@@ -577,7 +581,7 @@ of this helper program; chances are you did not intend to run this program.\n\
++_dl_skip_args;
--_dl_argc;
- ++_dl_argv;
+ ++INTUSE(_dl_argv);
/* Initialize the data structures for the search paths for shared
objects. */
@@ -589,19 +593,17 @@ of this helper program; chances are you did not intend to run this program.\n\
const char *err_str = NULL;
struct map_args args;
- args.str = _dl_argv[0];
+ args.str = rtld_progname;
(void) INTUSE(_dl_catch_error) (&objname, &err_str, map_doit, &args);
if (__builtin_expect (err_str != NULL, 0))
- {
- if (err_str != _dl_out_of_memory)
- free ((char *) err_str);
- _exit (EXIT_FAILURE);
- }
+ /* We don't free the returned string, the programs stops
+ anyway. */
+ _exit (EXIT_FAILURE);
}
else
{
HP_TIMING_NOW (start);
- INTUSE(_dl_map_object) (NULL, _dl_argv[0], 0, lt_library, 0, 0);
+ INTUSE(_dl_map_object) (NULL, rtld_progname, 0, lt_library, 0, 0);
HP_TIMING_NOW (stop);
HP_TIMING_DIFF (load_time, start, stop);
@@ -814,7 +816,7 @@ of this helper program; chances are you did not intend to run this program.\n\
/* Prevent optimizing strsep. Speed is not important here. */
while ((p = (strsep) (&list, " :")) != NULL)
if (p[0] != '\0'
- && (__builtin_expect (! __libc_enable_secure, 1)
+ && (__builtin_expect (! INTUSE(__libc_enable_secure), 1)
|| strchr (p, '/') == NULL))
{
struct link_map *new_map = INTUSE(_dl_map_object) (GL(dl_loaded),
@@ -1029,9 +1031,9 @@ of this helper program; chances are you did not intend to run this program.\n\
GL(dl_trace_prelink_map) = l;
_dl_printf ("\t%s => %s (0x%0*Zx, 0x%0*Zx)\n",
l->l_libname->name[0] ? l->l_libname->name
- : _dl_argv[0] ?: "<main program>",
+ : rtld_progname ?: "<main program>",
l->l_name[0] ? l->l_name
- : _dl_argv[0] ?: "<main program>",
+ : rtld_progname ?: "<main program>",
(int) sizeof l->l_map_start * 2,
l->l_map_start,
(int) sizeof l->l_addr * 2,
@@ -1058,14 +1060,15 @@ of this helper program; chances are you did not intend to run this program.\n\
ElfW(Addr) loadbase;
lookup_t result;
- result = INTUSE(_dl_lookup_symbol) (_dl_argv[i], GL(dl_loaded),
+ result = INTUSE(_dl_lookup_symbol) (INTUSE(_dl_argv)[i],
+ GL(dl_loaded),
&ref, GL(dl_loaded)->l_scope,
ELF_RTYPE_CLASS_PLT, 1);
loadbase = LOOKUP_VALUE_ADDRESS (result);
_dl_printf ("%s found at 0x%0*Zd in object at 0x%0*Zd\n",
- _dl_argv[i],
+ INTUSE(_dl_argv)[i],
(int) sizeof ref->st_value * 2, ref->st_value,
(int) sizeof loadbase * 2, loadbase);
}
@@ -1127,7 +1130,7 @@ of this helper program; chances are you did not intend to run this program.\n\
}
_dl_printf ("\t%s:\n",
- map->l_name[0] ? map->l_name : _dl_argv[0]);
+ map->l_name[0] ? map->l_name : rtld_progname);
while (1)
{
@@ -1459,7 +1462,7 @@ print_unresolved (int errcode __attribute__ ((unused)), const char *objname,
const char *errstring)
{
if (objname[0] == '\0')
- objname = _dl_argv[0] ?: "<main program>";
+ objname = rtld_progname ?: "<main program>";
_dl_error_printf ("%s (%s)\n", errstring, objname);
}
@@ -1469,7 +1472,7 @@ static void
print_missing_version (int errcode __attribute__ ((unused)),
const char *objname, const char *errstring)
{
- _dl_error_printf ("%s: %s: %s\n", _dl_argv[0] ?: "<program name unknown>",
+ _dl_error_printf ("%s: %s: %s\n", rtld_progname ?: "<program name unknown>",
objname, errstring);
}
@@ -1585,8 +1588,8 @@ process_envvars (enum mode *modep)
char *debug_output = NULL;
/* This is the default place for profiling data file. */
- GL(dl_profile_output) = &"/var/tmp\0/var/profile"[__libc_enable_secure
- ? 9 : 0];
+ GL(dl_profile_output)
+ = &"/var/tmp\0/var/profile"[INTUSE(__libc_enable_secure) ? 9 : 0];
while ((envline = _dl_next_ld_env_entry (&runp)) != NULL)
{
@@ -1661,7 +1664,7 @@ process_envvars (enum mode *modep)
case 11:
/* Path where the binary is found. */
- if (!__libc_enable_secure
+ if (!INTUSE(__libc_enable_secure)
&& memcmp (envline, "ORIGIN_PATH", 11) == 0)
GL(dl_origin_path) = &envline[12];
break;
@@ -1687,7 +1690,7 @@ process_envvars (enum mode *modep)
case 14:
/* Where to place the profiling data file. */
- if (!__libc_enable_secure
+ if (!INTUSE(__libc_enable_secure)
&& memcmp (envline, "PROFILE_OUTPUT", 14) == 0
&& envline[15] != '\0')
GL(dl_profile_output) = &envline[15];
@@ -1725,7 +1728,7 @@ process_envvars (enum mode *modep)
/* Extra security for SUID binaries. Remove all dangerous environment
variables. */
- if (__builtin_expect (__libc_enable_secure, 0))
+ if (__builtin_expect (INTUSE(__libc_enable_secure), 0))
{
static const char unsecure_envvars[] =
#ifdef EXTRA_UNSECURE_ENVVARS