From e6caf4e12ebb89254977a74b882757e371c5cc16 Mon Sep 17 00:00:00 2001 From: Ulrich Drepper Date: Fri, 1 Mar 2002 09:44:29 +0000 Subject: Update. 2002-03-01 Ulrich Drepper * 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. --- sysdeps/arm/dl-machine.h | 40 +++++++++++++++++-------------------- sysdeps/cris/dl-machine.h | 3 +-- sysdeps/generic/dl-origin.c | 2 ++ sysdeps/generic/dl-sysdep.c | 9 +++++---- sysdeps/generic/ldsodefs.h | 11 ++++++++++ sysdeps/hppa/dl-machine.h | 2 +- sysdeps/i386/dl-machine.h | 2 +- sysdeps/m68k/dl-machine.h | 3 +-- sysdeps/mach/hurd/dl-sysdep.c | 7 ++++--- sysdeps/powerpc/dl-machine.c | 2 +- sysdeps/s390/s390-32/dl-machine.h | 2 +- sysdeps/s390/s390-64/dl-machine.h | 2 +- sysdeps/sh/dl-machine.h | 4 +--- sysdeps/sparc/sparc32/dl-machine.h | 3 +-- sysdeps/sparc/sparc64/dl-machine.h | 3 +-- sysdeps/unix/sysv/linux/dl-origin.c | 4 +++- sysdeps/x86_64/dl-machine.h | 2 +- 17 files changed, 54 insertions(+), 47 deletions(-) (limited to 'sysdeps') diff --git a/sysdeps/arm/dl-machine.h b/sysdeps/arm/dl-machine.h index 177a375..4a7ab38 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] ?: "", + rtld_progname ?: "", 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 966d86b..51ae43d 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] ?: "", + rtld_progname ?: "", 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 db990e6..b198f70 100644 --- a/sysdeps/generic/dl-origin.c +++ b/sysdeps/generic/dl-origin.c @@ -26,6 +26,7 @@ #include +#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 3385226..1975fe8a 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 08f5829..4aa5621 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 6d42494..b30a3ba 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] ?: "", + rtld_progname ?: "", strtab + refsym->st_name); } memcpy (reloc_addr, (void *) value, diff --git a/sysdeps/i386/dl-machine.h b/sysdeps/i386/dl-machine.h index f51dab8..3edfb00 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] ?: "", + rtld_progname ?: "", 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 b2e1c6b..ce80aad 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] ?: "", + rtld_progname ?: "", 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 5203855..883c959 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 7081466..28a31f6 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] ?: "", + rtld_progname ?: "", 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 5a8f706..557c04e 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] ?: "", + rtld_progname ?: "", 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 c4f2a45..95056a8 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] ?: "", + rtld_progname ?: "", 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 74495fa..498293c 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] ?: "", + rtld_progname ?: "", 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 17a1aa6..4534464 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] ?: "", + rtld_progname ?: "", 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 af3b2d2..8d9bf7a 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] ?: "", + rtld_progname ?: "", 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 b054ae2..3824681 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 182bd5f..2e2eb9f 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] ?: "", + rtld_progname ?: "", strtab + refsym->st_name); } memcpy (reloc_addr, (void *) value, MIN (sym->st_size, -- cgit v1.1