From 7969407a01a108298ea506e0c37c1d6b7c9d424c Mon Sep 17 00:00:00 2001 From: Ulrich Drepper Date: Sun, 3 Feb 2002 00:31:37 +0000 Subject: Update. Change ld.so to not use functions which are exported. One cannot interpose them anyway. Use INT() to mark uses, INTDEF() to mark definitions. * include/libc-symbols.h: Define INT and INTDEF. * sysdeps/generic/ldsodefs.h: Declare _dl_debug_printf_internal, _dl_signal_error_internal, _dl_map_object_internal, _dl_map_object_deps_internal, _dl_lookup_symbol_internal, _dl_lookup_versioned_symbol_internal, _dl_relocate_object_internal, _dl_debug_state_internal, _dl_start_profile_internal, and _dl_unload_cache_internal. * include/dlfcn.h: Declare _dl_catch_error_internal. * elf/rtld.c: Use INT for calls to any of the *_internal functions above. Add INTDEF to function definitions. * elf/dl-debug.c: Likewise. * elf/dl-deps.c: Likewise. * elf/dl-dst.h: 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-misc.c: Likewise. * elf/dl-open.c: Likewise. * elf/dl-profile.c: Likewise. * elf/dl-reloc.c: Likewise. * elf/dl-runtime.c: Likewise. * elf/dl-version.c: Likewise. * elf/do-lookup.h: Likewise. * sysdeps/generic/dl-cache.c: Likewise. * sysdeps/generic/dl-sysdep.c: Likewise. * sysdeps/alpha/dl-machine.h (RTLD_START): Call _dl_init_internal instead of _dl_init. * 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/ia64/dl-machine.h: Likewise. * sysdeps/m68k/dl-machine.h: Likewise. * sysdeps/mips/dl-machine.h: Likewise. * sysdeps/mips/mips64/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/sparc32/dl-machine.h: Likewise. * sysdeps/sparc/sparc64/dl-machine.h: Likewise. * sysdeps/x86_64/dl-machine.h: Likewise. * sysdeps/powerpc/dl-start.S (_dl_start_user): Likewise. * elf/Versions: Don't export _dl_check_all_versions, _dl_sysdep_start, and _dl_debug_initialize. --- elf/Versions | 6 ++--- elf/dl-debug.c | 1 + elf/dl-deps.c | 68 +++++++++++++++++++++++++++-------------------------- elf/dl-dst.h | 10 ++++---- elf/dl-error.c | 5 +++- elf/dl-fini.c | 4 ++-- elf/dl-init.c | 15 ++++++------ elf/dl-load.c | 68 ++++++++++++++++++++++++++++++----------------------- elf/dl-lookup.c | 39 +++++++++++++++++-------------- elf/dl-misc.c | 1 + elf/dl-open.c | 14 +++++------ elf/dl-profile.c | 1 + elf/dl-reloc.c | 27 +++++++++++---------- elf/dl-runtime.c | 31 ++++++++++++++----------- elf/dl-version.c | 16 +++++++------ elf/do-lookup.h | 4 ++-- elf/rtld.c | 71 +++++++++++++++++++++++++++++++------------------------- 17 files changed, 209 insertions(+), 172 deletions(-) (limited to 'elf') diff --git a/elf/Versions b/elf/Versions index 4c7806d8e6..091f444eb9 100644 --- a/elf/Versions +++ b/elf/Versions @@ -38,13 +38,13 @@ ld { GLIBC_PRIVATE { # Those are in the dynamic linker, but used by libc.so. __libc_enable_secure; __libc_stack_end; - _dl_argv; _dl_catch_error; _dl_check_all_versions; _dl_check_map_versions; - _dl_debug_initialize; _dl_debug_printf; _dl_debug_state; _dl_dst_count; + _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_sysdep_start; _dl_unload_cache; + _dl_unload_cache; _rtld_global; } } diff --git a/elf/dl-debug.c b/elf/dl-debug.c index 4e8197227e..462a21e8a8 100644 --- a/elf/dl-debug.c +++ b/elf/dl-debug.c @@ -55,3 +55,4 @@ void _dl_debug_state (void) { } +INTDEF (_dl_debug_state) diff --git a/elf/dl-deps.c b/elf/dl-deps.c index 368ad2d557..43a0bd8bf3 100644 --- a/elf/dl-deps.c +++ b/elf/dl-deps.c @@ -59,10 +59,10 @@ openaux (void *a) { struct openaux_args *args = (struct openaux_args *) a; - 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, 0); + args->aux = INT(_dl_map_object) (args->map, args->name, 0, + (args->map->l_type == lt_executable + ? lt_library : args->map->l_type), + args->trace_mode, 0); } static ptrdiff_t @@ -107,28 +107,28 @@ struct list \ /* DST must not appear in SUID/SGID programs. */ \ if (__libc_enable_secure) \ - _dl_signal_error (0, __str, NULL, \ - N_("DST not allowed in SUID/SGID programs")); \ + INT(_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 = DL_DST_SUBSTITUTE (l, __str, __newp, 0); \ + __result = INT(_dl_dst_substitute) (l, __str, __newp, 0); \ \ if (*__result == '\0') \ { \ /* The replacement for the DST is not known. We can't \ processed. */ \ if (fatal) \ - _dl_signal_error (0, __str, NULL, N_("\ + INT(_dl_signal_error) (0, __str, NULL, N_("\ empty dynamics string token substitution")); \ else \ { \ /* This is for DT_AUXILIARY. */ \ if (__builtin_expect (GL(dl_debug_mask) & DL_DEBUG_LIBS, 0)) \ - _dl_debug_printf ("cannot load auxiliary `%s' because of" \ - "empty dynamic string token " \ - "substitution\n", __str); \ + INT(_dl_debug_printf) (N_("\ +cannot load auxiliary `%s' because of empty dynamic string token " \ + "substitution\n"), __str); \ continue; \ } \ } \ @@ -239,7 +239,8 @@ _dl_map_object_deps (struct link_map *map, /* Store the tag in the argument structure. */ args.name = name; - err = _dl_catch_error (&objname, &errstring, openaux, &args); + err = INT(_dl_catch_error) (&objname, &errstring, openaux, + &args); if (__builtin_expect (errstring != NULL, 0)) { if (err) @@ -290,15 +291,15 @@ _dl_map_object_deps (struct link_map *map, /* Say that we are about to load an auxiliary library. */ if (__builtin_expect (GL(dl_debug_mask) & DL_DEBUG_LIBS, 0)) - _dl_debug_printf ("load auxiliary object=%s" - " requested by file=%s\n", name, - l->l_name[0] - ? l->l_name : _dl_argv[0]); + INT(_dl_debug_printf) ("load auxiliary object=%s" + " requested by file=%s\n", name, + l->l_name[0] + ? l->l_name : _dl_argv[0]); /* We must be prepared that the addressed shared object is not available. */ - err = _dl_catch_error (&objname, &errstring, openaux, - &args); + err = INT(_dl_catch_error) (&objname, &errstring, openaux, + &args); if (__builtin_expect (errstring != NULL, 0)) { /* We are not interested in the error message. */ @@ -317,14 +318,14 @@ _dl_map_object_deps (struct link_map *map, /* Say that we are about to load an auxiliary library. */ if (__builtin_expect (GL(dl_debug_mask) & DL_DEBUG_LIBS, 0)) - _dl_debug_printf ("load filtered object=%s" - " requested by file=%s\n", name, - l->l_name[0] - ? l->l_name : _dl_argv[0]); + INT(_dl_debug_printf) ("load filtered object=%s" + " requested by file=%s\n", name, + l->l_name[0] + ? l->l_name : _dl_argv[0]); /* For filter objects the dependency must be available. */ - err = _dl_catch_error (&objname, &errstring, openaux, - &args); + err = INT(_dl_catch_error) (&objname, &errstring, openaux, + &args); if (__builtin_expect (errstring != NULL, 0)) { if (err) @@ -452,8 +453,8 @@ _dl_map_object_deps (struct link_map *map, l->l_initfini = (struct link_map **) malloc ((nneeded + 1) * sizeof needed[0]); if (l->l_initfini == NULL) - _dl_signal_error (ENOMEM, map->l_name, NULL, - N_("cannot allocate dependency list")); + INT(_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]); } @@ -483,8 +484,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) - _dl_signal_error (ENOMEM, map->l_name, NULL, - N_("cannot allocate symbol search list")); + INT(_dl_signal_error) (ENOMEM, map->l_name, NULL, + N_("cannot allocate symbol search list")); map->l_searchlist.r_list = &map->l_initfini[nlist + 1]; @@ -524,7 +525,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. */ - _dl_signal_error (EINVAL, l->l_name, NULL, N_("\ + INT(_dl_signal_error) (EINVAL, l->l_name, NULL, N_("\ Filters not supported with LD_TRACE_PRELINKING")); } @@ -538,8 +539,8 @@ Filters not supported with LD_TRACE_PRELINKING")); + (cnt * sizeof (struct link_map *))); if (l->l_local_scope[0] == NULL) - _dl_signal_error (ENOMEM, map->l_name, NULL, - N_("cannot allocate symbol search list")); + INT(_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); @@ -618,6 +619,7 @@ Filters not supported with LD_TRACE_PRELINKING")); map->l_initfini[nlist] = NULL; if (errno_reason) - _dl_signal_error (errno_reason == -1 ? 0 : errno_reason, - objname, NULL, errstring); + INT(_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 af4a94a3b3..4112e591e0 100644 --- a/elf/dl-dst.h +++ b/elf/dl-dst.h @@ -25,12 +25,13 @@ const char *__sf = strchr (name, '$'); \ \ if (__builtin_expect (__sf != NULL, 0)) \ - __cnt = _dl_dst_count (__sf, is_path); \ + __cnt = INT(_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); /* Guess from the number of DSTs the length of the result string. */ @@ -62,11 +63,8 @@ extern size_t _dl_dst_count (const char *name, int is_path); /* Find origin of the executable. */ extern const char *_dl_get_origin (void); - -/* Perform the DST substitution. */ -#define DL_DST_SUBSTITUTE(l, name, res, is_path) \ - _dl_dst_substitute (l, name, res, is_path) - /* 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 922de5caeb..a297189d77 100644 --- a/elf/dl-error.c +++ b/elf/dl-error.c @@ -110,6 +110,7 @@ _dl_signal_error (int errcode, const char *objname, const char *occation, : "")); } } +INTDEF (_dl_signal_error) void @@ -125,7 +126,7 @@ _dl_signal_cerror (int errcode, const char *objname, const char *occation, (*receiver) (errcode, objname, errstring); } else - _dl_signal_error (errcode, objname, occation, errstring); + INT(_dl_signal_error) (errcode, objname, occation, errstring); } @@ -162,6 +163,8 @@ _dl_catch_error (const char **objname, const char **errstring, *errstring = c.errstring; return errcode == -1 ? 0 : errcode; } +INTDEF (_dl_catch_error) + void internal_function diff --git a/elf/dl-fini.c b/elf/dl-fini.c index e8533a471c..ab6bf9c496 100644 --- a/elf/dl-fini.c +++ b/elf/dl-fini.c @@ -147,8 +147,8 @@ _dl_fini (void) /* When debugging print a message first. */ if (__builtin_expect (GL(dl_debug_mask) & DL_DEBUG_IMPCALLS, 0)) - _dl_debug_printf ("\ncalling fini: %s\n\n", - l->l_name[0] ? l->l_name : _dl_argv[0]); + INT(_dl_debug_printf) ("\ncalling fini: %s\n\n", + l->l_name[0] ? l->l_name : _dl_argv[0]); /* 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 700efc58e5..b58ff197dc 100644 --- a/elf/dl-init.c +++ b/elf/dl-init.c @@ -51,8 +51,8 @@ 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)) - _dl_debug_printf ("\ncalling init: %s\n\n", - l->l_name[0] ? l->l_name : _dl_argv[0]); + INT(_dl_debug_printf) ("\ncalling init: %s\n\n", + l->l_name[0] ? l->l_name : _dl_argv[0]); /* Now run the local constructors. There are two forms of them: - the one named by DT_INIT @@ -106,9 +106,9 @@ _dl_init (struct link_map *main_map, int argc, char **argv, char **env) unsigned int cnt; if (__builtin_expect (GL(dl_debug_mask) & DL_DEBUG_IMPCALLS, 0)) - _dl_debug_printf ("\ncalling preinit: %s\n\n", - main_map->l_name[0] - ? main_map->l_name : _dl_argv[0]); + INT(_dl_debug_printf) ("\ncalling preinit: %s\n\n", + main_map->l_name[0] + ? main_map->l_name : _dl_argv[0]); addrs = (ElfW(Addr) *) (main_map->l_info[DT_PREINIT_ARRAY]->d_un.d_ptr + main_map->l_addr); @@ -121,7 +121,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; - _dl_debug_state (); + INT(_dl_debug_state) (); /* Stupid users forced the ELF specification to be changed. It now says that the dynamic loader is responsible for determining the @@ -139,8 +139,9 @@ _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; - _dl_debug_state (); + INT(_dl_debug_state) (); /* Finished starting up. */ _dl_starting_up = 0; } +INTDEF (_dl_init) diff --git a/elf/dl-load.c b/elf/dl-load.c index ebaccfc000..574d4dad4e 100644 --- a/elf/dl-load.c +++ b/elf/dl-load.c @@ -212,6 +212,7 @@ _dl_dst_count (const char *name, int is_path) return cnt; } +INTDEF (_dl_dst_count) char * @@ -273,6 +274,7 @@ _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 @@ -306,7 +308,7 @@ expand_dynamic_string_token (struct link_map *l, const char *s) if (result == NULL) return NULL; - return DL_DST_SUBSTITUTE (l, s, result, 1); + return INT(_dl_dst_substitute) (l, s, result, 1); } @@ -332,7 +334,8 @@ add_name_to_object (struct link_map *l, const char *name) if (newname == NULL) { /* No more memory. */ - _dl_signal_error (ENOMEM, name, NULL, N_("cannot allocate name record")); + INT(_dl_signal_error) (ENOMEM, name, NULL, + N_("cannot allocate name record")); return; } /* The object should have a libname set from _dl_new_object. */ @@ -433,8 +436,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) - _dl_signal_error (ENOMEM, NULL, NULL, - N_("cannot create cache for search path")); + INT(_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)); @@ -509,7 +512,7 @@ decompose_rpath (struct r_search_path_struct *sps, signal_error_cache: errstring = N_("cannot create cache for search path"); signal_error: - _dl_signal_error (ENOMEM, NULL, NULL, errstring); + INT(_dl_signal_error) (ENOMEM, NULL, NULL, errstring); } result[0] = NULL; @@ -584,7 +587,7 @@ _dl_init_paths (const char *llp) { errstring = N_("cannot create search path array"); signal_error: - _dl_signal_error (ENOMEM, NULL, NULL, errstring); + INT(_dl_signal_error) (ENOMEM, NULL, NULL, errstring); } round_size = ((2 * sizeof (struct r_search_path_elem) - 1 @@ -749,7 +752,7 @@ lose (int code, int fd, const char *name, char *realname, struct link_map *l, free (l); } free (realname); - _dl_signal_error (code, name, NULL, msg); + INT(_dl_signal_error) (code, name, NULL, msg); } @@ -808,7 +811,7 @@ _dl_map_object_from_fd (const char *name, int fd, struct filebuf *fbp, /* Print debugging message. */ if (__builtin_expect (GL(dl_debug_mask) & DL_DEBUG_FILES, 0)) - _dl_debug_printf ("file=%s; generating link map\n", name); + INT(_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; @@ -821,8 +824,8 @@ _dl_map_object_from_fd (const char *name, int fd, struct filebuf *fbp, if (_dl_zerofd == -1) { __close (fd); - _dl_signal_error (errno, NULL, NULL, - N_("cannot open zero fill device")); + INT(_dl_signal_error) (errno, NULL, NULL, + N_("cannot open zero fill device")); } } #endif @@ -1107,14 +1110,19 @@ _dl_map_object_from_fd (const char *name, int fd, struct filebuf *fbp, l->l_entry += l->l_addr; if (__builtin_expect (GL(dl_debug_mask) & DL_DEBUG_FILES, 0)) - _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, (unsigned long int) l->l_ld, - (int) sizeof (void *) * 2, (unsigned long int) l->l_addr, - (int) sizeof (void *) * 2, maplength, - (int) sizeof (void *) * 2, (unsigned long int) l->l_entry, - (int) sizeof (void *) * 2, (unsigned long int) l->l_phdr, - (int) sizeof (void *) * 2, l->l_phnum); + INT(_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, + (unsigned long int) l->l_ld, + (int) sizeof (void *) * 2, + (unsigned long int) l->l_addr, + (int) sizeof (void *) * 2, maplength, + (int) sizeof (void *) * 2, + (unsigned long int) l->l_entry, + (int) sizeof (void *) * 2, + (unsigned long int) l->l_phdr, + (int) sizeof (void *) * 2, l->l_phnum); elf_get_dynamic_info (l); @@ -1189,7 +1197,7 @@ print_search_path (struct r_search_path_elem **list, char buf[max_dirnamelen + max_capstrlen]; int first = 1; - _dl_debug_printf (" search path="); + INT(_dl_debug_printf) (" search path="); while (*list != NULL && (*list)->what == what) /* Yes, ==. */ { @@ -1460,7 +1468,7 @@ open_path (const char *name, size_t namelen, int preloaded, /* Print name we try if this is wanted. */ if (__builtin_expect (GL(dl_debug_mask) & DL_DEBUG_LIBS, 0)) - _dl_debug_printf (" trying file=%s\n", buf); + INT(_dl_debug_printf) (" trying file=%s\n", buf); fd = open_verify (buf, fbp); if (this_dir->status[cnt] == unknown) @@ -1592,9 +1600,10 @@ _dl_map_object (struct link_map *loader, const char *name, int preloaded, } /* Display information if we are debugging. */ - if (__builtin_expect (GL(dl_debug_mask) & DL_DEBUG_FILES, 0) && loader != NULL) - _dl_debug_printf ("\nfile=%s; needed by %s\n", name, - loader->l_name[0] ? loader->l_name : _dl_argv[0]); + if (__builtin_expect (GL(dl_debug_mask) & DL_DEBUG_FILES, 0) + && loader != NULL) + INT(_dl_debug_printf) ("\nfile=%s; needed by %s\n", name, + loader->l_name[0] ? loader->l_name : _dl_argv[0]); if (strchr (name, '/') == NULL) { @@ -1603,7 +1612,7 @@ _dl_map_object (struct link_map *loader, const char *name, int preloaded, size_t namelen = strlen (name) + 1; if (__builtin_expect (GL(dl_debug_mask) & DL_DEBUG_LIBS, 0)) - _dl_debug_printf ("find library=%s; searching\n", name); + INT(_dl_debug_printf) ("find library=%s; searching\n", name); fd = -1; @@ -1752,7 +1761,7 @@ _dl_map_object (struct link_map *loader, const char *name, int preloaded, /* Add another newline when we a tracing the library loading. */ if (__builtin_expect (GL(dl_debug_mask) & DL_DEBUG_LIBS, 0)) - _dl_debug_printf ("\n"); + INT(_dl_debug_printf) ("\n"); } else { @@ -1784,8 +1793,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) - _dl_signal_error (ENOMEM, name, NULL, - N_("cannot create shared object descriptor")); + INT(_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 @@ -1798,9 +1807,10 @@ _dl_map_object (struct link_map *loader, const char *name, int preloaded, return l; } else - _dl_signal_error (errno, name, NULL, - N_("cannot open shared object file")); + INT(_dl_signal_error) (errno, name, NULL, + N_("cannot open shared object file")); } return _dl_map_object_from_fd (name, fd, &fb, realname, loader, type, mode); } +INTDEF (_dl_map_object) diff --git a/elf/dl-lookup.c b/elf/dl-lookup.c index 4f3285fee5..49ee42ad3c 100644 --- a/elf/dl-lookup.c +++ b/elf/dl-lookup.c @@ -168,11 +168,11 @@ add_dependency (struct link_map *undef_map, struct link_map *map) /* Display information if we are debugging. */ if (__builtin_expect (GL(dl_debug_mask) & DL_DEBUG_FILES, 0)) - _dl_debug_printf ("\ + INT(_dl_debug_printf) ("\ \nfile=%s; needed by %s (relocation dependency)\n\n", - map->l_name[0] ? map->l_name : _dl_argv[0], - undef_map->l_name[0] - ? undef_map->l_name : _dl_argv[0]); + map->l_name[0] ? map->l_name : _dl_argv[0], + undef_map->l_name[0] + ? undef_map->l_name : _dl_argv[0]); } else /* Whoa, that was bad luck. We have to search again. */ @@ -203,8 +203,9 @@ static void internal_function _dl_debug_bindings (const char *undef_name, struct link_map *undef_map, const ElfW(Sym) **ref, struct r_scope_elem *symbol_scope[], - struct sym_val *value, const struct r_found_version *version, - int type_class, int protected); + struct sym_val *value, + const struct r_found_version *version, int type_class, + int protected); /* Search loaded objects' symbol tables for a definition of the symbol UNDEF_NAME. */ @@ -239,8 +240,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 _dl_lookup_symbol (undef_name, undef_map, ref, symbol_scope, - type_class, 0); + return INT(_dl_lookup_symbol) (undef_name, undef_map, ref, + symbol_scope, type_class, 0); break; } @@ -288,6 +289,7 @@ _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,9 +402,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 _dl_lookup_versioned_symbol (undef_name, undef_map, ref, - symbol_scope, version, - type_class, 0); + return INT(_dl_lookup_versioned_symbol) (undef_name, undef_map, + ref, symbol_scope, + version, type_class, 0); break; } @@ -478,6 +480,7 @@ _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 @@ -597,12 +600,14 @@ _dl_debug_bindings (const char *undef_name, struct link_map *undef_map, if (GL(dl_debug_mask) & DL_DEBUG_BINDINGS) { - _dl_debug_printf ("binding file %s to %s: %s symbol `%s'", - (reference_name[0] - ? reference_name : (_dl_argv[0] ?: "
")), - value->m->l_name[0] ? value->m->l_name : _dl_argv[0], - protected ? "protected" : "normal", - undef_name); + INT(_dl_debug_printf) ("binding file %s to %s: %s symbol `%s'", + (reference_name[0] + ? reference_name + : (_dl_argv[0] ?: "
")), + value->m->l_name[0] + ? value->m->l_name : _dl_argv[0], + 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 d4d9d13e03..0a37b59ad7 100644 --- a/elf/dl-misc.c +++ b/elf/dl-misc.c @@ -249,6 +249,7 @@ _dl_debug_printf (const char *fmt, ...) _dl_debug_vdprintf (GL(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 56b6cbb319..e5f7ac835b 100644 --- a/elf/dl-open.c +++ b/elf/dl-open.c @@ -40,9 +40,6 @@ extern ElfW(Addr) _dl_sysdep_start (void **start_argptr, ElfW(Addr) *user_entry)); weak_extern (BP_SYM (_dl_sysdep_start)) -/* This function is used to unload the cache file if necessary. */ -extern void _dl_unload_cache (void); - extern int __libc_multiple_libcs; /* Defined in init-first.c. */ extern int __libc_argc; @@ -200,7 +197,7 @@ dl_open_worker (void *a) new_file = (char *) alloca (required + 1); /* Generate the new file name. */ - DL_DST_SUBSTITUTE (call_map, file, new_file, 0); + _dl_dst_substitute (call_map, file, new_file, 0); /* If the substitution failed don't try to load. */ if (*new_file == '\0') @@ -374,10 +371,11 @@ dl_open_worker (void *a) if (__builtin_expect (mode & RTLD_NODELETE, 0)) new->l_flags_1 |= DF_1_NODELETE; - if (_dl_sysdep_start == NULL) - /* We must be the static _dl_open in libc.a. A static program that - has loaded a dynamic object now has competition. */ - __libc_multiple_libcs = 1; +#ifndef SHARED + /* We must be the static _dl_open in libc.a. A static program that + has loaded a dynamic object now has competition. */ + __libc_multiple_libcs = 1; +#endif /* Let the user know about the opencount. */ if (__builtin_expect (GL(dl_debug_mask) & DL_DEBUG_FILES, 0)) diff --git a/elf/dl-profile.c b/elf/dl-profile.c index 163a841d6f..83e849561a 100644 --- a/elf/dl-profile.c +++ b/elf/dl-profile.c @@ -430,6 +430,7 @@ _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-reloc.c b/elf/dl-reloc.c index 8fea3fd778..67a47aa14a 100644 --- a/elf/dl-reloc.c +++ b/elf/dl-reloc.c @@ -87,7 +87,7 @@ _dl_relocate_object (struct link_map *l, struct r_scope_elem *scope[], { errstring = N_("cannot make segment writable for relocation"); call_error: - _dl_signal_error (errno, l->l_name, NULL, errstring); + INT(_dl_signal_error) (errno, l->l_name, NULL, errstring); } #if (PF_R | PF_W | PF_X) == 7 && (PROT_READ | PROT_WRITE | PROT_EXEC) == 7 @@ -126,11 +126,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 \ - ? _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, 0)); \ + ? INT(_dl_lookup_versioned_symbol) (strtab \ + + (*ref)->st_name, \ + l, (ref), scope, \ + (version), _tc, 0) \ + : INT(_dl_lookup_symbol) (strtab + (*ref)->st_name, l, \ + (ref), scope, _tc, 0)); \ l->l_lookup_cache.ret = (*ref); \ l->l_lookup_cache.value = _lr; })) \ : l) @@ -146,11 +147,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 \ - ? _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, 0)); \ + ? INT(_dl_lookup_versioned_symbol) (strtab \ + + (*ref)->st_name, \ + l, (ref), scope, \ + (version), _tc, 0) \ + : INT(_dl_lookup_symbol) (strtab + (*ref)->st_name, l, \ + (ref), scope, _tc, 0)); \ l->l_lookup_cache.ret = (*ref); \ l->l_lookup_cache.value = _lr; })) \ : l->l_addr) @@ -201,6 +203,7 @@ _dl_relocate_object (struct link_map *l, struct r_scope_elem *scope[], textrels = textrels->next; } } +INTDEF (_dl_relocate_object) void @@ -220,5 +223,5 @@ _dl_reloc_bad_type (struct link_map *map, unsigned int type, int plt) *cp++ = DIGIT (type >> 4); *cp = DIGIT (type); - _dl_signal_error (0, map->l_name, NULL, msgbuf); + INT(_dl_signal_error) (0, map->l_name, NULL, msgbuf); } diff --git a/elf/dl-runtime.c b/elf/dl-runtime.c index 44af537ab7..be5d8b68ad 100644 --- a/elf/dl-runtime.c +++ b/elf/dl-runtime.c @@ -87,16 +87,18 @@ fixup ( if (version->hash != 0) { - result = _dl_lookup_versioned_symbol (strtab + sym->st_name, - l, &sym, l->l_scope, - version, - ELF_RTYPE_CLASS_PLT, 0); + result = INT(_dl_lookup_versioned_symbol) (strtab + + sym->st_name, + l, &sym, l->l_scope, + version, + ELF_RTYPE_CLASS_PLT, + 0); break; } } case 0: - result = _dl_lookup_symbol (strtab + sym->st_name, l, &sym, - l->l_scope, ELF_RTYPE_CLASS_PLT, 0); + result = INT(_dl_lookup_symbol) (strtab + sym->st_name, l, &sym, + l->l_scope, ELF_RTYPE_CLASS_PLT, 0); } /* Currently result contains the base load address (or link map) @@ -179,17 +181,20 @@ profile_fixup ( if (version->hash != 0) { - result = _dl_lookup_versioned_symbol(strtab + sym->st_name, - l, &sym, l->l_scope, - version, - ELF_RTYPE_CLASS_PLT, - 0); + result = INT(_dl_lookup_versioned_symbol) (strtab + + sym->st_name, + l, &sym, + l->l_scope, + version, + ELF_RTYPE_CLASS_PLT, + 0); break; } } case 0: - result = _dl_lookup_symbol (strtab + sym->st_name, l, &sym, - l->l_scope, ELF_RTYPE_CLASS_PLT, 0); + result = INT(_dl_lookup_symbol) (strtab + sym->st_name, l, &sym, + l->l_scope, ELF_RTYPE_CLASS_PLT, + 0); } /* Currently result contains the base load address (or link map) diff --git a/elf/dl-version.c b/elf/dl-version.c index 7edb8ec359..9ba91b2efe 100644 --- a/elf/dl-version.c +++ b/elf/dl-version.c @@ -87,10 +87,10 @@ match_symbol (const char *name, ElfW(Word) hash, const char *string, /* Display information about what we are doing while debugging. */ if (__builtin_expect (GL(dl_debug_mask) & DL_DEBUG_VERSIONS, 0)) - _dl_debug_printf ("\ + INT(_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); + string, map->l_name[0] + ? map->l_name : _dl_argv[0], name); if (__builtin_expect (map->l_info[VERSYMIDX (DT_VERDEF)] == NULL, 0)) { @@ -214,9 +214,9 @@ _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: - _dl_signal_error (errval, (*map->l_name - ? map->l_name : _dl_argv[0]), - NULL, errstring); + INT(_dl_signal_error) (errval, (*map->l_name + ? map->l_name : _dl_argv[0]), + NULL, errstring); } while (1) @@ -374,6 +374,7 @@ _dl_check_map_versions (struct link_map *map, int verbose, int trace_mode) return result; } +INTDEF (_dl_check_map_versions) int @@ -384,7 +385,8 @@ _dl_check_all_versions (struct link_map *map, int verbose, int trace_mode) int result = 0; for (l = map; l != NULL; l = l->l_next) - result |= ! l->l_faked && _dl_check_map_versions (l, verbose, trace_mode); + result |= (! l->l_faked + && INT(_dl_check_map_versions) (l, verbose, trace_mode)); return result; } diff --git a/elf/do-lookup.h b/elf/do-lookup.h index 18d1ab5bfe..c42c93ae27 100644 --- a/elf/do-lookup.h +++ b/elf/do-lookup.h @@ -61,8 +61,8 @@ 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)) - _dl_debug_printf ("symbol=%s; lookup in file=%s\n", undef_name, - map->l_name[0] ? map->l_name : _dl_argv[0]); + INT(_dl_debug_printf) ("symbol=%s; lookup in file=%s\n", undef_name, + map->l_name[0] ? map->l_name : _dl_argv[0]); 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 b835bd5dda..4dd288b072 100644 --- a/elf/rtld.c +++ b/elf/rtld.c @@ -297,15 +297,14 @@ relocate_doit (void *a) { struct relocate_args *args = (struct relocate_args *) a; - _dl_relocate_object (args->l, args->l->l_scope, - args->lazy, 0); + INT(_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->main_map = _dl_map_object (NULL, args->str, 0, lt_library, 0, 0); + args->main_map = INT(_dl_map_object) (NULL, args->str, 0, lt_library, 0, 0); } static void @@ -495,7 +494,7 @@ of this helper program; chances are you did not intend to run this program.\n\ struct map_args args; args.str = _dl_argv[0]; - (void) _dl_catch_error (&objname, &err_str, map_doit, &args); + (void) INT(_dl_catch_error) (&objname, &err_str, map_doit, &args); if (__builtin_expect (err_str != NULL, 0)) { if (err_str != _dl_out_of_memory) @@ -506,7 +505,7 @@ of this helper program; chances are you did not intend to run this program.\n\ else { HP_TIMING_NOW (start); - _dl_map_object (NULL, _dl_argv[0], 0, lt_library, 0, 0); + INT(_dl_map_object) (NULL, _dl_argv[0], 0, lt_library, 0, 0); HP_TIMING_NOW (stop); HP_TIMING_DIFF (load_time, start, stop); @@ -703,8 +702,9 @@ of this helper program; chances are you did not intend to run this program.\n\ && (__builtin_expect (! __libc_enable_secure, 1) || strchr (p, '/') == NULL)) { - struct link_map *new_map = _dl_map_object (GL(dl_loaded), p, 1, - lt_library, 0, 0); + struct link_map *new_map = INT(_dl_map_object) (GL(dl_loaded), p, + 1, lt_library, + 0, 0); if (++new_map->l_opencount == 1) /* It is no duplicate. */ ++npreloads; @@ -771,8 +771,10 @@ of this helper program; chances are you did not intend to run this program.\n\ while ((p = strsep (&runp, ": \t\n")) != NULL) if (p[0] != '\0') { - struct link_map *new_map = _dl_map_object (GL(dl_loaded), p, 1, - lt_library, 0, 0); + struct link_map *new_map = INT(_dl_map_object) (GL(dl_loaded), + p, 1, + lt_library, + 0, 0); if (++new_map->l_opencount == 1) /* It is no duplicate. */ ++npreloads; @@ -782,8 +784,8 @@ of this helper program; chances are you did not intend to run this program.\n\ if (problem != NULL) { char *p = strndupa (problem, file_size - (problem - file)); - struct link_map *new_map = _dl_map_object (GL(dl_loaded), p, 1, - lt_library, 0, 0); + struct link_map *new_map = INT(_dl_map_object) (GL(dl_loaded), p, 1, + lt_library, 0, 0); if (++new_map->l_opencount == 1) /* It is no duplicate. */ ++npreloads; @@ -816,7 +818,7 @@ of this helper program; chances are you did not intend to run this program.\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); - _dl_map_object_deps (GL(dl_loaded), preloads, npreloads, mode == trace); + INT(_dl_map_object_deps) (GL(dl_loaded), preloads, npreloads, mode == trace); HP_TIMING_NOW (stop); HP_TIMING_DIFF (diff, start, stop); HP_TIMING_ACCUM_NT (load_time, diff); @@ -938,9 +940,9 @@ of this helper program; chances are you did not intend to run this program.\n\ ElfW(Addr) loadbase; lookup_t result; - result = _dl_lookup_symbol (_dl_argv[i], GL(dl_loaded), - &ref, GL(dl_loaded)->l_scope, - ELF_RTYPE_CLASS_PLT, 1); + result = INT(_dl_lookup_symbol) (_dl_argv[i], GL(dl_loaded), + &ref, GL(dl_loaded)->l_scope, + ELF_RTYPE_CLASS_PLT, 1); loadbase = LOOKUP_VALUE_ADDRESS (result); @@ -976,8 +978,8 @@ of this helper program; chances are you did not intend to run this program.\n\ if ((GL(dl_debug_mask) & DL_DEBUG_PRELINK) && GL(dl_rtld_map).l_opencount > 1) - _dl_relocate_object (&GL(dl_rtld_map), GL(dl_loaded)->l_scope, - 0, 0); + INT(_dl_relocate_object) (&GL(dl_rtld_map), + GL(dl_loaded)->l_scope, 0, 0); } #define VERNEEDTAG (DT_NUM + DT_THISPROCNUM + DT_VERSIONTAGIDX (DT_VERNEED)) @@ -1174,7 +1176,8 @@ of this helper program; chances are you did not intend to run this program.\n\ } if (l != &GL(dl_rtld_map)) - _dl_relocate_object (l, l->l_scope, GL(dl_lazy), consider_profiling); + INT(_dl_relocate_object) (l, l->l_scope, GL(dl_lazy), + consider_profiling); l = l->l_prev; } @@ -1196,14 +1199,15 @@ of this helper program; chances are you did not intend to run this program.\n\ 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. */ - _dl_start_profile (GL(dl_profile_map), GL(dl_profile_output)); + INT(_dl_start_profile) (GL(dl_profile_map), GL(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); - _dl_relocate_object (&GL(dl_rtld_map), GL(dl_loaded)->l_scope, 0, 0); + INT(_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); @@ -1248,12 +1252,12 @@ of this helper program; chances are you did not intend to run this program.\n\ /* Notify the debugger that all objects are now mapped in. */ r->r_state = RT_ADD; - _dl_debug_state (); + INT(_dl_debug_state) (); } #ifndef MAP_COPY /* We must munmap() the cache file. */ - _dl_unload_cache (); + INT(_dl_unload_cache) (); #endif /* Once we return, _dl_sysdep_start will invoke @@ -1593,8 +1597,9 @@ print_statistics (void) if (HP_TIMING_AVAIL) { HP_TIMING_PRINT (buf, sizeof (buf), rtld_total_time); - _dl_debug_printf ("\nruntime linker statistics:\n" - " total startup time in dynamic loader: %s\n", buf); + INT(_dl_debug_printf) ("\nruntime linker statistics:\n" + " total startup time in dynamic loader: %s\n", + buf); } /* Print relocation statistics. */ @@ -1616,14 +1621,15 @@ print_statistics (void) *wp++ = *cp++; } *wp = '\0'; - _dl_debug_printf (" time needed for relocation: %s (%s%%)\n", - buf, pbuf); + INT(_dl_debug_printf) ("\ + time needed for relocation: %s (%s%%)\n", + buf, pbuf); } #endif - _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)); + INT(_dl_debug_printf) (" number of relocations: %lu\n", + GL(dl_num_relocations)); + INT(_dl_debug_printf) (" number of relocations from cache: %lu\n", + GL(dl_num_cache_relocations)); #ifndef HP_TIMING_NONAVAIL /* Time spend while loading the object and the dependencies. */ @@ -1645,8 +1651,9 @@ print_statistics (void) *wp++ = *cp++; } *wp = '\0'; - _dl_debug_printf (" time needed to load objects: %s (%s%%)\n", - buf, pbuf); + INT(_dl_debug_printf) ("\ + time needed to load objects: %s (%s%%)\n", + buf, pbuf); } #endif } -- cgit 1.4.1