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