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