diff options
Diffstat (limited to 'elf')
-rw-r--r-- | elf/Versions | 14 | ||||
-rw-r--r-- | elf/dl-close.c | 12 | ||||
-rw-r--r-- | elf/dl-debug.c | 5 | ||||
-rw-r--r-- | elf/dl-deps.c | 66 | ||||
-rw-r--r-- | elf/dl-dst.h | 24 | ||||
-rw-r--r-- | elf/dl-error.c | 8 | ||||
-rw-r--r-- | elf/dl-fini.c | 15 | ||||
-rw-r--r-- | elf/dl-init.c | 14 | ||||
-rw-r--r-- | elf/dl-libc.c | 16 | ||||
-rw-r--r-- | elf/dl-load.c | 45 | ||||
-rw-r--r-- | elf/dl-lookup.c | 37 | ||||
-rw-r--r-- | elf/dl-misc.c | 1 | ||||
-rw-r--r-- | elf/dl-open.c | 59 | ||||
-rw-r--r-- | elf/dl-profile.c | 1 | ||||
-rw-r--r-- | elf/dl-profstub.c | 7 | ||||
-rw-r--r-- | elf/dl-reloc.c | 44 | ||||
-rw-r--r-- | elf/dl-runtime.c | 36 | ||||
-rw-r--r-- | elf/dl-sym.c | 66 | ||||
-rw-r--r-- | elf/dl-version.c | 14 | ||||
-rw-r--r-- | elf/do-lookup.h | 6 | ||||
-rw-r--r-- | elf/rtld.c | 101 |
21 files changed, 299 insertions, 292 deletions
diff --git a/elf/Versions b/elf/Versions index 709a657775..3797cc4eee 100644 --- a/elf/Versions +++ b/elf/Versions @@ -46,17 +46,13 @@ ld { GLIBC_PRIVATE { # Those are in the dynamic linker, but used by libc.so. __libc_enable_secure; - _dl_argv; _dl_catch_error; _dl_check_map_versions; - _dl_debug_printf; _dl_debug_state; _dl_dst_count; - _dl_dst_substitute; _dl_init; _dl_lookup_symbol; _dl_lookup_symbol_skip; - _dl_lookup_versioned_symbol; _dl_lookup_versioned_symbol_skip; - _dl_map_object; _dl_map_object_deps; _dl_out_of_memory; - _dl_relocate_object; _dl_signal_error; _dl_start_profile; _dl_starting_up; - _dl_unload_cache; + _dl_argv; + _dl_out_of_memory; + _dl_starting_up; _rtld_global; _rtld_global_ro; - _dl_tls_symaddr; _dl_allocate_tls; _dl_deallocate_tls; + _dl_allocate_tls; _dl_deallocate_tls; _dl_get_tls_static_info; _dl_allocate_tls_init; - _dl_get_origin; _dl_tls_setup; _dl_rtld_di_serinfo; + _dl_tls_setup; _dl_rtld_di_serinfo; _dl_make_stack_executable; } } diff --git a/elf/dl-close.c b/elf/dl-close.c index c63dabbfe1..62c257ce4f 100644 --- a/elf/dl-close.c +++ b/elf/dl-close.c @@ -125,7 +125,7 @@ _dl_close (void *_map) return; if (__builtin_expect (map->l_opencount, 1) == 0) - _dl_signal_error (0, map->l_name, NULL, N_("shared object not open")); + GLRO(dl_signal_error) (0, map->l_name, NULL, N_("shared object not open")); /* Acquire the lock. */ __rtld_lock_lock_recursive (GL(dl_load_lock)); @@ -135,8 +135,8 @@ _dl_close (void *_map) { /* There are still references to this object. Do nothing more. */ if (__builtin_expect (GLRO(dl_debug_mask) & DL_DEBUG_FILES, 0)) - _dl_debug_printf ("\nclosing file=%s; opencount == %u\n", - map->l_name, map->l_opencount); + GLRO(dl_debug_printf) ("\nclosing file=%s; opencount == %u\n", + map->l_name, map->l_opencount); /* Decrement the object's reference counter, not the dependencies'. */ --map->l_opencount; @@ -225,7 +225,7 @@ _dl_close (void *_map) { /* When debugging print a message first. */ if (__builtin_expect (GLRO(dl_debug_mask) & DL_DEBUG_IMPCALLS, 0)) - _dl_debug_printf ("\ncalling fini: %s\n\n", imap->l_name); + GLRO(dl_debug_printf) ("\ncalling fini: %s\n\n", imap->l_name); /* Call its termination function. Do not do it for half-cooked objects. */ @@ -318,7 +318,7 @@ _dl_close (void *_map) /* Notify the debugger we are about to remove some loaded objects. */ _r_debug.r_state = RT_DELETE; - _dl_debug_state (); + GLRO(dl_debug_state) (); #ifdef USE_TLS size_t tls_free_start; @@ -537,7 +537,7 @@ _dl_close (void *_map) /* Notify the debugger those objects are finalized and gone. */ _r_debug.r_state = RT_CONSISTENT; - _dl_debug_state (); + GLRO(dl_debug_state) (); /* Now we can perhaps also remove the modules for which we had dependencies because of symbol lookup. */ diff --git a/elf/dl-debug.c b/elf/dl-debug.c index e072b685f2..2feb0c5b96 100644 --- a/elf/dl-debug.c +++ b/elf/dl-debug.c @@ -1,5 +1,5 @@ /* Communicate dynamic linker state to the debugger at runtime. - Copyright (C) 1996, 1998, 2000, 2002 Free Software Foundation, Inc. + Copyright (C) 1996, 1998, 2000, 2002, 2004 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -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)) &INTUSE(_dl_debug_state); + _r_debug.r_brk = (ElfW(Addr)) &_dl_debug_state; } return &_r_debug; @@ -55,4 +55,3 @@ void _dl_debug_state (void) { } -INTDEF (_dl_debug_state) diff --git a/elf/dl-deps.c b/elf/dl-deps.c index b2e6ec612b..1c383b7b98 100644 --- a/elf/dl-deps.c +++ b/elf/dl-deps.c @@ -60,10 +60,10 @@ openaux (void *a) { struct openaux_args *args = (struct openaux_args *) a; - args->aux = INTUSE(_dl_map_object) (args->map, args->name, 0, - (args->map->l_type == lt_executable - ? lt_library : args->map->l_type), - args->trace_mode, args->open_mode); + args->aux = _dl_map_object (args->map, args->name, 0, + (args->map->l_type == lt_executable + ? lt_library : args->map->l_type), + args->trace_mode, args->open_mode); } static ptrdiff_t @@ -108,26 +108,26 @@ struct list \ /* DST must not appear in SUID/SGID programs. */ \ if (INTUSE(__libc_enable_secure)) \ - INTUSE(_dl_signal_error) (0, __str, NULL, N_("\ + _dl_signal_error (0, __str, NULL, N_("\ DST not allowed in SUID/SGID programs")); \ \ __newp = (char *) alloca (DL_DST_REQUIRED (l, __str, strlen (__str), \ __cnt)); \ \ - __result = INTUSE(_dl_dst_substitute) (l, __str, __newp, 0); \ + __result = _dl_dst_substitute (l, __str, __newp, 0); \ \ if (*__result == '\0') \ { \ /* The replacement for the DST is not known. We can't \ processed. */ \ if (fatal) \ - INTUSE(_dl_signal_error) (0, __str, NULL, N_("\ + _dl_signal_error (0, __str, NULL, N_("\ empty dynamics string token substitution")); \ else \ { \ /* This is for DT_AUXILIARY. */ \ if (__builtin_expect (GLRO(dl_debug_mask) & DL_DEBUG_LIBS, 0))\ - INTUSE(_dl_debug_printf) (N_("\ + _dl_debug_printf (N_("\ cannot load auxiliary `%s' because of empty dynamic string token " \ "substitution\n"), __str); \ continue; \ @@ -241,8 +241,7 @@ _dl_map_object_deps (struct link_map *map, /* Store the tag in the argument structure. */ args.name = name; - err = INTUSE(_dl_catch_error) (&objname, &errstring, openaux, - &args); + err = _dl_catch_error (&objname, &errstring, openaux, &args); if (__builtin_expect (errstring != NULL, 0)) { if (err) @@ -293,16 +292,16 @@ _dl_map_object_deps (struct link_map *map, /* Say that we are about to load an auxiliary library. */ if (__builtin_expect (GLRO(dl_debug_mask) & DL_DEBUG_LIBS, 0)) - INTUSE(_dl_debug_printf) ("load auxiliary object=%s" - " requested by file=%s\n", - name, - l->l_name[0] - ? l->l_name : rtld_progname); + _dl_debug_printf ("load auxiliary object=%s" + " requested by file=%s\n", + name, + l->l_name[0] + ? l->l_name : rtld_progname); /* We must be prepared that the addressed shared object is not available. */ - err = INTUSE(_dl_catch_error) (&objname, &errstring, - openaux, &args); + err = _dl_catch_error (&objname, &errstring, openaux, + &args); if (__builtin_expect (errstring != NULL, 0)) { /* We are not interested in the error message. */ @@ -321,15 +320,15 @@ _dl_map_object_deps (struct link_map *map, /* Say that we are about to load an auxiliary library. */ if (__builtin_expect (GLRO(dl_debug_mask) & DL_DEBUG_LIBS, 0)) - INTUSE(_dl_debug_printf) ("load filtered object=%s" - " requested by file=%s\n", - name, - l->l_name[0] - ? l->l_name : rtld_progname); + _dl_debug_printf ("load filtered object=%s" + " requested by file=%s\n", + name, + l->l_name[0] + ? l->l_name : rtld_progname); /* For filter objects the dependency must be available. */ - err = INTUSE(_dl_catch_error) (&objname, &errstring, - openaux, &args); + err = _dl_catch_error (&objname, &errstring, openaux, + &args); if (__builtin_expect (errstring != NULL, 0)) { if (err) @@ -457,8 +456,8 @@ _dl_map_object_deps (struct link_map *map, l->l_initfini = (struct link_map **) malloc ((2 * nneeded + 1) * sizeof needed[0]); if (l->l_initfini == NULL) - INTUSE(_dl_signal_error) (ENOMEM, map->l_name, NULL, - N_("cannot allocate dependency list")); + _dl_signal_error (ENOMEM, map->l_name, NULL, + N_("cannot allocate dependency list")); l->l_initfini[0] = l; memcpy (&l->l_initfini[1], needed, nneeded * sizeof needed[0]); memcpy (&l->l_initfini[nneeded + 1], l->l_initfini, @@ -490,8 +489,8 @@ _dl_map_object_deps (struct link_map *map, (struct link_map **) malloc ((2 * nlist + 1) * sizeof (struct link_map *)); if (map->l_initfini == NULL) - INTUSE(_dl_signal_error) (ENOMEM, map->l_name, NULL, - N_("cannot allocate symbol search list")); + _dl_signal_error (ENOMEM, map->l_name, NULL, + N_("cannot allocate symbol search list")); map->l_searchlist.r_list = &map->l_initfini[nlist + 1]; @@ -531,7 +530,7 @@ _dl_map_object_deps (struct link_map *map, /* As current DT_AUXILIARY/DT_FILTER implementation needs to be rewritten, no need to bother with prelinking the old implementation. */ - INTUSE(_dl_signal_error) (EINVAL, l->l_name, NULL, N_("\ + _dl_signal_error (EINVAL, l->l_name, NULL, N_("\ Filters not supported with LD_TRACE_PRELINKING")); } @@ -545,8 +544,8 @@ Filters not supported with LD_TRACE_PRELINKING")); + (cnt * sizeof (struct link_map *))); if (l->l_local_scope[0] == NULL) - INTUSE(_dl_signal_error) (ENOMEM, map->l_name, NULL, - N_("cannot allocate symbol search list")); + _dl_signal_error (ENOMEM, map->l_name, NULL, + N_("cannot allocate symbol search list")); l->l_local_scope[0]->r_nlist = cnt; l->l_local_scope[0]->r_list = (struct link_map **) (l->l_local_scope[0] + 1); @@ -629,7 +628,6 @@ Filters not supported with LD_TRACE_PRELINKING")); map->l_initfini[nlist] = NULL; if (errno_reason) - INTUSE(_dl_signal_error) (errno_reason == -1 ? 0 : errno_reason, objname, - NULL, errstring); + _dl_signal_error (errno_reason == -1 ? 0 : errno_reason, objname, + NULL, errstring); } -INTDEF (_dl_map_object_deps) diff --git a/elf/dl-dst.h b/elf/dl-dst.h index b50d6735e3..42bd4185af 100644 --- a/elf/dl-dst.h +++ b/elf/dl-dst.h @@ -25,13 +25,12 @@ const char *__sf = strchr (name, '$'); \ \ if (__builtin_expect (__sf != NULL, 0)) \ - __cnt = INTUSE(_dl_dst_count) (__sf, is_path); \ + __cnt = _dl_dst_count (__sf, is_path); \ \ __cnt; }) - -/* Prototype for used function. */ -extern size_t _dl_dst_count (const char *name, int is_path); -extern size_t _dl_dst_count_internal (const char *name, int is_path); +#ifndef IS_IN_rtld +# define _dl_dst_count GLRO(dl_dst_count) +#endif /* Guess from the number of DSTs the length of the result string. */ @@ -67,16 +66,7 @@ extern size_t _dl_dst_count_internal (const char *name, int is_path); \ __len; }) -/* Find origin of the executable. */ -extern const char *_dl_get_origin (void); -extern const char *_dl_get_origin_internal (void); - -#ifdef IS_IN_rtld -# define _dl_get_origin INTUSE(_dl_get_origin) +#ifndef IS_IN_rtld +# define _dl_get_origin GLRO(dl_get_origin) +# define _dl_dst_substitute GLRO(dl_dst_substitute) #endif - -/* Prototype for used function. */ -extern char *_dl_dst_substitute (struct link_map *l, const char *name, - char *result, int is_path); -extern char *_dl_dst_substitute_internal (struct link_map *l, const char *name, - char *result, int is_path); diff --git a/elf/dl-error.c b/elf/dl-error.c index f234026701..0ef76c82ee 100644 --- a/elf/dl-error.c +++ b/elf/dl-error.c @@ -113,7 +113,6 @@ _dl_signal_error (int errcode, const char *objname, const char *occation, : "")); } } -INTDEF (_dl_signal_error) void @@ -123,8 +122,8 @@ _dl_signal_cerror (int errcode, const char *objname, const char *occation, { if (__builtin_expect (GLRO(dl_debug_mask) & ~(DL_DEBUG_STATISTICS|DL_DEBUG_PRELINK), 0)) - INTUSE(_dl_debug_printf) ("%s: error: %s: %s (%s)\n", objname, occation, - errstring, receiver ? "continued" : "fatal"); + _dl_debug_printf ("%s: error: %s: %s (%s)\n", objname, occation, + errstring, receiver ? "continued" : "fatal"); if (receiver) { @@ -134,7 +133,7 @@ _dl_signal_cerror (int errcode, const char *objname, const char *occation, (*receiver) (errcode, objname, errstring); } else - INTUSE(_dl_signal_error) (errcode, objname, occation, errstring); + _dl_signal_error (errcode, objname, occation, errstring); } @@ -172,7 +171,6 @@ _dl_catch_error (const char **objname, const char **errstring, *errstring = c.errstring; return errcode == -1 ? 0 : errcode; } -INTDEF (_dl_catch_error) void diff --git a/elf/dl-fini.c b/elf/dl-fini.c index 3dc1db16c9..a56722f6ce 100644 --- a/elf/dl-fini.c +++ b/elf/dl-fini.c @@ -147,9 +147,8 @@ _dl_fini (void) /* When debugging print a message first. */ if (__builtin_expect (GLRO(dl_debug_mask) & DL_DEBUG_IMPCALLS, 0)) - INTUSE(_dl_debug_printf) ("\ncalling fini: %s\n\n", - l->l_name[0] - ? l->l_name : rtld_progname); + _dl_debug_printf ("\ncalling fini: %s\n\n", + l->l_name[0] ? l->l_name : rtld_progname); /* First see whether an array is given. */ if (l->l_info[DT_FINI_ARRAY] != NULL) @@ -176,12 +175,12 @@ _dl_fini (void) if (__builtin_expect (GLRO(dl_debug_mask) & DL_DEBUG_STATISTICS, 0)) { - INTUSE(_dl_debug_printf) ("\nruntime linker statistics:\n"); - INTUSE(_dl_debug_printf) ("\ + _dl_debug_printf ("\nruntime linker statistics:\n"); + _dl_debug_printf ("\ final number of relocations: %lu\n", - GL(dl_num_relocations)); - INTUSE(_dl_debug_printf) ("\ + GL(dl_num_relocations)); + _dl_debug_printf ("\ final number of relocations from cache: %lu\n", - GL(dl_num_cache_relocations)); + GL(dl_num_cache_relocations)); } } diff --git a/elf/dl-init.c b/elf/dl-init.c index 37d5045d03..c06c71bbeb 100644 --- a/elf/dl-init.c +++ b/elf/dl-init.c @@ -52,8 +52,8 @@ call_init (struct link_map *l, int argc, char **argv, char **env) /* Print a debug message if wanted. */ if (__builtin_expect (GLRO(dl_debug_mask) & DL_DEBUG_IMPCALLS, 0)) - INTUSE(_dl_debug_printf) ("\ncalling init: %s\n\n", - l->l_name[0] ? l->l_name : rtld_progname); + _dl_debug_printf ("\ncalling init: %s\n\n", + 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 @@ -109,9 +109,9 @@ _dl_init (struct link_map *main_map, int argc, char **argv, char **env) unsigned int cnt; if (__builtin_expect (GLRO(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 : rtld_progname); + _dl_debug_printf ("\ncalling preinit: %s\n\n", + main_map->l_name[0] + ? main_map->l_name : rtld_progname); addrs = (ElfW(Addr) *) (preinit_array->d_un.d_ptr + main_map->l_addr); for (cnt = 0; cnt < i; ++cnt) @@ -123,7 +123,7 @@ _dl_init (struct link_map *main_map, int argc, char **argv, char **env) not been used before. */ r = _dl_debug_initialize (0); r->r_state = RT_ADD; - INTUSE(_dl_debug_state) (); + _dl_debug_state (); /* Stupid users forced the ELF specification to be changed. It now says that the dynamic loader is responsible for determining the @@ -141,7 +141,7 @@ _dl_init (struct link_map *main_map, int argc, char **argv, char **env) /* Notify the debugger all new objects are now ready to go. */ r->r_state = RT_CONSISTENT; - INTUSE(_dl_debug_state) (); + _dl_debug_state (); /* Finished starting up. */ INTUSE(_dl_starting_up) = 0; diff --git a/elf/dl-libc.c b/elf/dl-libc.c index 557d2c3241..2b8cb0e15d 100644 --- a/elf/dl-libc.c +++ b/elf/dl-libc.c @@ -1,5 +1,5 @@ /* Handle loading and unloading shared objects for internal libc purposes. - Copyright (C) 1999, 2000, 2001, 2002 Free Software Foundation, Inc. + Copyright (C) 1999, 2000, 2001, 2002, 2004 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Zack Weinberg <zack@rabi.columbia.edu>, 1999. @@ -39,7 +39,7 @@ dlerror_run (void (*operate) (void *), void *args) const char *last_errstring = NULL; int result; - (void) _dl_catch_error (&objname, &last_errstring, operate, args); + (void) GLRO(dl_catch_error) (&objname, &last_errstring, operate, args); result = last_errstring != NULL; if (result && last_errstring != _dl_out_of_memory) @@ -85,9 +85,9 @@ do_dlsym (void *ptr) { struct do_dlsym_args *args = (struct do_dlsym_args *) ptr; args->ref = NULL; - args->loadbase = _dl_lookup_symbol (args->name, args->map, &args->ref, - args->map->l_local_scope, 0, - DL_LOOKUP_RETURN_NEWEST); + args->loadbase = GLRO(dl_lookup_symbol) (args->name, args->map, &args->ref, + args->map->l_local_scope, 0, + DL_LOOKUP_RETURN_NEWEST); } static void @@ -126,9 +126,9 @@ do_dlsym_private (void *ptr) struct do_dlsym_args *args = (struct do_dlsym_args *) ptr; args->ref = NULL; - l = _dl_lookup_versioned_symbol (args->name, args->map, - &args->ref, args->map->l_scope, - &vers, 0, 0); + l = GLRO(dl_lookup_versioned_symbol) (args->name, args->map, + &args->ref, args->map->l_scope, + &vers, 0, 0); args->loadbase = l; } diff --git a/elf/dl-load.c b/elf/dl-load.c index f7449bce9c..1ff12836ec 100644 --- a/elf/dl-load.c +++ b/elf/dl-load.c @@ -220,7 +220,6 @@ _dl_dst_count (const char *name, int is_path) return cnt; } -INTDEF (_dl_dst_count) char * @@ -283,7 +282,6 @@ _dl_dst_substitute (struct link_map *l, const char *name, char *result, return result; } -INTDEF (_dl_dst_substitute) /* Return copy of argument with all recognized dynamic string tokens @@ -317,7 +315,7 @@ expand_dynamic_string_token (struct link_map *l, const char *s) if (result == NULL) return NULL; - return INTUSE(_dl_dst_substitute) (l, s, result, 1); + return _dl_dst_substitute (l, s, result, 1); } @@ -343,8 +341,7 @@ add_name_to_object (struct link_map *l, const char *name) if (newname == NULL) { /* No more memory. */ - INTUSE(_dl_signal_error) (ENOMEM, name, NULL, - N_("cannot allocate name record")); + _dl_signal_error (ENOMEM, name, NULL, N_("cannot allocate name record")); return; } /* The object should have a libname set from _dl_new_object. */ @@ -445,8 +442,8 @@ fillin_rpath (char *rpath, struct r_search_path_elem **result, const char *sep, malloc (sizeof (*dirp) + ncapstr * sizeof (enum r_dir_status) + where_len + len + 1); if (dirp == NULL) - INTUSE(_dl_signal_error) (ENOMEM, NULL, NULL, - N_("cannot create cache for search path")); + _dl_signal_error (ENOMEM, NULL, NULL, + N_("cannot create cache for search path")); dirp->dirname = ((char *) dirp + sizeof (*dirp) + ncapstr * sizeof (enum r_dir_status)); @@ -527,7 +524,7 @@ decompose_rpath (struct r_search_path_struct *sps, signal_error_cache: errstring = N_("cannot create cache for search path"); signal_error: - INTUSE(_dl_signal_error) (ENOMEM, NULL, NULL, errstring); + _dl_signal_error (ENOMEM, NULL, NULL, errstring); } sps->dirs = result; @@ -633,7 +630,7 @@ _dl_init_paths (const char *llp) { errstring = N_("cannot create search path array"); signal_error: - INTUSE(_dl_signal_error) (ENOMEM, NULL, NULL, errstring); + _dl_signal_error (ENOMEM, NULL, NULL, errstring); } round_size = ((2 * sizeof (struct r_search_path_elem) - 1 @@ -786,7 +783,7 @@ lose (int code, int fd, const char *name, char *realname, struct link_map *l, free (l); } free (realname); - INTUSE(_dl_signal_error) (code, name, NULL, msg); + _dl_signal_error (code, name, NULL, msg); } @@ -845,7 +842,7 @@ _dl_map_object_from_fd (const char *name, int fd, struct filebuf *fbp, /* Print debugging message. */ if (__builtin_expect (GLRO(dl_debug_mask) & DL_DEBUG_FILES, 0)) - INTUSE(_dl_debug_printf) ("file=%s; generating link map\n", name); + _dl_debug_printf ("file=%s; generating link map\n", name); /* This is the ELF header. We read it in `open_verify'. */ header = (void *) fbp->buf; @@ -858,8 +855,8 @@ _dl_map_object_from_fd (const char *name, int fd, struct filebuf *fbp, if (_dl_zerofd == -1) { __close (fd); - INTUSE(_dl_signal_error) (errno, NULL, NULL, - N_("cannot open zero fill device")); + _dl_signal_error (errno, NULL, NULL, + N_("cannot open zero fill device")); } } #endif @@ -1260,7 +1257,7 @@ cannot allocate TLS data structures for initial thread"); l->l_entry += l->l_addr; if (__builtin_expect (GLRO(dl_debug_mask) & DL_DEBUG_FILES, 0)) - INTUSE(_dl_debug_printf) ("\ + _dl_debug_printf ("\ dynamic: 0x%0*lx base: 0x%0*lx size: 0x%0*Zx\n\ entry: 0x%0*lx phdr: 0x%0*lx phnum: %*u\n\n", (int) sizeof (void *) * 2, @@ -1367,7 +1364,7 @@ print_search_path (struct r_search_path_elem **list, char buf[max_dirnamelen + max_capstrlen]; int first = 1; - INTUSE(_dl_debug_printf) (" search path="); + _dl_debug_printf (" search path="); while (*list != NULL && (*list)->what == what) /* Yes, ==. */ { @@ -1638,7 +1635,7 @@ open_path (const char *name, size_t namelen, int preloaded, /* Print name we try if this is wanted. */ if (__builtin_expect (GLRO(dl_debug_mask) & DL_DEBUG_LIBS, 0)) - INTUSE(_dl_debug_printf) (" trying file=%s\n", buf); + _dl_debug_printf (" trying file=%s\n", buf); fd = open_verify (buf, fbp); if (this_dir->status[cnt] == unknown) @@ -1772,7 +1769,7 @@ _dl_map_object (struct link_map *loader, const char *name, int preloaded, /* Display information if we are debugging. */ if (__builtin_expect (GLRO(dl_debug_mask) & DL_DEBUG_FILES, 0) && loader != NULL) - INTUSE(_dl_debug_printf) ("\nfile=%s; needed by %s\n", name, + _dl_debug_printf ("\nfile=%s; needed by %s\n", name, loader->l_name[0] ? loader->l_name : rtld_progname); @@ -1783,7 +1780,7 @@ _dl_map_object (struct link_map *loader, const char *name, int preloaded, size_t namelen = strlen (name) + 1; if (__builtin_expect (GLRO(dl_debug_mask) & DL_DEBUG_LIBS, 0)) - INTUSE(_dl_debug_printf) ("find library=%s; searching\n", name); + _dl_debug_printf ("find library=%s; searching\n", name); fd = -1; @@ -1888,7 +1885,7 @@ _dl_map_object (struct link_map *loader, const char *name, int preloaded, /* Add another newline when we are tracing the library loading. */ if (__builtin_expect (GLRO(dl_debug_mask) & DL_DEBUG_LIBS, 0)) - INTUSE(_dl_debug_printf) ("\n"); + _dl_debug_printf ("\n"); } else { @@ -1920,8 +1917,8 @@ _dl_map_object (struct link_map *loader, const char *name, int preloaded, /* Enter the new object in the list of loaded objects. */ if ((name_copy = local_strdup (name)) == NULL || (l = _dl_new_object (name_copy, name, type, loader)) == NULL) - INTUSE(_dl_signal_error) (ENOMEM, name, NULL, N_("\ -cannot create shared object descriptor")); + _dl_signal_error (ENOMEM, name, NULL, + N_("cannot create shared object descriptor")); /* Signal that this is a faked entry. */ l->l_faked = 1; /* Since the descriptor is initialized with zero we do not @@ -1934,15 +1931,15 @@ cannot create shared object descriptor")); return l; } else - INTUSE(_dl_signal_error) (errno, name, NULL, - N_("cannot open shared object file")); + _dl_signal_error (errno, name, NULL, + N_("cannot open shared object file")); } void *stack_end = __libc_stack_end; return _dl_map_object_from_fd (name, fd, &fb, realname, loader, type, mode, &stack_end); } -INTDEF (_dl_map_object) + void internal_function diff --git a/elf/dl-lookup.c b/elf/dl-lookup.c index f4ebd93fc3..925f01c102 100644 --- a/elf/dl-lookup.c +++ b/elf/dl-lookup.c @@ -191,11 +191,11 @@ add_dependency (struct link_map *undef_map, struct link_map *map) /* Display information if we are debugging. */ if (__builtin_expect (GLRO(dl_debug_mask) & DL_DEBUG_FILES, 0)) - INTUSE(_dl_debug_printf) ("\ + _dl_debug_printf ("\ \nfile=%s; needed by %s (relocation dependency)\n\n", - map->l_name[0] ? map->l_name : rtld_progname, - undef_map->l_name[0] - ? undef_map->l_name : rtld_progname); + map->l_name[0] ? map->l_name : rtld_progname, + undef_map->l_name[0] + ? undef_map->l_name : rtld_progname); } else /* Whoa, that was bad luck. We have to search again. */ @@ -312,8 +312,8 @@ _dl_lookup_symbol (const char *undef_name, struct link_map *undef_map, && add_dependency (undef_map, current_value.m) < 0) /* Something went wrong. Perhaps the object we tried to reference was just removed. Try finding another definition. */ - return INTUSE(_dl_lookup_symbol) (undef_name, undef_map, ref, - symbol_scope, type_class, flags); + return _dl_lookup_symbol (undef_name, undef_map, ref, symbol_scope, + type_class, flags); if (__builtin_expect (GLRO(dl_debug_mask) & (DL_DEBUG_BINDINGS|DL_DEBUG_PRELINK), 0)) @@ -323,7 +323,6 @@ _dl_lookup_symbol (const char *undef_name, struct link_map *undef_map, *ref = current_value.s; return LOOKUP_VALUE (current_value.m); } -INTDEF (_dl_lookup_symbol) /* This function is nearly the same as `_dl_lookup_symbol' but it @@ -400,8 +399,7 @@ _dl_lookup_symbol_skip (const char *undef_name, /* This function works like _dl_lookup_symbol but it takes an - additional arguement with the version number of the requested - symbol. + additional argument with the version number of the requested symbol. XXX We'll see whether we need this separate function. */ lookup_t @@ -518,9 +516,9 @@ _dl_lookup_versioned_symbol (const char *undef_name, && add_dependency (undef_map, current_value.m) < 0) /* Something went wrong. Perhaps the object we tried to reference was just removed. Try finding another definition. */ - return INTUSE(_dl_lookup_versioned_symbol) (undef_name, undef_map, - ref, symbol_scope, - version, type_class, flags); + return _dl_lookup_versioned_symbol (undef_name, undef_map, ref, + symbol_scope, version, type_class, + flags); if (__builtin_expect (GLRO(dl_debug_mask) & (DL_DEBUG_BINDINGS|DL_DEBUG_PRELINK), 0)) @@ -530,7 +528,6 @@ _dl_lookup_versioned_symbol (const char *undef_name, *ref = current_value.s; return LOOKUP_VALUE (current_value.m); } -INTDEF (_dl_lookup_versioned_symbol) /* Similar to _dl_lookup_symbol_skip but takes an additional argument @@ -652,14 +649,12 @@ _dl_debug_bindings (const char *undef_name, struct link_map *undef_map, if (GLRO(dl_debug_mask) & DL_DEBUG_BINDINGS) { - INTUSE(_dl_debug_printf) ("binding file %s to %s: %s symbol `%s'", - (reference_name[0] - ? reference_name - : (rtld_progname ?: "<main program>")), - value->m->l_name[0] - ? value->m->l_name : rtld_progname, - protected ? "protected" : "normal", - undef_name); + _dl_debug_printf ("binding file %s to %s: %s symbol `%s'", + (reference_name[0] + ? reference_name + : (rtld_progname ?: "<main program>")), + value->m->l_name[0] ? value->m->l_name : rtld_progname, + protected ? "protected" : "normal", undef_name); if (version) _dl_debug_printf_c (" [%s]\n", version->name); else diff --git a/elf/dl-misc.c b/elf/dl-misc.c index 9b29bcf4cd..abc5cbb853 100644 --- a/elf/dl-misc.c +++ b/elf/dl-misc.c @@ -279,7 +279,6 @@ _dl_debug_printf (const char *fmt, ...) _dl_debug_vdprintf (GLRO(dl_debug_fd), 1, fmt, arg); va_end (arg); } -INTDEF(_dl_debug_printf) /* Write to debug file but don't start with a tag. */ diff --git a/elf/dl-open.c b/elf/dl-open.c index 09687d8940..ce9a959ea7 100644 --- a/elf/dl-open.c +++ b/elf/dl-open.c @@ -111,8 +111,8 @@ add_to_global (struct link_map *new) { GL(dl_global_scope_alloc) = 0; nomem: - _dl_signal_error (ENOMEM, new->l_libname->name, NULL, - N_("cannot extend global scope")); + GLRO(dl_signal_error) (ENOMEM, new->l_libname->name, NULL, + N_("cannot extend global scope")); return 1; } @@ -235,7 +235,7 @@ dl_open_worker (void *a) #ifdef SHARED /* Check whether _dl_open() has been called from a valid DSO. */ if (check_libc_caller (args->caller_dl_open) != 0) - _dl_signal_error (0, "dlopen", NULL, N_("invalid caller")); + GLRO(dl_signal_error) (0, "dlopen", NULL, N_("invalid caller")); #endif /* Maybe we have to expand a DST. */ @@ -251,8 +251,8 @@ dl_open_worker (void *a) /* DSTs must not appear in SUID/SGID programs. */ if (__libc_enable_secure) /* This is an error. */ - _dl_signal_error (0, "dlopen", NULL, - N_("DST not allowed in SUID/SGID programs")); + GLRO(dl_signal_error) (0, "dlopen", NULL, + N_("DST not allowed in SUID/SGID programs")); /* We have to find out from which object the caller is calling. */ call_map = NULL; @@ -282,15 +282,15 @@ dl_open_worker (void *a) /* If the substitution failed don't try to load. */ if (*new_file == '\0') - _dl_signal_error (0, "dlopen", NULL, - N_("empty dynamic string token substitution")); + GLRO(dl_signal_error) (0, "dlopen", NULL, + N_("empty dynamic string token substitution")); /* Now we have a new file name. */ file = new_file; } /* Load the named object. */ - args->map = new = _dl_map_object (NULL, file, 0, lt_loaded, 0, mode); + args->map = new = GLRO(dl_map_object) (NULL, file, 0, lt_loaded, 0, mode); /* If the pointer returned is NULL this means the RTLD_NOLOAD flag is set and the object is not already loaded. */ @@ -309,8 +309,8 @@ dl_open_worker (void *a) { /* Let the user know about the opencount. */ if (__builtin_expect (GLRO(dl_debug_mask) & DL_DEBUG_FILES, 0)) - _dl_debug_printf ("opening file=%s; opencount == %u\n\n", - new->l_name, new->l_opencount); + GLRO(dl_debug_printf) ("opening file=%s; opencount == %u\n\n", + new->l_name, new->l_opencount); /* If the user requested the object to be in the global namespace but it is not so far, add it now. */ @@ -324,12 +324,12 @@ dl_open_worker (void *a) } /* Load that object's dependencies. */ - _dl_map_object_deps (new, NULL, 0, 0, mode & __RTLD_DLOPEN); + GLRO(dl_map_object_deps) (new, NULL, 0, 0, mode & __RTLD_DLOPEN); /* So far, so good. Now check the versions. */ for (i = 0; i < new->l_searchlist.r_nlist; ++i) if (new->l_searchlist.r_list[i]->l_versions == NULL) - (void) _dl_check_map_versions (new->l_searchlist.r_list[i], 0, 0); + (void) GLRO(dl_check_map_versions) (new->l_searchlist.r_list[i], 0, 0); #ifdef SCOPE_DEBUG show_scope (new); @@ -358,16 +358,16 @@ dl_open_worker (void *a) start the profiling. */ struct link_map *old_profile_map = GL(dl_profile_map); - _dl_relocate_object (l, l->l_scope, 1, 1); + GLRO(dl_relocate_object) (l, l->l_scope, 1, 1); if (old_profile_map == NULL && GL(dl_profile_map) != NULL) /* We must prepare the profiling. */ - _dl_start_profile (GL(dl_profile_map), - GLRO(dl_profile_output)); + GLRO(dl_start_profile) (GL(dl_profile_map), + GLRO(dl_profile_output)); } else #endif - _dl_relocate_object (l, l->l_scope, lazy, 0); + GLRO(dl_relocate_object) (l, l->l_scope, lazy, 0); } if (l == new) @@ -430,8 +430,8 @@ dl_open_worker (void *a) newp = (struct r_scope_elem **) malloc (new_size * sizeof (struct r_scope_elem *)); if (newp == NULL) - _dl_signal_error (ENOMEM, "dlopen", NULL, - N_("cannot create scope list")); + GLRO(dl_signal_error) (ENOMEM, "dlopen", NULL, + N_("cannot create scope list")); imap->l_scope = memcpy (newp, imap->l_scope, cnt * sizeof (imap->l_scope[0])); } @@ -441,8 +441,8 @@ dl_open_worker (void *a) realloc (imap->l_scope, new_size * sizeof (struct r_scope_elem *)); if (newp == NULL) - _dl_signal_error (ENOMEM, "dlopen", NULL, - N_("cannot create scope list")); + GLRO(dl_signal_error) (ENOMEM, "dlopen", NULL, + N_("cannot create scope list")); imap->l_scope = newp; } @@ -503,8 +503,8 @@ dl_open_worker (void *a) generation. */ ++GL(dl_tls_generation); - _dl_signal_error (ENOMEM, "dlopen", NULL, - N_("cannot create TLS data structures")); + GLRO(dl_signal_error) (ENOMEM, "dlopen", NULL, N_("\ +cannot create TLS data structures")); } listp->len = TLS_SLOTINFO_SURPLUS; @@ -528,7 +528,7 @@ dl_open_worker (void *a) #endif /* Run the initializer functions of new objects. */ - _dl_init (new, __libc_argc, __libc_argv, __environ); + GLRO(dl_init) (new, __libc_argc, __libc_argv, __environ); /* Now we can make the new map available in the global scope. */ if (mode & RTLD_GLOBAL) @@ -550,8 +550,8 @@ dl_open_worker (void *a) /* Let the user know about the opencount. */ if (__builtin_expect (GLRO(dl_debug_mask) & DL_DEBUG_FILES, 0)) - _dl_debug_printf ("opening file=%s; opencount == %u\n\n", - new->l_name, new->l_opencount); + GLRO(dl_debug_printf) ("opening file=%s; opencount == %u\n\n", + new->l_name, new->l_opencount); } @@ -566,7 +566,8 @@ _dl_open (const char *file, int mode, const void *caller_dlopen) if ((mode & RTLD_BINDING_MASK) == 0) /* One of the flags must be set. */ - _dl_signal_error (EINVAL, file, NULL, N_("invalid mode for dlopen()")); + GLRO(dl_signal_error) (EINVAL, file, NULL, + N_("invalid mode for dlopen()")); /* Make sure we are alone. */ __rtld_lock_lock_recursive (GL(dl_load_lock)); @@ -576,11 +577,11 @@ _dl_open (const char *file, int mode, const void *caller_dlopen) args.caller_dlopen = caller_dlopen; args.caller_dl_open = RETURN_ADDRESS (0); args.map = NULL; - errcode = _dl_catch_error (&objname, &errstring, dl_open_worker, &args); + errcode = GLRO(dl_catch_error) (&objname, &errstring, dl_open_worker, &args); #ifndef MAP_COPY /* We must munmap() the cache file. */ - _dl_unload_cache (); + GLRO(dl_unload_cache) (); #endif /* Release the lock. */ @@ -636,7 +637,7 @@ _dl_open (const char *file, int mode, const void *caller_dlopen) free ((char *) errstring); /* Reraise the error. */ - _dl_signal_error (errcode, objname, NULL, local_errstring); + GLRO(dl_signal_error) (errcode, objname, NULL, local_errstring); } #ifndef SHARED diff --git a/elf/dl-profile.c b/elf/dl-profile.c index 164ae98f99..3b99fad8ea 100644 --- a/elf/dl-profile.c +++ b/elf/dl-profile.c @@ -450,7 +450,6 @@ _dl_start_profile (struct link_map *map, const char *output_dir) /* Turn on profiling. */ running = 1; } -INTDEF (_dl_start_profile) void diff --git a/elf/dl-profstub.c b/elf/dl-profstub.c index c8184b9aad..ad0f003abd 100644 --- a/elf/dl-profstub.c +++ b/elf/dl-profstub.c @@ -1,5 +1,5 @@ /* Helper definitions for profiling of shared libraries. - Copyright (C) 1998, 2000, 2002 Free Software Foundation, Inc. + Copyright (C) 1998, 2000, 2002, 2004 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997. @@ -24,13 +24,12 @@ /* This is the map for the shared object we profile. It is defined here only because we test for this value being NULL or not. */ -//Xextern struct link_map *_dl_profile_map; void _dl_mcount_wrapper (void *selfpc) { - _dl_mcount ((ElfW(Addr)) RETURN_ADDRESS (0), (ElfW(Addr)) selfpc); + GLRO(dl_mcount) ((ElfW(Addr)) RETURN_ADDRESS (0), (ElfW(Addr)) selfpc); } @@ -38,6 +37,6 @@ void _dl_mcount_wrapper_check (void *selfpc) { if (GL(dl_profile_map) != NULL) - _dl_mcount ((ElfW(Addr)) RETURN_ADDRESS (0), (ElfW(Addr)) selfpc); + GLRO(dl_mcount) ((ElfW(Addr)) RETURN_ADDRESS (0), (ElfW(Addr)) selfpc); } libc_hidden_def (_dl_mcount_wrapper_check) diff --git a/elf/dl-reloc.c b/elf/dl-reloc.c index dab5dea13b..4349dc27fb 100644 --- a/elf/dl-reloc.c +++ b/elf/dl-reloc.c @@ -54,7 +54,7 @@ _dl_allocate_static_tls (struct link_map *map) if (map->l_tls_align > GL(dl_tls_static_align)) { fail: - INTUSE(_dl_signal_error) (0, map->l_name, NULL, N_("\ + _dl_signal_error (0, map->l_name, NULL, N_("\ cannot allocate memory in static TLS block")); } @@ -147,9 +147,9 @@ _dl_relocate_object (struct link_map *l, struct r_scope_elem *scope[], lazy = 0; if (__builtin_expect (GLRO(dl_debug_mask) & DL_DEBUG_RELOC, 0)) - INTUSE(_dl_debug_printf) ("\nrelocation processing: %s%s\n", - l->l_name[0] ? l->l_name : rtld_progname, - lazy ? " (lazy)" : ""); + _dl_debug_printf ("\nrelocation processing: %s%s\n", + 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. But we rewrite the DT_FLAGS entry to a DT_TEXTREL entry to make @@ -175,7 +175,7 @@ _dl_relocate_object (struct link_map *l, struct r_scope_elem *scope[], { errstring = N_("cannot make segment writable for relocation"); call_error: - INTUSE(_dl_signal_error) (errno, l->l_name, NULL, errstring); + _dl_signal_error (errno, l->l_name, NULL, errstring); } #if (PF_R | PF_W | PF_X) == 7 && (PROT_READ | PROT_WRITE | PROT_EXEC) == 7 @@ -214,13 +214,12 @@ _dl_relocate_object (struct link_map *l, struct r_scope_elem *scope[], l->l_lookup_cache.type_class = _tc; \ l->l_lookup_cache.sym = (*ref); \ _lr = ((version) != NULL && (version)->hash != 0 \ - ? INTUSE(_dl_lookup_versioned_symbol) (strtab \ - + (*ref)->st_name, \ - l, (ref), scope, \ - (version), _tc, 0) \ - : INTUSE(_dl_lookup_symbol) (strtab + (*ref)->st_name, l, \ - (ref), scope, _tc, \ - DL_LOOKUP_ADD_DEPENDENCY)); \ + ? _dl_lookup_versioned_symbol (strtab + (*ref)->st_name, \ + l, (ref), scope, (version),\ + _tc, 0) \ + : _dl_lookup_symbol (strtab + (*ref)->st_name, l, (ref), \ + scope, _tc, \ + DL_LOOKUP_ADD_DEPENDENCY)); \ l->l_lookup_cache.ret = (*ref); \ l->l_lookup_cache.value = _lr; })) \ : l) @@ -236,13 +235,12 @@ _dl_relocate_object (struct link_map *l, struct r_scope_elem *scope[], l->l_lookup_cache.type_class = _tc; \ l->l_lookup_cache.sym = (*ref); \ _lr = ((version) != NULL && (version)->hash != 0 \ - ? INTUSE(_dl_lookup_versioned_symbol) (strtab \ - + (*ref)->st_name, \ - l, (ref), scope, \ - (version), _tc, 0) \ - : INTUSE(_dl_lookup_symbol) (strtab + (*ref)->st_name, l, \ - (ref), scope, _tc, \ - DL_LOOKUP_ADD_DEPENDENCY)); \ + ? _dl_lookup_versioned_symbol (strtab + (*ref)->st_name, \ + l, (ref), scope, \ + (version), _tc, 0) \ + : _dl_lookup_symbol (strtab + (*ref)->st_name, l, (ref), \ + scope, _tc, \ + DL_LOOKUP_ADD_DEPENDENCY)); \ l->l_lookup_cache.ret = (*ref); \ l->l_lookup_cache.value = _lr; })) \ : l->l_addr) @@ -313,7 +311,7 @@ _dl_relocate_object (struct link_map *l, struct r_scope_elem *scope[], if (l->l_relro_size != 0) _dl_protect_relro (l); } -INTDEF (_dl_relocate_object) + void internal_function _dl_protect_relro (struct link_map *l) @@ -326,9 +324,9 @@ _dl_protect_relro (struct link_map *l) if (start != end && __mprotect ((void *) start, end - start, PROT_READ) < 0) { - const char *errstring = N_("\ + static const char errstring[] = N_("\ cannot apply additional memory protection after relocation"); - INTUSE(_dl_signal_error) (errno, l->l_name, NULL, errstring); + _dl_signal_error (errno, l->l_name, NULL, errstring); } } @@ -365,5 +363,5 @@ _dl_reloc_bad_type (struct link_map *map, unsigned int type, int plt) *cp++ = DIGIT (type); *cp = '\0'; - INTUSE(_dl_signal_error) (0, map->l_name, NULL, msgbuf); + _dl_signal_error (0, map->l_name, NULL, msgbuf); } diff --git a/elf/dl-runtime.c b/elf/dl-runtime.c index b71dee5e75..f89cc68de2 100644 --- a/elf/dl-runtime.c +++ b/elf/dl-runtime.c @@ -84,19 +84,17 @@ fixup ( if (version->hash != 0) { - result = INTUSE(_dl_lookup_versioned_symbol) (strtab - + sym->st_name, - l, &sym, l->l_scope, - version, - ELF_RTYPE_CLASS_PLT, - 0); + result = _dl_lookup_versioned_symbol (strtab + sym->st_name, + l, &sym, l->l_scope, + version, + ELF_RTYPE_CLASS_PLT, 0); break; } } case 0: - result = INTUSE(_dl_lookup_symbol) (strtab + sym->st_name, l, &sym, - l->l_scope, ELF_RTYPE_CLASS_PLT, - DL_LOOKUP_ADD_DEPENDENCY); + result = _dl_lookup_symbol (strtab + sym->st_name, l, &sym, + l->l_scope, ELF_RTYPE_CLASS_PLT, + DL_LOOKUP_ADD_DEPENDENCY); } /* Currently result contains the base load address (or link map) @@ -174,21 +172,19 @@ profile_fixup ( if (version->hash != 0) { - result = INTUSE(_dl_lookup_versioned_symbol) (strtab - + sym->st_name, - l, &sym, - l->l_scope, - version, - ELF_RTYPE_CLASS_PLT, - 0); + result = _dl_lookup_versioned_symbol (strtab + + sym->st_name, + l, &sym, l->l_scope, + version, + ELF_RTYPE_CLASS_PLT, + 0); break; } } case 0: - result = INTUSE(_dl_lookup_symbol) (strtab + sym->st_name, l, - &sym, l->l_scope, - ELF_RTYPE_CLASS_PLT, - DL_LOOKUP_ADD_DEPENDENCY); + result = _dl_lookup_symbol (strtab + sym->st_name, l, &sym, + l->l_scope, ELF_RTYPE_CLASS_PLT, + DL_LOOKUP_ADD_DEPENDENCY); } /* Currently result contains the base load address (or link map) diff --git a/elf/dl-sym.c b/elf/dl-sym.c index 851d6b518e..bee49f1fda 100644 --- a/elf/dl-sym.c +++ b/elf/dl-sym.c @@ -24,6 +24,37 @@ #include <dlfcn.h> #include <ldsodefs.h> #include <dl-hash.h> +#include <dl-tls.h> + + +#if defined USE_TLS && defined SHARED +/* Systems which do not have tls_index also probably have to define + DONT_USE_TLS_INDEX. */ + +# ifndef __TLS_GET_ADDR +# define __TLS_GET_ADDR __tls_get_addr +# endif + +/* Return the symbol address given the map of the module it is in and + the symbol record. This is used in dl-sym.c. */ +static void * +internal_function +_dl_tls_symaddr (struct link_map *map, const ElfW(Sym) *ref) +{ +# ifndef DONT_USE_TLS_INDEX + tls_index tmp = + { + .ti_module = map->l_tls_modid, + .ti_offset = ref->st_value + }; + + return __TLS_GET_ADDR (&tmp); +# else + return __TLS_GET_ADDR (map->l_tls_modid, ref->st_value); +# endif +} +#endif + void * internal_function @@ -51,9 +82,9 @@ _dl_sym (void *handle, const char *name, void *who) if (handle == RTLD_DEFAULT) /* Search the global scope as seen in the caller object. */ - result = _dl_lookup_symbol (name, match, &ref, match->l_scope, 0, - DL_LOOKUP_RETURN_NEWEST - | DL_LOOKUP_ADD_DEPENDENCY); + result = GLRO(dl_lookup_symbol) (name, match, &ref, match->l_scope, 0, + DL_LOOKUP_RETURN_NEWEST + | DL_LOOKUP_ADD_DEPENDENCY); else { if (handle != RTLD_NEXT) @@ -61,8 +92,9 @@ _dl_sym (void *handle, const char *name, void *who) /* Search the scope of the given object. */ struct link_map *map = handle; - result = _dl_lookup_symbol (name, match, &ref, map->l_local_scope, - 0, DL_LOOKUP_RETURN_NEWEST); + result = GLRO(dl_lookup_symbol) (name, match, &ref, + map->l_local_scope, 0, + DL_LOOKUP_RETURN_NEWEST); } else { @@ -71,7 +103,7 @@ _dl_sym (void *handle, const char *name, void *who) if (! GL(dl_loaded) || caller < GL(dl_loaded)->l_map_start || caller >= GL(dl_loaded)->l_map_end) - _dl_signal_error (0, NULL, NULL, N_("\ + GLRO(dl_signal_error) (0, NULL, NULL, N_("\ RTLD_NEXT used in code not dynamically loaded")); } @@ -79,8 +111,8 @@ RTLD_NEXT used in code not dynamically loaded")); while (l->l_loader != NULL) l = l->l_loader; - result = _dl_lookup_symbol_skip (name, l, &ref, l->l_local_scope, - match); + result = GLRO(dl_lookup_symbol_skip) (name, l, &ref, + l->l_local_scope, match); } } @@ -133,8 +165,9 @@ _dl_vsym (void *handle, const char *name, const char *version, void *who) if (handle == RTLD_DEFAULT) /* Search the global scope. */ - result = _dl_lookup_versioned_symbol (name, match, &ref, match->l_scope, - &vers, 0, DL_LOOKUP_ADD_DEPENDENCY); + result = GLRO(dl_lookup_versioned_symbol) (name, match, &ref, + match->l_scope, &vers, 0, + DL_LOOKUP_ADD_DEPENDENCY); else if (handle == RTLD_NEXT) { if (__builtin_expect (match == GL(dl_loaded), 0)) @@ -142,7 +175,7 @@ _dl_vsym (void *handle, const char *name, const char *version, void *who) if (! GL(dl_loaded) || caller < GL(dl_loaded)->l_map_start || caller >= GL(dl_loaded)->l_map_end) - _dl_signal_error (0, NULL, NULL, N_("\ + GLRO(dl_signal_error) (0, NULL, NULL, N_("\ RTLD_NEXT used in code not dynamically loaded")); } @@ -150,16 +183,17 @@ RTLD_NEXT used in code not dynamically loaded")); while (l->l_loader != NULL) l = l->l_loader; - result = _dl_lookup_versioned_symbol_skip (name, l, &ref, - l->l_local_scope, - &vers, match); + result = GLRO(dl_lookup_versioned_symbol_skip) (name, l, &ref, + l->l_local_scope, + &vers, match); } else { /* Search the scope of the given object. */ struct link_map *map = handle; - result = _dl_lookup_versioned_symbol (name, map, &ref, - map->l_local_scope, &vers, 0, 0); + result = GLRO(dl_lookup_versioned_symbol) (name, map, &ref, + map->l_local_scope, &vers, + 0, 0); } if (ref != NULL) diff --git a/elf/dl-version.c b/elf/dl-version.c index 83d63f30de..9176aeb5ea 100644 --- a/elf/dl-version.c +++ b/elf/dl-version.c @@ -88,10 +88,10 @@ match_symbol (const char *name, ElfW(Word) hash, const char *string, /* Display information about what we are doing while debugging. */ if (__builtin_expect (GLRO(dl_debug_mask) & DL_DEBUG_VERSIONS, 0)) - INTUSE(_dl_debug_printf) ("\ + _dl_debug_printf ("\ checking for version `%s' in file %s required by file %s\n", - string, map->l_name[0] - ? map->l_name : rtld_progname, name); + string, map->l_name[0] ? map->l_name : rtld_progname, + name); if (__builtin_expect (map->l_info[VERSYMIDX (DT_VERDEF)] == NULL, 0)) { @@ -215,9 +215,8 @@ _dl_check_map_versions (struct link_map *map, int verbose, int trace_mode) &buf[sizeof (buf) - 1], 10, 0), " of Verneed record\n"); call_error: - INTUSE(_dl_signal_error) (errval, (*map->l_name - ? map->l_name : rtld_progname), - NULL, errstring); + _dl_signal_error (errval, *map->l_name ? map->l_name : rtld_progname, + NULL, errstring); } while (1) @@ -375,7 +374,6 @@ _dl_check_map_versions (struct link_map *map, int verbose, int trace_mode) return result; } -INTDEF (_dl_check_map_versions) int @@ -387,7 +385,7 @@ _dl_check_all_versions (struct link_map *map, int verbose, int trace_mode) for (l = map; l != NULL; l = l->l_next) result |= (! l->l_faked - && INTUSE(_dl_check_map_versions) (l, verbose, trace_mode)); + && _dl_check_map_versions (l, verbose, trace_mode)); return result; } diff --git a/elf/do-lookup.h b/elf/do-lookup.h index 15900cdf99..014a06a5aa 100644 --- a/elf/do-lookup.h +++ b/elf/do-lookup.h @@ -61,9 +61,9 @@ FCT (const char *undef_name, unsigned long int hash, const ElfW(Sym) *ref, /* Print some debugging info if wanted. */ if (__builtin_expect (GLRO(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 : rtld_progname)); + _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 c0e15a696c..cf82d5ad3b 100644 --- a/elf/rtld.c +++ b/elf/rtld.c @@ -18,6 +18,7 @@ 02111-1307 USA. */ #include <errno.h> +#include <dlfcn.h> #include <fcntl.h> #include <stdbool.h> #include <stdlib.h> @@ -121,6 +122,27 @@ struct rtld_global_ro _rtld_global_ro attribute_relro = ._dl_hwcap_mask = HWCAP_IMPORTANT, ._dl_lazy = 1, ._dl_fpu_control = _FPU_DEFAULT, + + /* Function pointers. */ + ._dl_get_origin = _dl_get_origin, + ._dl_dst_count = _dl_dst_count, + ._dl_dst_substitute = _dl_dst_substitute, + ._dl_map_object = _dl_map_object, + ._dl_map_object_deps = _dl_map_object_deps, + ._dl_relocate_object = _dl_relocate_object, + ._dl_check_map_versions = _dl_check_map_versions, + ._dl_init = _dl_init, + ._dl_debug_state = _dl_debug_state, + ._dl_unload_cache = _dl_unload_cache, + ._dl_debug_printf = _dl_debug_printf, + ._dl_catch_error = _dl_catch_error, + ._dl_signal_error = _dl_signal_error, + ._dl_start_profile = _dl_start_profile, + ._dl_mcount = _dl_mcount_internal, + ._dl_lookup_symbol = _dl_lookup_symbol, + ._dl_lookup_versioned_symbol = _dl_lookup_versioned_symbol, + ._dl_lookup_symbol_skip = _dl_lookup_symbol_skip, + ._dl_lookup_versioned_symbol_skip = _dl_lookup_versioned_symbol_skip, }; /* If we would use strong_alias here the compiler would see a non-hidden definition. This would undo the effect of the previous @@ -551,16 +573,15 @@ relocate_doit (void *a) { struct relocate_args *args = (struct relocate_args *) a; - INTUSE(_dl_relocate_object) (args->l, args->l->l_scope, args->lazy, 0); + _dl_relocate_object (args->l, args->l->l_scope, args->lazy, 0); } static void map_doit (void *a) { struct map_args *args = (struct map_args *) a; - args->map = INTUSE(_dl_map_object) (args->loader, args->str, - args->is_preloaded, lt_library, 0, - args->mode); + args->map = _dl_map_object (args->loader, args->str, + args->is_preloaded, lt_library, 0, args->mode); } static void @@ -823,7 +844,7 @@ of this helper program; chances are you did not intend to run this program.\n\ args.loader = NULL; args.is_preloaded = 0; args.mode = __RTLD_OPENEXEC; - (void) INTUSE(_dl_catch_error) (&objname, &err_str, map_doit, &args); + (void) _dl_catch_error (&objname, &err_str, map_doit, &args); if (__builtin_expect (err_str != NULL, 0)) /* We don't free the returned string, the programs stops anyway. */ @@ -832,8 +853,8 @@ of this helper program; chances are you did not intend to run this program.\n\ else { HP_TIMING_NOW (start); - INTUSE(_dl_map_object) (NULL, rtld_progname, 0, lt_library, 0, - __RTLD_OPENEXEC); + _dl_map_object (NULL, rtld_progname, 0, lt_library, 0, + __RTLD_OPENEXEC); HP_TIMING_NOW (stop); HP_TIMING_DIFF (load_time, start, stop); @@ -1094,10 +1115,8 @@ of this helper program; chances are you did not intend to run this program.\n\ && (__builtin_expect (! INTUSE(__libc_enable_secure), 1) || strchr (p, '/') == NULL)) { - struct link_map *new_map = INTUSE(_dl_map_object) (GL(dl_loaded), - p, 1, - lt_library, - 0, 0); + struct link_map *new_map = _dl_map_object (GL(dl_loaded), p, 1, + lt_library, 0, 0); if (++new_map->l_opencount == 1) /* It is no duplicate. */ ++npreloads; @@ -1174,8 +1193,7 @@ of this helper program; chances are you did not intend to run this program.\n\ args.is_preloaded = 1; args.mode = 0; - (void) INTUSE(_dl_catch_error) (&objname, &err_str, map_doit, - &args); + (void) _dl_catch_error (&objname, &err_str, map_doit, &args); if (__builtin_expect (err_str != NULL, 0)) { _dl_error_printf ("\ @@ -1193,9 +1211,8 @@ ERROR: ld.so: object '%s' from %s cannot be preloaded: ignored.\n", if (problem != NULL) { char *p = strndupa (problem, file_size - (problem - file)); - struct link_map *new_map = INTUSE(_dl_map_object) (GL(dl_loaded), p, - 1, lt_library, - 0, 0); + struct link_map *new_map = _dl_map_object (GL(dl_loaded), p, 1, + lt_library, 0, 0); if (++new_map->l_opencount == 1) /* It is no duplicate. */ ++npreloads; @@ -1294,8 +1311,7 @@ ERROR: ld.so: object '%s' from %s cannot be preloaded: ignored.\n", specified some libraries to load, these are inserted before the actual dependencies in the executable's searchlist for symbol resolution. */ HP_TIMING_NOW (start); - INTUSE(_dl_map_object_deps) (GL(dl_loaded), preloads, npreloads, - mode == trace, 0); + _dl_map_object_deps (GL(dl_loaded), preloads, npreloads, mode == trace, 0); HP_TIMING_NOW (stop); HP_TIMING_DIFF (diff, start, stop); HP_TIMING_ACCUM_NT (load_time, diff); @@ -1505,10 +1521,9 @@ cannot allocate TLS data structures for initial thread"); ElfW(Addr) loadbase; lookup_t result; - result = INTUSE(_dl_lookup_symbol) (INTUSE(_dl_argv)[i], - GL(dl_loaded), - &ref, GL(dl_loaded)->l_scope, - ELF_RTYPE_CLASS_PLT, 1); + result = _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); @@ -1545,8 +1560,8 @@ cannot allocate TLS data structures for initial thread"); if ((GLRO(dl_debug_mask) & DL_DEBUG_PRELINK) && GL(dl_rtld_map).l_opencount > 1) - INTUSE(_dl_relocate_object) (&GL(dl_rtld_map), - GL(dl_loaded)->l_scope, 0, 0); + _dl_relocate_object (&GL(dl_rtld_map), GL(dl_loaded)->l_scope, + 0, 0); } #define VERNEEDTAG (DT_NUM + DT_THISPROCNUM + DT_VERSIONTAGIDX (DT_VERNEED)) @@ -1783,8 +1798,8 @@ cannot allocate TLS data structures for initial thread"); } if (l != &GL(dl_rtld_map)) - INTUSE(_dl_relocate_object) (l, l->l_scope, GLRO(dl_lazy), - consider_profiling); + _dl_relocate_object (l, l->l_scope, GLRO(dl_lazy), + consider_profiling); l = l->l_prev; } @@ -1806,16 +1821,14 @@ cannot allocate TLS data structures for initial thread"); needs to have _dl_profile_map set up by the relocator. */ if (__builtin_expect (GL(dl_profile_map) != NULL, 0)) /* We must prepare the profiling. */ - INTUSE(_dl_start_profile) (GL(dl_profile_map), - GLRO(dl_profile_output)); + _dl_start_profile (GL(dl_profile_map), GLRO(dl_profile_output)); if (GL(dl_rtld_map).l_opencount > 1) { /* There was an explicit ref to the dynamic linker as a shared lib. Re-relocate ourselves with user-controlled symbol definitions. */ HP_TIMING_NOW (start); - INTUSE(_dl_relocate_object) (&GL(dl_rtld_map), GL(dl_loaded)->l_scope, - 0, 0); + _dl_relocate_object (&GL(dl_rtld_map), GL(dl_loaded)->l_scope, 0, 0); HP_TIMING_NOW (stop); HP_TIMING_DIFF (add, start, stop); HP_TIMING_ACCUM_NT (relocate_time, add); @@ -1854,11 +1867,11 @@ cannot allocate TLS data structures for initial thread"); /* Notify the debugger that all objects are now mapped in. */ r->r_state = RT_ADD; - INTUSE(_dl_debug_state) (); + _dl_debug_state (); #ifndef MAP_COPY /* We must munmap() the cache file. */ - INTUSE(_dl_unload_cache) (); + _dl_unload_cache (); #endif /* Once we return, _dl_sysdep_start will invoke @@ -2211,9 +2224,8 @@ print_statistics (hp_timing_t *rtld_total_timep) if (HP_TIMING_AVAIL) { HP_TIMING_PRINT (buf, sizeof (buf), *rtld_total_timep); - INTUSE(_dl_debug_printf) ("\nruntime linker statistics:\n" - " total startup time in dynamic loader: %s\n", - buf); + _dl_debug_printf ("\nruntime linker statistics:\n" + " total startup time in dynamic loader: %s\n", buf); /* Print relocation statistics. */ char pbuf[30]; @@ -2232,9 +2244,8 @@ print_statistics (hp_timing_t *rtld_total_timep) *wp++ = *cp++; } *wp = '\0'; - INTUSE(_dl_debug_printf) ("\ - time needed for relocation: %s (%s%%)\n", - buf, pbuf); + _dl_debug_printf ("\ + time needed for relocation: %s (%s%%)\n", buf, pbuf); } #endif @@ -2255,12 +2266,12 @@ print_statistics (hp_timing_t *rtld_total_timep) num_relative_relocations += l->l_info[VERSYMIDX (DT_RELACOUNT)]->d_un.d_val; } - INTUSE(_dl_debug_printf) (" number of relocations: %lu\n", - GL(dl_num_relocations)); - INTUSE(_dl_debug_printf) (" number of relocations from cache: %lu\n", - GL(dl_num_cache_relocations)); - INTUSE(_dl_debug_printf) (" number of relative relocations: %lu\n", - num_relative_relocations); + _dl_debug_printf (" number of relocations: %lu\n", + GL(dl_num_relocations)); + _dl_debug_printf (" number of relocations from cache: %lu\n", + GL(dl_num_cache_relocations)); + _dl_debug_printf (" number of relative relocations: %lu\n", + num_relative_relocations); #ifndef HP_TIMING_NONAVAIL /* Time spend while loading the object and the dependencies. */ @@ -2282,7 +2293,7 @@ print_statistics (hp_timing_t *rtld_total_timep) *wp++ = *cp++; } *wp = '\0'; - INTUSE(_dl_debug_printf) ("\ + _dl_debug_printf ("\ time needed to load objects: %s (%s%%)\n", buf, pbuf); } |