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