diff options
37 files changed, 224 insertions, 123 deletions
diff --git a/ChangeLog b/ChangeLog index 5505efa5fc..12991b733b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,64 @@ +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. + 2002-02-28 Jakub Jelinek <jakub@redhat.com> * elf/rtld.c (_rtld_global): Remove .protected. diff --git a/elf/Makefile b/elf/Makefile index 4ff6f89b64..dd4c787dd1 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 37d11d87b9..477fd2d220 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 bf48acd8a4..07ebfe5378 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 462a21e8a8..e072b685f2 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 e79e8f1b7b..6dac54ab23 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 615580b481..05bdee5ee9 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 71088fbe4c..fbb35d242c 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 5beb24b042..4e2e66e841 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 a328716bf3..74810feff1 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 2be2083408..b404205d0f 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 521f032b2b..f9a229d8ea 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 05b5c28fcb..489d12bdd8 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 c9f298a8cf..9e3901470c 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 de4639a3d0..3cc832512f 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 e33cd5203c..e9553e4744 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 3e7290241b..bbbb4d4d81 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 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 diff --git a/include/libc-symbols.h b/include/libc-symbols.h index 22f7d854c1..bc1c24033f 100644 --- a/include/libc-symbols.h +++ b/include/libc-symbols.h @@ -349,15 +349,27 @@ strong_alias(real, name) #endif +#if defined HAVE_VISIBILITY_ATTRIBUTE && defined SHARED +# define attribute_hidden __attribute__ ((visibility ("hidden"))) +#else +# define attribute_hidden +#endif + /* Handling on non-exported internal names. We have to do this only for shared code. */ #ifdef SHARED # define INTUSE(name) name##_internal -# define INTDEF(name) strong_alias (name, name##_internal); -# define INTDEF2(name, newname) strong_alias (name, newname##_internal); +# define INTDEF(name) strong_alias (name, name##_internal) +# define INTVARDEF(name) \ + _INTVARDEF(name, name##_internal) +# define _INTVARDEF(name, aliasname) \ + extern __typeof (name) aliasname __attribute__ ((visibility ("hidden"))); \ + strong_alias (name, name##_internal) +# define INTDEF2(name, newname) strong_alias (name, newname##_internal) #else # define INTUSE(name) name # define INTDEF(name) +# define INTVARDEF(name) # define INTDEF2(name, newname) #endif diff --git a/include/unistd.h b/include/unistd.h index b8bc8bbf72..8fd7088320 100644 --- a/include/unistd.h +++ b/include/unistd.h @@ -98,6 +98,10 @@ extern void *__sbrk (intptr_t __delta); and some functions contained in the C library ignore various environment variables that normally affect them. */ extern int __libc_enable_secure; +#ifdef _RTLD_LOCAL +/* XXX The #ifdef should go. */ +extern int __libc_enable_secure_internal attribute_hidden; +#endif /* Various internal function. */ diff --git a/sysdeps/arm/dl-machine.h b/sysdeps/arm/dl-machine.h index 177a375be5..4a7ab3867c 100644 --- a/sysdeps/arm/dl-machine.h +++ b/sysdeps/arm/dl-machine.h @@ -377,11 +377,9 @@ elf_machine_plt_value (struct link_map *map, const Elf32_Rel *reloc, /* ARM never uses Elf32_Rela relocations for the dynamic linker. Prelinked libraries may use Elf32_Rela though. */ -#ifdef RTLD_BOOTSTRAP -#define ELF_MACHINE_NO_RELA 1 -#endif - -extern char **_dl_argv; +# ifdef RTLD_BOOTSTRAP +# define ELF_MACHINE_NO_RELA 1 +# endif /* Deal with an out-of-range PC24 reloc. */ static Elf32_Addr @@ -426,15 +424,15 @@ elf_machine_rel (struct link_map *map, const Elf32_Rel *reloc, if (__builtin_expect (r_type == R_ARM_RELATIVE, 0)) { -#ifndef RTLD_BOOTSTRAP +# ifndef RTLD_BOOTSTRAP if (map != &_dl_rtld_map) /* Already done in rtld itself. */ -#endif +# endif *reloc_addr += map->l_addr; } -#ifndef RTLD_BOOTSTRAP +# ifndef RTLD_BOOTSTRAP else if (__builtin_expect (r_type == R_ARM_NONE, 0)) return; -#endif +# endif else { const Elf32_Sym *const refsym = sym; @@ -457,7 +455,7 @@ elf_machine_rel (struct link_map *map, const Elf32_Rel *reloc, strtab = (const void *) D_PTR (map, l_info[DT_STRTAB]); _dl_error_printf ("\ %s: Symbol `%s' has different size in shared object, consider re-linking\n", - _dl_argv[0] ?: "<program name unknown>", + rtld_progname ?: "<program name unknown>", strtab + refsym->st_name); } memcpy (reloc_addr, (void *) value, MIN (sym->st_size, @@ -465,26 +463,26 @@ elf_machine_rel (struct link_map *map, const Elf32_Rel *reloc, break; case R_ARM_GLOB_DAT: case R_ARM_JUMP_SLOT: -#ifdef RTLD_BOOTSTRAP +# ifdef RTLD_BOOTSTRAP /* Fix weak undefined references. */ if (sym != NULL && sym->st_value == 0) *reloc_addr = 0; else -#endif +# endif *reloc_addr = value; break; case R_ARM_ABS32: { -#ifndef RTLD_BOOTSTRAP +# ifndef RTLD_BOOTSTRAP /* This is defined in rtld.c, but nowhere in the static libc.a; make the reference weak so static programs can still link. This declaration cannot be done when compiling rtld.c (i.e. #ifdef RTLD_BOOTSTRAP) because rtld.c contains the common defn for _dl_rtld_map, which is incompatible with a weak decl in the same file. */ -# ifndef SHARED +# ifndef SHARED weak_extern (_dl_rtld_map); -# endif +# endif if (map == &_dl_rtld_map) /* Undo the relocation done here during bootstrapping. Now we will relocate it anew, possibly using a @@ -492,7 +490,7 @@ elf_machine_rel (struct link_map *map, const Elf32_Rel *reloc, rather than the dynamic linker's built-in definitions used while loading those libraries. */ value -= map->l_addr + refsym->st_value; -#endif +# endif *reloc_addr += value; break; } @@ -529,7 +527,7 @@ elf_machine_rel (struct link_map *map, const Elf32_Rel *reloc, } } -#ifndef RTLD_BOOTSTRAP +# ifndef RTLD_BOOTSTRAP static inline void elf_machine_rela (struct link_map *map, const Elf32_Rela *reloc, const Elf32_Sym *sym, const struct r_found_version *version, @@ -539,10 +537,8 @@ elf_machine_rela (struct link_map *map, const Elf32_Rela *reloc, if (__builtin_expect (r_type == R_ARM_RELATIVE, 0)) *reloc_addr = map->l_addr + reloc->r_addend; -#ifndef RTLD_BOOTSTRAP else if (__builtin_expect (r_type == R_ARM_NONE, 0)) return; -#endif else { const Elf32_Sym *const refsym = sym; @@ -585,7 +581,7 @@ elf_machine_rela (struct link_map *map, const Elf32_Rela *reloc, } } } -#endif +# endif static inline void elf_machine_rel_relative (Elf32_Addr l_addr, const Elf32_Rel *reloc, @@ -594,14 +590,14 @@ elf_machine_rel_relative (Elf32_Addr l_addr, const Elf32_Rel *reloc, *reloc_addr += l_addr; } -#ifndef RTLD_BOOTSTRAP +# ifndef RTLD_BOOTSTRAP static inline void elf_machine_rela_relative (Elf32_Addr l_addr, const Elf32_Rela *reloc, Elf32_Addr *const reloc_addr) { *reloc_addr = l_addr + reloc->r_addend; } -#endif +# endif static inline void elf_machine_lazy_rel (struct link_map *map, diff --git a/sysdeps/cris/dl-machine.h b/sysdeps/cris/dl-machine.h index 966d86b27b..51ae43d096 100644 --- a/sysdeps/cris/dl-machine.h +++ b/sysdeps/cris/dl-machine.h @@ -314,13 +314,12 @@ elf_machine_rela (struct link_map *map, const Elf32_Rela *reloc, if (sym->st_size > refsym->st_size || (GL(dl_verbose) && sym->st_size < refsym->st_size)) { - extern char **_dl_argv; const char *strtab; strtab = (const void *) D_PTR (map, l_info[DT_STRTAB]); _dl_error_printf ("\ %s: Symbol `%s' has different size in shared object, consider re-linking\n", - _dl_argv[0] ?: "<program name unknown>", + rtld_progname ?: "<program name unknown>", strtab + refsym->st_name); } memcpy (reloc_addr, (void *) value, MIN (sym->st_size, diff --git a/sysdeps/generic/dl-origin.c b/sysdeps/generic/dl-origin.c index db990e6d36..b198f70d5d 100644 --- a/sysdeps/generic/dl-origin.c +++ b/sysdeps/generic/dl-origin.c @@ -26,6 +26,7 @@ #include <dl-dst.h> +#undef _dl_get_origin const char * _dl_get_origin (void) { @@ -49,3 +50,4 @@ _dl_get_origin (void) return result; } +INTDEF(_dl_get_origin) diff --git a/sysdeps/generic/dl-sysdep.c b/sysdeps/generic/dl-sysdep.c index 3385226de0..1975fe8a66 100644 --- a/sysdeps/generic/dl-sysdep.c +++ b/sysdeps/generic/dl-sysdep.c @@ -47,7 +47,8 @@ extern void __libc_check_standard_fds (void); #ifdef NEED_DL_BASE_ADDR ElfW(Addr) _dl_base_addr; #endif -int __libc_enable_secure; +int __libc_enable_secure = 0; +INTVARDEF(__libc_enable_secure) int __libc_multiple_libcs = 0; /* Defining this here avoids the inclusion of init-first. */ /* This variable contains the lowest stack address ever used. */ @@ -89,7 +90,7 @@ _dl_sysdep_start (void **start_argptr, # define set_seen(tag) seen |= M ((tag)->a_type) #endif - DL_FIND_ARG_COMPONENTS (start_argptr, _dl_argc, _dl_argv, _environ, + DL_FIND_ARG_COMPONENTS (start_argptr, _dl_argc, INTUSE(_dl_argv), _environ, _dl_auxv); user_entry = (ElfW(Addr)) ENTRY_POINT; @@ -156,7 +157,7 @@ _dl_sysdep_start (void **start_argptr, SEE (EGID, egid); #endif - __libc_enable_secure = uid != euid || gid != egid; + INTUSE(__libc_enable_secure) = uid != euid || gid != egid; #ifndef HAVE_AUX_PAGESIZE if (GL(dl_pagesize) == 0) @@ -186,7 +187,7 @@ _dl_sysdep_start (void **start_argptr, /* If this is a SUID program we make sure that FDs 0, 1, and 2 are allocated. If necessary we are doing it ourself. If it is not possible we stop the program. */ - if (__builtin_expect (__libc_enable_secure, 0)) + if (__builtin_expect (INTUSE(__libc_enable_secure), 0)) __libc_check_standard_fds (); (*dl_main) (phdr, phnum, &user_entry); diff --git a/sysdeps/generic/ldsodefs.h b/sysdeps/generic/ldsodefs.h index 08f5829895..4aa5621c19 100644 --- a/sysdeps/generic/ldsodefs.h +++ b/sysdeps/generic/ldsodefs.h @@ -394,9 +394,19 @@ extern struct rtld_global _rtld_local __rtld_local_attribute__; /* Parameters passed to the dynamic linker. */ extern int _dl_argc; extern char **_dl_argv; +#ifdef _RTLD_LOCAL +extern char **_dl_argv_internal attribute_hidden; +# define rtld_progname (INTUSE(_dl_argv)[0]) +#else +# define rtld_progname _dl_argv[0] +#endif /* The array with message we print as a last resort. */ extern const char _dl_out_of_memory[]; +#ifdef _RTLD_LOCAL +/* XXX #ifdef should go away. */ +extern const char _dl_out_of_memory_internal[] attribute_hidden; +#endif /* OS-dependent function to open the zero-fill device. */ @@ -645,6 +655,7 @@ extern void _dl_start_profile_internal (struct link_map *map, /* The actual functions used to keep book on the calls. */ extern void _dl_mcount (ElfW(Addr) frompc, ElfW(Addr) selfpc); +extern void _dl_mcount_internal (ElfW(Addr) frompc, ElfW(Addr) selfpc); /* This function is simply a wrapper around the _dl_mcount function which does not require a FROMPC parameter since this is the diff --git a/sysdeps/hppa/dl-machine.h b/sysdeps/hppa/dl-machine.h index 6d4249437d..b30a3ba62d 100644 --- a/sysdeps/hppa/dl-machine.h +++ b/sysdeps/hppa/dl-machine.h @@ -611,7 +611,7 @@ elf_machine_rela (struct link_map *map, const Elf32_Rela *reloc, strtab = (const char *) D_PTR (map, l_info[DT_STRTAB]); _dl_error_printf ("\ %s: Symbol `%s' has different size in shared object, consider re-linking\n", - _dl_argv[0] ?: "<program name unknown>", + rtld_progname ?: "<program name unknown>", strtab + refsym->st_name); } memcpy (reloc_addr, (void *) value, diff --git a/sysdeps/i386/dl-machine.h b/sysdeps/i386/dl-machine.h index f51dab87e2..3edfb00c0a 100644 --- a/sysdeps/i386/dl-machine.h +++ b/sysdeps/i386/dl-machine.h @@ -433,7 +433,7 @@ elf_machine_rel (struct link_map *map, const Elf32_Rel *reloc, strtab = (const char *) D_PTR (map, l_info[DT_STRTAB]); _dl_error_printf ("\ %s: Symbol `%s' has different size in shared object, consider re-linking\n", - _dl_argv[0] ?: "<program name unknown>", + rtld_progname ?: "<program name unknown>", strtab + refsym->st_name); } memcpy (reloc_addr, (void *) value, MIN (sym->st_size, diff --git a/sysdeps/m68k/dl-machine.h b/sysdeps/m68k/dl-machine.h index b2e1c6b8b4..ce80aad8fa 100644 --- a/sysdeps/m68k/dl-machine.h +++ b/sysdeps/m68k/dl-machine.h @@ -253,13 +253,12 @@ elf_machine_rela (struct link_map *map, const Elf32_Rela *reloc, if (sym->st_size > refsym->st_size || (sym->st_size < refsym->st_size && GL(dl_verbose))) { - extern char **_dl_argv; const char *strtab; strtab = (const void *) D_PTR (map, l_info[DT_STRTAB]); _dl_error_printf ("\ %s: Symbol `%s' has different size in shared object, consider re-linking\n", - _dl_argv[0] ?: "<program name unknown>", + rtld_progname ?: "<program name unknown>", strtab + refsym->st_name); } memcpy (reloc_addr, (void *) value, MIN (sym->st_size, diff --git a/sysdeps/mach/hurd/dl-sysdep.c b/sysdeps/mach/hurd/dl-sysdep.c index 520385513d..883c959bee 100644 --- a/sysdeps/mach/hurd/dl-sysdep.c +++ b/sysdeps/mach/hurd/dl-sysdep.c @@ -47,7 +47,8 @@ extern int _dl_argc; extern char **_dl_argv; extern char **_environ; -int __libc_enable_secure; +int __libc_enable_secure = 0; +INTVARDEF(__libc_enable_secure) int __libc_multiple_libcs = 0; /* Defining this here avoids the inclusion of init-first. */ /* This variable containts the lowest stack address ever used. */ @@ -128,7 +129,7 @@ _dl_sysdep_start (void **start_argptr, else _dl_hurd_data = (void *) p; - __libc_enable_secure = _dl_hurd_data->flags & EXEC_SECURE; + INTUSE(__libc_enable_secure) = _dl_hurd_data->flags & EXEC_SECURE; if (_dl_hurd_data->flags & EXEC_STACK_ARGS && _dl_hurd_data->user_entry == 0) @@ -208,7 +209,7 @@ unfmh(); /* XXX */ environment list. We use memmove, since the locations might overlap. */ - if (__libc_enable_secure || _dl_skip_args) + if (INTUSE(__libc_enable_secure) || _dl_skip_args) { char **newp; diff --git a/sysdeps/powerpc/dl-machine.c b/sysdeps/powerpc/dl-machine.c index 7081466945..28a31f6d91 100644 --- a/sysdeps/powerpc/dl-machine.c +++ b/sysdeps/powerpc/dl-machine.c @@ -474,7 +474,7 @@ __process_machine_rela (struct link_map *map, strtab = (const void *) D_PTR (map, l_info[DT_STRTAB]); _dl_error_printf ("\ %s: Symbol `%s' has different size in shared object, onsider re-linking\n", - _dl_argv[0] ?: "<program name unknown>", + rtld_progname ?: "<program name unknown>", strtab + refsym->st_name); } memcpy (reloc_addr, (char *) finaladdr, MIN (sym->st_size, diff --git a/sysdeps/s390/s390-32/dl-machine.h b/sysdeps/s390/s390-32/dl-machine.h index 5a8f706ead..557c04e4ea 100644 --- a/sysdeps/s390/s390-32/dl-machine.h +++ b/sysdeps/s390/s390-32/dl-machine.h @@ -406,7 +406,7 @@ elf_machine_rela (struct link_map *map, const Elf32_Rela *reloc, strtab = (const char *) D_PTR(map,l_info[DT_STRTAB]); _dl_error_printf ("\ %s: Symbol `%s' has different size in shared object, consider re-linking\n", - _dl_argv[0] ?: "<program name unknown>", + rtld_progname ?: "<program name unknown>", strtab + refsym->st_name); } memcpy (reloc_addr, (void *) value, MIN (sym->st_size, diff --git a/sysdeps/s390/s390-64/dl-machine.h b/sysdeps/s390/s390-64/dl-machine.h index c4f2a45fb8..95056a8ee9 100644 --- a/sysdeps/s390/s390-64/dl-machine.h +++ b/sysdeps/s390/s390-64/dl-machine.h @@ -374,7 +374,7 @@ elf_machine_rela (struct link_map *map, const Elf64_Rela *reloc, strtab = (const char *) D_PTR (map,l_info[DT_STRTAB]); _dl_error_printf ("\ %s: Symbol `%s' has different size in shared object, consider re-linking\n", - _dl_argv[0] ?: "<program name unknown>", + rtld_progname ?: "<program name unknown>", strtab + refsym->st_name); } memcpy (reloc_addr, (void *) value, MIN (sym->st_size, diff --git a/sysdeps/sh/dl-machine.h b/sysdeps/sh/dl-machine.h index 74495fabcd..498293cb57 100644 --- a/sysdeps/sh/dl-machine.h +++ b/sysdeps/sh/dl-machine.h @@ -442,8 +442,6 @@ elf_machine_plt_value (struct link_map *map, const Elf32_Rela *reloc, /* SH never uses Elf32_Rel relocations. */ #define ELF_MACHINE_NO_REL 1 -extern char **_dl_argv; - /* Perform the relocation specified by RELOC and SYM (which is fully resolved). MAP is the object containing the reloc. */ @@ -520,7 +518,7 @@ elf_machine_rela (struct link_map *map, const Elf32_Rela *reloc, strtab = (const char *) D_PTR (map, l_info[DT_STRTAB]); _dl_error_printf ("\ %s: Symbol `%s' has different size in shared object, consider re-linking\n", - _dl_argv[0] ?: "<program name unknown>", + rtld_progname ?: "<program name unknown>", strtab + refsym->st_name); } memcpy (reloc_addr, (void *) value, MIN (sym->st_size, diff --git a/sysdeps/sparc/sparc32/dl-machine.h b/sysdeps/sparc/sparc32/dl-machine.h index 17a1aa6f17..4534464987 100644 --- a/sysdeps/sparc/sparc32/dl-machine.h +++ b/sysdeps/sparc/sparc32/dl-machine.h @@ -460,13 +460,12 @@ elf_machine_rela (struct link_map *map, const Elf32_Rela *reloc, if (sym->st_size > refsym->st_size || (GL(dl_verbose) && sym->st_size < refsym->st_size)) { - extern char **_dl_argv; const char *strtab; strtab = (const void *) D_PTR (map, l_info[DT_STRTAB]); _dl_error_printf ("\ %s: Symbol `%s' has different size in shared object, consider re-linking\n", - _dl_argv[0] ?: "<program name unknown>", + rtld_progname ?: "<program name unknown>", strtab + refsym->st_name); } memcpy (reloc_addr, (void *) value, MIN (sym->st_size, diff --git a/sysdeps/sparc/sparc64/dl-machine.h b/sysdeps/sparc/sparc64/dl-machine.h index af3b2d21a7..8d9bf7aa67 100644 --- a/sysdeps/sparc/sparc64/dl-machine.h +++ b/sysdeps/sparc/sparc64/dl-machine.h @@ -286,13 +286,12 @@ elf_machine_rela (struct link_map *map, const Elf64_Rela *reloc, if (sym->st_size > refsym->st_size || (GL(dl_verbose) && sym->st_size < refsym->st_size)) { - extern char **_dl_argv; const char *strtab; strtab = (const void *) D_PTR (map, l_info[DT_STRTAB]); _dl_error_printf ("\ %s: Symbol `%s' has different size in shared object, consider re-linking\n", - _dl_argv[0] ?: "<program name unknown>", + rtld_progname ?: "<program name unknown>", strtab + refsym->st_name); } memcpy (reloc_addr, (void *) value, MIN (sym->st_size, diff --git a/sysdeps/unix/sysv/linux/dl-origin.c b/sysdeps/unix/sysv/linux/dl-origin.c index b054ae2157..3824681fa7 100644 --- a/sysdeps/unix/sysv/linux/dl-origin.c +++ b/sysdeps/unix/sysv/linux/dl-origin.c @@ -31,6 +31,7 @@ the path of the application from the /proc/self/exe symlink. Try this first and fall back on the generic method if necessary. */ +#undef _dl_get_origin const char * _dl_get_origin (void) { @@ -38,7 +39,7 @@ _dl_get_origin (void) char *result; int len; - if ((len = __readlink ("/proc/self/exe", linkval, PATH_MAX)) > 0 + if ((len = __readlink ("/proc/self/exe", linkval, sizeof (linkval))) > 0 && linkval[0] != '[') { /* We can use this value. */ @@ -76,3 +77,4 @@ _dl_get_origin (void) return result; } +INTDEF(_dl_get_origin) diff --git a/sysdeps/x86_64/dl-machine.h b/sysdeps/x86_64/dl-machine.h index 182bd5fbda..2e2eb9fc5c 100644 --- a/sysdeps/x86_64/dl-machine.h +++ b/sysdeps/x86_64/dl-machine.h @@ -386,7 +386,7 @@ elf_machine_rela (struct link_map *map, const Elf64_Rela *reloc, strtab = (const char *) D_PTR (map, l_info[DT_STRTAB]); _dl_error_printf ("\ %s: Symbol `%s' has different size in shared object, consider re-linking\n", - _dl_argv[0] ?: "<program name unknown>", + rtld_progname ?: "<program name unknown>", strtab + refsym->st_name); } memcpy (reloc_addr, (void *) value, MIN (sym->st_size, |