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