aboutsummaryrefslogtreecommitdiff
path: root/elf/rtld.c
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/rtld.c
parent90a77d0a958c5822ad8a2f479c466a6f4d093e74 (diff)
downloadglibc-e6caf4e12ebb89254977a74b882757e371c5cc16.tar
glibc-e6caf4e12ebb89254977a74b882757e371c5cc16.tar.gz
glibc-e6caf4e12ebb89254977a74b882757e371c5cc16.tar.bz2
glibc-e6caf4e12ebb89254977a74b882757e371c5cc16.zip
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/rtld.c')
-rw-r--r--elf/rtld.c73
1 files changed, 38 insertions, 35 deletions
diff --git a/elf/rtld.c b/elf/rtld.c
index 12b3cc557b..97acf20b60 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