Update copyright dates with scripts/update-copyrights.
[glibc.git] / include / libc-symbols.h
blob2da0ab4896b954ee7121e6b93406496d0cea33c7
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-2015 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 #define IN_MODULE PASTE_NAME (MODULE_, MODULE_NAME)
24 #define IS_IN(lib) (IN_MODULE == MODULE_##lib)
26 /* Returns true if the current module is a versioned library. Versioned
27 library names culled from shlib-versions files are assigned a MODULE_*
28 value lower than MODULE_LIBS_BEGIN. */
29 #define IS_IN_LIB (IN_MODULE > MODULE_LIBS_BEGIN)
31 #define PASTE_NAME(a,b) PASTE_NAME1 (a,b)
32 #define PASTE_NAME1(a,b) a##b
34 /* This file's macros are included implicitly in the compilation of every
35 file in the C library by -imacros.
37 We include config.h which is generated by configure.
38 It should define for us the following symbols:
40 * HAVE_ASM_SET_DIRECTIVE if we have `.set B, A' instead of `A = B'.
41 * HAVE_ASM_WEAK_DIRECTIVE if we have weak symbols using `.weak'.
42 * HAVE_ASM_WEAKEXT_DIRECTIVE if we have weak symbols using `.weakext'.
46 /* This is defined for the compilation of all C library code. features.h
47 tests this to avoid inclusion of stubs.h while compiling the library,
48 before stubs.h has been generated. Some library code that is shared
49 with other packages also tests this symbol to see if it is being
50 compiled as part of the C library. We must define this before including
51 config.h, because it makes some definitions conditional on whether libc
52 itself is being compiled, or just some generator program. */
53 #define _LIBC 1
55 /* Enable declarations of GNU extensions, since we are compiling them. */
56 #define _GNU_SOURCE 1
57 /* And we also need the data for the reentrant functions. */
58 #define _REENTRANT 1
60 #include <config.h>
62 /* Define this for the benefit of portable GNU code that wants to check it.
63 Code that checks with #if will not #include <config.h> again, since we've
64 already done it (and this file is implicitly included in every compile,
65 via -include). Code that checks with #ifdef will #include <config.h>,
66 but that file should always be idempotent (i.e., it's just #define/#undef
67 and nothing else anywhere should be changing the macro state it touches),
68 so it's harmless. */
69 #define HAVE_CONFIG_H 0
71 /* Define these macros for the benefit of portable GNU code that wants to check
72 them. Of course, STDC_HEADERS is never false when building libc! */
73 #define STDC_HEADERS 1
74 #define HAVE_MBSTATE_T 1
75 #define HAVE_MBSRTOWCS 1
76 #define HAVE_LIBINTL_H 1
77 #define HAVE_WCTYPE_H 1
78 #define HAVE_ISWCTYPE 1
79 #define ENABLE_NLS 1
81 /* The symbols in all the user (non-_) macros are C symbols. */
83 #if !defined HAVE_ASM_WEAK_DIRECTIVE && !defined HAVE_ASM_WEAKEXT_DIRECTIVE
84 # error "weak symbol support needed"
85 #endif
87 #ifndef __SYMBOL_PREFIX
88 # define __SYMBOL_PREFIX
89 #endif
91 #ifndef C_SYMBOL_NAME
92 # define C_SYMBOL_NAME(name) name
93 #endif
95 #ifndef ASM_LINE_SEP
96 # define ASM_LINE_SEP ;
97 #endif
99 #ifdef HAVE_ASM_GLOBAL_DOT_NAME
100 # ifndef C_SYMBOL_DOT_NAME
101 # if defined __GNUC__ && defined __GNUC_MINOR__ \
102 && (__GNUC__ << 16) + __GNUC_MINOR__ >= (3 << 16) + 1
103 # define C_SYMBOL_DOT_NAME(name) .name
104 # else
105 # define C_SYMBOL_DOT_NAME(name) .##name
106 # endif
107 # endif
108 #endif
110 #ifndef __ASSEMBLER__
111 /* GCC understands weak symbols and aliases; use its interface where
112 possible, instead of embedded assembly language. */
114 /* Define ALIASNAME as a strong alias for NAME. */
115 # define strong_alias(name, aliasname) _strong_alias(name, aliasname)
116 # define _strong_alias(name, aliasname) \
117 extern __typeof (name) aliasname __attribute__ ((alias (#name)));
119 /* This comes between the return type and function name in
120 a function definition to make that definition weak. */
121 # define weak_function __attribute__ ((weak))
122 # define weak_const_function __attribute__ ((weak, __const__))
124 /* Define ALIASNAME as a weak alias for NAME.
125 If weak aliases are not available, this defines a strong alias. */
126 # define weak_alias(name, aliasname) _weak_alias (name, aliasname)
127 # define _weak_alias(name, aliasname) \
128 extern __typeof (name) aliasname __attribute__ ((weak, alias (#name)));
130 /* Same as WEAK_ALIAS, but mark symbol as hidden. */
131 # define weak_hidden_alias(name, aliasname) \
132 _weak_hidden_alias (name, aliasname)
133 # define _weak_hidden_alias(name, aliasname) \
134 extern __typeof (name) aliasname \
135 __attribute__ ((weak, alias (#name), __visibility__ ("hidden")));
137 /* Declare SYMBOL as weak undefined symbol (resolved to 0 if not defined). */
138 # define weak_extern(symbol) _weak_extern (weak symbol)
139 # define _weak_extern(expr) _Pragma (#expr)
142 #else /* __ASSEMBLER__ */
144 # ifdef HAVE_ASM_SET_DIRECTIVE
145 # ifdef HAVE_ASM_GLOBAL_DOT_NAME
146 # define strong_alias(original, alias) \
147 .globl C_SYMBOL_NAME (alias) ASM_LINE_SEP \
148 .set C_SYMBOL_NAME (alias),C_SYMBOL_NAME (original) ASM_LINE_SEP \
149 .globl C_SYMBOL_DOT_NAME (alias) ASM_LINE_SEP \
150 .set C_SYMBOL_DOT_NAME (alias),C_SYMBOL_DOT_NAME (original)
151 # define strong_data_alias(original, alias) \
152 .globl C_SYMBOL_NAME (alias) ASM_LINE_SEP \
153 .set C_SYMBOL_NAME (alias),C_SYMBOL_NAME (original)
154 # else
155 # define strong_alias(original, alias) \
156 .globl C_SYMBOL_NAME (alias) ASM_LINE_SEP \
157 .set C_SYMBOL_NAME (alias),C_SYMBOL_NAME (original)
158 # define strong_data_alias(original, alias) strong_alias(original, alias)
159 # endif
160 # else
161 # ifdef HAVE_ASM_GLOBAL_DOT_NAME
162 # define strong_alias(original, alias) \
163 .globl C_SYMBOL_NAME (alias) ASM_LINE_SEP \
164 C_SYMBOL_NAME (alias) = C_SYMBOL_NAME (original) ASM_LINE_SEP \
165 .globl C_SYMBOL_DOT_NAME (alias) ASM_LINE_SEP \
166 C_SYMBOL_DOT_NAME (alias) = C_SYMBOL_DOT_NAME (original)
167 # define strong_data_alias(original, alias) \
168 .globl C_SYMBOL_NAME (alias) ASM_LINE_SEP \
169 C_SYMBOL_NAME (alias) = C_SYMBOL_NAME (original)
170 # else
171 # define strong_alias(original, alias) \
172 .globl C_SYMBOL_NAME (alias) ASM_LINE_SEP \
173 C_SYMBOL_NAME (alias) = C_SYMBOL_NAME (original)
174 # define strong_data_alias(original, alias) strong_alias(original, alias)
175 # endif
176 # endif
178 # ifdef HAVE_ASM_WEAKEXT_DIRECTIVE
179 # ifdef HAVE_ASM_GLOBAL_DOT_NAME
180 # define weak_alias(original, alias) \
181 .weakext C_SYMBOL_NAME (alias), C_SYMBOL_NAME (original) ASM_LINE_SEP \
182 .weakext C_SYMBOL_DOT_NAME (alias), C_SYMBOL_DOT_NAME (original)
183 # else
184 # define weak_alias(original, alias) \
185 .weakext C_SYMBOL_NAME (alias), C_SYMBOL_NAME (original)
186 # endif
187 # define weak_extern(symbol) \
188 .weakext C_SYMBOL_NAME (symbol)
190 # else /* ! HAVE_ASM_WEAKEXT_DIRECTIVE */
192 # ifdef HAVE_ASM_GLOBAL_DOT_NAME
193 # define weak_alias(original, alias) \
194 .weak C_SYMBOL_NAME (alias) ASM_LINE_SEP \
195 C_SYMBOL_NAME (alias) = C_SYMBOL_NAME (original) ASM_LINE_SEP \
196 .weak C_SYMBOL_DOT_NAME (alias) ASM_LINE_SEP \
197 C_SYMBOL_DOT_NAME (alias) = C_SYMBOL_DOT_NAME (original)
198 # else
199 # define weak_alias(original, alias) \
200 .weak C_SYMBOL_NAME (alias) ASM_LINE_SEP \
201 C_SYMBOL_NAME (alias) = C_SYMBOL_NAME (original)
202 # endif
204 # define weak_extern(symbol) \
205 .weak C_SYMBOL_NAME (symbol)
207 # endif /* ! HAVE_ASM_WEAKEXT_DIRECTIVE */
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 /* Determine the return address. */
219 #define RETURN_ADDRESS(nr) \
220 __builtin_extract_return_addr (__builtin_return_address (nr))
222 /* When a reference to SYMBOL is encountered, the linker will emit a
223 warning message MSG. */
224 /* We want the .gnu.warning.SYMBOL section to be unallocated. */
225 #ifdef HAVE_ASM_PREVIOUS_DIRECTIVE
226 # define __make_section_unallocated(section_string) \
227 asm (".section " section_string "\n\t.previous");
228 #elif defined HAVE_ASM_POPSECTION_DIRECTIVE
229 # define __make_section_unallocated(section_string) \
230 asm (".pushsection " section_string "\n\t.popsection");
231 #else
232 # define __make_section_unallocated(section_string)
233 #endif
235 /* Tacking on "\n\t#" to the section name makes gcc put it's bogus
236 section attributes on what looks like a comment to the assembler. */
237 #ifdef HAVE_SECTION_QUOTES
238 # define __sec_comment "\"\n\t#\""
239 #else
240 # define __sec_comment "\n\t#"
241 #endif
242 #define link_warning(symbol, msg) \
243 __make_section_unallocated (".gnu.warning." #symbol) \
244 static const char __evoke_link_warning_##symbol[] \
245 __attribute__ ((used, section (".gnu.warning." #symbol __sec_comment))) \
246 = msg;
247 #define libc_freeres_ptr(decl) \
248 __make_section_unallocated ("__libc_freeres_ptrs, \"aw\", %nobits") \
249 decl __attribute__ ((section ("__libc_freeres_ptrs" __sec_comment)))
250 #define __libc_freeres_fn_section \
251 __attribute__ ((section ("__libc_freeres_fn")))
253 #define libc_freeres_fn(name) \
254 static void name (void) __attribute_used__ __libc_freeres_fn_section; \
255 text_set_element (__libc_subfreeres, name); \
256 static void name (void)
258 /* A canned warning for sysdeps/stub functions. */
259 #define stub_warning(name) \
260 __make_section_unallocated (".gnu.glibc-stub." #name) \
261 link_warning (name, #name " is not implemented and will always fail")
263 /* Warning for linking functions calling dlopen into static binaries. */
264 #ifdef SHARED
265 #define static_link_warning(name)
266 #else
267 #define static_link_warning(name) static_link_warning1(name)
268 #define static_link_warning1(name) \
269 link_warning(name, "Using '" #name "' in statically linked applications \
270 requires at runtime the shared libraries from the glibc version used \
271 for linking")
272 #endif
274 /* Declare SYMBOL to be TYPE (`function' or `object') of SIZE bytes
275 alias to ORIGINAL, when the assembler supports such declarations
276 (such as in ELF).
277 This is only necessary when defining something in assembly, or playing
278 funny alias games where the size should be other than what the compiler
279 thinks it is. */
280 #define declare_symbol_alias(symbol, original, type, size) \
281 declare_symbol_alias_1 (symbol, original, type, size)
282 #ifdef __ASSEMBLER__
283 # define declare_symbol_alias_1(symbol, original, type, size) \
284 strong_alias (original, symbol); \
285 .type C_SYMBOL_NAME (symbol), %##type; \
286 .size C_SYMBOL_NAME (symbol), size
287 #else /* Not __ASSEMBLER__. */
288 # define declare_symbol_alias_1(symbol, original, type, size) \
289 asm (".globl " __SYMBOL_PREFIX #symbol \
290 "\n\t" declare_symbol_alias_1_alias (symbol, original) \
291 "\n\t.type " __SYMBOL_PREFIX #symbol ", " \
292 "%" #type \
293 "\n\t.size " __SYMBOL_PREFIX #symbol ", " #size);
294 # ifdef HAVE_ASM_SET_DIRECTIVE
295 # define declare_symbol_alias_1_alias(symbol, original) \
296 ".set " __SYMBOL_PREFIX #symbol ", " __SYMBOL_PREFIX #original
297 # else
298 # define declare_symbol_alias_1_alias(symbol, original) \
299 __SYMBOL_PREFIX #symbol " = " __SYMBOL_PREFIX #original
300 # endif /* HAVE_ASM_SET_DIRECTIVE */
301 #endif /* __ASSEMBLER__ */
308 /* Symbol set support macros. */
310 /* Make SYMBOL, which is in the text segment, an element of SET. */
311 #define text_set_element(set, symbol) _elf_set_element(set, symbol)
312 /* Make SYMBOL, which is in the data segment, an element of SET. */
313 #define data_set_element(set, symbol) _elf_set_element(set, symbol)
314 /* Make SYMBOL, which is in the bss segment, an element of SET. */
315 #define bss_set_element(set, symbol) _elf_set_element(set, symbol)
317 /* These are all done the same way in ELF.
318 There is a new section created for each set. */
319 #ifdef SHARED
320 /* When building a shared library, make the set section writable,
321 because it will need to be relocated at run time anyway. */
322 # define _elf_set_element(set, symbol) \
323 static const void *__elf_set_##set##_element_##symbol##__ \
324 __attribute__ ((used, section (#set))) = &(symbol)
325 #else
326 # define _elf_set_element(set, symbol) \
327 static const void *const __elf_set_##set##_element_##symbol##__ \
328 __attribute__ ((used, section (#set))) = &(symbol)
329 #endif
331 /* Define SET as a symbol set. This may be required (it is in a.out) to
332 be able to use the set's contents. */
333 #define symbol_set_define(set) symbol_set_declare(set)
335 /* Declare SET for use in this module, if defined in another module.
336 In a shared library, this is always local to that shared object.
337 For static linking, the set might be wholly absent and so we use
338 weak references. */
339 #define symbol_set_declare(set) \
340 extern char const __start_##set[] __symbol_set_attribute; \
341 extern char const __stop_##set[] __symbol_set_attribute;
342 #ifdef SHARED
343 # define __symbol_set_attribute attribute_hidden
344 #else
345 # define __symbol_set_attribute __attribute__ ((weak))
346 #endif
348 /* Return a pointer (void *const *) to the first element of SET. */
349 #define symbol_set_first_element(set) ((void *const *) (&__start_##set))
351 /* Return true iff PTR (a void *const *) has been incremented
352 past the last element in SET. */
353 #define symbol_set_end_p(set, ptr) ((ptr) >= (void *const *) &__stop_##set)
355 #ifdef SHARED
356 # define symbol_version(real, name, version) \
357 _symbol_version(real, name, version)
358 # define default_symbol_version(real, name, version) \
359 _default_symbol_version(real, name, version)
360 # ifdef __ASSEMBLER__
361 # ifdef HAVE_ASM_GLOBAL_DOT_NAME
362 # define _symbol_version(real, name, version) \
363 .symver real, name##@##version ASM_LINE_SEP \
364 .symver C_SYMBOL_DOT_NAME(real), C_SYMBOL_DOT_NAME(name##@##version)
365 # define _default_symbol_version(real, name, version) \
366 .symver real, name##@##@##version ASM_LINE_SEP \
367 .symver C_SYMBOL_DOT_NAME(real), C_SYMBOL_DOT_NAME(name##@##@##version)
368 # else
369 # define _symbol_version(real, name, version) \
370 .symver real, name##@##version
371 # define _default_symbol_version(real, name, version) \
372 .symver real, name##@##@##version
373 # endif
374 # else
375 # ifdef HAVE_ASM_GLOBAL_DOT_NAME
376 # define _symbol_version(real, name, version) \
377 __asm__ (".symver " #real "," #name "@" #version "\n\t" \
378 ".symver ." #real ",." #name "@" #version)
379 # define _default_symbol_version(real, name, version) \
380 __asm__ (".symver " #real "," #name "@@" #version "\n\t" \
381 ".symver ." #real ",." #name "@@" #version)
382 # else
383 # define _symbol_version(real, name, version) \
384 __asm__ (".symver " #real "," #name "@" #version)
385 # define _default_symbol_version(real, name, version) \
386 __asm__ (".symver " #real "," #name "@@" #version)
387 # endif
388 # endif
389 #else
390 # define symbol_version(real, name, version)
391 # define default_symbol_version(real, name, version) \
392 strong_alias(real, name)
393 #endif
395 #if defined SHARED || defined LIBC_NONSHARED
396 # define attribute_hidden __attribute__ ((visibility ("hidden")))
397 #else
398 # define attribute_hidden
399 #endif
401 #define attribute_tls_model_ie __attribute__ ((tls_model ("initial-exec")))
403 #define attribute_relro __attribute__ ((section (".data.rel.ro")))
405 /* The following macros are used for PLT bypassing within libc.so
406 (and if needed other libraries similarly).
407 First of all, you need to have the function prototyped somewhere,
408 say in foo/foo.h:
410 int foo (int __bar);
412 If calls to foo within libc.so should always go to foo defined in libc.so,
413 then in include/foo.h you add:
415 libc_hidden_proto (foo)
417 line and after the foo function definition:
419 int foo (int __bar)
421 return __bar;
423 libc_hidden_def (foo)
427 int foo (int __bar)
429 return __bar;
431 libc_hidden_weak (foo)
433 Similarly for global data. If references to foo within libc.so should
434 always go to foo defined in libc.so, then in include/foo.h you add:
436 libc_hidden_proto (foo)
438 line and after foo's definition:
440 int foo = INITIAL_FOO_VALUE;
441 libc_hidden_data_def (foo)
445 int foo = INITIAL_FOO_VALUE;
446 libc_hidden_data_weak (foo)
448 If foo is normally just an alias (strong or weak) to some other function,
449 you should use the normal strong_alias first, then add libc_hidden_def
450 or libc_hidden_weak:
452 int baz (int __bar)
454 return __bar;
456 strong_alias (baz, foo)
457 libc_hidden_weak (foo)
459 If the function should be internal to multiple objects, say ld.so and
460 libc.so, the best way is to use:
462 #if IS_IN (libc) || IS_IN (rtld)
463 hidden_proto (foo)
464 #endif
466 in include/foo.h and the normal macros at all function definitions
467 depending on what DSO they belong to.
469 If versioned_symbol macro is used to define foo,
470 libc_hidden_ver macro should be used, as in:
472 int __real_foo (int __bar)
474 return __bar;
476 versioned_symbol (libc, __real_foo, foo, GLIBC_2_1);
477 libc_hidden_ver (__real_foo, foo) */
479 #if defined SHARED && !defined NO_HIDDEN
480 # ifndef __ASSEMBLER__
481 # define __hidden_proto_hiddenattr(attrs...) \
482 __attribute__ ((visibility ("hidden"), ##attrs))
483 # define hidden_proto(name, attrs...) \
484 __hidden_proto (name, , __GI_##name, ##attrs)
485 # define hidden_tls_proto(name, attrs...) \
486 __hidden_proto (name, __thread, __GI_##name, ##attrs)
487 # define __hidden_proto(name, thread, internal, attrs...) \
488 extern thread __typeof (name) name __asm__ (__hidden_asmname (#internal)) \
489 __hidden_proto_hiddenattr (attrs);
490 # define __hidden_asmname(name) \
491 __hidden_asmname1 (__USER_LABEL_PREFIX__, name)
492 # define __hidden_asmname1(prefix, name) __hidden_asmname2(prefix, name)
493 # define __hidden_asmname2(prefix, name) #prefix name
494 # define __hidden_ver1(local, internal, name) \
495 extern __typeof (name) __EI_##name __asm__(__hidden_asmname (#internal)); \
496 extern __typeof (name) __EI_##name \
497 __attribute__((alias (__hidden_asmname (#local))))
498 # define hidden_ver(local, name) __hidden_ver1(local, __GI_##name, name);
499 # define hidden_data_ver(local, name) hidden_ver(local, name)
500 # define hidden_def(name) __hidden_ver1(__GI_##name, name, name);
501 # define hidden_data_def(name) hidden_def(name)
502 # define hidden_weak(name) \
503 __hidden_ver1(__GI_##name, name, name) __attribute__((weak));
504 # define hidden_data_weak(name) hidden_weak(name)
505 # define hidden_nolink(name, lib, version) \
506 __hidden_nolink1 (__GI_##name, __EI_##name, name, VERSION_##lib##_##version)
507 # define __hidden_nolink1(local, internal, name, version) \
508 __hidden_nolink2 (local, internal, name, version)
509 # define __hidden_nolink2(local, internal, name, version) \
510 extern __typeof (name) internal __attribute__ ((alias (#local))); \
511 __hidden_nolink3 (local, internal, #name "@" #version)
512 # define __hidden_nolink3(local, internal, vername) \
513 __asm__ (".symver " #internal ", " vername);
514 # else
515 /* For assembly, we need to do the opposite of what we do in C:
516 in assembly gcc __REDIRECT stuff is not in place, so functions
517 are defined by its normal name and we need to create the
518 __GI_* alias to it, in C __REDIRECT causes the function definition
519 to use __GI_* name and we need to add alias to the real name.
520 There is no reason to use hidden_weak over hidden_def in assembly,
521 but we provide it for consistency with the C usage.
522 hidden_proto doesn't make sense for assembly but the equivalent
523 is to call via the HIDDEN_JUMPTARGET macro instead of JUMPTARGET. */
524 # define hidden_def(name) strong_alias (name, __GI_##name)
525 # define hidden_weak(name) hidden_def (name)
526 # define hidden_ver(local, name) strong_alias (local, __GI_##name)
527 # define hidden_data_def(name) strong_data_alias (name, __GI_##name)
528 # define hidden_data_weak(name) hidden_data_def (name)
529 # define hidden_data_ver(local, name) strong_data_alias (local, __GI_##name)
530 # ifdef HAVE_ASM_GLOBAL_DOT_NAME
531 # define HIDDEN_JUMPTARGET(name) .__GI_##name
532 # else
533 # define HIDDEN_JUMPTARGET(name) __GI_##name
534 # endif
535 # endif
536 #else
537 # ifndef __ASSEMBLER__
538 # define hidden_proto(name, attrs...)
539 # define hidden_tls_proto(name, attrs...)
540 # else
541 # define HIDDEN_JUMPTARGET(name) JUMPTARGET(name)
542 # endif /* Not __ASSEMBLER__ */
543 # define hidden_weak(name)
544 # define hidden_def(name)
545 # define hidden_ver(local, name)
546 # define hidden_data_weak(name)
547 # define hidden_data_def(name)
548 # define hidden_data_ver(local, name)
549 # define hidden_nolink(name, lib, version)
550 #endif
552 #if IS_IN (libc)
553 # define libc_hidden_proto(name, attrs...) hidden_proto (name, ##attrs)
554 # define libc_hidden_tls_proto(name, attrs...) hidden_tls_proto (name, ##attrs)
555 # define libc_hidden_def(name) hidden_def (name)
556 # define libc_hidden_weak(name) hidden_weak (name)
557 # ifdef LINK_OBSOLETE_RPC
558 /* libc_hidden_nolink_sunrpc should only get used in sunrpc code. */
559 # define libc_hidden_nolink_sunrpc(name, version) hidden_def (name)
560 # else
561 # define libc_hidden_nolink_sunrpc(name, version) hidden_nolink (name, libc, version)
562 # endif
563 # define libc_hidden_ver(local, name) hidden_ver (local, name)
564 # define libc_hidden_data_def(name) hidden_data_def (name)
565 # define libc_hidden_data_weak(name) hidden_data_weak (name)
566 # define libc_hidden_data_ver(local, name) hidden_data_ver (local, name)
567 #else
568 # define libc_hidden_proto(name, attrs...)
569 # define libc_hidden_tls_proto(name, attrs...)
570 # define libc_hidden_def(name)
571 # define libc_hidden_weak(name)
572 # define libc_hidden_ver(local, name)
573 # define libc_hidden_data_def(name)
574 # define libc_hidden_data_weak(name)
575 # define libc_hidden_data_ver(local, name)
576 #endif
578 #if IS_IN (rtld)
579 # define rtld_hidden_proto(name, attrs...) hidden_proto (name, ##attrs)
580 # define rtld_hidden_tls_proto(name, attrs...) hidden_tls_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_tls_proto(name, attrs...)
590 # define rtld_hidden_def(name)
591 # define rtld_hidden_weak(name)
592 # define rtld_hidden_ver(local, name)
593 # define rtld_hidden_data_def(name)
594 # define rtld_hidden_data_weak(name)
595 # define rtld_hidden_data_ver(local, name)
596 #endif
598 #if IS_IN (libm)
599 # define libm_hidden_proto(name, attrs...) hidden_proto (name, ##attrs)
600 # define libm_hidden_tls_proto(name, attrs...) hidden_tls_proto (name, ##attrs)
601 # define libm_hidden_def(name) hidden_def (name)
602 # define libm_hidden_weak(name) hidden_weak (name)
603 # define libm_hidden_ver(local, name) hidden_ver (local, name)
604 # define libm_hidden_data_def(name) hidden_data_def (name)
605 # define libm_hidden_data_weak(name) hidden_data_weak (name)
606 # define libm_hidden_data_ver(local, name) hidden_data_ver (local, name)
607 #else
608 # define libm_hidden_proto(name, attrs...)
609 # define libm_hidden_tls_proto(name, attrs...)
610 # define libm_hidden_def(name)
611 # define libm_hidden_weak(name)
612 # define libm_hidden_ver(local, name)
613 # define libm_hidden_data_def(name)
614 # define libm_hidden_data_weak(name)
615 # define libm_hidden_data_ver(local, name)
616 #endif
618 #if IS_IN (libresolv)
619 # define libresolv_hidden_proto(name, attrs...) hidden_proto (name, ##attrs)
620 # define libresolv_hidden_tls_proto(name, attrs...) \
621 hidden_tls_proto (name, ##attrs)
622 # define libresolv_hidden_def(name) hidden_def (name)
623 # define libresolv_hidden_weak(name) hidden_weak (name)
624 # define libresolv_hidden_ver(local, name) hidden_ver (local, name)
625 # define libresolv_hidden_data_def(name) hidden_data_def (name)
626 # define libresolv_hidden_data_weak(name) hidden_data_weak (name)
627 # define libresolv_hidden_data_ver(local, name) hidden_data_ver (local, name)
628 #else
629 # define libresolv_hidden_proto(name, attrs...)
630 # define libresolv_hidden_tls_proto(name, attrs...)
631 # define libresolv_hidden_def(name)
632 # define libresolv_hidden_weak(name)
633 # define libresolv_hidden_ver(local, name)
634 # define libresolv_hidden_data_def(name)
635 # define libresolv_hidden_data_weak(name)
636 # define libresolv_hidden_data_ver(local, name)
637 #endif
639 #if IS_IN (librt)
640 # define librt_hidden_proto(name, attrs...) hidden_proto (name, ##attrs)
641 # define librt_hidden_tls_proto(name, attrs...) \
642 hidden_tls_proto (name, ##attrs)
643 # define librt_hidden_def(name) hidden_def (name)
644 # define librt_hidden_weak(name) hidden_weak (name)
645 # define librt_hidden_ver(local, name) hidden_ver (local, name)
646 # define librt_hidden_data_def(name) hidden_data_def (name)
647 # define librt_hidden_data_weak(name) hidden_data_weak (name)
648 # define librt_hidden_data_ver(local, name) hidden_data_ver (local, name)
649 #else
650 # define librt_hidden_proto(name, attrs...)
651 # define librt_hidden_tls_proto(name, attrs...)
652 # define librt_hidden_def(name)
653 # define librt_hidden_weak(name)
654 # define librt_hidden_ver(local, name)
655 # define librt_hidden_data_def(name)
656 # define librt_hidden_data_weak(name)
657 # define librt_hidden_data_ver(local, name)
658 #endif
660 #if IS_IN (libdl)
661 # define libdl_hidden_proto(name, attrs...) hidden_proto (name, ##attrs)
662 # define libdl_hidden_tls_proto(name, attrs...) \
663 hidden_tls_proto (name, ##attrs)
664 # define libdl_hidden_def(name) hidden_def (name)
665 # define libdl_hidden_weak(name) hidden_weak (name)
666 # define libdl_hidden_ver(local, name) hidden_ver (local, name)
667 # define libdl_hidden_data_def(name) hidden_data_def (name)
668 # define libdl_hidden_data_weak(name) hidden_data_weak (name)
669 # define libdl_hidden_data_ver(local, name) hidden_data_ver (local, name)
670 #else
671 # define libdl_hidden_proto(name, attrs...)
672 # define libdl_hidden_tls_proto(name, attrs...)
673 # define libdl_hidden_def(name)
674 # define libdl_hidden_weak(name)
675 # define libdl_hidden_ver(local, name)
676 # define libdl_hidden_data_def(name)
677 # define libdl_hidden_data_weak(name)
678 # define libdl_hidden_data_ver(local, name)
679 #endif
681 #if IS_IN (libnss_files)
682 # define libnss_files_hidden_proto(name, attrs...) hidden_proto (name, ##attrs)
683 # define libnss_files_hidden_tls_proto(name, attrs...) \
684 hidden_tls_proto (name, ##attrs)
685 # define libnss_files_hidden_def(name) hidden_def (name)
686 # define libnss_files_hidden_weak(name) hidden_weak (name)
687 # define libnss_files_hidden_ver(local, name) hidden_ver (local, name)
688 # define libnss_files_hidden_data_def(name) hidden_data_def (name)
689 # define libnss_files_hidden_data_weak(name) hidden_data_weak (name)
690 # define libnss_files_hidden_data_ver(local, name) hidden_data_ver(local, name)
691 #else
692 # define libnss_files_hidden_proto(name, attrs...)
693 # define libnss_files_hidden_tls_proto(name, attrs...)
694 # define libnss_files_hidden_def(name)
695 # define libnss_files_hidden_weak(name)
696 # define libnss_files_hidden_ver(local, name)
697 # define libnss_files_hidden_data_def(name)
698 # define libnss_files_hidden_data_weak(name)
699 # define libnss_files_hidden_data_ver(local, name)
700 #endif
702 #if IS_IN (libnsl)
703 # define libnsl_hidden_proto(name, attrs...) hidden_proto (name, ##attrs)
704 # define libnsl_hidden_tls_proto(name, attrs...) \
705 hidden_tls_proto (name, ##attrs)
706 # define libnsl_hidden_def(name) hidden_def (name)
707 # define libnsl_hidden_weak(name) hidden_weak (name)
708 # define libnsl_hidden_ver(local, name) hidden_ver (local, name)
709 # define libnsl_hidden_data_def(name) hidden_data_def (name)
710 # define libnsl_hidden_data_weak(name) hidden_data_weak (name)
711 # define libnsl_hidden_data_ver(local, name) hidden_data_ver (local, name)
712 #else
713 # define libnsl_hidden_proto(name, attrs...)
714 # define libnsl_hidden_tls_proto(name, attrs...)
715 # define libnsl_hidden_def(name)
716 # define libnsl_hidden_weak(name)
717 # define libnsl_hidden_ver(local, name)
718 # define libnsl_hidden_data_def(name)
719 # define libnsl_hidden_data_weak(name)
720 # define libnsl_hidden_data_ver(local, name)
721 #endif
723 #if IS_IN (libnss_nisplus)
724 # define libnss_nisplus_hidden_proto(name, attrs...) hidden_proto (name, ##attrs)
725 # define libnss_nisplus_hidden_tls_proto(name, attrs...) \
726 hidden_tls_proto (name, ##attrs)
727 # define libnss_nisplus_hidden_def(name) hidden_def (name)
728 # define libnss_nisplus_hidden_weak(name) hidden_weak (name)
729 # define libnss_nisplus_hidden_ver(local, name) hidden_ver (local, name)
730 # define libnss_nisplus_hidden_data_def(name) hidden_data_def (name)
731 # define libnss_nisplus_hidden_data_weak(name) hidden_data_weak (name)
732 # define libnss_nisplus_hidden_data_ver(local, name) hidden_data_ver (local, name)
733 #else
734 # define libnss_nisplus_hidden_proto(name, attrs...)
735 # define libnss_nisplus_hidden_tls_proto(name, attrs...)
736 # define libnss_nisplus_hidden_def(name)
737 # define libnss_nisplus_hidden_weak(name)
738 # define libnss_nisplus_hidden_ver(local, name)
739 # define libnss_nisplus_hidden_data_def(name)
740 # define libnss_nisplus_hidden_data_weak(name)
741 # define libnss_nisplus_hidden_data_ver(local, name)
742 #endif
744 #define libc_hidden_builtin_proto(name, attrs...) libc_hidden_proto (name, ##attrs)
745 #define libc_hidden_builtin_def(name) libc_hidden_def (name)
746 #define libc_hidden_builtin_weak(name) libc_hidden_weak (name)
747 #define libc_hidden_builtin_ver(local, name) libc_hidden_ver (local, name)
748 #ifdef __ASSEMBLER__
749 # define HIDDEN_BUILTIN_JUMPTARGET(name) HIDDEN_JUMPTARGET(name)
750 #endif
752 #if IS_IN (libutil)
753 # define libutil_hidden_proto(name, attrs...) hidden_proto (name, ##attrs)
754 # define libutil_hidden_tls_proto(name, attrs...) \
755 hidden_tls_proto (name, ##attrs)
756 # define libutil_hidden_def(name) hidden_def (name)
757 # define libutil_hidden_weak(name) hidden_weak (name)
758 # define libutil_hidden_ver(local, name) hidden_ver (local, name)
759 # define libutil_hidden_data_def(name) hidden_data_def (name)
760 # define libutil_hidden_data_weak(name) hidden_data_weak (name)
761 # define libutil_hidden_data_ver(local, name) hidden_data_ver (local, name)
762 #else
763 # define libutil_hidden_proto(name, attrs...)
764 # define libutil_hidden_tls_proto(name, attrs...)
765 # define libutil_hidden_def(name)
766 # define libutil_hidden_weak(name)
767 # define libutil_hidden_ver(local, name)
768 # define libutil_hidden_data_def(name)
769 # define libutil_hidden_data_weak(name)
770 # define libutil_hidden_data_ver(local, name)
771 #endif
773 /* Get some dirty hacks. */
774 #include <symbol-hacks.h>
776 /* Move compatibility symbols out of the way by placing them all in a
777 special section. */
778 #ifndef __ASSEMBLER__
779 # define attribute_compat_text_section \
780 __attribute__ ((section (".text.compat")))
781 # define attribute_compat_data_section \
782 __attribute__ ((section (".data.compat")))
783 #else
784 # define compat_text_section .section ".text.compat", "ax";
785 # define compat_data_section .section ".data.compat", "aw";
786 #endif
788 /* Marker used for indirection function symbols. */
789 #define libc_ifunc(name, expr) \
790 extern void *name##_ifunc (void) __asm__ (#name); \
791 void *name##_ifunc (void) \
793 INIT_ARCH (); \
794 __typeof (name) *res = expr; \
795 return res; \
797 __asm__ (".type " #name ", %gnu_indirect_function");
799 /* The body of the function is supposed to use __get_cpu_features
800 which will, if necessary, initialize the data first. */
801 #define libm_ifunc(name, expr) \
802 extern void *name##_ifunc (void) __asm__ (#name); \
803 void *name##_ifunc (void) \
805 __typeof (name) *res = expr; \
806 return res; \
808 __asm__ (".type " #name ", %gnu_indirect_function");
810 #ifdef HAVE_ASM_SET_DIRECTIVE
811 # define libc_ifunc_hidden_def1(local, name) \
812 __asm__ (".globl " #local "\n\t" \
813 ".hidden " #local "\n\t" \
814 ".set " #local ", " #name);
815 #else
816 # define libc_ifunc_hidden_def1(local, name) \
817 __asm__ (".globl " #local "\n\t" \
818 ".hidden " #local "\n\t" \
819 #local " = " #name);
820 #endif
822 #define libc_ifunc_hidden_def(name) \
823 libc_ifunc_hidden_def1 (__GI_##name, name)
825 /* Add the compiler optimization to inhibit loop transformation to library
826 calls. This is used to avoid recursive calls in memset and memmove
827 default implementations. */
828 #ifdef HAVE_CC_INHIBIT_LOOP_TO_LIBCALL
829 # define inhibit_loop_to_libcall \
830 __attribute__ ((__optimize__ ("-fno-tree-loop-distribute-patterns")))
831 #else
832 # define inhibit_loop_to_libcall
833 #endif
835 #endif /* libc-symbols.h */