Define __ASSUME_AT_RANDOM.
[glibc/history.git] / include / libc-symbols.h
blobd53bcb9b77644cba69b36a8287b855a2b49a3e1c
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-2006, 2008 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 /* Same as WEAK_ALIAS, but mark symbol as hidden. */
117 # define weak_hidden_alias(name, aliasname) \
118 _weak_hidden_alias (name, aliasname)
119 # define _weak_hidden_alias(name, aliasname) \
120 extern __typeof (name) aliasname \
121 __attribute__ ((weak, alias (#name), __visibility__ ("hidden")));
123 /* Declare SYMBOL as weak undefined symbol (resolved to 0 if not defined). */
124 # define weak_extern(symbol) _weak_extern (weak symbol)
125 # define _weak_extern(expr) _Pragma (#expr)
127 # else
129 # define weak_alias(name, aliasname) strong_alias(name, aliasname)
130 # define weak_hidden_alias(name, aliasname) strong_alias(name, aliasname)
131 # define weak_extern(symbol) /* Nothing. */
133 # endif
135 #else /* __ASSEMBLER__ */
137 # ifdef HAVE_ASM_SET_DIRECTIVE
138 # ifdef HAVE_ASM_GLOBAL_DOT_NAME
139 # define strong_alias(original, alias) \
140 ASM_GLOBAL_DIRECTIVE C_SYMBOL_NAME (alias) ASM_LINE_SEP \
141 .set C_SYMBOL_NAME (alias),C_SYMBOL_NAME (original) ASM_LINE_SEP \
142 ASM_GLOBAL_DIRECTIVE C_SYMBOL_DOT_NAME (alias) ASM_LINE_SEP \
143 .set C_SYMBOL_DOT_NAME (alias),C_SYMBOL_DOT_NAME (original)
144 # define strong_data_alias(original, alias) \
145 ASM_GLOBAL_DIRECTIVE C_SYMBOL_NAME (alias) ASM_LINE_SEP \
146 .set C_SYMBOL_NAME (alias),C_SYMBOL_NAME (original)
147 # else
148 # define strong_alias(original, alias) \
149 ASM_GLOBAL_DIRECTIVE C_SYMBOL_NAME (alias) ASM_LINE_SEP \
150 .set C_SYMBOL_NAME (alias),C_SYMBOL_NAME (original)
151 # define strong_data_alias(original, alias) strong_alias(original, alias)
152 # endif
153 # else
154 # ifdef HAVE_ASM_GLOBAL_DOT_NAME
155 # define strong_alias(original, alias) \
156 ASM_GLOBAL_DIRECTIVE C_SYMBOL_NAME (alias) ASM_LINE_SEP \
157 C_SYMBOL_NAME (alias) = C_SYMBOL_NAME (original) ASM_LINE_SEP \
158 ASM_GLOBAL_DIRECTIVE C_SYMBOL_DOT_NAME (alias) ASM_LINE_SEP \
159 C_SYMBOL_DOT_NAME (alias) = C_SYMBOL_DOT_NAME (original)
160 # define strong_data_alias(original, alias) \
161 ASM_GLOBAL_DIRECTIVE C_SYMBOL_NAME (alias) ASM_LINE_SEP \
162 C_SYMBOL_NAME (alias) = C_SYMBOL_NAME (original)
163 # else
164 # define strong_alias(original, alias) \
165 ASM_GLOBAL_DIRECTIVE C_SYMBOL_NAME (alias) ASM_LINE_SEP \
166 C_SYMBOL_NAME (alias) = C_SYMBOL_NAME (original)
167 # define strong_data_alias(original, alias) strong_alias(original, alias)
168 # endif
169 # endif
171 # ifdef HAVE_WEAK_SYMBOLS
172 # ifdef HAVE_ASM_WEAKEXT_DIRECTIVE
173 # ifdef HAVE_ASM_GLOBAL_DOT_NAME
174 # define weak_alias(original, alias) \
175 .weakext C_SYMBOL_NAME (alias), C_SYMBOL_NAME (original) ASM_LINE_SEP \
176 .weakext C_SYMBOL_DOT_NAME (alias), C_SYMBOL_DOT_NAME (original)
177 # else
178 # define weak_alias(original, alias) \
179 .weakext C_SYMBOL_NAME (alias), C_SYMBOL_NAME (original)
180 # endif
181 # define weak_extern(symbol) \
182 .weakext C_SYMBOL_NAME (symbol)
184 # else /* ! HAVE_ASM_WEAKEXT_DIRECTIVE */
186 # ifdef HAVE_ASM_GLOBAL_DOT_NAME
187 # define weak_alias(original, alias) \
188 .weak C_SYMBOL_NAME (alias) ASM_LINE_SEP \
189 C_SYMBOL_NAME (alias) = C_SYMBOL_NAME (original) ASM_LINE_SEP \
190 .weak C_SYMBOL_DOT_NAME (alias) ASM_LINE_SEP \
191 C_SYMBOL_DOT_NAME (alias) = C_SYMBOL_DOT_NAME (original)
192 # else
193 # define weak_alias(original, alias) \
194 .weak C_SYMBOL_NAME (alias) ASM_LINE_SEP \
195 C_SYMBOL_NAME (alias) = C_SYMBOL_NAME (original)
196 # endif
198 # define weak_extern(symbol) \
199 .weak C_SYMBOL_NAME (symbol)
201 # endif /* ! HAVE_ASM_WEAKEXT_DIRECTIVE */
203 # else /* ! HAVE_WEAK_SYMBOLS */
205 # define weak_alias(original, alias) strong_alias(original, alias)
206 # define weak_extern(symbol) /* Nothing */
207 # endif /* ! HAVE_WEAK_SYMBOLS */
209 #endif /* __ASSEMBLER__ */
211 /* On some platforms we can make internal function calls (i.e., calls of
212 functions not exported) a bit faster by using a different calling
213 convention. */
214 #ifndef internal_function
215 # define internal_function /* empty */
216 #endif
218 /* Prepare for the case that `__builtin_expect' is not available. */
219 #ifndef HAVE_BUILTIN_EXPECT
220 # define __builtin_expect(expr, val) (expr)
221 #endif
223 /* Determine the return address. */
224 #define RETURN_ADDRESS(nr) \
225 __builtin_extract_return_addr (__builtin_return_address (nr))
227 /* When a reference to SYMBOL is encountered, the linker will emit a
228 warning message MSG. */
229 #ifdef HAVE_ELF
231 /* We want the .gnu.warning.SYMBOL section to be unallocated. */
232 # ifdef HAVE_ASM_PREVIOUS_DIRECTIVE
233 # define __make_section_unallocated(section_string) \
234 asm (".section " section_string "\n\t.previous");
235 # elif defined HAVE_ASM_POPSECTION_DIRECTIVE
236 # define __make_section_unallocated(section_string) \
237 asm (".pushsection " section_string "\n\t.popsection");
238 # else
239 # define __make_section_unallocated(section_string)
240 # endif
242 /* Tacking on "\n\t#" to the section name makes gcc put it's bogus
243 section attributes on what looks like a comment to the assembler. */
244 # ifdef HAVE_SECTION_QUOTES
245 # define __sec_comment "\"\n\t#\""
246 # else
247 # define __sec_comment "\n\t#"
248 # endif
249 # define link_warning(symbol, msg) \
250 __make_section_unallocated (".gnu.warning." #symbol) \
251 static const char __evoke_link_warning_##symbol[] \
252 __attribute__ ((used, section (".gnu.warning." #symbol __sec_comment))) \
253 = msg;
254 # define libc_freeres_ptr(decl) \
255 __make_section_unallocated ("__libc_freeres_ptrs, \"aw\", %nobits") \
256 decl __attribute__ ((section ("__libc_freeres_ptrs" __sec_comment)))
257 # define __libc_freeres_fn_section \
258 __attribute__ ((section ("__libc_freeres_fn")))
259 #else /* Not ELF: a.out */
260 # ifdef HAVE_XCOFF
261 /* XCOFF does not support .stabs.
262 The native aix linker will remove the .stab and .stabstr sections
263 The gnu linker will have a fatal error if there is a relocation for
264 symbol in the .stab section. Silently disable this macro. */
265 # define link_warning(symbol, msg)
266 # else
267 # define link_warning(symbol, msg) \
268 asm (".stabs \"" msg "\",30,0,0,0\n\t" \
269 ".stabs \"" __SYMBOL_PREFIX #symbol "\",1,0,0,0\n");
270 # endif /* XCOFF */
271 # define libc_freeres_ptr(decl) decl
272 # define __libc_freeres_fn_section
273 #endif
274 #define libc_freeres_fn(name) \
275 static void name (void) __attribute_used__ __libc_freeres_fn_section; \
276 text_set_element (__libc_subfreeres, name); \
277 static void name (void)
279 /* A canned warning for sysdeps/stub functions. */
280 #define stub_warning(name) \
281 __make_section_unallocated (".gnu.glibc-stub." #name) \
282 link_warning (name, \
283 "warning: " #name " is not implemented and will always fail")
285 /* Warning for linking functions calling dlopen into static binaries. */
286 #ifdef SHARED
287 #define static_link_warning(name)
288 #else
289 #define static_link_warning(name) static_link_warning1(name)
290 #define static_link_warning1(name) \
291 link_warning(name, "Using '" #name "' in statically linked applications \
292 requires at runtime the shared libraries from the glibc version used \
293 for linking")
294 #endif
296 /* Declare SYMBOL to be TYPE (`function' or `object') of SIZE bytes
297 alias to ORIGINAL, when the assembler supports such declarations
298 (such as in ELF).
299 This is only necessary when defining something in assembly, or playing
300 funny alias games where the size should be other than what the compiler
301 thinks it is. */
302 #define declare_symbol_alias(symbol, original, type, size) \
303 declare_symbol_alias_1 (symbol, original, type, size)
304 #ifdef ASM_TYPE_DIRECTIVE_PREFIX
305 # ifdef __ASSEMBLER__
306 # define declare_symbol_alias_1(symbol, original, type, size) \
307 strong_alias (original, symbol); \
308 .type C_SYMBOL_NAME (symbol), \
309 declare_symbol_alias_1_paste (ASM_TYPE_DIRECTIVE_PREFIX, type); \
310 .size C_SYMBOL_NAME (symbol), size
311 # define declare_symbol_alias_1_paste(a, b) \
312 declare_symbol_alias_1_paste_1 (a,b)
313 # define declare_symbol_alias_1_paste_1(a,b) a##b
314 # else /* Not __ASSEMBLER__. */
315 # define declare_symbol_alias_1(symbol, original, type, size) \
316 asm (declare_symbol_alias_1_stringify (ASM_GLOBAL_DIRECTIVE) \
317 " " __SYMBOL_PREFIX #symbol \
318 "\n\t" declare_symbol_alias_1_alias (symbol, original) \
319 "\n\t.type " __SYMBOL_PREFIX #symbol ", " \
320 declare_symbol_alias_1_stringify (ASM_TYPE_DIRECTIVE_PREFIX) #type \
321 "\n\t.size " __SYMBOL_PREFIX #symbol ", " #size);
322 # define declare_symbol_alias_1_stringify(x) \
323 declare_symbol_alias_1_stringify_1 (x)
324 # define declare_symbol_alias_1_stringify_1(x) #x
325 # ifdef HAVE_ASM_SET_DIRECTIVE
326 # define declare_symbol_alias_1_alias(symbol, original) \
327 ".set " __SYMBOL_PREFIX #symbol ", " __SYMBOL_PREFIX #original
328 # else
329 # define declare_symbol_alias_1_alias(symbol, original) \
330 __SYMBOL_PREFIX #symbol " = " __SYMBOL_PREFIX #original
331 # endif /* HAVE_ASM_SET_DIRECTIVE */
332 # endif /* __ASSEMBLER__ */
333 #else
334 # define declare_symbol_1(symbol, type, size) /* Nothing. */
335 #endif
342 /* Symbol set support macros. */
344 #ifdef HAVE_ELF
346 /* Make SYMBOL, which is in the text segment, an element of SET. */
347 # define text_set_element(set, symbol) _elf_set_element(set, symbol)
348 /* Make SYMBOL, which is in the data segment, an element of SET. */
349 # define data_set_element(set, symbol) _elf_set_element(set, symbol)
350 /* Make SYMBOL, which is in the bss segment, an element of SET. */
351 # define bss_set_element(set, symbol) _elf_set_element(set, symbol)
353 /* These are all done the same way in ELF.
354 There is a new section created for each set. */
355 # ifdef SHARED
356 /* When building a shared library, make the set section writable,
357 because it will need to be relocated at run time anyway. */
358 # define _elf_set_element(set, symbol) \
359 static const void *__elf_set_##set##_element_##symbol##__ \
360 __attribute__ ((used, section (#set))) = &(symbol)
361 # else
362 # define _elf_set_element(set, symbol) \
363 static const void *const __elf_set_##set##_element_##symbol##__ \
364 __attribute__ ((used, section (#set))) = &(symbol)
365 # endif
367 /* Define SET as a symbol set. This may be required (it is in a.out) to
368 be able to use the set's contents. */
369 # define symbol_set_define(set) symbol_set_declare(set)
371 /* Declare SET for use in this module, if defined in another module.
372 In a shared library, this is always local to that shared object.
373 For static linking, the set might be wholly absent and so we use
374 weak references. */
375 # define symbol_set_declare(set) \
376 extern char const __start_##set[] __symbol_set_attribute; \
377 extern char const __stop_##set[] __symbol_set_attribute;
378 # ifdef SHARED
379 # define __symbol_set_attribute attribute_hidden
380 # else
381 # define __symbol_set_attribute __attribute__ ((weak))
382 # endif
384 /* Return a pointer (void *const *) to the first element of SET. */
385 # define symbol_set_first_element(set) ((void *const *) (&__start_##set))
387 /* Return true iff PTR (a void *const *) has been incremented
388 past the last element in SET. */
389 # define symbol_set_end_p(set, ptr) ((ptr) >= (void *const *) &__stop_##set)
391 #else /* Not ELF: a.out. */
393 # ifdef HAVE_XCOFF
394 /* XCOFF does not support .stabs.
395 The native aix linker will remove the .stab and .stabstr sections
396 The gnu linker will have a fatal error if there is a relocation for
397 symbol in the .stab section. Silently disable these macros. */
398 # define text_set_element(set, symbol)
399 # define data_set_element(set, symbol)
400 # define bss_set_element(set, symbol)
401 # else
402 # define text_set_element(set, symbol) \
403 asm (".stabs \"" __SYMBOL_PREFIX #set "\",23,0,0," __SYMBOL_PREFIX #symbol)
404 # define data_set_element(set, symbol) \
405 asm (".stabs \"" __SYMBOL_PREFIX #set "\",25,0,0," __SYMBOL_PREFIX #symbol)
406 # define bss_set_element(set, symbol) ?error Must use initialized data.
407 # endif /* XCOFF */
408 # define symbol_set_define(set) void *const (set)[1];
409 # define symbol_set_declare(set) extern void *const (set)[1];
411 # define symbol_set_first_element(set) &(set)[1]
412 # define symbol_set_end_p(set, ptr) (*(ptr) == 0)
414 #endif /* ELF. */
416 #if DO_VERSIONING
417 # define symbol_version(real, name, version) \
418 _symbol_version(real, name, version)
419 # define default_symbol_version(real, name, version) \
420 _default_symbol_version(real, name, version)
421 # ifdef __ASSEMBLER__
422 # ifdef HAVE_ASM_GLOBAL_DOT_NAME
423 # define _symbol_version(real, name, version) \
424 .symver real, name##@##version ASM_LINE_SEP \
425 .symver C_SYMBOL_DOT_NAME(real), C_SYMBOL_DOT_NAME(name##@##version)
426 # define _default_symbol_version(real, name, version) \
427 .symver real, name##@##@##version ASM_LINE_SEP \
428 .symver C_SYMBOL_DOT_NAME(real), C_SYMBOL_DOT_NAME(name##@##@##version)
429 # else
430 # define _symbol_version(real, name, version) \
431 .symver real, name##@##version
432 # define _default_symbol_version(real, name, version) \
433 .symver real, name##@##@##version
434 # endif
435 # else
436 # ifdef HAVE_ASM_GLOBAL_DOT_NAME
437 # define _symbol_version(real, name, version) \
438 __asm__ (".symver " #real "," #name "@" #version "\n\t" \
439 ".symver ." #real ",." #name "@" #version)
440 # define _default_symbol_version(real, name, version) \
441 __asm__ (".symver " #real "," #name "@@" #version "\n\t" \
442 ".symver ." #real ",." #name "@@" #version)
443 # else
444 # define _symbol_version(real, name, version) \
445 __asm__ (".symver " #real "," #name "@" #version)
446 # define _default_symbol_version(real, name, version) \
447 __asm__ (".symver " #real "," #name "@@" #version)
448 # endif
449 # endif
450 #else
451 # define symbol_version(real, name, version)
452 # define default_symbol_version(real, name, version) \
453 strong_alias(real, name)
454 #endif
456 #if defined SHARED || defined LIBC_NONSHARED
457 # define attribute_hidden __attribute__ ((visibility ("hidden")))
458 #else
459 # define attribute_hidden
460 #endif
462 #ifdef HAVE_TLS_MODEL_ATTRIBUTE
463 # define attribute_tls_model_ie __attribute__ ((tls_model ("initial-exec")))
464 #else
465 # define attribute_tls_model_ie
466 #endif
468 #define attribute_relro __attribute__ ((section (".data.rel.ro")))
470 /* Handling on non-exported internal names. We have to do this only
471 for shared code. */
472 #ifdef SHARED
473 # define INTUSE(name) name##_internal
474 # define INTDEF(name) strong_alias (name, name##_internal)
475 # define INTVARDEF(name) \
476 _INTVARDEF (name, name##_internal)
477 # define _INTVARDEF(name, aliasname) \
478 extern __typeof (name) aliasname __attribute__ ((alias (#name), \
479 visibility ("hidden")));
480 # define INTDEF2(name, newname) strong_alias (name, newname##_internal)
481 # define INTVARDEF2(name, newname) _INTVARDEF (name, newname##_internal)
482 #else
483 # define INTUSE(name) name
484 # define INTDEF(name)
485 # define INTVARDEF(name)
486 # define INTDEF2(name, newname)
487 # define INTVARDEF2(name, newname)
488 #endif
490 /* The following macros are used for PLT bypassing within libc.so
491 (and if needed other libraries similarly).
492 First of all, you need to have the function prototyped somewhere,
493 say in foo/foo.h:
495 int foo (int __bar);
497 If calls to foo within libc.so should always go to foo defined in libc.so,
498 then in include/foo.h you add:
500 libc_hidden_proto (foo)
502 line and after the foo function definition:
504 int foo (int __bar)
506 return __bar;
508 libc_hidden_def (foo)
512 int foo (int __bar)
514 return __bar;
516 libc_hidden_weak (foo)
518 Similarly for global data. If references to foo within libc.so should
519 always go to foo defined in libc.so, then in include/foo.h you add:
521 libc_hidden_proto (foo)
523 line and after foo's definition:
525 int foo = INITIAL_FOO_VALUE;
526 libc_hidden_data_def (foo)
530 int foo = INITIAL_FOO_VALUE;
531 libc_hidden_data_weak (foo)
533 If foo is normally just an alias (strong or weak) to some other function,
534 you should use the normal strong_alias first, then add libc_hidden_def
535 or libc_hidden_weak:
537 int baz (int __bar)
539 return __bar;
541 strong_alias (baz, foo)
542 libc_hidden_weak (foo)
544 If the function should be internal to multiple objects, say ld.so and
545 libc.so, the best way is to use:
547 #if !defined NOT_IN_libc || defined IS_IN_rtld
548 hidden_proto (foo)
549 #endif
551 in include/foo.h and the normal macros at all function definitions
552 depending on what DSO they belong to.
554 If versioned_symbol macro is used to define foo,
555 libc_hidden_ver macro should be used, as in:
557 int __real_foo (int __bar)
559 return __bar;
561 versioned_symbol (libc, __real_foo, foo, GLIBC_2_1);
562 libc_hidden_ver (__real_foo, foo) */
564 #if defined SHARED && defined DO_VERSIONING && !defined NO_HIDDEN
565 # ifndef __ASSEMBLER__
566 # define __hidden_proto_hiddenattr(attrs...) \
567 __attribute__ ((visibility ("hidden"), ##attrs))
568 # define hidden_proto(name, attrs...) \
569 __hidden_proto (name, __GI_##name, ##attrs)
570 # define __hidden_proto(name, internal, attrs...) \
571 extern __typeof (name) name __asm__ (__hidden_asmname (#internal)) \
572 __hidden_proto_hiddenattr (attrs);
573 # define __hidden_asmname(name) \
574 __hidden_asmname1 (__USER_LABEL_PREFIX__, name)
575 # define __hidden_asmname1(prefix, name) __hidden_asmname2(prefix, name)
576 # define __hidden_asmname2(prefix, name) #prefix name
577 # define __hidden_ver1(local, internal, name) \
578 extern __typeof (name) __EI_##name __asm__(__hidden_asmname (#internal)); \
579 extern __typeof (name) __EI_##name \
580 __attribute__((alias (__hidden_asmname (#local))))
581 # define hidden_ver(local, name) __hidden_ver1(local, __GI_##name, name);
582 # define hidden_data_ver(local, name) hidden_ver(local, name)
583 # define hidden_def(name) __hidden_ver1(__GI_##name, name, name);
584 # define hidden_data_def(name) hidden_def(name)
585 # define hidden_weak(name) \
586 __hidden_ver1(__GI_##name, name, name) __attribute__((weak));
587 # define hidden_data_weak(name) hidden_weak(name)
588 # else
589 /* For assembly, we need to do the opposite of what we do in C:
590 in assembly gcc __REDIRECT stuff is not in place, so functions
591 are defined by its normal name and we need to create the
592 __GI_* alias to it, in C __REDIRECT causes the function definition
593 to use __GI_* name and we need to add alias to the real name.
594 There is no reason to use hidden_weak over hidden_def in assembly,
595 but we provide it for consistency with the C usage.
596 hidden_proto doesn't make sense for assembly but the equivalent
597 is to call via the HIDDEN_JUMPTARGET macro instead of JUMPTARGET. */
598 # define hidden_def(name) strong_alias (name, __GI_##name)
599 # define hidden_weak(name) hidden_def (name)
600 # define hidden_ver(local, name) strong_alias (local, __GI_##name)
601 # define hidden_data_def(name) strong_data_alias (name, __GI_##name)
602 # define hidden_data_weak(name) hidden_data_def (name)
603 # define hidden_data_ver(local, name) strong_data_alias (local, __GI_##name)
604 # ifdef HAVE_ASM_GLOBAL_DOT_NAME
605 # define HIDDEN_JUMPTARGET(name) .__GI_##name
606 # else
607 # define HIDDEN_JUMPTARGET(name) __GI_##name
608 # endif
609 # endif
610 #else
611 # ifndef __ASSEMBLER__
612 # define hidden_proto(name, attrs...)
613 # else
614 # define HIDDEN_JUMPTARGET(name) JUMPTARGET(name)
615 # endif /* Not __ASSEMBLER__ */
616 # define hidden_weak(name)
617 # define hidden_def(name)
618 # define hidden_ver(local, name)
619 # define hidden_data_weak(name)
620 # define hidden_data_def(name)
621 # define hidden_data_ver(local, name)
622 #endif
624 #if !defined NOT_IN_libc
625 # define libc_hidden_proto(name, attrs...) hidden_proto (name, ##attrs)
626 # define libc_hidden_def(name) hidden_def (name)
627 # define libc_hidden_weak(name) hidden_weak (name)
628 # define libc_hidden_ver(local, name) hidden_ver (local, name)
629 # define libc_hidden_data_def(name) hidden_data_def (name)
630 # define libc_hidden_data_weak(name) hidden_data_weak (name)
631 # define libc_hidden_data_ver(local, name) hidden_data_ver (local, name)
632 #else
633 # define libc_hidden_proto(name, attrs...)
634 # define libc_hidden_def(name)
635 # define libc_hidden_weak(name)
636 # define libc_hidden_ver(local, name)
637 # define libc_hidden_data_def(name)
638 # define libc_hidden_data_weak(name)
639 # define libc_hidden_data_ver(local, name)
640 #endif
642 #if defined NOT_IN_libc && defined IS_IN_rtld
643 # define rtld_hidden_proto(name, attrs...) hidden_proto (name, ##attrs)
644 # define rtld_hidden_def(name) hidden_def (name)
645 # define rtld_hidden_weak(name) hidden_weak (name)
646 # define rtld_hidden_ver(local, name) hidden_ver (local, name)
647 # define rtld_hidden_data_def(name) hidden_data_def (name)
648 # define rtld_hidden_data_weak(name) hidden_data_weak (name)
649 # define rtld_hidden_data_ver(local, name) hidden_data_ver (local, name)
650 #else
651 # define rtld_hidden_proto(name, attrs...)
652 # define rtld_hidden_def(name)
653 # define rtld_hidden_weak(name)
654 # define rtld_hidden_ver(local, name)
655 # define rtld_hidden_data_def(name)
656 # define rtld_hidden_data_weak(name)
657 # define rtld_hidden_data_ver(local, name)
658 #endif
660 #if defined NOT_IN_libc && defined IS_IN_libm
661 # define libm_hidden_proto(name, attrs...) hidden_proto (name, ##attrs)
662 # define libm_hidden_def(name) hidden_def (name)
663 # define libm_hidden_weak(name) hidden_weak (name)
664 # define libm_hidden_ver(local, name) hidden_ver (local, name)
665 # define libm_hidden_data_def(name) hidden_data_def (name)
666 # define libm_hidden_data_weak(name) hidden_data_weak (name)
667 # define libm_hidden_data_ver(local, name) hidden_data_ver (local, name)
668 #else
669 # define libm_hidden_proto(name, attrs...)
670 # define libm_hidden_def(name)
671 # define libm_hidden_weak(name)
672 # define libm_hidden_ver(local, name)
673 # define libm_hidden_data_def(name)
674 # define libm_hidden_data_weak(name)
675 # define libm_hidden_data_ver(local, name)
676 #endif
678 #if defined NOT_IN_libc && defined IS_IN_libresolv
679 # define libresolv_hidden_proto(name, attrs...) hidden_proto (name, ##attrs)
680 # define libresolv_hidden_def(name) hidden_def (name)
681 # define libresolv_hidden_weak(name) hidden_weak (name)
682 # define libresolv_hidden_ver(local, name) hidden_ver (local, name)
683 # define libresolv_hidden_data_def(name) hidden_data_def (name)
684 # define libresolv_hidden_data_weak(name) hidden_data_weak (name)
685 # define libresolv_hidden_data_ver(local, name) hidden_data_ver (local, name)
686 #else
687 # define libresolv_hidden_proto(name, attrs...)
688 # define libresolv_hidden_def(name)
689 # define libresolv_hidden_weak(name)
690 # define libresolv_hidden_ver(local, name)
691 # define libresolv_hidden_data_def(name)
692 # define libresolv_hidden_data_weak(name)
693 # define libresolv_hidden_data_ver(local, name)
694 #endif
696 #if defined NOT_IN_libc && defined IS_IN_librt
697 # define librt_hidden_proto(name, attrs...) hidden_proto (name, ##attrs)
698 # define librt_hidden_def(name) hidden_def (name)
699 # define librt_hidden_weak(name) hidden_weak (name)
700 # define librt_hidden_ver(local, name) hidden_ver (local, name)
701 # define librt_hidden_data_def(name) hidden_data_def (name)
702 # define librt_hidden_data_weak(name) hidden_data_weak (name)
703 # define librt_hidden_data_ver(local, name) hidden_data_ver (local, name)
704 #else
705 # define librt_hidden_proto(name, attrs...)
706 # define librt_hidden_def(name)
707 # define librt_hidden_weak(name)
708 # define librt_hidden_ver(local, name)
709 # define librt_hidden_data_def(name)
710 # define librt_hidden_data_weak(name)
711 # define librt_hidden_data_ver(local, name)
712 #endif
714 #if defined NOT_IN_libc && defined IS_IN_libdl
715 # define libdl_hidden_proto(name, attrs...) hidden_proto (name, ##attrs)
716 # define libdl_hidden_def(name) hidden_def (name)
717 # define libdl_hidden_weak(name) hidden_weak (name)
718 # define libdl_hidden_ver(local, name) hidden_ver (local, name)
719 # define libdl_hidden_data_def(name) hidden_data_def (name)
720 # define libdl_hidden_data_weak(name) hidden_data_weak (name)
721 # define libdl_hidden_data_ver(local, name) hidden_data_ver (local, name)
722 #else
723 # define libdl_hidden_proto(name, attrs...)
724 # define libdl_hidden_def(name)
725 # define libdl_hidden_weak(name)
726 # define libdl_hidden_ver(local, name)
727 # define libdl_hidden_data_def(name)
728 # define libdl_hidden_data_weak(name)
729 # define libdl_hidden_data_ver(local, name)
730 #endif
732 #if defined NOT_IN_libc && defined IS_IN_libnss_files
733 # define libnss_files_hidden_proto(name, attrs...) hidden_proto (name, ##attrs)
734 # define libnss_files_hidden_def(name) hidden_def (name)
735 # define libnss_files_hidden_weak(name) hidden_weak (name)
736 # define libnss_files_hidden_ver(local, name) hidden_ver (local, name)
737 # define libnss_files_hidden_data_def(name) hidden_data_def (name)
738 # define libnss_files_hidden_data_weak(name) hidden_data_weak (name)
739 # define libnss_files_hidden_data_ver(local, name) hidden_data_ver(local, name)
740 #else
741 # define libnss_files_hidden_proto(name, attrs...)
742 # define libnss_files_hidden_def(name)
743 # define libnss_files_hidden_weak(name)
744 # define libnss_files_hidden_ver(local, name)
745 # define libnss_files_hidden_data_def(name)
746 # define libnss_files_hidden_data_weak(name)
747 # define libnss_files_hidden_data_ver(local, name)
748 #endif
750 #if defined NOT_IN_libc && defined IS_IN_libnsl
751 # define libnsl_hidden_proto(name, attrs...) hidden_proto (name, ##attrs)
752 # define libnsl_hidden_def(name) hidden_def (name)
753 # define libnsl_hidden_weak(name) hidden_weak (name)
754 # define libnsl_hidden_ver(local, name) hidden_ver (local, name)
755 # define libnsl_hidden_data_def(name) hidden_data_def (name)
756 # define libnsl_hidden_data_weak(name) hidden_data_weak (name)
757 # define libnsl_hidden_data_ver(local, name) hidden_data_ver (local, name)
758 #else
759 # define libnsl_hidden_proto(name, attrs...)
760 # define libnsl_hidden_def(name)
761 # define libnsl_hidden_weak(name)
762 # define libnsl_hidden_ver(local, name)
763 # define libnsl_hidden_data_def(name)
764 # define libnsl_hidden_data_weak(name)
765 # define libnsl_hidden_data_ver(local, name)
766 #endif
768 #if defined NOT_IN_libc && defined IS_IN_libnss_nisplus
769 # define libnss_nisplus_hidden_proto(name, attrs...) hidden_proto (name, ##attrs)
770 # define libnss_nisplus_hidden_def(name) hidden_def (name)
771 # define libnss_nisplus_hidden_weak(name) hidden_weak (name)
772 # define libnss_nisplus_hidden_ver(local, name) hidden_ver (local, name)
773 # define libnss_nisplus_hidden_data_def(name) hidden_data_def (name)
774 # define libnss_nisplus_hidden_data_weak(name) hidden_data_weak (name)
775 # define libnss_nisplus_hidden_data_ver(local, name) hidden_data_ver (local, name)
776 #else
777 # define libnss_nisplus_hidden_proto(name, attrs...)
778 # define libnss_nisplus_hidden_def(name)
779 # define libnss_nisplus_hidden_weak(name)
780 # define libnss_nisplus_hidden_ver(local, name)
781 # define libnss_nisplus_hidden_data_def(name)
782 # define libnss_nisplus_hidden_data_weak(name)
783 # define libnss_nisplus_hidden_data_ver(local, name)
784 #endif
786 #ifdef HAVE_BUILTIN_REDIRECTION
787 # define libc_hidden_builtin_proto(name, attrs...) libc_hidden_proto (name, ##attrs)
788 # define libc_hidden_builtin_def(name) libc_hidden_def (name)
789 # define libc_hidden_builtin_weak(name) libc_hidden_weak (name)
790 # define libc_hidden_builtin_ver(local, name) libc_hidden_ver (local, name)
791 # ifdef __ASSEMBLER__
792 # define HIDDEN_BUILTIN_JUMPTARGET(name) HIDDEN_JUMPTARGET(name)
793 # endif
794 #else
795 # define libc_hidden_builtin_proto(name, attrs...)
796 # define libc_hidden_builtin_def(name)
797 # define libc_hidden_builtin_weak(name)
798 # define libc_hidden_builtin_ver(local, name)
799 # ifdef __ASSEMBLER__
800 # define HIDDEN_BUILTIN_JUMPTARGET(name) JUMPTARGET(name)
801 # endif
802 #endif
804 #if defined NOT_IN_libc && defined IS_IN_libutil
805 # define libutil_hidden_proto(name, attrs...) hidden_proto (name, ##attrs)
806 # define libutil_hidden_def(name) hidden_def (name)
807 # define libutil_hidden_weak(name) hidden_weak (name)
808 # define libutil_hidden_ver(local, name) hidden_ver (local, name)
809 # define libutil_hidden_data_def(name) hidden_data_def (name)
810 # define libutil_hidden_data_weak(name) hidden_data_weak (name)
811 # define libutil_hidden_data_ver(local, name) hidden_data_ver (local, name)
812 #else
813 # define libutil_hidden_proto(name, attrs...)
814 # define libutil_hidden_def(name)
815 # define libutil_hidden_weak(name)
816 # define libutil_hidden_ver(local, name)
817 # define libutil_hidden_data_def(name)
818 # define libutil_hidden_data_weak(name)
819 # define libutil_hidden_data_ver(local, name)
820 #endif
822 /* Get some dirty hacks. */
823 #include <symbol-hacks.h>
825 /* Move compatibility symbols out of the way by placing them all in a
826 special section. */
827 #ifndef __ASSEMBLER__
828 # define attribute_compat_text_section \
829 __attribute__ ((section (".text.compat")))
830 # define attribute_compat_data_section \
831 __attribute__ ((section (".data.compat")))
832 #else
833 # define compat_text_section .section ".text.compat", "ax";
834 # define compat_data_section .section ".data.compat", "aw";
835 #endif
837 /* Marker used for indirection function symbols. */
838 #define libc_ifunc(name, expr) \
839 extern void *name##_ifunc (void) __asm__ (#name); \
840 void *name##_ifunc (void) \
842 INIT_ARCH (); \
843 __typeof (name) *res = expr; \
844 return res; \
846 __asm__ (".type " #name ", %gnu_indirect_function");
848 #endif /* libc-symbols.h */