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