drop ports ignore
[glibc.git] / include / libc-symbols.h
blob12b3639647a4c3687808dc2b6acf90f83a0f21d0
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-2012 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, see
18 <http://www.gnu.org/licenses/>. */
20 #ifndef _LIBC_SYMBOLS_H
21 #define _LIBC_SYMBOLS_H 1
23 /* This file's macros are included implicitly in the compilation of every
24 file in the C library by -imacros.
26 We include config.h which is generated by configure.
27 It should define for us the following symbols:
29 * HAVE_ASM_SET_DIRECTIVE if we have `.set B, A' instead of `A = B'.
30 * ASM_GLOBAL_DIRECTIVE with `.globl' or `.global'.
31 * ASM_TYPE_DIRECTIVE_PREFIX with `@' or `#' or whatever for .type,
32 or leave it undefined if there is no .type directive.
33 * HAVE_ASM_WEAK_DIRECTIVE if we have weak symbols using `.weak'.
34 * HAVE_ASM_WEAKEXT_DIRECTIVE if we have weak symbols using `.weakext'.
38 /* This is defined for the compilation of all C library code. features.h
39 tests this to avoid inclusion of stubs.h while compiling the library,
40 before stubs.h has been generated. Some library code that is shared
41 with other packages also tests this symbol to see if it is being
42 compiled as part of the C library. We must define this before including
43 config.h, because it makes some definitions conditional on whether libc
44 itself is being compiled, or just some generator program. */
45 #define _LIBC 1
47 /* Enable declarations of GNU extensions, since we are compiling them. */
48 #define _GNU_SOURCE 1
49 /* And we also need the data for the reentrant functions. */
50 #define _REENTRANT 1
52 #include <config.h>
54 /* The symbols in all the user (non-_) macros are C symbols. */
56 #if !defined HAVE_ASM_WEAK_DIRECTIVE && !defined HAVE_ASM_WEAKEXT_DIRECTIVE
57 # error "weak symbol support needed"
58 #endif
60 #ifndef __SYMBOL_PREFIX
61 # define __SYMBOL_PREFIX
62 #endif
64 #ifndef C_SYMBOL_NAME
65 # define C_SYMBOL_NAME(name) name
66 #endif
68 #ifndef ASM_LINE_SEP
69 # define ASM_LINE_SEP ;
70 #endif
72 #ifdef HAVE_ASM_GLOBAL_DOT_NAME
73 # ifndef C_SYMBOL_DOT_NAME
74 # if defined __GNUC__ && defined __GNUC_MINOR__ \
75 && (__GNUC__ << 16) + __GNUC_MINOR__ >= (3 << 16) + 1
76 # define C_SYMBOL_DOT_NAME(name) .name
77 # else
78 # define C_SYMBOL_DOT_NAME(name) .##name
79 # endif
80 # endif
81 #endif
83 #ifndef __ASSEMBLER__
84 /* GCC understands weak symbols and aliases; use its interface where
85 possible, instead of embedded assembly language. */
87 /* Define ALIASNAME as a strong alias for NAME. */
88 # define strong_alias(name, aliasname) _strong_alias(name, aliasname)
89 # define _strong_alias(name, aliasname) \
90 extern __typeof (name) aliasname __attribute__ ((alias (#name)));
92 /* This comes between the return type and function name in
93 a function definition to make that definition weak. */
94 # define weak_function __attribute__ ((weak))
95 # define weak_const_function __attribute__ ((weak, __const__))
97 /* Define ALIASNAME as a weak alias for NAME.
98 If weak aliases are not available, this defines a strong alias. */
99 # define weak_alias(name, aliasname) _weak_alias (name, aliasname)
100 # define _weak_alias(name, aliasname) \
101 extern __typeof (name) aliasname __attribute__ ((weak, alias (#name)));
103 /* Same as WEAK_ALIAS, but mark symbol as hidden. */
104 # define weak_hidden_alias(name, aliasname) \
105 _weak_hidden_alias (name, aliasname)
106 # define _weak_hidden_alias(name, aliasname) \
107 extern __typeof (name) aliasname \
108 __attribute__ ((weak, alias (#name), __visibility__ ("hidden")));
110 /* Declare SYMBOL as weak undefined symbol (resolved to 0 if not defined). */
111 # define weak_extern(symbol) _weak_extern (weak symbol)
112 # define _weak_extern(expr) _Pragma (#expr)
115 #else /* __ASSEMBLER__ */
117 # ifdef HAVE_ASM_SET_DIRECTIVE
118 # ifdef HAVE_ASM_GLOBAL_DOT_NAME
119 # define strong_alias(original, alias) \
120 ASM_GLOBAL_DIRECTIVE C_SYMBOL_NAME (alias) ASM_LINE_SEP \
121 .set C_SYMBOL_NAME (alias),C_SYMBOL_NAME (original) ASM_LINE_SEP \
122 ASM_GLOBAL_DIRECTIVE C_SYMBOL_DOT_NAME (alias) ASM_LINE_SEP \
123 .set C_SYMBOL_DOT_NAME (alias),C_SYMBOL_DOT_NAME (original)
124 # define strong_data_alias(original, alias) \
125 ASM_GLOBAL_DIRECTIVE C_SYMBOL_NAME (alias) ASM_LINE_SEP \
126 .set C_SYMBOL_NAME (alias),C_SYMBOL_NAME (original)
127 # else
128 # define strong_alias(original, alias) \
129 ASM_GLOBAL_DIRECTIVE C_SYMBOL_NAME (alias) ASM_LINE_SEP \
130 .set C_SYMBOL_NAME (alias),C_SYMBOL_NAME (original)
131 # define strong_data_alias(original, alias) strong_alias(original, alias)
132 # endif
133 # else
134 # ifdef HAVE_ASM_GLOBAL_DOT_NAME
135 # define strong_alias(original, alias) \
136 ASM_GLOBAL_DIRECTIVE C_SYMBOL_NAME (alias) ASM_LINE_SEP \
137 C_SYMBOL_NAME (alias) = C_SYMBOL_NAME (original) ASM_LINE_SEP \
138 ASM_GLOBAL_DIRECTIVE C_SYMBOL_DOT_NAME (alias) ASM_LINE_SEP \
139 C_SYMBOL_DOT_NAME (alias) = C_SYMBOL_DOT_NAME (original)
140 # define strong_data_alias(original, alias) \
141 ASM_GLOBAL_DIRECTIVE C_SYMBOL_NAME (alias) ASM_LINE_SEP \
142 C_SYMBOL_NAME (alias) = C_SYMBOL_NAME (original)
143 # else
144 # define strong_alias(original, alias) \
145 ASM_GLOBAL_DIRECTIVE C_SYMBOL_NAME (alias) ASM_LINE_SEP \
146 C_SYMBOL_NAME (alias) = C_SYMBOL_NAME (original)
147 # define strong_data_alias(original, alias) strong_alias(original, alias)
148 # endif
149 # endif
151 # ifdef HAVE_ASM_WEAKEXT_DIRECTIVE
152 # ifdef HAVE_ASM_GLOBAL_DOT_NAME
153 # define weak_alias(original, alias) \
154 .weakext C_SYMBOL_NAME (alias), C_SYMBOL_NAME (original) ASM_LINE_SEP \
155 .weakext C_SYMBOL_DOT_NAME (alias), C_SYMBOL_DOT_NAME (original)
156 # else
157 # define weak_alias(original, alias) \
158 .weakext C_SYMBOL_NAME (alias), C_SYMBOL_NAME (original)
159 # endif
160 # define weak_extern(symbol) \
161 .weakext C_SYMBOL_NAME (symbol)
163 # else /* ! HAVE_ASM_WEAKEXT_DIRECTIVE */
165 # ifdef HAVE_ASM_GLOBAL_DOT_NAME
166 # define weak_alias(original, alias) \
167 .weak C_SYMBOL_NAME (alias) ASM_LINE_SEP \
168 C_SYMBOL_NAME (alias) = C_SYMBOL_NAME (original) ASM_LINE_SEP \
169 .weak C_SYMBOL_DOT_NAME (alias) ASM_LINE_SEP \
170 C_SYMBOL_DOT_NAME (alias) = C_SYMBOL_DOT_NAME (original)
171 # else
172 # define weak_alias(original, alias) \
173 .weak C_SYMBOL_NAME (alias) ASM_LINE_SEP \
174 C_SYMBOL_NAME (alias) = C_SYMBOL_NAME (original)
175 # endif
177 # define weak_extern(symbol) \
178 .weak C_SYMBOL_NAME (symbol)
180 # endif /* ! HAVE_ASM_WEAKEXT_DIRECTIVE */
182 #endif /* __ASSEMBLER__ */
184 /* On some platforms we can make internal function calls (i.e., calls of
185 functions not exported) a bit faster by using a different calling
186 convention. */
187 #ifndef internal_function
188 # define internal_function /* empty */
189 #endif
191 /* Determine the return address. */
192 #define RETURN_ADDRESS(nr) \
193 __builtin_extract_return_addr (__builtin_return_address (nr))
195 /* When a reference to SYMBOL is encountered, the linker will emit a
196 warning message MSG. */
197 /* We want the .gnu.warning.SYMBOL section to be unallocated. */
198 #ifdef HAVE_ASM_PREVIOUS_DIRECTIVE
199 # define __make_section_unallocated(section_string) \
200 asm (".section " section_string "\n\t.previous");
201 #elif defined HAVE_ASM_POPSECTION_DIRECTIVE
202 # define __make_section_unallocated(section_string) \
203 asm (".pushsection " section_string "\n\t.popsection");
204 #else
205 # define __make_section_unallocated(section_string)
206 #endif
208 /* Tacking on "\n\t#" to the section name makes gcc put it's bogus
209 section attributes on what looks like a comment to the assembler. */
210 #ifdef HAVE_SECTION_QUOTES
211 # define __sec_comment "\"\n\t#\""
212 #else
213 # define __sec_comment "\n\t#"
214 #endif
215 #define link_warning(symbol, msg) \
216 __make_section_unallocated (".gnu.warning." #symbol) \
217 static const char __evoke_link_warning_##symbol[] \
218 __attribute__ ((used, section (".gnu.warning." #symbol __sec_comment))) \
219 = msg;
220 #define libc_freeres_ptr(decl) \
221 __make_section_unallocated ("__libc_freeres_ptrs, \"aw\", %nobits") \
222 decl __attribute__ ((section ("__libc_freeres_ptrs" __sec_comment)))
223 #define __libc_freeres_fn_section \
224 __attribute__ ((section ("__libc_freeres_fn")))
226 #define libc_freeres_fn(name) \
227 static void name (void) __attribute_used__ __libc_freeres_fn_section; \
228 text_set_element (__libc_subfreeres, name); \
229 static void name (void)
231 /* A canned warning for sysdeps/stub functions. */
232 #define stub_warning(name) \
233 __make_section_unallocated (".gnu.glibc-stub." #name) \
234 link_warning (name, \
235 "warning: " #name " is not implemented and will always fail")
237 /* Warning for linking functions calling dlopen into static binaries. */
238 #ifdef SHARED
239 #define static_link_warning(name)
240 #else
241 #define static_link_warning(name) static_link_warning1(name)
242 #define static_link_warning1(name) \
243 link_warning(name, "Using '" #name "' in statically linked applications \
244 requires at runtime the shared libraries from the glibc version used \
245 for linking")
246 #endif
248 /* Declare SYMBOL to be TYPE (`function' or `object') of SIZE bytes
249 alias to ORIGINAL, when the assembler supports such declarations
250 (such as in ELF).
251 This is only necessary when defining something in assembly, or playing
252 funny alias games where the size should be other than what the compiler
253 thinks it is. */
254 #define declare_symbol_alias(symbol, original, type, size) \
255 declare_symbol_alias_1 (symbol, original, type, size)
256 #ifdef ASM_TYPE_DIRECTIVE_PREFIX
257 # ifdef __ASSEMBLER__
258 # define declare_symbol_alias_1(symbol, original, type, size) \
259 strong_alias (original, symbol); \
260 .type C_SYMBOL_NAME (symbol), \
261 declare_symbol_alias_1_paste (ASM_TYPE_DIRECTIVE_PREFIX, type); \
262 .size C_SYMBOL_NAME (symbol), size
263 # define declare_symbol_alias_1_paste(a, b) \
264 declare_symbol_alias_1_paste_1 (a,b)
265 # define declare_symbol_alias_1_paste_1(a,b) a##b
266 # else /* Not __ASSEMBLER__. */
267 # define declare_symbol_alias_1(symbol, original, type, size) \
268 asm (declare_symbol_alias_1_stringify (ASM_GLOBAL_DIRECTIVE) \
269 " " __SYMBOL_PREFIX #symbol \
270 "\n\t" declare_symbol_alias_1_alias (symbol, original) \
271 "\n\t.type " __SYMBOL_PREFIX #symbol ", " \
272 declare_symbol_alias_1_stringify (ASM_TYPE_DIRECTIVE_PREFIX) #type \
273 "\n\t.size " __SYMBOL_PREFIX #symbol ", " #size);
274 # define declare_symbol_alias_1_stringify(x) \
275 declare_symbol_alias_1_stringify_1 (x)
276 # define declare_symbol_alias_1_stringify_1(x) #x
277 # ifdef HAVE_ASM_SET_DIRECTIVE
278 # define declare_symbol_alias_1_alias(symbol, original) \
279 ".set " __SYMBOL_PREFIX #symbol ", " __SYMBOL_PREFIX #original
280 # else
281 # define declare_symbol_alias_1_alias(symbol, original) \
282 __SYMBOL_PREFIX #symbol " = " __SYMBOL_PREFIX #original
283 # endif /* HAVE_ASM_SET_DIRECTIVE */
284 # endif /* __ASSEMBLER__ */
285 #else
286 # define declare_symbol_1(symbol, type, size) /* Nothing. */
287 #endif
294 /* Symbol set support macros. */
296 /* Make SYMBOL, which is in the text segment, an element of SET. */
297 #define text_set_element(set, symbol) _elf_set_element(set, symbol)
298 /* Make SYMBOL, which is in the data segment, an element of SET. */
299 #define data_set_element(set, symbol) _elf_set_element(set, symbol)
300 /* Make SYMBOL, which is in the bss segment, an element of SET. */
301 #define bss_set_element(set, symbol) _elf_set_element(set, symbol)
303 /* These are all done the same way in ELF.
304 There is a new section created for each set. */
305 #ifdef SHARED
306 /* When building a shared library, make the set section writable,
307 because it will need to be relocated at run time anyway. */
308 # define _elf_set_element(set, symbol) \
309 static const void *__elf_set_##set##_element_##symbol##__ \
310 __attribute__ ((used, section (#set))) = &(symbol)
311 #else
312 # define _elf_set_element(set, symbol) \
313 static const void *const __elf_set_##set##_element_##symbol##__ \
314 __attribute__ ((used, section (#set))) = &(symbol)
315 #endif
317 /* Define SET as a symbol set. This may be required (it is in a.out) to
318 be able to use the set's contents. */
319 #define symbol_set_define(set) symbol_set_declare(set)
321 /* Declare SET for use in this module, if defined in another module.
322 In a shared library, this is always local to that shared object.
323 For static linking, the set might be wholly absent and so we use
324 weak references. */
325 #define symbol_set_declare(set) \
326 extern char const __start_##set[] __symbol_set_attribute; \
327 extern char const __stop_##set[] __symbol_set_attribute;
328 #ifdef SHARED
329 # define __symbol_set_attribute attribute_hidden
330 #else
331 # define __symbol_set_attribute __attribute__ ((weak))
332 #endif
334 /* Return a pointer (void *const *) to the first element of SET. */
335 #define symbol_set_first_element(set) ((void *const *) (&__start_##set))
337 /* Return true iff PTR (a void *const *) has been incremented
338 past the last element in SET. */
339 #define symbol_set_end_p(set, ptr) ((ptr) >= (void *const *) &__stop_##set)
341 #if DO_VERSIONING
342 # define symbol_version(real, name, version) \
343 _symbol_version(real, name, version)
344 # define default_symbol_version(real, name, version) \
345 _default_symbol_version(real, name, version)
346 # ifdef __ASSEMBLER__
347 # ifdef HAVE_ASM_GLOBAL_DOT_NAME
348 # define _symbol_version(real, name, version) \
349 .symver real, name##@##version ASM_LINE_SEP \
350 .symver C_SYMBOL_DOT_NAME(real), C_SYMBOL_DOT_NAME(name##@##version)
351 # define _default_symbol_version(real, name, version) \
352 .symver real, name##@##@##version ASM_LINE_SEP \
353 .symver C_SYMBOL_DOT_NAME(real), C_SYMBOL_DOT_NAME(name##@##@##version)
354 # else
355 # define _symbol_version(real, name, version) \
356 .symver real, name##@##version
357 # define _default_symbol_version(real, name, version) \
358 .symver real, name##@##@##version
359 # endif
360 # else
361 # ifdef HAVE_ASM_GLOBAL_DOT_NAME
362 # define _symbol_version(real, name, version) \
363 __asm__ (".symver " #real "," #name "@" #version "\n\t" \
364 ".symver ." #real ",." #name "@" #version)
365 # define _default_symbol_version(real, name, version) \
366 __asm__ (".symver " #real "," #name "@@" #version "\n\t" \
367 ".symver ." #real ",." #name "@@" #version)
368 # else
369 # define _symbol_version(real, name, version) \
370 __asm__ (".symver " #real "," #name "@" #version)
371 # define _default_symbol_version(real, name, version) \
372 __asm__ (".symver " #real "," #name "@@" #version)
373 # endif
374 # endif
375 #else
376 # define symbol_version(real, name, version)
377 # define default_symbol_version(real, name, version) \
378 strong_alias(real, name)
379 #endif
381 #if defined SHARED || defined LIBC_NONSHARED
382 # define attribute_hidden __attribute__ ((visibility ("hidden")))
383 #else
384 # define attribute_hidden
385 #endif
387 #define attribute_tls_model_ie __attribute__ ((tls_model ("initial-exec")))
389 #define attribute_relro __attribute__ ((section (".data.rel.ro")))
391 /* Handling on non-exported internal names. We have to do this only
392 for shared code. */
393 #ifdef SHARED
394 # define INTUSE(name) name##_internal
395 # define INTDEF(name) strong_alias (name, name##_internal)
396 # define INTVARDEF(name) \
397 _INTVARDEF (name, name##_internal)
398 # define _INTVARDEF(name, aliasname) \
399 extern __typeof (name) aliasname __attribute__ ((alias (#name), \
400 visibility ("hidden")));
401 # define INTDEF2(name, newname) strong_alias (name, newname##_internal)
402 # define INTVARDEF2(name, newname) _INTVARDEF (name, newname##_internal)
403 #else
404 # define INTUSE(name) name
405 # define INTDEF(name)
406 # define INTVARDEF(name)
407 # define INTDEF2(name, newname)
408 # define INTVARDEF2(name, newname)
409 #endif
411 /* The following macros are used for PLT bypassing within libc.so
412 (and if needed other libraries similarly).
413 First of all, you need to have the function prototyped somewhere,
414 say in foo/foo.h:
416 int foo (int __bar);
418 If calls to foo within libc.so should always go to foo defined in libc.so,
419 then in include/foo.h you add:
421 libc_hidden_proto (foo)
423 line and after the foo function definition:
425 int foo (int __bar)
427 return __bar;
429 libc_hidden_def (foo)
433 int foo (int __bar)
435 return __bar;
437 libc_hidden_weak (foo)
439 Similarly for global data. If references to foo within libc.so should
440 always go to foo defined in libc.so, then in include/foo.h you add:
442 libc_hidden_proto (foo)
444 line and after foo's definition:
446 int foo = INITIAL_FOO_VALUE;
447 libc_hidden_data_def (foo)
451 int foo = INITIAL_FOO_VALUE;
452 libc_hidden_data_weak (foo)
454 If foo is normally just an alias (strong or weak) to some other function,
455 you should use the normal strong_alias first, then add libc_hidden_def
456 or libc_hidden_weak:
458 int baz (int __bar)
460 return __bar;
462 strong_alias (baz, foo)
463 libc_hidden_weak (foo)
465 If the function should be internal to multiple objects, say ld.so and
466 libc.so, the best way is to use:
468 #if !defined NOT_IN_libc || defined IS_IN_rtld
469 hidden_proto (foo)
470 #endif
472 in include/foo.h and the normal macros at all function definitions
473 depending on what DSO they belong to.
475 If versioned_symbol macro is used to define foo,
476 libc_hidden_ver macro should be used, as in:
478 int __real_foo (int __bar)
480 return __bar;
482 versioned_symbol (libc, __real_foo, foo, GLIBC_2_1);
483 libc_hidden_ver (__real_foo, foo) */
485 #if defined SHARED && defined DO_VERSIONING && !defined NO_HIDDEN
486 # ifndef __ASSEMBLER__
487 # define __hidden_proto_hiddenattr(attrs...) \
488 __attribute__ ((visibility ("hidden"), ##attrs))
489 # define hidden_proto(name, attrs...) \
490 __hidden_proto (name, __GI_##name, ##attrs)
491 # define __hidden_proto(name, internal, attrs...) \
492 extern __typeof (name) name __asm__ (__hidden_asmname (#internal)) \
493 __hidden_proto_hiddenattr (attrs);
494 # define __hidden_asmname(name) \
495 __hidden_asmname1 (__USER_LABEL_PREFIX__, name)
496 # define __hidden_asmname1(prefix, name) __hidden_asmname2(prefix, name)
497 # define __hidden_asmname2(prefix, name) #prefix name
498 # define __hidden_ver1(local, internal, name) \
499 extern __typeof (name) __EI_##name __asm__(__hidden_asmname (#internal)); \
500 extern __typeof (name) __EI_##name \
501 __attribute__((alias (__hidden_asmname (#local))))
502 # define hidden_ver(local, name) __hidden_ver1(local, __GI_##name, name);
503 # define hidden_data_ver(local, name) hidden_ver(local, name)
504 # define hidden_def(name) __hidden_ver1(__GI_##name, name, name);
505 # define hidden_data_def(name) hidden_def(name)
506 # define hidden_weak(name) \
507 __hidden_ver1(__GI_##name, name, name) __attribute__((weak));
508 # define hidden_data_weak(name) hidden_weak(name)
509 # define hidden_nolink(name, lib, version) \
510 __hidden_nolink1 (__GI_##name, __EI_##name, name, VERSION_##lib##_##version)
511 # define __hidden_nolink1(local, internal, name, version) \
512 __hidden_nolink2 (local, internal, name, version)
513 # define __hidden_nolink2(local, internal, name, version) \
514 extern __typeof (name) internal __attribute__ ((alias (#local))); \
515 __hidden_nolink3 (local, internal, #name "@" #version)
516 # define __hidden_nolink3(local, internal, vername) \
517 __asm__ (".symver " #internal ", " vername);
518 # else
519 /* For assembly, we need to do the opposite of what we do in C:
520 in assembly gcc __REDIRECT stuff is not in place, so functions
521 are defined by its normal name and we need to create the
522 __GI_* alias to it, in C __REDIRECT causes the function definition
523 to use __GI_* name and we need to add alias to the real name.
524 There is no reason to use hidden_weak over hidden_def in assembly,
525 but we provide it for consistency with the C usage.
526 hidden_proto doesn't make sense for assembly but the equivalent
527 is to call via the HIDDEN_JUMPTARGET macro instead of JUMPTARGET. */
528 # define hidden_def(name) strong_alias (name, __GI_##name)
529 # define hidden_weak(name) hidden_def (name)
530 # define hidden_ver(local, name) strong_alias (local, __GI_##name)
531 # define hidden_data_def(name) strong_data_alias (name, __GI_##name)
532 # define hidden_data_weak(name) hidden_data_def (name)
533 # define hidden_data_ver(local, name) strong_data_alias (local, __GI_##name)
534 # ifdef HAVE_ASM_GLOBAL_DOT_NAME
535 # define HIDDEN_JUMPTARGET(name) .__GI_##name
536 # else
537 # define HIDDEN_JUMPTARGET(name) __GI_##name
538 # endif
539 # endif
540 #else
541 # ifndef __ASSEMBLER__
542 # define hidden_proto(name, attrs...)
543 # else
544 # define HIDDEN_JUMPTARGET(name) JUMPTARGET(name)
545 # endif /* Not __ASSEMBLER__ */
546 # define hidden_weak(name)
547 # define hidden_def(name)
548 # define hidden_ver(local, name)
549 # define hidden_data_weak(name)
550 # define hidden_data_def(name)
551 # define hidden_data_ver(local, name)
552 # define hidden_nolink(name, lib, version)
553 #endif
555 #if !defined NOT_IN_libc
556 # define libc_hidden_proto(name, attrs...) hidden_proto (name, ##attrs)
557 # define libc_hidden_def(name) hidden_def (name)
558 # define libc_hidden_weak(name) hidden_weak (name)
559 # ifdef LINK_OBSOLETE_RPC
560 /* libc_hidden_nolink_sunrpc should only get used in sunrpc code. */
561 # define libc_hidden_nolink_sunrpc(name, version) hidden_def (name)
562 # else
563 # define libc_hidden_nolink_sunrpc(name, version) hidden_nolink (name, libc, version)
564 # endif
565 # define libc_hidden_ver(local, name) hidden_ver (local, name)
566 # define libc_hidden_data_def(name) hidden_data_def (name)
567 # define libc_hidden_data_weak(name) hidden_data_weak (name)
568 # define libc_hidden_data_ver(local, name) hidden_data_ver (local, name)
569 #else
570 # define libc_hidden_proto(name, attrs...)
571 # define libc_hidden_def(name)
572 # define libc_hidden_weak(name)
573 # define libc_hidden_ver(local, name)
574 # define libc_hidden_data_def(name)
575 # define libc_hidden_data_weak(name)
576 # define libc_hidden_data_ver(local, name)
577 #endif
579 #if defined NOT_IN_libc && defined IS_IN_rtld
580 # define rtld_hidden_proto(name, attrs...) hidden_proto (name, ##attrs)
581 # define rtld_hidden_def(name) hidden_def (name)
582 # define rtld_hidden_weak(name) hidden_weak (name)
583 # define rtld_hidden_ver(local, name) hidden_ver (local, name)
584 # define rtld_hidden_data_def(name) hidden_data_def (name)
585 # define rtld_hidden_data_weak(name) hidden_data_weak (name)
586 # define rtld_hidden_data_ver(local, name) hidden_data_ver (local, name)
587 #else
588 # define rtld_hidden_proto(name, attrs...)
589 # define rtld_hidden_def(name)
590 # define rtld_hidden_weak(name)
591 # define rtld_hidden_ver(local, name)
592 # define rtld_hidden_data_def(name)
593 # define rtld_hidden_data_weak(name)
594 # define rtld_hidden_data_ver(local, name)
595 #endif
597 #if defined NOT_IN_libc && defined IS_IN_libm
598 # define libm_hidden_proto(name, attrs...) hidden_proto (name, ##attrs)
599 # define libm_hidden_def(name) hidden_def (name)
600 # define libm_hidden_weak(name) hidden_weak (name)
601 # define libm_hidden_ver(local, name) hidden_ver (local, name)
602 # define libm_hidden_data_def(name) hidden_data_def (name)
603 # define libm_hidden_data_weak(name) hidden_data_weak (name)
604 # define libm_hidden_data_ver(local, name) hidden_data_ver (local, name)
605 #else
606 # define libm_hidden_proto(name, attrs...)
607 # define libm_hidden_def(name)
608 # define libm_hidden_weak(name)
609 # define libm_hidden_ver(local, name)
610 # define libm_hidden_data_def(name)
611 # define libm_hidden_data_weak(name)
612 # define libm_hidden_data_ver(local, name)
613 #endif
615 #if defined NOT_IN_libc && defined IS_IN_libresolv
616 # define libresolv_hidden_proto(name, attrs...) hidden_proto (name, ##attrs)
617 # define libresolv_hidden_def(name) hidden_def (name)
618 # define libresolv_hidden_weak(name) hidden_weak (name)
619 # define libresolv_hidden_ver(local, name) hidden_ver (local, name)
620 # define libresolv_hidden_data_def(name) hidden_data_def (name)
621 # define libresolv_hidden_data_weak(name) hidden_data_weak (name)
622 # define libresolv_hidden_data_ver(local, name) hidden_data_ver (local, name)
623 #else
624 # define libresolv_hidden_proto(name, attrs...)
625 # define libresolv_hidden_def(name)
626 # define libresolv_hidden_weak(name)
627 # define libresolv_hidden_ver(local, name)
628 # define libresolv_hidden_data_def(name)
629 # define libresolv_hidden_data_weak(name)
630 # define libresolv_hidden_data_ver(local, name)
631 #endif
633 #if defined NOT_IN_libc && defined IS_IN_librt
634 # define librt_hidden_proto(name, attrs...) hidden_proto (name, ##attrs)
635 # define librt_hidden_def(name) hidden_def (name)
636 # define librt_hidden_weak(name) hidden_weak (name)
637 # define librt_hidden_ver(local, name) hidden_ver (local, name)
638 # define librt_hidden_data_def(name) hidden_data_def (name)
639 # define librt_hidden_data_weak(name) hidden_data_weak (name)
640 # define librt_hidden_data_ver(local, name) hidden_data_ver (local, name)
641 #else
642 # define librt_hidden_proto(name, attrs...)
643 # define librt_hidden_def(name)
644 # define librt_hidden_weak(name)
645 # define librt_hidden_ver(local, name)
646 # define librt_hidden_data_def(name)
647 # define librt_hidden_data_weak(name)
648 # define librt_hidden_data_ver(local, name)
649 #endif
651 #if defined NOT_IN_libc && defined IS_IN_libdl
652 # define libdl_hidden_proto(name, attrs...) hidden_proto (name, ##attrs)
653 # define libdl_hidden_def(name) hidden_def (name)
654 # define libdl_hidden_weak(name) hidden_weak (name)
655 # define libdl_hidden_ver(local, name) hidden_ver (local, name)
656 # define libdl_hidden_data_def(name) hidden_data_def (name)
657 # define libdl_hidden_data_weak(name) hidden_data_weak (name)
658 # define libdl_hidden_data_ver(local, name) hidden_data_ver (local, name)
659 #else
660 # define libdl_hidden_proto(name, attrs...)
661 # define libdl_hidden_def(name)
662 # define libdl_hidden_weak(name)
663 # define libdl_hidden_ver(local, name)
664 # define libdl_hidden_data_def(name)
665 # define libdl_hidden_data_weak(name)
666 # define libdl_hidden_data_ver(local, name)
667 #endif
669 #if defined NOT_IN_libc && defined IS_IN_libnss_files
670 # define libnss_files_hidden_proto(name, attrs...) hidden_proto (name, ##attrs)
671 # define libnss_files_hidden_def(name) hidden_def (name)
672 # define libnss_files_hidden_weak(name) hidden_weak (name)
673 # define libnss_files_hidden_ver(local, name) hidden_ver (local, name)
674 # define libnss_files_hidden_data_def(name) hidden_data_def (name)
675 # define libnss_files_hidden_data_weak(name) hidden_data_weak (name)
676 # define libnss_files_hidden_data_ver(local, name) hidden_data_ver(local, name)
677 #else
678 # define libnss_files_hidden_proto(name, attrs...)
679 # define libnss_files_hidden_def(name)
680 # define libnss_files_hidden_weak(name)
681 # define libnss_files_hidden_ver(local, name)
682 # define libnss_files_hidden_data_def(name)
683 # define libnss_files_hidden_data_weak(name)
684 # define libnss_files_hidden_data_ver(local, name)
685 #endif
687 #if defined NOT_IN_libc && defined IS_IN_libnsl
688 # define libnsl_hidden_proto(name, attrs...) hidden_proto (name, ##attrs)
689 # define libnsl_hidden_def(name) hidden_def (name)
690 # define libnsl_hidden_weak(name) hidden_weak (name)
691 # define libnsl_hidden_ver(local, name) hidden_ver (local, name)
692 # define libnsl_hidden_data_def(name) hidden_data_def (name)
693 # define libnsl_hidden_data_weak(name) hidden_data_weak (name)
694 # define libnsl_hidden_data_ver(local, name) hidden_data_ver (local, name)
695 #else
696 # define libnsl_hidden_proto(name, attrs...)
697 # define libnsl_hidden_def(name)
698 # define libnsl_hidden_weak(name)
699 # define libnsl_hidden_ver(local, name)
700 # define libnsl_hidden_data_def(name)
701 # define libnsl_hidden_data_weak(name)
702 # define libnsl_hidden_data_ver(local, name)
703 #endif
705 #if defined NOT_IN_libc && defined IS_IN_libnss_nisplus
706 # define libnss_nisplus_hidden_proto(name, attrs...) hidden_proto (name, ##attrs)
707 # define libnss_nisplus_hidden_def(name) hidden_def (name)
708 # define libnss_nisplus_hidden_weak(name) hidden_weak (name)
709 # define libnss_nisplus_hidden_ver(local, name) hidden_ver (local, name)
710 # define libnss_nisplus_hidden_data_def(name) hidden_data_def (name)
711 # define libnss_nisplus_hidden_data_weak(name) hidden_data_weak (name)
712 # define libnss_nisplus_hidden_data_ver(local, name) hidden_data_ver (local, name)
713 #else
714 # define libnss_nisplus_hidden_proto(name, attrs...)
715 # define libnss_nisplus_hidden_def(name)
716 # define libnss_nisplus_hidden_weak(name)
717 # define libnss_nisplus_hidden_ver(local, name)
718 # define libnss_nisplus_hidden_data_def(name)
719 # define libnss_nisplus_hidden_data_weak(name)
720 # define libnss_nisplus_hidden_data_ver(local, name)
721 #endif
723 #define libc_hidden_builtin_proto(name, attrs...) libc_hidden_proto (name, ##attrs)
724 #define libc_hidden_builtin_def(name) libc_hidden_def (name)
725 #define libc_hidden_builtin_weak(name) libc_hidden_weak (name)
726 #define libc_hidden_builtin_ver(local, name) libc_hidden_ver (local, name)
727 #ifdef __ASSEMBLER__
728 # define HIDDEN_BUILTIN_JUMPTARGET(name) HIDDEN_JUMPTARGET(name)
729 #endif
731 #if defined NOT_IN_libc && defined IS_IN_libutil
732 # define libutil_hidden_proto(name, attrs...) hidden_proto (name, ##attrs)
733 # define libutil_hidden_def(name) hidden_def (name)
734 # define libutil_hidden_weak(name) hidden_weak (name)
735 # define libutil_hidden_ver(local, name) hidden_ver (local, name)
736 # define libutil_hidden_data_def(name) hidden_data_def (name)
737 # define libutil_hidden_data_weak(name) hidden_data_weak (name)
738 # define libutil_hidden_data_ver(local, name) hidden_data_ver (local, name)
739 #else
740 # define libutil_hidden_proto(name, attrs...)
741 # define libutil_hidden_def(name)
742 # define libutil_hidden_weak(name)
743 # define libutil_hidden_ver(local, name)
744 # define libutil_hidden_data_def(name)
745 # define libutil_hidden_data_weak(name)
746 # define libutil_hidden_data_ver(local, name)
747 #endif
749 /* Get some dirty hacks. */
750 #include <symbol-hacks.h>
752 /* Move compatibility symbols out of the way by placing them all in a
753 special section. */
754 #ifndef __ASSEMBLER__
755 # define attribute_compat_text_section \
756 __attribute__ ((section (".text.compat")))
757 # define attribute_compat_data_section \
758 __attribute__ ((section (".data.compat")))
759 #else
760 # define compat_text_section .section ".text.compat", "ax";
761 # define compat_data_section .section ".data.compat", "aw";
762 #endif
764 /* Marker used for indirection function symbols. */
765 #define libc_ifunc(name, expr) \
766 extern void *name##_ifunc (void) __asm__ (#name); \
767 void *name##_ifunc (void) \
769 INIT_ARCH (); \
770 __typeof (name) *res = expr; \
771 return res; \
773 __asm__ (".type " #name ", %gnu_indirect_function");
775 /* The body of the function is supposed to use __get_cpu_features
776 which will, if necessary, initialize the data first. */
777 #define libm_ifunc(name, expr) \
778 extern void *name##_ifunc (void) __asm__ (#name); \
779 void *name##_ifunc (void) \
781 __typeof (name) *res = expr; \
782 return res; \
784 __asm__ (".type " #name ", %gnu_indirect_function");
786 #ifdef HAVE_ASM_SET_DIRECTIVE
787 # define libc_ifunc_hidden_def1(local, name) \
788 __asm__ (declare_symbol_alias_1_stringify (ASM_GLOBAL_DIRECTIVE) \
789 " " #local "\n\t" \
790 ".hidden " #local "\n\t" \
791 ".set " #local ", " #name);
792 #else
793 # define libc_ifunc_hidden_def1(local, name) \
794 __asm__ (declare_symbol_alias_1_stringify (ASM_GLOBAL_DIRECTIVE) \
795 " " #local "\n\t" \
796 ".hidden " #local "\n\t" \
797 #local " = " #name);
798 #endif
800 #define libc_ifunc_hidden_def(name) \
801 libc_ifunc_hidden_def1 (__GI_##name, name)
803 #endif /* libc-symbols.h */