* elf/dl-lookup.c (_dl_debug_bindings): Remove unised symbol_scope
[glibc.git] / elf / dl-dst.h
blob83d16bdb0e090dcf75404111c00ceb018f409c50
1 /* Handling of dynamic sring tokens.
2 Copyright (C) 1999,2001,2002,2003,2004,2006 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, write to the Free
17 Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
18 02111-1307 USA. */
20 /* Determine the number of DST elements in the name. Only if IS_PATH is
21 nonzero paths are recognized (i.e., multiple, ':' separated filenames). */
22 #define DL_DST_COUNT(name, is_path) \
23 ({ \
24 size_t __cnt = 0; \
25 const char *__sf = strchr (name, '$'); \
27 if (__builtin_expect (__sf != NULL, 0)) \
28 __cnt = _dl_dst_count (__sf, is_path); \
30 __cnt; })
31 #ifndef IS_IN_rtld
32 # define _dl_dst_count GLRO(dl_dst_count)
33 #endif
36 /* Guess from the number of DSTs the length of the result string. */
37 #define DL_DST_REQUIRED(l, name, len, cnt) \
38 ({ \
39 size_t __len = (len); \
40 size_t __cnt = (cnt); \
42 if (__cnt > 0) \
43 { \
44 size_t origin_len; \
45 /* Now we make a guess how many extra characters on top of the \
46 length of S we need to represent the result. We know that \
47 we have CNT replacements. Each at most can use \
48 MAX (strlen (ORIGIN), strlen (_dl_platform)) \
49 minus 7 (which is the length of "$ORIGIN"). \
51 First get the origin string if it is not available yet. \
52 This can only happen for the map of the executable. */ \
53 DL_DST_REQ_STATIC \
54 if ((l)->l_origin == NULL) \
55 { \
56 assert ((l)->l_name[0] == '\0'); \
57 (l)->l_origin = _dl_get_origin (); \
58 origin_len = ((l)->l_origin && (l)->l_origin != (char *) -1 \
59 ? strlen ((l)->l_origin) : 0); \
60 } \
61 else \
62 origin_len = (l)->l_origin == (char *) -1 \
63 ? 0 : strlen ((l)->l_origin); \
65 __len += __cnt * (MAX (origin_len, GLRO(dl_platformlen)) - 7); \
66 } \
68 __len; })
70 #ifdef SHARED
71 # define DL_DST_REQ_STATIC /* nothing */
72 #else
73 # define DL_DST_REQ_STATIC \
74 if ((l) == NULL) \
75 { \
76 const char *origin = _dl_get_origin (); \
77 origin_len = (origin && origin != (char *) -1 ? strlen (origin) : 0); \
78 } \
79 else
80 #endif
82 #ifndef IS_IN_rtld
83 # define _dl_get_origin GLRO(dl_get_origin)
84 # define _dl_dst_substitute GLRO(dl_dst_substitute)
85 #endif