Fix __printf_fp wmemset namespace (bug 17574).
[platform/upstream/glibc.git] / include / libc-symbols.h
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.
5
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.
10
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.
15
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/>.  */
19
20 #ifndef _LIBC_SYMBOLS_H
21 #define _LIBC_SYMBOLS_H 1
22
23 /* This file's macros are included implicitly in the compilation of every
24    file in the C library by -imacros.
25
26    We include config.h which is generated by configure.
27    It should define for us the following symbols:
28
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'.
32
33    */
34
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
43
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
48
49 #include <config.h>
50
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
59
60 /* Define these macros for the benefit of portable GNU code that wants to check
61    them.  Of course, STDC_HEADERS is never false when building libc!  */
62 #define STDC_HEADERS    1
63 #define HAVE_MBSTATE_T  1
64 #define HAVE_MBSRTOWCS  1
65 #define HAVE_LIBINTL_H  1
66 #define HAVE_WCTYPE_H   1
67 #define HAVE_ISWCTYPE   1
68 #define ENABLE_NLS      1
69
70 /* The symbols in all the user (non-_) macros are C symbols.  */
71
72 #if !defined HAVE_ASM_WEAK_DIRECTIVE && !defined HAVE_ASM_WEAKEXT_DIRECTIVE
73 # error "weak symbol support needed"
74 #endif
75
76 #ifndef __SYMBOL_PREFIX
77 # define __SYMBOL_PREFIX
78 #endif
79
80 #ifndef C_SYMBOL_NAME
81 # define C_SYMBOL_NAME(name) name
82 #endif
83
84 #ifndef ASM_LINE_SEP
85 # define ASM_LINE_SEP ;
86 #endif
87
88 #ifdef HAVE_ASM_GLOBAL_DOT_NAME
89 # ifndef C_SYMBOL_DOT_NAME
90 #  if defined __GNUC__ && defined __GNUC_MINOR__ \
91       && (__GNUC__ << 16) + __GNUC_MINOR__ >= (3 << 16) + 1
92 #   define C_SYMBOL_DOT_NAME(name) .name
93 #  else
94 #   define C_SYMBOL_DOT_NAME(name) .##name
95 #  endif
96 # endif
97 #endif
98
99 #ifndef __ASSEMBLER__
100 /* GCC understands weak symbols and aliases; use its interface where
101    possible, instead of embedded assembly language.  */
102
103 /* Define ALIASNAME as a strong alias for NAME.  */
104 # define strong_alias(name, aliasname) _strong_alias(name, aliasname)
105 # define _strong_alias(name, aliasname) \
106   extern __typeof (name) aliasname __attribute__ ((alias (#name)));
107
108 /* This comes between the return type and function name in
109    a function definition to make that definition weak.  */
110 # define weak_function __attribute__ ((weak))
111 # define weak_const_function __attribute__ ((weak, __const__))
112
113 /* Define ALIASNAME as a weak alias for NAME.
114    If weak aliases are not available, this defines a strong alias.  */
115 # define weak_alias(name, aliasname) _weak_alias (name, aliasname)
116 # define _weak_alias(name, aliasname) \
117   extern __typeof (name) aliasname __attribute__ ((weak, alias (#name)));
118
119 /* Same as WEAK_ALIAS, but mark symbol as hidden.  */
120 # define weak_hidden_alias(name, aliasname) \
121   _weak_hidden_alias (name, aliasname)
122 # define _weak_hidden_alias(name, aliasname) \
123   extern __typeof (name) aliasname \
124     __attribute__ ((weak, alias (#name), __visibility__ ("hidden")));
125
126 /* Declare SYMBOL as weak undefined symbol (resolved to 0 if not defined).  */
127 # define weak_extern(symbol) _weak_extern (weak symbol)
128 # define _weak_extern(expr) _Pragma (#expr)
129
130
131 #else /* __ASSEMBLER__ */
132
133 # ifdef HAVE_ASM_SET_DIRECTIVE
134 #  ifdef HAVE_ASM_GLOBAL_DOT_NAME
135 #   define strong_alias(original, alias)                                \
136   .globl C_SYMBOL_NAME (alias) ASM_LINE_SEP             \
137   .set C_SYMBOL_NAME (alias),C_SYMBOL_NAME (original) ASM_LINE_SEP      \
138   .globl C_SYMBOL_DOT_NAME (alias) ASM_LINE_SEP         \
139   .set C_SYMBOL_DOT_NAME (alias),C_SYMBOL_DOT_NAME (original)
140 #   define strong_data_alias(original, alias)                           \
141   .globl C_SYMBOL_NAME (alias) ASM_LINE_SEP             \
142   .set C_SYMBOL_NAME (alias),C_SYMBOL_NAME (original)
143 #  else
144 #   define strong_alias(original, alias)                                \
145   .globl C_SYMBOL_NAME (alias) ASM_LINE_SEP             \
146   .set C_SYMBOL_NAME (alias),C_SYMBOL_NAME (original)
147 #   define strong_data_alias(original, alias) strong_alias(original, alias)
148 #  endif
149 # else
150 #  ifdef HAVE_ASM_GLOBAL_DOT_NAME
151 #   define strong_alias(original, alias)                                \
152   .globl C_SYMBOL_NAME (alias) ASM_LINE_SEP             \
153   C_SYMBOL_NAME (alias) = C_SYMBOL_NAME (original) ASM_LINE_SEP         \
154   .globl C_SYMBOL_DOT_NAME (alias) ASM_LINE_SEP         \
155   C_SYMBOL_DOT_NAME (alias) = C_SYMBOL_DOT_NAME (original)
156 #   define strong_data_alias(original, alias)                           \
157   .globl C_SYMBOL_NAME (alias) ASM_LINE_SEP             \
158   C_SYMBOL_NAME (alias) = C_SYMBOL_NAME (original)
159 #  else
160 #   define strong_alias(original, alias)                                \
161   .globl C_SYMBOL_NAME (alias) ASM_LINE_SEP             \
162   C_SYMBOL_NAME (alias) = C_SYMBOL_NAME (original)
163 #   define strong_data_alias(original, alias) strong_alias(original, alias)
164 #  endif
165 # endif
166
167 # ifdef HAVE_ASM_WEAKEXT_DIRECTIVE
168 #  ifdef HAVE_ASM_GLOBAL_DOT_NAME
169 #   define weak_alias(original, alias)                                  \
170   .weakext C_SYMBOL_NAME (alias), C_SYMBOL_NAME (original) ASM_LINE_SEP \
171   .weakext C_SYMBOL_DOT_NAME (alias), C_SYMBOL_DOT_NAME (original)
172 #  else
173 #   define weak_alias(original, alias)                                  \
174   .weakext C_SYMBOL_NAME (alias), C_SYMBOL_NAME (original)
175 #  endif
176 #  define weak_extern(symbol)                                           \
177   .weakext C_SYMBOL_NAME (symbol)
178
179 # else /* ! HAVE_ASM_WEAKEXT_DIRECTIVE */
180
181 #  ifdef HAVE_ASM_GLOBAL_DOT_NAME
182 #   define weak_alias(original, alias)                                  \
183   .weak C_SYMBOL_NAME (alias) ASM_LINE_SEP                              \
184   C_SYMBOL_NAME (alias) = C_SYMBOL_NAME (original) ASM_LINE_SEP         \
185   .weak C_SYMBOL_DOT_NAME (alias) ASM_LINE_SEP                          \
186   C_SYMBOL_DOT_NAME (alias) = C_SYMBOL_DOT_NAME (original)
187 #  else
188 #   define weak_alias(original, alias)                                  \
189   .weak C_SYMBOL_NAME (alias) ASM_LINE_SEP                              \
190   C_SYMBOL_NAME (alias) = C_SYMBOL_NAME (original)
191 #  endif
192
193 #  define weak_extern(symbol)                                           \
194   .weak C_SYMBOL_NAME (symbol)
195
196 # endif /* ! HAVE_ASM_WEAKEXT_DIRECTIVE */
197
198 #endif /* __ASSEMBLER__ */
199
200 /* On some platforms we can make internal function calls (i.e., calls of
201    functions not exported) a bit faster by using a different calling
202    convention.  */
203 #ifndef internal_function
204 # define internal_function      /* empty */
205 #endif
206
207 /* Determine the return address.  */
208 #define RETURN_ADDRESS(nr) \
209   __builtin_extract_return_addr (__builtin_return_address (nr))
210
211 /* When a reference to SYMBOL is encountered, the linker will emit a
212    warning message MSG.  */
213 /* We want the .gnu.warning.SYMBOL section to be unallocated.  */
214 #ifdef HAVE_ASM_PREVIOUS_DIRECTIVE
215 # define __make_section_unallocated(section_string)     \
216   asm (".section " section_string "\n\t.previous");
217 #elif defined HAVE_ASM_POPSECTION_DIRECTIVE
218 # define __make_section_unallocated(section_string)     \
219   asm (".pushsection " section_string "\n\t.popsection");
220 #else
221 # define __make_section_unallocated(section_string)
222 #endif
223
224 /* Tacking on "\n\t#" to the section name makes gcc put it's bogus
225    section attributes on what looks like a comment to the assembler.  */
226 #ifdef HAVE_SECTION_QUOTES
227 # define __sec_comment "\"\n\t#\""
228 #else
229 # define __sec_comment "\n\t#"
230 #endif
231 #define link_warning(symbol, msg) \
232   __make_section_unallocated (".gnu.warning." #symbol) \
233   static const char __evoke_link_warning_##symbol[]     \
234     __attribute__ ((used, section (".gnu.warning." #symbol __sec_comment))) \
235     = msg;
236 #define libc_freeres_ptr(decl) \
237   __make_section_unallocated ("__libc_freeres_ptrs, \"aw\", %nobits") \
238   decl __attribute__ ((section ("__libc_freeres_ptrs" __sec_comment)))
239 #define __libc_freeres_fn_section \
240   __attribute__ ((section ("__libc_freeres_fn")))
241
242 #define libc_freeres_fn(name)   \
243   static void name (void) __attribute_used__ __libc_freeres_fn_section; \
244   text_set_element (__libc_subfreeres, name);                           \
245   static void name (void)
246
247 /* A canned warning for sysdeps/stub functions.  */
248 #define stub_warning(name) \
249   __make_section_unallocated (".gnu.glibc-stub." #name) \
250   link_warning (name, #name " is not implemented and will always fail")
251
252 /* Warning for linking functions calling dlopen into static binaries.  */
253 #ifdef SHARED
254 #define static_link_warning(name)
255 #else
256 #define static_link_warning(name) static_link_warning1(name)
257 #define static_link_warning1(name) \
258   link_warning(name, "Using '" #name "' in statically linked applications \
259 requires at runtime the shared libraries from the glibc version used \
260 for linking")
261 #endif
262
263 /* Declare SYMBOL to be TYPE (`function' or `object') of SIZE bytes
264    alias to ORIGINAL, when the assembler supports such declarations
265    (such as in ELF).
266    This is only necessary when defining something in assembly, or playing
267    funny alias games where the size should be other than what the compiler
268    thinks it is.  */
269 #define declare_symbol_alias(symbol, original, type, size) \
270   declare_symbol_alias_1 (symbol, original, type, size)
271 #ifdef __ASSEMBLER__
272 # define declare_symbol_alias_1(symbol, original, type, size) \
273    strong_alias (original, symbol); \
274    .type C_SYMBOL_NAME (symbol), %##type; \
275    .size C_SYMBOL_NAME (symbol), size
276 #else /* Not __ASSEMBLER__.  */
277 # define declare_symbol_alias_1(symbol, original, type, size) \
278    asm (".globl " __SYMBOL_PREFIX #symbol \
279         "\n\t" declare_symbol_alias_1_alias (symbol, original) \
280         "\n\t.type " __SYMBOL_PREFIX #symbol ", " \
281         "%" #type \
282         "\n\t.size " __SYMBOL_PREFIX #symbol ", " #size);
283 # ifdef HAVE_ASM_SET_DIRECTIVE
284 #  define declare_symbol_alias_1_alias(symbol, original) \
285      ".set " __SYMBOL_PREFIX #symbol ", " __SYMBOL_PREFIX #original
286 # else
287 #  define declare_symbol_alias_1_alias(symbol, original) \
288      __SYMBOL_PREFIX #symbol " = " __SYMBOL_PREFIX #original
289 # endif /* HAVE_ASM_SET_DIRECTIVE */
290 #endif /* __ASSEMBLER__ */
291
292
293 /*
294 \f
295 */
296
297 /* Symbol set support macros.  */
298
299 /* Make SYMBOL, which is in the text segment, an element of SET.  */
300 #define text_set_element(set, symbol)   _elf_set_element(set, symbol)
301 /* Make SYMBOL, which is in the data segment, an element of SET.  */
302 #define data_set_element(set, symbol)   _elf_set_element(set, symbol)
303 /* Make SYMBOL, which is in the bss segment, an element of SET.  */
304 #define bss_set_element(set, symbol)    _elf_set_element(set, symbol)
305
306 /* These are all done the same way in ELF.
307    There is a new section created for each set.  */
308 #ifdef SHARED
309 /* When building a shared library, make the set section writable,
310    because it will need to be relocated at run time anyway.  */
311 # define _elf_set_element(set, symbol) \
312   static const void *__elf_set_##set##_element_##symbol##__ \
313     __attribute__ ((used, section (#set))) = &(symbol)
314 #else
315 # define _elf_set_element(set, symbol) \
316   static const void *const __elf_set_##set##_element_##symbol##__ \
317     __attribute__ ((used, section (#set))) = &(symbol)
318 #endif
319
320 /* Define SET as a symbol set.  This may be required (it is in a.out) to
321    be able to use the set's contents.  */
322 #define symbol_set_define(set)  symbol_set_declare(set)
323
324 /* Declare SET for use in this module, if defined in another module.
325    In a shared library, this is always local to that shared object.
326    For static linking, the set might be wholly absent and so we use
327    weak references.  */
328 #define symbol_set_declare(set) \
329   extern char const __start_##set[] __symbol_set_attribute; \
330   extern char const __stop_##set[] __symbol_set_attribute;
331 #ifdef SHARED
332 # define __symbol_set_attribute attribute_hidden
333 #else
334 # define __symbol_set_attribute __attribute__ ((weak))
335 #endif
336
337 /* Return a pointer (void *const *) to the first element of SET.  */
338 #define symbol_set_first_element(set)   ((void *const *) (&__start_##set))
339
340 /* Return true iff PTR (a void *const *) has been incremented
341    past the last element in SET.  */
342 #define symbol_set_end_p(set, ptr) ((ptr) >= (void *const *) &__stop_##set)
343
344 #ifdef SHARED
345 # define symbol_version(real, name, version) \
346      _symbol_version(real, name, version)
347 # define default_symbol_version(real, name, version) \
348      _default_symbol_version(real, name, version)
349 # ifdef __ASSEMBLER__
350 #  ifdef HAVE_ASM_GLOBAL_DOT_NAME
351 #   define _symbol_version(real, name, version) \
352      .symver real, name##@##version ASM_LINE_SEP                        \
353      .symver C_SYMBOL_DOT_NAME(real), C_SYMBOL_DOT_NAME(name##@##version)
354 #   define _default_symbol_version(real, name, version) \
355      .symver real, name##@##@##version ASM_LINE_SEP                     \
356      .symver C_SYMBOL_DOT_NAME(real), C_SYMBOL_DOT_NAME(name##@##@##version)
357 #  else
358 #   define _symbol_version(real, name, version) \
359      .symver real, name##@##version
360 #   define _default_symbol_version(real, name, version) \
361      .symver real, name##@##@##version
362 #  endif
363 # else
364 #  ifdef HAVE_ASM_GLOBAL_DOT_NAME
365 #   define _symbol_version(real, name, version) \
366      __asm__ (".symver " #real "," #name "@" #version "\n\t"    \
367               ".symver ." #real ",." #name "@" #version)
368 #   define _default_symbol_version(real, name, version) \
369      __asm__ (".symver " #real "," #name "@@" #version "\n\t"   \
370               ".symver ." #real ",." #name "@@" #version)
371 #  else
372 #   define _symbol_version(real, name, version) \
373      __asm__ (".symver " #real "," #name "@" #version)
374 #   define _default_symbol_version(real, name, version) \
375      __asm__ (".symver " #real "," #name "@@" #version)
376 #  endif
377 # endif
378 #else
379 # define symbol_version(real, name, version)
380 # define default_symbol_version(real, name, version) \
381   strong_alias(real, name)
382 #endif
383
384 #if defined SHARED || defined LIBC_NONSHARED
385 # define attribute_hidden __attribute__ ((visibility ("hidden")))
386 #else
387 # define attribute_hidden
388 #endif
389
390 #define attribute_tls_model_ie __attribute__ ((tls_model ("initial-exec")))
391
392 #define attribute_relro __attribute__ ((section (".data.rel.ro")))
393
394 /* The following macros are used for PLT bypassing within libc.so
395    (and if needed other libraries similarly).
396    First of all, you need to have the function prototyped somewhere,
397    say in foo/foo.h:
398
399    int foo (int __bar);
400
401    If calls to foo within libc.so should always go to foo defined in libc.so,
402    then in include/foo.h you add:
403
404    libc_hidden_proto (foo)
405
406    line and after the foo function definition:
407
408    int foo (int __bar)
409    {
410      return __bar;
411    }
412    libc_hidden_def (foo)
413
414    or
415
416    int foo (int __bar)
417    {
418      return __bar;
419    }
420    libc_hidden_weak (foo)
421
422    Similarly for global data.  If references to foo within libc.so should
423    always go to foo defined in libc.so, then in include/foo.h you add:
424
425    libc_hidden_proto (foo)
426
427    line and after foo's definition:
428
429    int foo = INITIAL_FOO_VALUE;
430    libc_hidden_data_def (foo)
431
432    or
433
434    int foo = INITIAL_FOO_VALUE;
435    libc_hidden_data_weak (foo)
436
437    If foo is normally just an alias (strong or weak) to some other function,
438    you should use the normal strong_alias first, then add libc_hidden_def
439    or libc_hidden_weak:
440
441    int baz (int __bar)
442    {
443      return __bar;
444    }
445    strong_alias (baz, foo)
446    libc_hidden_weak (foo)
447
448    If the function should be internal to multiple objects, say ld.so and
449    libc.so, the best way is to use:
450
451    #if !defined NOT_IN_libc || defined IS_IN_rtld
452    hidden_proto (foo)
453    #endif
454
455    in include/foo.h and the normal macros at all function definitions
456    depending on what DSO they belong to.
457
458    If versioned_symbol macro is used to define foo,
459    libc_hidden_ver macro should be used, as in:
460
461    int __real_foo (int __bar)
462    {
463      return __bar;
464    }
465    versioned_symbol (libc, __real_foo, foo, GLIBC_2_1);
466    libc_hidden_ver (__real_foo, foo)  */
467
468 #if defined SHARED && !defined NO_HIDDEN
469 # ifndef __ASSEMBLER__
470 #  define __hidden_proto_hiddenattr(attrs...) \
471   __attribute__ ((visibility ("hidden"), ##attrs))
472 #  define hidden_proto(name, attrs...) \
473   __hidden_proto (name, , __GI_##name, ##attrs)
474 #  define hidden_tls_proto(name, attrs...) \
475   __hidden_proto (name, __thread, __GI_##name, ##attrs)
476 #  define __hidden_proto(name, thread, internal, attrs...)           \
477   extern thread __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 #  define hidden_tls_proto(name, attrs...)
529 # else
530 #  define HIDDEN_JUMPTARGET(name) JUMPTARGET(name)
531 # endif /* Not  __ASSEMBLER__ */
532 # define hidden_weak(name)
533 # define hidden_def(name)
534 # define hidden_ver(local, name)
535 # define hidden_data_weak(name)
536 # define hidden_data_def(name)
537 # define hidden_data_ver(local, name)
538 # define hidden_nolink(name, lib, version)
539 #endif
540
541 #if !defined NOT_IN_libc
542 # define libc_hidden_proto(name, attrs...) hidden_proto (name, ##attrs)
543 # define libc_hidden_tls_proto(name, attrs...) hidden_tls_proto (name, ##attrs)
544 # define libc_hidden_def(name) hidden_def (name)
545 # define libc_hidden_weak(name) hidden_weak (name)
546 # ifdef LINK_OBSOLETE_RPC
547    /* libc_hidden_nolink_sunrpc should only get used in sunrpc code.  */
548 #  define libc_hidden_nolink_sunrpc(name, version) hidden_def (name)
549 # else
550 #  define libc_hidden_nolink_sunrpc(name, version) hidden_nolink (name, libc, version)
551 # endif
552 # define libc_hidden_ver(local, name) hidden_ver (local, name)
553 # define libc_hidden_data_def(name) hidden_data_def (name)
554 # define libc_hidden_data_weak(name) hidden_data_weak (name)
555 # define libc_hidden_data_ver(local, name) hidden_data_ver (local, name)
556 #else
557 # define libc_hidden_proto(name, attrs...)
558 # define libc_hidden_tls_proto(name, attrs...)
559 # define libc_hidden_def(name)
560 # define libc_hidden_weak(name)
561 # define libc_hidden_ver(local, name)
562 # define libc_hidden_data_def(name)
563 # define libc_hidden_data_weak(name)
564 # define libc_hidden_data_ver(local, name)
565 #endif
566
567 #ifdef IS_IN_rtld
568 # define rtld_hidden_proto(name, attrs...) hidden_proto (name, ##attrs)
569 # define rtld_hidden_tls_proto(name, attrs...) hidden_tls_proto (name, ##attrs)
570 # define rtld_hidden_def(name) hidden_def (name)
571 # define rtld_hidden_weak(name) hidden_weak (name)
572 # define rtld_hidden_ver(local, name) hidden_ver (local, name)
573 # define rtld_hidden_data_def(name) hidden_data_def (name)
574 # define rtld_hidden_data_weak(name) hidden_data_weak (name)
575 # define rtld_hidden_data_ver(local, name) hidden_data_ver (local, name)
576 #else
577 # define rtld_hidden_proto(name, attrs...)
578 # define rtld_hidden_tls_proto(name, attrs...)
579 # define rtld_hidden_def(name)
580 # define rtld_hidden_weak(name)
581 # define rtld_hidden_ver(local, name)
582 # define rtld_hidden_data_def(name)
583 # define rtld_hidden_data_weak(name)
584 # define rtld_hidden_data_ver(local, name)
585 #endif
586
587 #ifdef IS_IN_libm
588 # define libm_hidden_proto(name, attrs...) hidden_proto (name, ##attrs)
589 # define libm_hidden_tls_proto(name, attrs...) hidden_tls_proto (name, ##attrs)
590 # define libm_hidden_def(name) hidden_def (name)
591 # define libm_hidden_weak(name) hidden_weak (name)
592 # define libm_hidden_ver(local, name) hidden_ver (local, name)
593 # define libm_hidden_data_def(name) hidden_data_def (name)
594 # define libm_hidden_data_weak(name) hidden_data_weak (name)
595 # define libm_hidden_data_ver(local, name) hidden_data_ver (local, name)
596 #else
597 # define libm_hidden_proto(name, attrs...)
598 # define libm_hidden_tls_proto(name, attrs...)
599 # define libm_hidden_def(name)
600 # define libm_hidden_weak(name)
601 # define libm_hidden_ver(local, name)
602 # define libm_hidden_data_def(name)
603 # define libm_hidden_data_weak(name)
604 # define libm_hidden_data_ver(local, name)
605 #endif
606
607 #ifdef IS_IN_libresolv
608 # define libresolv_hidden_proto(name, attrs...) hidden_proto (name, ##attrs)
609 # define libresolv_hidden_tls_proto(name, attrs...) \
610   hidden_tls_proto (name, ##attrs)
611 # define libresolv_hidden_def(name) hidden_def (name)
612 # define libresolv_hidden_weak(name) hidden_weak (name)
613 # define libresolv_hidden_ver(local, name) hidden_ver (local, name)
614 # define libresolv_hidden_data_def(name) hidden_data_def (name)
615 # define libresolv_hidden_data_weak(name) hidden_data_weak (name)
616 # define libresolv_hidden_data_ver(local, name) hidden_data_ver (local, name)
617 #else
618 # define libresolv_hidden_proto(name, attrs...)
619 # define libresolv_hidden_tls_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
627
628 #ifdef IS_IN_librt
629 # define librt_hidden_proto(name, attrs...) hidden_proto (name, ##attrs)
630 # define librt_hidden_tls_proto(name, attrs...) \
631   hidden_tls_proto (name, ##attrs)
632 # define librt_hidden_def(name) hidden_def (name)
633 # define librt_hidden_weak(name) hidden_weak (name)
634 # define librt_hidden_ver(local, name) hidden_ver (local, name)
635 # define librt_hidden_data_def(name) hidden_data_def (name)
636 # define librt_hidden_data_weak(name) hidden_data_weak (name)
637 # define librt_hidden_data_ver(local, name) hidden_data_ver (local, name)
638 #else
639 # define librt_hidden_proto(name, attrs...)
640 # define librt_hidden_tls_proto(name, attrs...)
641 # define librt_hidden_def(name)
642 # define librt_hidden_weak(name)
643 # define librt_hidden_ver(local, name)
644 # define librt_hidden_data_def(name)
645 # define librt_hidden_data_weak(name)
646 # define librt_hidden_data_ver(local, name)
647 #endif
648
649 #ifdef IS_IN_libdl
650 # define libdl_hidden_proto(name, attrs...) hidden_proto (name, ##attrs)
651 # define libdl_hidden_tls_proto(name, attrs...) \
652   hidden_tls_proto (name, ##attrs)
653 # define libdl_hidden_def(name) hidden_def (name)
654 # define libdl_hidden_weak(name) hidden_weak (name)
655 # define libdl_hidden_ver(local, name) hidden_ver (local, name)
656 # define libdl_hidden_data_def(name) hidden_data_def (name)
657 # define libdl_hidden_data_weak(name) hidden_data_weak (name)
658 # define libdl_hidden_data_ver(local, name) hidden_data_ver (local, name)
659 #else
660 # define libdl_hidden_proto(name, attrs...)
661 # define libdl_hidden_tls_proto(name, attrs...)
662 # define libdl_hidden_def(name)
663 # define libdl_hidden_weak(name)
664 # define libdl_hidden_ver(local, name)
665 # define libdl_hidden_data_def(name)
666 # define libdl_hidden_data_weak(name)
667 # define libdl_hidden_data_ver(local, name)
668 #endif
669
670 #ifdef IS_IN_libnss_files
671 # define libnss_files_hidden_proto(name, attrs...) hidden_proto (name, ##attrs)
672 # define libnss_files_hidden_tls_proto(name, attrs...) \
673   hidden_tls_proto (name, ##attrs)
674 # define libnss_files_hidden_def(name) hidden_def (name)
675 # define libnss_files_hidden_weak(name) hidden_weak (name)
676 # define libnss_files_hidden_ver(local, name) hidden_ver (local, name)
677 # define libnss_files_hidden_data_def(name) hidden_data_def (name)
678 # define libnss_files_hidden_data_weak(name) hidden_data_weak (name)
679 # define libnss_files_hidden_data_ver(local, name) hidden_data_ver(local, name)
680 #else
681 # define libnss_files_hidden_proto(name, attrs...)
682 # define libnss_files_hidden_tls_proto(name, attrs...)
683 # define libnss_files_hidden_def(name)
684 # define libnss_files_hidden_weak(name)
685 # define libnss_files_hidden_ver(local, name)
686 # define libnss_files_hidden_data_def(name)
687 # define libnss_files_hidden_data_weak(name)
688 # define libnss_files_hidden_data_ver(local, name)
689 #endif
690
691 #ifdef IS_IN_libnsl
692 # define libnsl_hidden_proto(name, attrs...) hidden_proto (name, ##attrs)
693 # define libnsl_hidden_tls_proto(name, attrs...) \
694   hidden_tls_proto (name, ##attrs)
695 # define libnsl_hidden_def(name) hidden_def (name)
696 # define libnsl_hidden_weak(name) hidden_weak (name)
697 # define libnsl_hidden_ver(local, name) hidden_ver (local, name)
698 # define libnsl_hidden_data_def(name) hidden_data_def (name)
699 # define libnsl_hidden_data_weak(name) hidden_data_weak (name)
700 # define libnsl_hidden_data_ver(local, name) hidden_data_ver (local, name)
701 #else
702 # define libnsl_hidden_proto(name, attrs...)
703 # define libnsl_hidden_tls_proto(name, attrs...)
704 # define libnsl_hidden_def(name)
705 # define libnsl_hidden_weak(name)
706 # define libnsl_hidden_ver(local, name)
707 # define libnsl_hidden_data_def(name)
708 # define libnsl_hidden_data_weak(name)
709 # define libnsl_hidden_data_ver(local, name)
710 #endif
711
712 #ifdef IS_IN_libnss_nisplus
713 # define libnss_nisplus_hidden_proto(name, attrs...) hidden_proto (name, ##attrs)
714 # define libnss_nisplus_hidden_tls_proto(name, attrs...) \
715   hidden_tls_proto (name, ##attrs)
716 # define libnss_nisplus_hidden_def(name) hidden_def (name)
717 # define libnss_nisplus_hidden_weak(name) hidden_weak (name)
718 # define libnss_nisplus_hidden_ver(local, name) hidden_ver (local, name)
719 # define libnss_nisplus_hidden_data_def(name) hidden_data_def (name)
720 # define libnss_nisplus_hidden_data_weak(name) hidden_data_weak (name)
721 # define libnss_nisplus_hidden_data_ver(local, name) hidden_data_ver (local, name)
722 #else
723 # define libnss_nisplus_hidden_proto(name, attrs...)
724 # define libnss_nisplus_hidden_tls_proto(name, attrs...)
725 # define libnss_nisplus_hidden_def(name)
726 # define libnss_nisplus_hidden_weak(name)
727 # define libnss_nisplus_hidden_ver(local, name)
728 # define libnss_nisplus_hidden_data_def(name)
729 # define libnss_nisplus_hidden_data_weak(name)
730 # define libnss_nisplus_hidden_data_ver(local, name)
731 #endif
732
733 #define libc_hidden_builtin_proto(name, attrs...) libc_hidden_proto (name, ##attrs)
734 #define libc_hidden_builtin_def(name) libc_hidden_def (name)
735 #define libc_hidden_builtin_weak(name) libc_hidden_weak (name)
736 #define libc_hidden_builtin_ver(local, name) libc_hidden_ver (local, name)
737 #ifdef __ASSEMBLER__
738 # define HIDDEN_BUILTIN_JUMPTARGET(name) HIDDEN_JUMPTARGET(name)
739 #endif
740
741 #ifdef IS_IN_libutil
742 # define libutil_hidden_proto(name, attrs...) hidden_proto (name, ##attrs)
743 # define libutil_hidden_tls_proto(name, attrs...) \
744   hidden_tls_proto (name, ##attrs)
745 # define libutil_hidden_def(name) hidden_def (name)
746 # define libutil_hidden_weak(name) hidden_weak (name)
747 # define libutil_hidden_ver(local, name) hidden_ver (local, name)
748 # define libutil_hidden_data_def(name) hidden_data_def (name)
749 # define libutil_hidden_data_weak(name) hidden_data_weak (name)
750 # define libutil_hidden_data_ver(local, name) hidden_data_ver (local, name)
751 #else
752 # define libutil_hidden_proto(name, attrs...)
753 # define libutil_hidden_tls_proto(name, attrs...)
754 # define libutil_hidden_def(name)
755 # define libutil_hidden_weak(name)
756 # define libutil_hidden_ver(local, name)
757 # define libutil_hidden_data_def(name)
758 # define libutil_hidden_data_weak(name)
759 # define libutil_hidden_data_ver(local, name)
760 #endif
761
762 /* Get some dirty hacks.  */
763 #include <symbol-hacks.h>
764
765 /* Move compatibility symbols out of the way by placing them all in a
766    special section.  */
767 #ifndef __ASSEMBLER__
768 # define attribute_compat_text_section \
769     __attribute__ ((section (".text.compat")))
770 # define attribute_compat_data_section \
771     __attribute__ ((section (".data.compat")))
772 #else
773 # define compat_text_section .section ".text.compat", "ax";
774 # define compat_data_section .section ".data.compat", "aw";
775 #endif
776
777 /* Marker used for indirection function symbols.  */
778 #define libc_ifunc(name, expr)                                          \
779   extern void *name##_ifunc (void) __asm__ (#name);                     \
780   void *name##_ifunc (void)                                             \
781   {                                                                     \
782     INIT_ARCH ();                                                       \
783     __typeof (name) *res = expr;                                        \
784     return res;                                                         \
785   }                                                                     \
786   __asm__ (".type " #name ", %gnu_indirect_function");
787
788 /* The body of the function is supposed to use __get_cpu_features
789    which will, if necessary, initialize the data first.  */
790 #define libm_ifunc(name, expr)                                          \
791   extern void *name##_ifunc (void) __asm__ (#name);                     \
792   void *name##_ifunc (void)                                             \
793   {                                                                     \
794     __typeof (name) *res = expr;                                        \
795     return res;                                                         \
796   }                                                                     \
797   __asm__ (".type " #name ", %gnu_indirect_function");
798
799 #ifdef HAVE_ASM_SET_DIRECTIVE
800 # define libc_ifunc_hidden_def1(local, name)                            \
801     __asm__ (".globl " #local "\n\t"                                    \
802              ".hidden " #local "\n\t"                                   \
803              ".set " #local ", " #name);
804 #else
805 # define libc_ifunc_hidden_def1(local, name)                            \
806     __asm__ (".globl " #local "\n\t"                                    \
807              ".hidden " #local "\n\t"                                   \
808              #local " = " #name);
809 #endif
810
811 #define libc_ifunc_hidden_def(name) \
812   libc_ifunc_hidden_def1 (__GI_##name, name)
813
814 /* Add the compiler optimization to inhibit loop transformation to library
815    calls.  This is used to avoid recursive calls in memset and memmove
816    default implementations.  */
817 #ifdef HAVE_CC_INHIBIT_LOOP_TO_LIBCALL
818 # define inhibit_loop_to_libcall \
819     __attribute__ ((__optimize__ ("-fno-tree-loop-distribute-patterns")))
820 #else
821 # define inhibit_loop_to_libcall
822 #endif
823
824 #endif /* libc-symbols.h */