1999-05-06 01:29:18 +02:00
|
|
|
/* Handling of dynamic sring tokens.
|
2003-12-31 12:17:09 +01:00
|
|
|
Copyright (C) 1999, 2001, 2002, 2003 Free Software Foundation, Inc.
|
1999-05-06 01:29:18 +02:00
|
|
|
This file is part of the GNU C Library.
|
|
|
|
|
|
|
|
The GNU C Library is free software; you can redistribute it and/or
|
2001-07-06 06:58:11 +02:00
|
|
|
modify it under the terms of the GNU Lesser General Public
|
|
|
|
License as published by the Free Software Foundation; either
|
|
|
|
version 2.1 of the License, or (at your option) any later version.
|
1999-05-06 01:29:18 +02:00
|
|
|
|
|
|
|
The GNU C Library is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
2001-07-06 06:58:11 +02:00
|
|
|
Lesser General Public License for more details.
|
1999-05-06 01:29:18 +02:00
|
|
|
|
2001-07-06 06:58:11 +02:00
|
|
|
You should have received a copy of the GNU Lesser General Public
|
|
|
|
License along with the GNU C Library; if not, write to the Free
|
|
|
|
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
|
|
|
|
02111-1307 USA. */
|
1999-05-06 01:29:18 +02:00
|
|
|
|
|
|
|
/* Determine the number of DST elements in the name. Only if IS_PATH is
|
|
|
|
nonzero paths are recognized (i.e., multiple, ':' separated filenames). */
|
|
|
|
#define DL_DST_COUNT(name, is_path) \
|
|
|
|
({ \
|
|
|
|
size_t __cnt = 0; \
|
|
|
|
const char *__sf = strchr (name, '$'); \
|
|
|
|
\
|
2001-03-20 07:52:36 +01:00
|
|
|
if (__builtin_expect (__sf != NULL, 0)) \
|
2002-02-06 15:14:51 +01:00
|
|
|
__cnt = INTUSE(_dl_dst_count) (__sf, is_path); \
|
1999-05-06 01:29:18 +02:00
|
|
|
\
|
|
|
|
__cnt; })
|
|
|
|
|
|
|
|
/* Prototype for used function. */
|
|
|
|
extern size_t _dl_dst_count (const char *name, int is_path);
|
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.
2002-02-03 01:31:37 +01:00
|
|
|
extern size_t _dl_dst_count_internal (const char *name, int is_path);
|
1999-05-06 01:29:18 +02:00
|
|
|
|
|
|
|
|
1999-06-28 17:52:36 +02:00
|
|
|
/* Guess from the number of DSTs the length of the result string. */
|
1999-05-06 01:29:18 +02:00
|
|
|
#define DL_DST_REQUIRED(l, name, len, cnt) \
|
|
|
|
({ \
|
|
|
|
size_t __len = (len); \
|
2003-12-31 12:17:09 +01:00
|
|
|
size_t __cnt = (cnt); \
|
1999-05-06 01:29:18 +02:00
|
|
|
\
|
2003-12-31 12:17:09 +01:00
|
|
|
if (__cnt > 0) \
|
1999-05-06 01:29:18 +02:00
|
|
|
{ \
|
2003-12-31 12:17:09 +01:00
|
|
|
size_t origin_len; \
|
|
|
|
/* Now we make a guess how many extra characters on top of the \
|
|
|
|
length of S we need to represent the result. We know that \
|
|
|
|
we have CNT replacements. Each at most can use \
|
|
|
|
MAX (strlen (ORIGIN), strlen (_dl_platform)) \
|
|
|
|
minus 7 (which is the length of "$ORIGIN"). \
|
|
|
|
\
|
|
|
|
First get the origin string if it is not available yet. \
|
|
|
|
This can only happen for the map of the executable. */ \
|
|
|
|
if ((l)->l_origin == NULL) \
|
|
|
|
{ \
|
|
|
|
assert ((l)->l_name[0] == '\0'); \
|
|
|
|
(l)->l_origin = _dl_get_origin (); \
|
|
|
|
origin_len = ((l)->l_origin && (l)->l_origin != (char *) -1 \
|
|
|
|
? strlen ((l)->l_origin) : 0); \
|
|
|
|
} \
|
|
|
|
else \
|
|
|
|
origin_len = (l)->l_origin == (char *) -1 \
|
|
|
|
? 0 : strlen ((l)->l_origin); \
|
|
|
|
\
|
|
|
|
__len += __cnt * (MAX (origin_len, GL(dl_platformlen)) - 7); \
|
1999-05-06 01:29:18 +02:00
|
|
|
} \
|
|
|
|
\
|
2003-12-31 12:17:09 +01:00
|
|
|
__len; })
|
1999-05-06 01:29:18 +02:00
|
|
|
|
|
|
|
/* Find origin of the executable. */
|
|
|
|
extern const char *_dl_get_origin (void);
|
2002-03-01 10:44:29 +01:00
|
|
|
extern const char *_dl_get_origin_internal (void);
|
|
|
|
|
2002-04-08 20:50:41 +02:00
|
|
|
#ifdef IS_IN_rtld
|
2002-03-01 10:44:29 +01:00
|
|
|
# define _dl_get_origin INTUSE(_dl_get_origin)
|
|
|
|
#endif
|
1999-05-06 01:29:18 +02:00
|
|
|
|
|
|
|
/* Prototype for used function. */
|
|
|
|
extern char *_dl_dst_substitute (struct link_map *l, const char *name,
|
|
|
|
char *result, int is_path);
|
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.
2002-02-03 01:31:37 +01:00
|
|
|
extern char *_dl_dst_substitute_internal (struct link_map *l, const char *name,
|
|
|
|
char *result, int is_path);
|