* string/Makefile (tests): Add bug-envz1.
[glibc.git] / include / libc-symbols.h
blobda46f5e8040e15395b97d7284203f78707410a8d
1 /* Support macros for making weak and strong aliases for symbols,
2 and for using symbol sets and linker warnings with GNU ld.
3 Copyright (C) 1995-1998,2000-2003,2004,2005,2006
4 Free Software Foundation, Inc.
5 This file is part of the GNU C Library.
7 The GNU C Library is free software; you can redistribute it and/or
8 modify it under the terms of the GNU Lesser General Public
9 License as published by the Free Software Foundation; either
10 version 2.1 of the License, or (at your option) any later version.
12 The GNU C Library is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 Lesser General Public License for more details.
17 You should have received a copy of the GNU Lesser General Public
18 License along with the GNU C Library; if not, write to the Free
19 Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
20 02111-1307 USA. */
22 #ifndef _LIBC_SYMBOLS_H
23 #define _LIBC_SYMBOLS_H 1
25 /* This file's macros are included implicitly in the compilation of every
26 file in the C library by -imacros.
28 We include config.h which is generated by configure.
29 It should define for us the following symbols:
31 * HAVE_ASM_SET_DIRECTIVE if we have `.set B, A' instead of `A = B'.
32 * ASM_GLOBAL_DIRECTIVE with `.globl' or `.global'.
33 * ASM_TYPE_DIRECTIVE_PREFIX with `@' or `#' or whatever for .type,
34 or leave it undefined if there is no .type directive.
35 * HAVE_ELF if using ELF, which supports weak symbols using `.weak'.
36 * HAVE_ASM_WEAK_DIRECTIVE if we have weak symbols using `.weak'.
37 * HAVE_ASM_WEAKEXT_DIRECTIVE if we have weak symbols using `.weakext'.
41 /* This is defined for the compilation of all C library code. features.h
42 tests this to avoid inclusion of stubs.h while compiling the library,
43 before stubs.h has been generated. Some library code that is shared
44 with other packages also tests this symbol to see if it is being
45 compiled as part of the C library. We must define this before including
46 config.h, because it makes some definitions conditional on whether libc
47 itself is being compiled, or just some generator program. */
48 #define _LIBC 1
50 /* Enable declarations of GNU extensions, since we are compiling them. */
51 #define _GNU_SOURCE 1
52 /* And we also need the data for the reentrant functions. */
53 #define _REENTRANT 1
55 #include <config.h>
57 /* The symbols in all the user (non-_) macros are C symbols.
58 NO HAVE_ELF implies a.out. */
60 #if defined HAVE_ASM_WEAK_DIRECTIVE || defined HAVE_ASM_WEAKEXT_DIRECTIVE
61 # define HAVE_WEAK_SYMBOLS
62 #endif
64 #ifndef __SYMBOL_PREFIX
65 # ifdef NO_UNDERSCORES
66 # define __SYMBOL_PREFIX
67 # else
68 # define __SYMBOL_PREFIX "_"
69 # endif
70 #endif
72 #ifndef C_SYMBOL_NAME
73 # ifdef NO_UNDERSCORES
74 # define C_SYMBOL_NAME(name) name
75 # else
76 # define C_SYMBOL_NAME(name) _##name
77 # endif
78 #endif
80 #ifndef ASM_LINE_SEP
81 # define ASM_LINE_SEP ;
82 #endif
84 #ifdef HAVE_ASM_GLOBAL_DOT_NAME
85 # ifndef C_SYMBOL_DOT_NAME
86 # if defined __GNUC__ && defined __GNUC_MINOR__ \
87 && (__GNUC__ << 16) + __GNUC_MINOR__ >= (3 << 16) + 1
88 # define C_SYMBOL_DOT_NAME(name) .name
89 # else
90 # define C_SYMBOL_DOT_NAME(name) .##name
91 # endif
92 # endif
93 #endif
95 #ifndef __ASSEMBLER__
96 /* GCC understands weak symbols and aliases; use its interface where
97 possible, instead of embedded assembly language. */
99 /* Define ALIASNAME as a strong alias for NAME. */
100 # define strong_alias(name, aliasname) _strong_alias(name, aliasname)
101 # define _strong_alias(name, aliasname) \
102 extern __typeof (name) aliasname __attribute__ ((alias (#name)));
104 /* This comes between the return type and function name in
105 a function definition to make that definition weak. */
106 # define weak_function __attribute__ ((weak))
107 # define weak_const_function __attribute__ ((weak, __const__))
109 # ifdef HAVE_WEAK_SYMBOLS
111 /* Define ALIASNAME as a weak alias for NAME.
112 If weak aliases are not available, this defines a strong alias. */
113 # define weak_alias(name, aliasname) _weak_alias (name, aliasname)
114 # define _weak_alias(name, aliasname) \
115 extern __typeof (name) aliasname __attribute__ ((weak, alias (#name)));
117 /* Declare SYMBOL as weak undefined symbol (resolved to 0 if not defined). */
118 # define weak_extern(symbol) _weak_extern (weak symbol)
119 # define _weak_extern(expr) _Pragma (#expr)
121 # else
123 # define weak_alias(name, aliasname) strong_alias(name, aliasname)
124 # define weak_extern(symbol) /* Nothing. */
126 # endif
128 #else /* __ASSEMBLER__ */
130 # ifdef HAVE_ASM_SET_DIRECTIVE
131 # ifdef HAVE_ASM_GLOBAL_DOT_NAME
132 # define strong_alias(original, alias) \
133 ASM_GLOBAL_DIRECTIVE C_SYMBOL_NAME (alias) ASM_LINE_SEP \
134 .set C_SYMBOL_NAME (alias),C_SYMBOL_NAME (original) ASM_LINE_SEP \
135 ASM_GLOBAL_DIRECTIVE C_SYMBOL_DOT_NAME (alias) ASM_LINE_SEP \
136 .set C_SYMBOL_DOT_NAME (alias),C_SYMBOL_DOT_NAME (original)
137 # define strong_data_alias(original, alias) \
138 ASM_GLOBAL_DIRECTIVE C_SYMBOL_NAME (alias) ASM_LINE_SEP \
139 .set C_SYMBOL_NAME (alias),C_SYMBOL_NAME (original)
140 # else
141 # define strong_alias(original, alias) \
142 ASM_GLOBAL_DIRECTIVE C_SYMBOL_NAME (alias) ASM_LINE_SEP \
143 .set C_SYMBOL_NAME (alias),C_SYMBOL_NAME (original)
144 # define strong_data_alias(original, alias) strong_alias(original, alias)
145 # endif
146 # else
147 # ifdef HAVE_ASM_GLOBAL_DOT_NAME
148 # define strong_alias(original, alias) \
149 ASM_GLOBAL_DIRECTIVE C_SYMBOL_NAME (alias) ASM_LINE_SEP \
150 C_SYMBOL_NAME (alias) = C_SYMBOL_NAME (original) ASM_LINE_SEP \
151 ASM_GLOBAL_DIRECTIVE C_SYMBOL_DOT_NAME (alias) ASM_LINE_SEP \
152 C_SYMBOL_DOT_NAME (alias) = C_SYMBOL_DOT_NAME (original)
153 # define strong_data_alias(original, alias) \
154 ASM_GLOBAL_DIRECTIVE C_SYMBOL_NAME (alias) ASM_LINE_SEP \
155 C_SYMBOL_NAME (alias) = C_SYMBOL_NAME (original)
156 # else
157 # define strong_alias(original, alias) \
158 ASM_GLOBAL_DIRECTIVE C_SYMBOL_NAME (alias) ASM_LINE_SEP \
159 C_SYMBOL_NAME (alias) = C_SYMBOL_NAME (original)
160 # define strong_data_alias(original, alias) strong_alias(original, alias)
161 # endif
162 # endif
164 # ifdef HAVE_WEAK_SYMBOLS
165 # ifdef HAVE_ASM_WEAKEXT_DIRECTIVE
166 # ifdef HAVE_ASM_GLOBAL_DOT_NAME
167 # define weak_alias(original, alias) \
168 .weakext C_SYMBOL_NAME (alias), C_SYMBOL_NAME (original) ASM_LINE_SEP \
169 .weakext C_SYMBOL_DOT_NAME (alias), C_SYMBOL_DOT_NAME (original)
170 # else
171 # define weak_alias(original, alias) \
172 .weakext C_SYMBOL_NAME (alias), C_SYMBOL_NAME (original)
173 # endif
174 # define weak_extern(symbol) \
175 .weakext C_SYMBOL_NAME (symbol)
177 # else /* ! HAVE_ASM_WEAKEXT_DIRECTIVE */
179 # ifdef HAVE_ASM_GLOBAL_DOT_NAME
180 # define weak_alias(original, alias) \
181 .weak C_SYMBOL_NAME (alias) ASM_LINE_SEP \
182 C_SYMBOL_NAME (alias) = C_SYMBOL_NAME (original) ASM_LINE_SEP \
183 .weak C_SYMBOL_DOT_NAME (alias) ASM_LINE_SEP \
184 C_SYMBOL_DOT_NAME (alias) = C_SYMBOL_DOT_NAME (original)
185 # else
186 # define weak_alias(original, alias) \
187 .weak C_SYMBOL_NAME (alias) ASM_LINE_SEP \
188 C_SYMBOL_NAME (alias) = C_SYMBOL_NAME (original)
189 # endif
191 # define weak_extern(symbol) \
192 .weak C_SYMBOL_NAME (symbol)
194 # endif /* ! HAVE_ASM_WEAKEXT_DIRECTIVE */
196 # else /* ! HAVE_WEAK_SYMBOLS */
198 # define weak_alias(original, alias) strong_alias(original, alias)
199 # define weak_extern(symbol) /* Nothing */
200 # endif /* ! HAVE_WEAK_SYMBOLS */
202 #endif /* __ASSEMBLER__ */
204 /* On some platforms we can make internal function calls (i.e., calls of
205 functions not exported) a bit faster by using a different calling
206 convention. */
207 #ifndef internal_function
208 # define internal_function /* empty */
209 #endif
211 /* Prepare for the case that `__builtin_expect' is not available. */
212 #ifndef HAVE_BUILTIN_EXPECT
213 # define __builtin_expect(expr, val) (expr)
214 #endif
216 /* Determine the return address. */
217 #define RETURN_ADDRESS(nr) \
218 __builtin_extract_return_addr (__builtin_return_address (nr))
220 /* When a reference to SYMBOL is encountered, the linker will emit a
221 warning message MSG. */
222 #ifdef HAVE_ELF
224 /* We want the .gnu.warning.SYMBOL section to be unallocated. */
225 # ifdef HAVE_ASM_PREVIOUS_DIRECTIVE
226 # define __make_section_unallocated(section_string) \
227 asm (".section " section_string "\n\t.previous");
228 # elif defined HAVE_ASM_POPSECTION_DIRECTIVE
229 # define __make_section_unallocated(section_string) \
230 asm (".pushsection " section_string "\n\t.popsection");
231 # else
232 # define __make_section_unallocated(section_string)
233 # endif
235 /* Tacking on "\n\t#" to the section name makes gcc put it's bogus
236 section attributes on what looks like a comment to the assembler. */
237 # ifdef HAVE_SECTION_QUOTES
238 # define __sec_comment "\"\n\t#\""
239 # else
240 # define __sec_comment "\n\t#"
241 # endif
242 # define link_warning(symbol, msg) \
243 __make_section_unallocated (".gnu.warning." #symbol) \
244 static const char __evoke_link_warning_##symbol[] \
245 __attribute__ ((used, section (".gnu.warning." #symbol __sec_comment))) \
246 = msg;
247 # define libc_freeres_ptr(decl) \
248 __make_section_unallocated ("__libc_freeres_ptrs, \"aw\", %nobits") \
249 decl __attribute__ ((section ("__libc_freeres_ptrs" __sec_comment)))
250 # define __libc_freeres_fn_section \
251 __attribute__ ((section ("__libc_freeres_fn")))
252 #else /* Not ELF: a.out */
253 # ifdef HAVE_XCOFF
254 /* XCOFF does not support .stabs.
255 The native aix linker will remove the .stab and .stabstr sections
256 The gnu linker will have a fatal error if there is a relocation for
257 symbol in the .stab section. Silently disable this macro. */
258 # define link_warning(symbol, msg)
259 # else
260 # define link_warning(symbol, msg) \
261 asm (".stabs \"" msg "\",30,0,0,0\n\t" \
262 ".stabs \"" __SYMBOL_PREFIX #symbol "\",1,0,0,0\n");
263 # endif /* XCOFF */
264 # define libc_freeres_ptr(decl) decl
265 # define __libc_freeres_fn_section
266 #endif
267 #define libc_freeres_fn(name) \
268 static void name (void) __attribute_used__ __libc_freeres_fn_section; \
269 text_set_element (__libc_subfreeres, name); \
270 static void name (void)
272 /* A canned warning for sysdeps/stub functions. */
273 #define stub_warning(name) \
274 __make_section_unallocated (".gnu.glibc-stub." #name) \
275 link_warning (name, \
276 "warning: " #name " is not implemented and will always fail")
278 /* Warning for linking functions calling dlopen into static binaries. */
279 #ifdef SHARED
280 #define static_link_warning(name)
281 #else
282 #define static_link_warning(name) static_link_warning1(name)
283 #define static_link_warning1(name) \
284 link_warning(name, "Using '" #name "' in statically linked applications \
285 requires at runtime the shared libraries from the glibc version used \
286 for linking")
287 #endif
289 /* Declare SYMBOL to be TYPE (`function' or `object') and of SIZE bytes,
290 when the assembler supports such declarations (such as in ELF).
291 This is only necessary when defining something in assembly, or playing
292 funny alias games where the size should be other than what the compiler
293 thinks it is. */
294 #define declare_symbol(symbol, type, size) \
295 declare_symbol_1 (symbol, type, size)
296 #ifdef ASM_TYPE_DIRECTIVE_PREFIX
297 # ifdef __ASSEMBLER__
298 # define declare_symbol_1(symbol, type, size) \
299 .type C_SYMBOL_NAME (symbol), \
300 declare_symbol_1_paste (ASM_TYPE_DIRECTIVE_PREFIX, type), size
301 # define declare_symbol_1_paste(a, b) declare_symbol_1_paste_1 (a,b)
302 # define declare_symbol_1_paste_1(a,b) a##b
303 # else /* Not __ASSEMBLER__. */
304 # define declare_symbol_1(symbol, type, size) \
305 asm (".type " __SYMBOL_PREFIX #symbol ", " \
306 declare_symbol_1_stringify (ASM_TYPE_DIRECTIVE_PREFIX) #type \
307 "\n\t.size " __SYMBOL_PREFIX #symbol ", " #size);
308 # define declare_symbol_1_stringify(x) declare_symbol_1_stringify_1 (x)
309 # define declare_symbol_1_stringify_1(x) #x
310 # endif /* __ASSEMBLER__ */
311 #else
312 # define declare_symbol_1(symbol, type, size) /* Nothing. */
313 #endif
320 /* Symbol set support macros. */
322 #ifdef HAVE_ELF
324 /* Make SYMBOL, which is in the text segment, an element of SET. */
325 # define text_set_element(set, symbol) _elf_set_element(set, symbol)
326 /* Make SYMBOL, which is in the data segment, an element of SET. */
327 # define data_set_element(set, symbol) _elf_set_element(set, symbol)
328 /* Make SYMBOL, which is in the bss segment, an element of SET. */
329 # define bss_set_element(set, symbol) _elf_set_element(set, symbol)
331 /* These are all done the same way in ELF.
332 There is a new section created for each set. */
333 # ifdef SHARED
334 /* When building a shared library, make the set section writable,
335 because it will need to be relocated at run time anyway. */
336 # define _elf_set_element(set, symbol) \
337 static const void *__elf_set_##set##_element_##symbol##__ \
338 __attribute__ ((used, section (#set))) = &(symbol)
339 # else
340 # define _elf_set_element(set, symbol) \
341 static const void *const __elf_set_##set##_element_##symbol##__ \
342 __attribute__ ((used, section (#set))) = &(symbol)
343 # endif
345 /* Define SET as a symbol set. This may be required (it is in a.out) to
346 be able to use the set's contents. */
347 # define symbol_set_define(set) symbol_set_declare(set)
349 /* Declare SET for use in this module, if defined in another module.
350 In a shared library, this is always local to that shared object.
351 For static linking, the set might be wholly absent and so we use
352 weak references. */
353 # define symbol_set_declare(set) \
354 extern char const __start_##set[] __symbol_set_attribute; \
355 extern char const __stop_##set[] __symbol_set_attribute;
356 # ifdef SHARED
357 # define __symbol_set_attribute attribute_hidden
358 # else
359 # define __symbol_set_attribute __attribute__ ((weak))
360 # endif
362 /* Return a pointer (void *const *) to the first element of SET. */
363 # define symbol_set_first_element(set) ((void *const *) (&__start_##set))
365 /* Return true iff PTR (a void *const *) has been incremented
366 past the last element in SET. */
367 # define symbol_set_end_p(set, ptr) ((ptr) >= (void *const *) &__stop_##set)
369 #else /* Not ELF: a.out. */
371 # ifdef HAVE_XCOFF
372 /* XCOFF does not support .stabs.
373 The native aix linker will remove the .stab and .stabstr sections
374 The gnu linker will have a fatal error if there is a relocation for
375 symbol in the .stab section. Silently disable these macros. */
376 # define text_set_element(set, symbol)
377 # define data_set_element(set, symbol)
378 # define bss_set_element(set, symbol)
379 # else
380 # define text_set_element(set, symbol) \
381 asm (".stabs \"" __SYMBOL_PREFIX #set "\",23,0,0," __SYMBOL_PREFIX #symbol)
382 # define data_set_element(set, symbol) \
383 asm (".stabs \"" __SYMBOL_PREFIX #set "\",25,0,0," __SYMBOL_PREFIX #symbol)
384 # define bss_set_element(set, symbol) ?error Must use initialized data.
385 # endif /* XCOFF */
386 # define symbol_set_define(set) void *const (set)[1];
387 # define symbol_set_declare(set) extern void *const (set)[1];
389 # define symbol_set_first_element(set) &(set)[1]
390 # define symbol_set_end_p(set, ptr) (*(ptr) == 0)
392 #endif /* ELF. */
394 #if DO_VERSIONING
395 # define symbol_version(real, name, version) \
396 _symbol_version(real, name, version)
397 # define default_symbol_version(real, name, version) \
398 _default_symbol_version(real, name, version)
399 # ifdef __ASSEMBLER__
400 # ifdef HAVE_ASM_GLOBAL_DOT_NAME
401 # define _symbol_version(real, name, version) \
402 .symver real, name##@##version ASM_LINE_SEP \
403 .symver C_SYMBOL_DOT_NAME(real), C_SYMBOL_DOT_NAME(name##@##version)
404 # define _default_symbol_version(real, name, version) \
405 .symver real, name##@##@##version ASM_LINE_SEP \
406 .symver C_SYMBOL_DOT_NAME(real), C_SYMBOL_DOT_NAME(name##@##@##version)
407 # else
408 # define _symbol_version(real, name, version) \
409 .symver real, name##@##version
410 # define _default_symbol_version(real, name, version) \
411 .symver real, name##@##@##version
412 # endif
413 # else
414 # ifdef HAVE_ASM_GLOBAL_DOT_NAME
415 # define _symbol_version(real, name, version) \
416 __asm__ (".symver " #real "," #name "@" #version "\n\t" \
417 ".symver ." #real ",." #name "@" #version)
418 # define _default_symbol_version(real, name, version) \
419 __asm__ (".symver " #real "," #name "@@" #version "\n\t" \
420 ".symver ." #real ",." #name "@@" #version)
421 # else
422 # define _symbol_version(real, name, version) \
423 __asm__ (".symver " #real "," #name "@" #version)
424 # define _default_symbol_version(real, name, version) \
425 __asm__ (".symver " #real "," #name "@@" #version)
426 # endif
427 # endif
428 #else
429 # define symbol_version(real, name, version)
430 # define default_symbol_version(real, name, version) \
431 strong_alias(real, name)
432 #endif
434 #if defined HAVE_VISIBILITY_ATTRIBUTE \
435 && (defined SHARED || defined LIBC_NONSHARED)
436 # define attribute_hidden __attribute__ ((visibility ("hidden")))
437 #else
438 # define attribute_hidden
439 #endif
441 #ifdef HAVE_TLS_MODEL_ATTRIBUTE
442 # define attribute_tls_model_ie __attribute__ ((tls_model ("initial-exec")))
443 #else
444 # define attribute_tls_model_ie
445 #endif
447 #ifdef HAVE_Z_RELRO
448 # define attribute_relro __attribute__ ((section (".data.rel.ro")))
449 #else
450 # define attribute_relro
451 #endif
453 /* Handling on non-exported internal names. We have to do this only
454 for shared code. */
455 #ifdef SHARED
456 # define INTUSE(name) name##_internal
457 # define INTDEF(name) strong_alias (name, name##_internal)
458 # define INTVARDEF(name) \
459 _INTVARDEF (name, name##_internal)
460 # if defined HAVE_VISIBILITY_ATTRIBUTE
461 # define _INTVARDEF(name, aliasname) \
462 extern __typeof (name) aliasname __attribute__ ((alias (#name), \
463 visibility ("hidden")));
464 # else
465 # define _INTVARDEF(name, aliasname) \
466 extern __typeof (name) aliasname __attribute__ ((alias (#name)));
467 # endif
468 # define INTDEF2(name, newname) strong_alias (name, newname##_internal)
469 # define INTVARDEF2(name, newname) _INTVARDEF (name, newname##_internal)
470 #else
471 # define INTUSE(name) name
472 # define INTDEF(name)
473 # define INTVARDEF(name)
474 # define INTDEF2(name, newname)
475 # define INTVARDEF2(name, newname)
476 #endif
478 /* The following macros are used for PLT bypassing within libc.so
479 (and if needed other libraries similarly).
480 First of all, you need to have the function prototyped somewhere,
481 say in foo/foo.h:
483 int foo (int __bar);
485 If calls to foo within libc.so should always go to foo defined in libc.so,
486 then in include/foo.h you add:
488 libc_hidden_proto (foo)
490 line and after the foo function definition:
492 int foo (int __bar)
494 return __bar;
496 libc_hidden_def (foo)
500 int foo (int __bar)
502 return __bar;
504 libc_hidden_weak (foo)
506 Similarly for global data. If references to foo within libc.so should
507 always go to foo defined in libc.so, then in include/foo.h you add:
509 libc_hidden_proto (foo)
511 line and after foo's definition:
513 int foo = INITIAL_FOO_VALUE;
514 libc_hidden_data_def (foo)
518 int foo = INITIAL_FOO_VALUE;
519 libc_hidden_data_weak (foo)
521 If foo is normally just an alias (strong or weak) to some other function,
522 you should use the normal strong_alias first, then add libc_hidden_def
523 or libc_hidden_weak:
525 int baz (int __bar)
527 return __bar;
529 strong_alias (baz, foo)
530 libc_hidden_weak (foo)
532 If the function should be internal to multiple objects, say ld.so and
533 libc.so, the best way is to use:
535 #if !defined NOT_IN_libc || defined IS_IN_rtld
536 hidden_proto (foo)
537 #endif
539 in include/foo.h and the normal macros at all function definitions
540 depending on what DSO they belong to.
542 If versioned_symbol macro is used to define foo,
543 libc_hidden_ver macro should be used, as in:
545 int __real_foo (int __bar)
547 return __bar;
549 versioned_symbol (libc, __real_foo, foo, GLIBC_2_1);
550 libc_hidden_ver (__real_foo, foo) */
552 #if defined SHARED && defined DO_VERSIONING \
553 && !defined HAVE_BROKEN_ALIAS_ATTRIBUTE && !defined NO_HIDDEN
554 # ifndef __ASSEMBLER__
555 # if !defined HAVE_VISIBILITY_ATTRIBUTE \
556 || defined HAVE_BROKEN_VISIBILITY_ATTRIBUTE
557 # define __hidden_proto_hiddenattr(attrs...)
558 # else
559 # define __hidden_proto_hiddenattr(attrs...) \
560 __attribute__ ((visibility ("hidden"), ##attrs))
561 # endif
562 # define hidden_proto(name, attrs...) \
563 __hidden_proto (name, __GI_##name, ##attrs)
564 # define __hidden_proto(name, internal, attrs...) \
565 extern __typeof (name) name __asm__ (__hidden_asmname (#internal)) \
566 __hidden_proto_hiddenattr (attrs);
567 # define __hidden_asmname(name) \
568 __hidden_asmname1 (__USER_LABEL_PREFIX__, name)
569 # define __hidden_asmname1(prefix, name) __hidden_asmname2(prefix, name)
570 # define __hidden_asmname2(prefix, name) #prefix name
571 # define __hidden_ver1(local, internal, name) \
572 extern __typeof (name) __EI_##name __asm__(__hidden_asmname (#internal)); \
573 extern __typeof (name) __EI_##name \
574 __attribute__((alias (__hidden_asmname (#local))))
575 # define hidden_ver(local, name) __hidden_ver1(local, __GI_##name, name);
576 # define hidden_data_ver(local, name) hidden_ver(local, name)
577 # define hidden_def(name) __hidden_ver1(__GI_##name, name, name);
578 # define hidden_data_def(name) hidden_def(name)
579 # define hidden_weak(name) \
580 __hidden_ver1(__GI_##name, name, name) __attribute__((weak));
581 # define hidden_data_weak(name) hidden_weak(name)
582 # else
583 /* For assembly, we need to do the opposite of what we do in C:
584 in assembly gcc __REDIRECT stuff is not in place, so functions
585 are defined by its normal name and we need to create the
586 __GI_* alias to it, in C __REDIRECT causes the function definition
587 to use __GI_* name and we need to add alias to the real name.
588 There is no reason to use hidden_weak over hidden_def in assembly,
589 but we provide it for consistency with the C usage.
590 hidden_proto doesn't make sense for assembly but the equivalent
591 is to call via the HIDDEN_JUMPTARGET macro instead of JUMPTARGET. */
592 # define hidden_def(name) strong_alias (name, __GI_##name)
593 # define hidden_weak(name) hidden_def (name)
594 # define hidden_ver(local, name) strong_alias (local, __GI_##name)
595 # define hidden_data_def(name) strong_data_alias (name, __GI_##name)
596 # define hidden_data_weak(name) hidden_data_def (name)
597 # define hidden_data_ver(local, name) strong_data_alias (local, __GI_##name)
598 # ifdef HAVE_ASM_GLOBAL_DOT_NAME
599 # define HIDDEN_JUMPTARGET(name) .__GI_##name
600 # else
601 # define HIDDEN_JUMPTARGET(name) __GI_##name
602 # endif
603 # endif
604 #else
605 # ifndef __ASSEMBLER__
606 # define hidden_proto(name, attrs...)
607 # else
608 # define HIDDEN_JUMPTARGET(name) JUMPTARGET(name)
609 # endif /* Not __ASSEMBLER__ */
610 # define hidden_weak(name)
611 # define hidden_def(name)
612 # define hidden_ver(local, name)
613 # define hidden_data_weak(name)
614 # define hidden_data_def(name)
615 # define hidden_data_ver(local, name)
616 #endif
618 #if !defined NOT_IN_libc
619 # define libc_hidden_proto(name, attrs...) hidden_proto (name, ##attrs)
620 # define libc_hidden_def(name) hidden_def (name)
621 # define libc_hidden_weak(name) hidden_weak (name)
622 # define libc_hidden_ver(local, name) hidden_ver (local, name)
623 # define libc_hidden_data_def(name) hidden_data_def (name)
624 # define libc_hidden_data_weak(name) hidden_data_weak (name)
625 # define libc_hidden_data_ver(local, name) hidden_data_ver (local, name)
626 #else
627 # define libc_hidden_proto(name, attrs...)
628 # define libc_hidden_def(name)
629 # define libc_hidden_weak(name)
630 # define libc_hidden_ver(local, name)
631 # define libc_hidden_data_def(name)
632 # define libc_hidden_data_weak(name)
633 # define libc_hidden_data_ver(local, name)
634 #endif
636 #if defined NOT_IN_libc && defined IS_IN_rtld
637 # define rtld_hidden_proto(name, attrs...) hidden_proto (name, ##attrs)
638 # define rtld_hidden_def(name) hidden_def (name)
639 # define rtld_hidden_weak(name) hidden_weak (name)
640 # define rtld_hidden_ver(local, name) hidden_ver (local, name)
641 # define rtld_hidden_data_def(name) hidden_data_def (name)
642 # define rtld_hidden_data_weak(name) hidden_data_weak (name)
643 # define rtld_hidden_data_ver(local, name) hidden_data_ver (local, name)
644 #else
645 # define rtld_hidden_proto(name, attrs...)
646 # define rtld_hidden_def(name)
647 # define rtld_hidden_weak(name)
648 # define rtld_hidden_ver(local, name)
649 # define rtld_hidden_data_def(name)
650 # define rtld_hidden_data_weak(name)
651 # define rtld_hidden_data_ver(local, name)
652 #endif
654 #if defined NOT_IN_libc && defined IS_IN_libm
655 # define libm_hidden_proto(name, attrs...) hidden_proto (name, ##attrs)
656 # define libm_hidden_def(name) hidden_def (name)
657 # define libm_hidden_weak(name) hidden_weak (name)
658 # define libm_hidden_ver(local, name) hidden_ver (local, name)
659 # define libm_hidden_data_def(name) hidden_data_def (name)
660 # define libm_hidden_data_weak(name) hidden_data_weak (name)
661 # define libm_hidden_data_ver(local, name) hidden_data_ver (local, name)
662 #else
663 # define libm_hidden_proto(name, attrs...)
664 # define libm_hidden_def(name)
665 # define libm_hidden_weak(name)
666 # define libm_hidden_ver(local, name)
667 # define libm_hidden_data_def(name)
668 # define libm_hidden_data_weak(name)
669 # define libm_hidden_data_ver(local, name)
670 #endif
672 #if defined NOT_IN_libc && defined IS_IN_libresolv
673 # define libresolv_hidden_proto(name, attrs...) hidden_proto (name, ##attrs)
674 # define libresolv_hidden_def(name) hidden_def (name)
675 # define libresolv_hidden_weak(name) hidden_weak (name)
676 # define libresolv_hidden_ver(local, name) hidden_ver (local, name)
677 # define libresolv_hidden_data_def(name) hidden_data_def (name)
678 # define libresolv_hidden_data_weak(name) hidden_data_weak (name)
679 # define libresolv_hidden_data_ver(local, name) hidden_data_ver (local, name)
680 #else
681 # define libresolv_hidden_proto(name, attrs...)
682 # define libresolv_hidden_def(name)
683 # define libresolv_hidden_weak(name)
684 # define libresolv_hidden_ver(local, name)
685 # define libresolv_hidden_data_def(name)
686 # define libresolv_hidden_data_weak(name)
687 # define libresolv_hidden_data_ver(local, name)
688 #endif
690 #if defined NOT_IN_libc && defined IS_IN_librt
691 # define librt_hidden_proto(name, attrs...) hidden_proto (name, ##attrs)
692 # define librt_hidden_def(name) hidden_def (name)
693 # define librt_hidden_weak(name) hidden_weak (name)
694 # define librt_hidden_ver(local, name) hidden_ver (local, name)
695 # define librt_hidden_data_def(name) hidden_data_def (name)
696 # define librt_hidden_data_weak(name) hidden_data_weak (name)
697 # define librt_hidden_data_ver(local, name) hidden_data_ver (local, name)
698 #else
699 # define librt_hidden_proto(name, attrs...)
700 # define librt_hidden_def(name)
701 # define librt_hidden_weak(name)
702 # define librt_hidden_ver(local, name)
703 # define librt_hidden_data_def(name)
704 # define librt_hidden_data_weak(name)
705 # define librt_hidden_data_ver(local, name)
706 #endif
708 #if defined NOT_IN_libc && defined IS_IN_libdl
709 # define libdl_hidden_proto(name, attrs...) hidden_proto (name, ##attrs)
710 # define libdl_hidden_def(name) hidden_def (name)
711 # define libdl_hidden_weak(name) hidden_weak (name)
712 # define libdl_hidden_ver(local, name) hidden_ver (local, name)
713 # define libdl_hidden_data_def(name) hidden_data_def (name)
714 # define libdl_hidden_data_weak(name) hidden_data_weak (name)
715 # define libdl_hidden_data_ver(local, name) hidden_data_ver (local, name)
716 #else
717 # define libdl_hidden_proto(name, attrs...)
718 # define libdl_hidden_def(name)
719 # define libdl_hidden_weak(name)
720 # define libdl_hidden_ver(local, name)
721 # define libdl_hidden_data_def(name)
722 # define libdl_hidden_data_weak(name)
723 # define libdl_hidden_data_ver(local, name)
724 #endif
726 #if defined NOT_IN_libc && defined IS_IN_libnss_files
727 # define libnss_files_hidden_proto(name, attrs...) hidden_proto (name, ##attrs)
728 # define libnss_files_hidden_def(name) hidden_def (name)
729 # define libnss_files_hidden_weak(name) hidden_weak (name)
730 # define libnss_files_hidden_ver(local, name) hidden_ver (local, name)
731 # define libnss_files_hidden_data_def(name) hidden_data_def (name)
732 # define libnss_files_hidden_data_weak(name) hidden_data_weak (name)
733 # define libnss_files_hidden_data_ver(local, name) hidden_data_ver(local, name)
734 #else
735 # define libnss_files_hidden_proto(name, attrs...)
736 # define libnss_files_hidden_def(name)
737 # define libnss_files_hidden_weak(name)
738 # define libnss_files_hidden_ver(local, name)
739 # define libnss_files_hidden_data_def(name)
740 # define libnss_files_hidden_data_weak(name)
741 # define libnss_files_hidden_data_ver(local, name)
742 #endif
744 #if defined NOT_IN_libc && defined IS_IN_libnsl
745 # define libnsl_hidden_proto(name, attrs...) hidden_proto (name, ##attrs)
746 # define libnsl_hidden_def(name) hidden_def (name)
747 # define libnsl_hidden_weak(name) hidden_weak (name)
748 # define libnsl_hidden_ver(local, name) hidden_ver (local, name)
749 # define libnsl_hidden_data_def(name) hidden_data_def (name)
750 # define libnsl_hidden_data_weak(name) hidden_data_weak (name)
751 # define libnsl_hidden_data_ver(local, name) hidden_data_ver (local, name)
752 #else
753 # define libnsl_hidden_proto(name, attrs...)
754 # define libnsl_hidden_def(name)
755 # define libnsl_hidden_weak(name)
756 # define libnsl_hidden_ver(local, name)
757 # define libnsl_hidden_data_def(name)
758 # define libnsl_hidden_data_weak(name)
759 # define libnsl_hidden_data_ver(local, name)
760 #endif
762 #if defined NOT_IN_libc && defined IS_IN_libnss_nisplus
763 # define libnss_nisplus_hidden_proto(name, attrs...) hidden_proto (name, ##attrs)
764 # define libnss_nisplus_hidden_def(name) hidden_def (name)
765 # define libnss_nisplus_hidden_weak(name) hidden_weak (name)
766 # define libnss_nisplus_hidden_ver(local, name) hidden_ver (local, name)
767 # define libnss_nisplus_hidden_data_def(name) hidden_data_def (name)
768 # define libnss_nisplus_hidden_data_weak(name) hidden_data_weak (name)
769 # define libnss_nisplus_hidden_data_ver(local, name) hidden_data_ver (local, name)
770 #else
771 # define libnss_nisplus_hidden_proto(name, attrs...)
772 # define libnss_nisplus_hidden_def(name)
773 # define libnss_nisplus_hidden_weak(name)
774 # define libnss_nisplus_hidden_ver(local, name)
775 # define libnss_nisplus_hidden_data_def(name)
776 # define libnss_nisplus_hidden_data_weak(name)
777 # define libnss_nisplus_hidden_data_ver(local, name)
778 #endif
780 #ifdef HAVE_BUILTIN_REDIRECTION
781 # define libc_hidden_builtin_proto(name, attrs...) libc_hidden_proto (name, ##attrs)
782 # define libc_hidden_builtin_def(name) libc_hidden_def (name)
783 # define libc_hidden_builtin_weak(name) libc_hidden_weak (name)
784 # define libc_hidden_builtin_ver(local, name) libc_hidden_ver (local, name)
785 # ifdef __ASSEMBLER__
786 # define HIDDEN_BUILTIN_JUMPTARGET(name) HIDDEN_JUMPTARGET(name)
787 # endif
788 #else
789 # define libc_hidden_builtin_proto(name, attrs...)
790 # define libc_hidden_builtin_def(name)
791 # define libc_hidden_builtin_weak(name)
792 # define libc_hidden_builtin_ver(local, name)
793 # ifdef __ASSEMBLER__
794 # define HIDDEN_BUILTIN_JUMPTARGET(name) JUMPTARGET(name)
795 # endif
796 #endif
798 #if defined NOT_IN_libc && defined IS_IN_libutil
799 # define libutil_hidden_proto(name, attrs...) hidden_proto (name, ##attrs)
800 # define libutil_hidden_def(name) hidden_def (name)
801 # define libutil_hidden_weak(name) hidden_weak (name)
802 # define libutil_hidden_ver(local, name) hidden_ver (local, name)
803 # define libutil_hidden_data_def(name) hidden_data_def (name)
804 # define libutil_hidden_data_weak(name) hidden_data_weak (name)
805 # define libutil_hidden_data_ver(local, name) hidden_data_ver (local, name)
806 #else
807 # define libutil_hidden_proto(name, attrs...)
808 # define libutil_hidden_def(name)
809 # define libutil_hidden_weak(name)
810 # define libutil_hidden_ver(local, name)
811 # define libutil_hidden_data_def(name)
812 # define libutil_hidden_data_weak(name)
813 # define libutil_hidden_data_ver(local, name)
814 #endif
816 /* Get some dirty hacks. */
817 #include <symbol-hacks.h>
819 /* Move compatibility symbols out of the way by placing them all in a
820 special section. */
821 #ifndef __ASSEMBLER__
822 # define attribute_compat_text_section \
823 __attribute__ ((section (".text.compat")))
824 # define attribute_compat_data_section \
825 __attribute__ ((section (".data.compat")))
826 #else
827 # define compat_text_section .section ".text.compat", "ax";
828 # define compat_data_section .section ".data.compat", "aw";
829 #endif
831 #endif /* libc-symbols.h */