]> rtime.felk.cvut.cz Git - l4.git/blob - l4/pkg/uclibc/lib/contrib/uclibc/include/libc-symbols.h
Inital import
[l4.git] / l4 / pkg / uclibc / lib / contrib / uclibc / 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-1998,2000-2003,2004,2005,2006
4         Free Software Foundation, Inc.
5    This file is part of the GNU C Library.
6
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.
11
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.
16
17    You should have received a copy of the GNU Lesser General Public
18    License along with the GNU C Library; if not, write to the Free
19    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
20    02111-1307 USA.  */
21
22 #ifndef _LIBC_SYMBOLS_H
23 #define _LIBC_SYMBOLS_H 1
24
25 /* This is defined for the compilation of all C library code.  features.h
26    tests this to avoid inclusion of stubs.h while compiling the library,
27    before stubs.h has been generated.  Some library code that is shared
28    with other packages also tests this symbol to see if it is being
29    compiled as part of the C library.  We must define this before including
30    config.h, because it makes some definitions conditional on whether libc
31    itself is being compiled, or just some generator program.  */
32 #define _LIBC   1
33
34
35 /* This file's macros are included implicitly in the compilation of every
36    file in the C library by -imacros.
37
38    We include uClibc_arch_features.h which is defined by arch devs.
39    It should define for us the following symbols:
40
41    * HAVE_ASM_SET_DIRECTIVE if we have `.set B, A' instead of `A = B'.
42    * ASM_GLOBAL_DIRECTIVE with `.globl' or `.global'.
43    * ASM_TYPE_DIRECTIVE_PREFIX with `@' or `#' or whatever for .type,
44      or leave it undefined if there is no .type directive.
45    * HAVE_ELF if using ELF, which supports weak symbols using `.weak'.
46    * HAVE_ASM_WEAK_DIRECTIVE if we have weak symbols using `.weak'.
47    * HAVE_ASM_WEAKEXT_DIRECTIVE if we have weak symbols using `.weakext'.
48
49    */
50
51 #include <bits/uClibc_arch_features.h>
52
53 /* Enable declarations of GNU extensions, since we are compiling them.  */
54 #define _GNU_SOURCE     1
55
56 /* Prepare for the case that `__builtin_expect' is not available.  */
57 #if defined __GNUC__ && __GNUC__ == 2 && __GNUC_MINOR__ < 96
58 # define __builtin_expect(x, expected_value) (x)
59 #endif
60 #ifndef likely
61 # define likely(x)      __builtin_expect((!!(x)),1)
62 #endif
63 #ifndef unlikely
64 # define unlikely(x)    __builtin_expect((!!(x)),0)
65 #endif
66 #if defined __GNUC__ && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3))
67 # ifndef __cold
68 #  define __cold __attribute__ ((__cold__))
69 # endif
70 # ifndef __hot
71 #  define __hot __attribute__ ((__hot__))
72 # endif
73 #else
74 # ifndef __cold
75 #  define __cold
76 # endif
77 # ifndef __hot
78 #  define __hot
79 # endif
80 #endif
81 #ifndef __LINUX_COMPILER_H
82 # define __LINUX_COMPILER_H
83 #endif
84 #ifndef __cast__
85 # define __cast__(_to)
86 #endif
87
88 #if defined __GNUC__ && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4))
89 # define attribute_optimize(lvl) __attribute__ ((optimize(x)))
90 #else
91 # define attribute_optimize(lvl)
92 #endif
93
94 #define attribute_unused __attribute__ ((unused))
95
96 #if defined __GNUC__ || defined __ICC
97 # define attribute_noreturn __attribute__ ((__noreturn__))
98 #else
99 # define attribute_noreturn
100 #endif
101
102 #ifndef NOT_IN_libc
103 # define IS_IN_libc 1
104 #endif
105
106 /* Indirect stringification.  Doing two levels allows
107  * the parameter to be a macro itself.
108  */
109 #define __stringify_1(x)    #x
110 #define __stringify(x)      __stringify_1(x)
111
112 #ifdef __UCLIBC_HAVE_ASM_SET_DIRECTIVE__
113 # define HAVE_ASM_SET_DIRECTIVE
114 #else
115 # undef HAVE_ASM_SET_DIRECTIVE
116 #endif
117
118 #ifdef __UCLIBC_ASM_GLOBAL_DIRECTIVE__
119 # define ASM_GLOBAL_DIRECTIVE __UCLIBC_ASM_GLOBAL_DIRECTIVE__
120 #else
121 # define ASM_GLOBAL_DIRECTIVE .global
122 #endif
123
124 #ifdef __UCLIBC_HAVE_ASM_WEAK_DIRECTIVE__
125 # define HAVE_ASM_WEAK_DIRECTIVE
126 #else
127 # undef HAVE_ASM_WEAK_DIRECTIVE
128 #endif
129
130 #ifdef __UCLIBC_HAVE_ASM_WEAKEXT_DIRECTIVE__
131 # define HAVE_ASM_WEAKEXT_DIRECTIVE
132 #else
133 # undef HAVE_ASM_WEAKEXT_DIRECTIVE
134 #endif
135
136 #ifdef __UCLIBC_HAVE_ASM_GLOBAL_DOT_NAME__
137 # define HAVE_ASM_GLOBAL_DOT_NAME
138 #else
139 # undef HAVE_ASM_GLOBAL_DOT_NAME
140 #endif
141
142 #ifdef __UCLIBC_HAVE_ASM_CFI_DIRECTIVES__
143 # define HAVE_ASM_CFI_DIRECTIVES
144 #else
145 # undef HAVE_ASM_CFI_DIRECTIVES
146 #endif
147
148 #if defined HAVE_ASM_WEAK_DIRECTIVE || defined HAVE_ASM_WEAKEXT_DIRECTIVE
149 # define HAVE_WEAK_SYMBOLS
150 #endif
151
152 #undef C_SYMBOL_NAME
153 #ifndef C_SYMBOL_NAME
154 # ifndef __UCLIBC_UNDERSCORES__
155 #  define C_SYMBOL_NAME(name) name
156 # else
157 #  define C_SYMBOL_NAME(name) _##name
158 # endif
159 #endif
160
161 #ifdef __UCLIBC_ASM_LINE_SEP__
162 # define ASM_LINE_SEP __UCLIBC_ASM_LINE_SEP__
163 #else
164 # define ASM_LINE_SEP ;
165 #endif
166
167 #ifdef HAVE_ASM_GLOBAL_DOT_NAME
168 # ifndef C_SYMBOL_DOT_NAME
169 #  if defined __GNUC__ && defined __GNUC_MINOR__ \
170       && (__GNUC__ << 16) + __GNUC_MINOR__ >= (3 << 16) + 1
171 #   define C_SYMBOL_DOT_NAME(name) .name
172 #  else
173 #   define C_SYMBOL_DOT_NAME(name) .##name
174 #  endif
175 # endif
176 #endif
177
178 #ifndef __ASSEMBLER__
179 /* GCC understands weak symbols and aliases; use its interface where
180    possible, instead of embedded assembly language.  */
181
182 /* Define ALIASNAME as a strong alias for NAME.  */
183 # define strong_alias(name, aliasname) _strong_alias(name, aliasname)
184 # define _strong_alias(name, aliasname) \
185   extern __typeof (name) aliasname __attribute__ ((alias (#name)));
186 /* Same, but does not check for type match. Use sparingly.
187    Example: strong_alias(stat,stat64) may fail, this one works: */
188 # define strong_alias_untyped(name, aliasname) \
189   _strong_alias_untyped(name, aliasname)
190 # define _strong_alias_untyped(name, aliasname) \
191   extern __typeof (aliasname) aliasname __attribute__ ((alias (#name)));
192
193 /* This comes between the return type and function name in
194    a function definition to make that definition weak.  */
195 # define weak_function __attribute__ ((weak))
196 # define weak_const_function __attribute__ ((weak, __const__))
197
198 # ifdef HAVE_WEAK_SYMBOLS
199
200 /* Define ALIASNAME as a weak alias for NAME.
201    If weak aliases are not available, this defines a strong alias.  */
202 #  define weak_alias(name, aliasname) _weak_alias (name, aliasname)
203 #  define _weak_alias(name, aliasname) \
204   extern __typeof (name) aliasname __attribute__ ((weak, alias (#name)));
205
206 /* Declare SYMBOL as weak undefined symbol (resolved to 0 if not defined).  */
207 #  define weak_extern(symbol) _weak_extern (weak symbol)
208 #  define _weak_extern(expr) _Pragma (#expr)
209
210 # else
211
212 #  define weak_alias(name, aliasname) strong_alias(name, aliasname)
213 #  define weak_extern(symbol) /* Nothing. */
214
215 # endif
216
217 #else /* __ASSEMBLER__ */
218
219 # ifdef HAVE_ASM_SET_DIRECTIVE
220 #  ifdef HAVE_ASM_GLOBAL_DOT_NAME
221 #   define strong_alias(original, alias) \
222         ASM_GLOBAL_DIRECTIVE C_SYMBOL_NAME(alias)               ASM_LINE_SEP \
223         .set    C_SYMBOL_NAME(alias),C_SYMBOL_NAME(original)    ASM_LINE_SEP \
224         ASM_GLOBAL_DIRECTIVE C_SYMBOL_DOT_NAME(alias)           ASM_LINE_SEP \
225         .set    C_SYMBOL_DOT_NAME(alias),C_SYMBOL_DOT_NAME(original)
226 #   define strong_data_alias(original, alias) \
227         ASM_GLOBAL_DIRECTIVE C_SYMBOL_NAME(alias)               ASM_LINE_SEP \
228         .set    C_SYMBOL_NAME(alias),C_SYMBOL_NAME(original)
229 #  else
230 #   define strong_alias(original, alias) \
231         ASM_GLOBAL_DIRECTIVE C_SYMBOL_NAME(alias)               ASM_LINE_SEP \
232         .set    C_SYMBOL_NAME(alias),C_SYMBOL_NAME(original)
233 #   define strong_data_alias(original, alias) strong_alias(original, alias)
234 #  endif
235 # else
236 #  ifdef HAVE_ASM_GLOBAL_DOT_NAME
237 #   define strong_alias(original, alias) \
238         ASM_GLOBAL_DIRECTIVE C_SYMBOL_NAME(alias)               ASM_LINE_SEP \
239         C_SYMBOL_NAME(alias) = C_SYMBOL_NAME(original)          ASM_LINE_SEP \
240         ASM_GLOBAL_DIRECTIVE C_SYMBOL_DOT_NAME(alias)           ASM_LINE_SEP \
241         C_SYMBOL_DOT_NAME(alias) = C_SYMBOL_DOT_NAME(original)
242 #   define strong_data_alias(original, alias) \
243         ASM_GLOBAL_DIRECTIVE C_SYMBOL_NAME(alias)               ASM_LINE_SEP \
244         C_SYMBOL_NAME(alias) = C_SYMBOL_NAME(original)
245 #  else
246 #   define strong_alias(original, alias) \
247         ASM_GLOBAL_DIRECTIVE C_SYMBOL_NAME(alias)               ASM_LINE_SEP \
248         C_SYMBOL_NAME(alias) = C_SYMBOL_NAME(original)
249 #   define strong_data_alias(original, alias) strong_alias(original, alias)
250 #  endif
251 # endif
252
253 # ifdef HAVE_WEAK_SYMBOLS
254 #  ifdef HAVE_ASM_WEAKEXT_DIRECTIVE
255 #   ifdef HAVE_ASM_GLOBAL_DOT_NAME
256 #    define weak_alias(original, alias) \
257         .weakext C_SYMBOL_NAME(alias),C_SYMBOL_NAME(original)   ASM_LINE_SEP \
258         .weakext C_SYMBOL_DOT_NAME(alias),C_SYMBOL_DOT_NAME(original)
259 #   else
260 #    define weak_alias(original, alias) \
261         .weakext C_SYMBOL_NAME(alias),C_SYMBOL_NAME(original)
262 #   endif
263 #   define weak_extern(symbol) \
264         .weakext C_SYMBOL_NAME(symbol)
265
266 #  else /* ! HAVE_ASM_WEAKEXT_DIRECTIVE */
267
268 #   ifdef HAVE_ASM_SET_DIRECTIVE
269 #    ifdef HAVE_ASM_GLOBAL_DOT_NAME
270 #     define weak_alias(original, alias) \
271         .weak   C_SYMBOL_NAME(alias)                            ASM_LINE_SEP \
272         .set    C_SYMBOL_NAME(alias),C_SYMBOL_NAME(original)    ASM_LINE_SEP \
273         .weak   C_SYMBOL_DOT_NAME(alias)                        ASM_LINE_SEP \
274         .set    C_SYMBOL_DOT_NAME(alias),C_SYMBOL_DOT_NAME(original)
275 #    else
276 #     define weak_alias(original, alias) \
277         .weak   C_SYMBOL_NAME(alias)                            ASM_LINE_SEP \
278         .set    C_SYMBOL_NAME(alias),C_SYMBOL_NAME(original)
279 #    endif
280 #   else /* ! HAVE_ASM_SET_DIRECTIVE */
281 #    ifdef HAVE_ASM_GLOBAL_DOT_NAME
282 #     define weak_alias(original, alias) \
283         .weak   C_SYMBOL_NAME(alias)                            ASM_LINE_SEP \
284         C_SYMBOL_NAME(alias) = C_SYMBOL_NAME(original)          ASM_LINE_SEP \
285         .weak   C_SYMBOL_DOT_NAME(alias)                        ASM_LINE_SEP \
286         C_SYMBOL_DOT_NAME(alias) = C_SYMBOL_DOT_NAME(original)
287 #    else
288 #     define weak_alias(original, alias) \
289         .weak   C_SYMBOL_NAME(alias)                            ASM_LINE_SEP \
290         C_SYMBOL_NAME(alias) = C_SYMBOL_NAME(original)
291 #    endif
292 #   endif
293 #   define weak_extern(symbol) \
294         .weak   C_SYMBOL_NAME(symbol)
295
296 #  endif /* ! HAVE_ASM_WEAKEXT_DIRECTIVE */
297
298 # else /* ! HAVE_WEAK_SYMBOLS */
299
300 #  define weak_alias(original, alias) strong_alias(original, alias)
301 #  define weak_extern(symbol) /* Nothing */
302 # endif /* ! HAVE_WEAK_SYMBOLS */
303
304 #endif /* __ASSEMBLER__ */
305
306
307 /* On some platforms we can make internal function calls (i.e., calls of
308    functions not exported) a bit faster by using a different calling
309    convention.  */
310 #ifndef internal_function
311 # define internal_function      /* empty */
312 #endif
313
314
315 /* We want the .gnu.warning.SYMBOL section to be unallocated.  */
316 #define __make_section_unallocated(section_string)      \
317   __asm__ (".section " section_string "\n\t.previous");
318
319
320 /* Tacking on "\n#APP\n\t#" to the section name makes gcc put it's bogus
321    section attributes on what looks like a comment to the assembler.  */
322 #ifdef __sparc__ /* HAVE_SECTION_QUOTES */
323 # define __sec_comment "\"\n#APP\n\t#\""
324 #else
325 # define __sec_comment "\n#APP\n\t#"
326 #endif
327
328
329 /* When a reference to SYMBOL is encountered, the linker will emit a
330    warning message MSG.  */
331 #define link_warning(symbol, msg) \
332   __make_section_unallocated (".gnu.warning." #symbol) \
333   static const char __evoke_link_warning_##symbol[]     \
334     __attribute__ ((used, section (".gnu.warning." #symbol __sec_comment))) \
335     = msg;
336
337 /* Handling on non-exported internal names.  We have to do this only
338    for shared code.  */
339 #ifdef SHARED
340 # define INTUSE(name) name##_internal
341 # define INTDEF(name) strong_alias (name, name##_internal)
342 # define INTVARDEF(name) _INTVARDEF (name, name##_internal)
343 # if defined HAVE_VISIBILITY_ATTRIBUTE
344 #  define _INTVARDEF(name, aliasname) \
345   extern __typeof (name) aliasname __attribute__ ((alias (#name), \
346                                                    visibility ("hidden")));
347 # else
348 #  define _INTVARDEF(name, aliasname) \
349   extern __typeof (name) aliasname __attribute__ ((alias (#name)));
350 # endif
351 # define INTDEF2(name, newname) strong_alias (name, newname##_internal)
352 # define INTVARDEF2(name, newname) _INTVARDEF (name, newname##_internal)
353 #else
354 # define INTUSE(name) name
355 # define INTDEF(name)
356 # define INTVARDEF(name)
357 # define INTDEF2(name, newname)
358 # define INTVARDEF2(name, newname)
359 #endif
360
361
362 /* The following macros are used for PLT bypassing within libc.so
363    (and if needed other libraries similarly).
364
365    If calls to foo within libc.so should always go to foo defined in libc.so,
366    then in include/foo.h you add:
367
368    int foo(int __bar);
369    libc_hidden_proto(foo)
370
371    line and after the foo function definition:
372
373    int foo(int __bar) {
374      return __bar;
375    }
376    libc_hidden_def(foo)
377
378    or
379
380    int foo(int __bar) {
381      return __bar;
382    }
383    libc_hidden_weak(foo)
384
385    Similarly for global data: if references to foo within libc.so
386    should always go to foo defined in libc.so, then in include/foo.h:
387
388    extern int foo;
389    libc_hidden_proto(foo)
390
391    and after foo's definition:
392
393    int foo = INITIAL_FOO_VALUE;
394    libc_hidden_data_def(foo)
395
396    or
397
398    int foo = INITIAL_FOO_VALUE;
399    libc_hidden_data_weak(foo)
400
401    If foo is normally just an alias (strong or weak) to some other function,
402    you should use the normal strong_alias first, then add libc_hidden_def
403    or libc_hidden_weak:
404
405    int baz(int __bar) {
406      return __bar;
407    }
408    strong_alias(baz, foo)
409    libc_hidden_weak(foo)
410
411    If the function should be internal to multiple objects, say ld.so and
412    libc.so, the best way is to use:
413
414    #if !defined NOT_IN_libc || defined IS_IN_rtld
415    hidden_proto(foo)
416    #endif
417
418    in include/foo.h and the normal macros at all function definitions
419    depending on what DSO they belong to.
420
421    If versioned_symbol macro is used to define foo,
422    libc_hidden_ver macro should be used, as in:
423
424    int __real_foo(int __bar) {
425      return __bar;
426    }
427    versioned_symbol(libc, __real_foo, foo, GLIBC_2_1);
428    libc_hidden_ver(__real_foo, foo)
429  */
430
431 /* uClibc specific (the above comment was copied from glibc):
432  *
433  * when ppc64 will be supported, we need changes to support
434  * strong_data_alias (used by asm hidden_data_def)
435  *
436  * no versioning support, hidden[_data]_ver are noop
437  *
438  * hidden_def() in asm is _hidden_strong_alias (not strong_alias)
439  *
440  * libc_hidden_proto(foo) should be added after declaration
441  * in the header, or after extern foo... in all source files
442  * (this is discouraged).
443  * libc_hidden_def does not hide __GI_foo itself, although the name
444  * suggests it (hiding is done exclusively by libc_hidden_proto).
445
446 FIXME! - ?
447  * The reasoning to have it after the header w/ foo's prototype is
448  * to get first the __REDIRECT from original header and then create
449  * the __GI_foo alias
450
451  * Hunt for references which still go through PLT (example for x86):
452  * build shared lib, then disassemble it and search for <xxx@plt>:
453  * $ objdump -drx libuClibc-*.so >disasm.txt
454  * $ grep -F '@plt>:' disasm.txt
455  *
456  * In uclibc, malloc/free and related functions should be called
457  * through PLT (making it possible to use alternative malloc),
458  * and possibly some __pthread_xxx functions can be called through PLT
459  * (why?). The rest should not use PLT.
460  */
461
462 #if (defined __GNUC__ && defined __GNUC_MINOR__ \
463         && (( __GNUC__ >= 3 && __GNUC_MINOR__ >= 3) || __GNUC__ >= 4) \
464     ) || defined __ICC
465 # define attribute_hidden __attribute__ ((visibility ("hidden")))
466 # define __hidden_proto_hiddenattr(attrs...) __attribute__ ((visibility ("hidden"), ##attrs))
467 #else
468 # define attribute_hidden
469 # define __hidden_proto_hiddenattr(attrs...)
470 #endif
471
472 #if defined NOT_FOR_L4 && /*!defined STATIC &&*/ !defined __BCC__
473
474 # ifndef __ASSEMBLER__
475 #  define hidden_proto(name, attrs...) __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) __hidden_asmname1 (__USER_LABEL_PREFIX__, name)
480 #  define __hidden_asmname1(prefix, name) __hidden_asmname2(prefix, name)
481 #  define __hidden_asmname2(prefix, name) #prefix name
482 #  define __hidden_ver1(local, internal, name) \
483         extern __typeof (name) __EI_##name __asm__(__hidden_asmname (#internal)); \
484         extern __typeof (name) __EI_##name __attribute__((alias (__hidden_asmname1 (,#local))))
485 #  define hidden_ver(local, name)       __hidden_ver1(local, __GI_##name, name);
486 #  define hidden_data_ver(local, name)  hidden_ver(local, name)
487 #  define hidden_def(name)              __hidden_ver1(__GI_##name, name, name);
488 #  define hidden_data_def(name)         hidden_def(name)
489 #  define hidden_weak(name) \
490         __hidden_ver1(__GI_##name, name, name) __attribute__((weak));
491 #  define hidden_data_weak(name)        hidden_weak(name)
492
493 # else /* __ASSEMBLER__ */
494
495 #  ifdef HAVE_ASM_SET_DIRECTIVE
496 #   ifdef HAVE_ASM_GLOBAL_DOT_NAME
497 #    define _hidden_strong_alias(original, alias) \
498         ASM_GLOBAL_DIRECTIVE C_SYMBOL_NAME(alias)               ASM_LINE_SEP \
499         .hidden C_SYMBOL_NAME(alias)                            ASM_LINE_SEP \
500         .set    C_SYMBOL_NAME(alias),C_SYMBOL_NAME(original)    ASM_LINE_SEP \
501         ASM_GLOBAL_DIRECTIVE C_SYMBOL_DOT_NAME(alias)           ASM_LINE_SEP \
502         .hidden C_SYMBOL_DOT_NAME(alias)                        ASM_LINE_SEP \
503         .set    C_SYMBOL_DOT_NAME(alias),C_SYMBOL_DOT_NAME(original)
504 #   else
505 #    define _hidden_strong_alias(original, alias) \
506         ASM_GLOBAL_DIRECTIVE C_SYMBOL_NAME(alias)               ASM_LINE_SEP \
507         .hidden C_SYMBOL_NAME(alias)                            ASM_LINE_SEP \
508         .set    C_SYMBOL_NAME(alias),C_SYMBOL_NAME(original)
509 #   endif
510 #  else /* dont have .set directive */
511 #   ifdef HAVE_ASM_GLOBAL_DOT_NAME
512 #    define _hidden_strong_alias(original, alias) \
513         ASM_GLOBAL_DIRECTIVE C_SYMBOL_NAME(alias)               ASM_LINE_SEP \
514         .hidden C_SYMBOL_NAME(alias)                            ASM_LINE_SEP \
515         C_SYMBOL_NAME(alias) = C_SYMBOL_NAME(original)          ASM_LINE_SEP \
516         ASM_GLOBAL_DIRECTIVE C_SYMBOL_DOT_NAME(alias)           ASM_LINE_SEP \
517         .hidden C_SYMBOL_DOT_NAME(alias)                        ASM_LINE_SEP \
518         C_SYMBOL_DOT_NAME(alias) = C_SYMBOL_DOT_NAME(original)
519 #   else
520 #    define _hidden_strong_alias(original, alias) \
521         ASM_GLOBAL_DIRECTIVE C_SYMBOL_NAME(alias)               ASM_LINE_SEP \
522         .hidden C_SYMBOL_NAME(alias)                            ASM_LINE_SEP \
523         C_SYMBOL_NAME(alias) = C_SYMBOL_NAME(original)
524 #   endif
525 #  endif
526
527 #  ifdef HAVE_ASM_GLOBAL_DOT_NAME
528 #   define _hidden_weak_alias(original, alias) \
529         .hidden C_SYMBOL_NAME(alias)                            ASM_LINE_SEP \
530         .hidden C_SYMBOL_DOT_NAME(alias)                        ASM_LINE_SEP \
531         weak_alias(original, alias)
532 #  else
533 #   define _hidden_weak_alias(original, alias) \
534         .hidden C_SYMBOL_NAME(alias)                            ASM_LINE_SEP \
535         weak_alias(original, alias)
536 #  endif
537
538 /* For assembly, we need to do the opposite of what we do in C:
539    in assembly gcc __REDIRECT stuff is not in place, so functions
540    are defined by its normal name and we need to create the
541    __GI_* alias to it, in C __REDIRECT causes the function definition
542    to use __GI_* name and we need to add alias to the real name.
543    There is no reason to use hidden_weak over hidden_def in assembly,
544    but we provide it for consistency with the C usage.
545    hidden_proto doesn't make sense for assembly but the equivalent
546    is to call via the HIDDEN_JUMPTARGET macro instead of JUMPTARGET.  */
547 #  define hidden_def(name)      _hidden_strong_alias (name, __GI_##name)
548 #  define hidden_weak(name)     _hidden_weak_alias (name, __GI_##name)
549 #  define hidden_ver(local, name) strong_alias (local, __GI_##name)
550 #  define hidden_data_def(name) _hidden_strong_alias (name, __GI_##name)
551 #  define hidden_data_weak(name)        _hidden_weak_alias (name, __GI_##name)
552 #  define hidden_data_ver(local, name) strong_data_alias (local, __GI_##name)
553 #  ifdef HAVE_ASM_GLOBAL_DOT_NAME
554 #   define HIDDEN_JUMPTARGET(name) .__GI_##name
555 #  else
556 #   define HIDDEN_JUMPTARGET(name) __GI_##name
557 #  endif
558 # endif /* __ASSEMBLER__ */
559
560 #else /* not SHARED */
561
562 # ifndef __ASSEMBLER__
563 #  define hidden_proto(name, attrs...)
564 # else
565 #  define HIDDEN_JUMPTARGET(name) name
566 # endif /* not __ASSEMBLER__ */
567 # define hidden_weak(name)
568 # define hidden_def(name)
569 # define hidden_ver(local, name)
570 # define hidden_data_weak(name)
571 # define hidden_data_def(name)
572 # define hidden_data_ver(local, name)
573
574 #endif /* SHARED / not SHARED */
575
576
577 /* uClibc does not support versioning yet. */
578 #define versioned_symbol(lib, local, symbol, version) /* weak_alias(local, symbol) */
579 #undef hidden_ver
580 #define hidden_ver(local, name) /* strong_alias(local, __GI_##name) */
581 #undef hidden_data_ver
582 #define hidden_data_ver(local, name) /* strong_alias(local,__GI_##name) */
583
584 #if !defined NOT_IN_libc
585 # define libc_hidden_proto(name, attrs...) hidden_proto (name, ##attrs)
586 # define libc_hidden_def(name) hidden_def (name)
587 # define libc_hidden_weak(name) hidden_weak (name)
588 # define libc_hidden_ver(local, name) hidden_ver (local, name)
589 # define libc_hidden_data_def(name) hidden_data_def (name)
590 # define libc_hidden_data_weak(name) hidden_data_weak (name)
591 # define libc_hidden_data_ver(local, name) hidden_data_ver (local, name)
592 #else
593 # define libc_hidden_proto(name, attrs...)
594 # define libc_hidden_def(name)
595 # define libc_hidden_weak(name)
596 # define libc_hidden_ver(local, name)
597 # define libc_hidden_data_def(name)
598 # define libc_hidden_data_weak(name)
599 # define libc_hidden_data_ver(local, name)
600 #endif
601
602 #if defined NOT_IN_libc && defined IS_IN_rtld
603 # define rtld_hidden_proto(name, attrs...) hidden_proto (name, ##attrs)
604 # define rtld_hidden_def(name) hidden_def (name)
605 # define rtld_hidden_weak(name) hidden_weak (name)
606 # define rtld_hidden_ver(local, name) hidden_ver (local, name)
607 # define rtld_hidden_data_def(name) hidden_data_def (name)
608 # define rtld_hidden_data_weak(name) hidden_data_weak (name)
609 # define rtld_hidden_data_ver(local, name) hidden_data_ver (local, name)
610 #else
611 # define rtld_hidden_proto(name, attrs...)
612 # define rtld_hidden_def(name)
613 # define rtld_hidden_weak(name)
614 # define rtld_hidden_ver(local, name)
615 # define rtld_hidden_data_def(name)
616 # define rtld_hidden_data_weak(name)
617 # define rtld_hidden_data_ver(local, name)
618 #endif
619
620 #if defined NOT_IN_libc && defined IS_IN_libm
621 # define libm_hidden_proto(name, attrs...) hidden_proto (name, ##attrs)
622 # define libm_hidden_def(name) hidden_def (name)
623 # define libm_hidden_weak(name) hidden_weak (name)
624 # define libm_hidden_ver(local, name) hidden_ver (local, name)
625 # define libm_hidden_data_def(name) hidden_data_def (name)
626 # define libm_hidden_data_weak(name) hidden_data_weak (name)
627 # define libm_hidden_data_ver(local, name) hidden_data_ver (local, name)
628 #else
629 # define libm_hidden_proto(name, attrs...)
630 # define libm_hidden_def(name)
631 # define libm_hidden_weak(name)
632 # define libm_hidden_ver(local, name)
633 # define libm_hidden_data_def(name)
634 # define libm_hidden_data_weak(name)
635 # define libm_hidden_data_ver(local, name)
636 #endif
637
638 #if defined NOT_IN_libc && defined IS_IN_libresolv
639 # define libresolv_hidden_proto(name, attrs...) hidden_proto (name, ##attrs)
640 # define libresolv_hidden_def(name) hidden_def (name)
641 # define libresolv_hidden_weak(name) hidden_weak (name)
642 # define libresolv_hidden_ver(local, name) hidden_ver (local, name)
643 # define libresolv_hidden_data_def(name) hidden_data_def (name)
644 # define libresolv_hidden_data_weak(name) hidden_data_weak (name)
645 # define libresolv_hidden_data_ver(local, name) hidden_data_ver (local, name)
646 #else
647 # define libresolv_hidden_proto(name, attrs...)
648 # define libresolv_hidden_def(name)
649 # define libresolv_hidden_weak(name)
650 # define libresolv_hidden_ver(local, name)
651 # define libresolv_hidden_data_def(name)
652 # define libresolv_hidden_data_weak(name)
653 # define libresolv_hidden_data_ver(local, name)
654 #endif
655
656 #if defined NOT_IN_libc && defined IS_IN_librt
657 # define librt_hidden_proto(name, attrs...) hidden_proto (name, ##attrs)
658 # define librt_hidden_def(name) hidden_def (name)
659 # define librt_hidden_weak(name) hidden_weak (name)
660 # define librt_hidden_ver(local, name) hidden_ver (local, name)
661 # define librt_hidden_data_def(name) hidden_data_def (name)
662 # define librt_hidden_data_weak(name) hidden_data_weak (name)
663 # define librt_hidden_data_ver(local, name) hidden_data_ver (local, name)
664 #else
665 # define librt_hidden_proto(name, attrs...)
666 # define librt_hidden_def(name)
667 # define librt_hidden_weak(name)
668 # define librt_hidden_ver(local, name)
669 # define librt_hidden_data_def(name)
670 # define librt_hidden_data_weak(name)
671 # define librt_hidden_data_ver(local, name)
672 #endif
673
674 #if defined NOT_IN_libc && defined IS_IN_libdl
675 # define libdl_hidden_proto(name, attrs...) hidden_proto (name, ##attrs)
676 # define libdl_hidden_def(name) hidden_def (name)
677 # define libdl_hidden_weak(name) hidden_weak (name)
678 # define libdl_hidden_ver(local, name) hidden_ver (local, name)
679 # define libdl_hidden_data_def(name) hidden_data_def (name)
680 # define libdl_hidden_data_weak(name) hidden_data_weak (name)
681 # define libdl_hidden_data_ver(local, name) hidden_data_ver (local, name)
682 #else
683 # define libdl_hidden_proto(name, attrs...)
684 # define libdl_hidden_def(name)
685 # define libdl_hidden_weak(name)
686 # define libdl_hidden_ver(local, name)
687 # define libdl_hidden_data_def(name)
688 # define libdl_hidden_data_weak(name)
689 # define libdl_hidden_data_ver(local, name)
690 #endif
691
692 #if defined NOT_IN_libc && defined IS_IN_libintl
693 # define libintl_hidden_proto(name, attrs...) hidden_proto (name, ##attrs)
694 # define libintl_hidden_def(name) hidden_def (name)
695 # define libintl_hidden_weak(name) hidden_weak (name)
696 # define libintl_hidden_ver(local, name) hidden_ver (local, name)
697 # define libintl_hidden_data_def(name) hidden_data_def (name)
698 # define libintl_hidden_data_weak(name) hidden_data_weak (name)
699 # define libintl_hidden_data_ver(local, name) hidden_data_ver(local, name)
700 #else
701 # define libintl_hidden_proto(name, attrs...)
702 # define libintl_hidden_def(name)
703 # define libintl_hidden_weak(name)
704 # define libintl_hidden_ver(local, name)
705 # define libintl_hidden_data_def(name)
706 # define libintl_hidden_data_weak(name)
707 # define libintl_hidden_data_ver(local, name)
708 #endif
709
710 #if defined NOT_IN_libc && defined IS_IN_libnsl
711 # define libnsl_hidden_proto(name, attrs...) hidden_proto (name, ##attrs)
712 # define libnsl_hidden_def(name) hidden_def (name)
713 # define libnsl_hidden_weak(name) hidden_weak (name)
714 # define libnsl_hidden_ver(local, name) hidden_ver (local, name)
715 # define libnsl_hidden_data_def(name) hidden_data_def (name)
716 # define libnsl_hidden_data_weak(name) hidden_data_weak (name)
717 # define libnsl_hidden_data_ver(local, name) hidden_data_ver (local, name)
718 #else
719 # define libnsl_hidden_proto(name, attrs...)
720 # define libnsl_hidden_def(name)
721 # define libnsl_hidden_weak(name)
722 # define libnsl_hidden_ver(local, name)
723 # define libnsl_hidden_data_def(name)
724 # define libnsl_hidden_data_weak(name)
725 # define libnsl_hidden_data_ver(local, name)
726 #endif
727
728 #if defined NOT_IN_libc && defined IS_IN_libutil
729 # define libutil_hidden_proto(name, attrs...) hidden_proto (name, ##attrs)
730 # define libutil_hidden_def(name) hidden_def (name)
731 # define libutil_hidden_weak(name) hidden_weak (name)
732 # define libutil_hidden_ver(local, name) hidden_ver (local, name)
733 # define libutil_hidden_data_def(name) hidden_data_def (name)
734 # define libutil_hidden_data_weak(name) hidden_data_weak (name)
735 # define libutil_hidden_data_ver(local, name) hidden_data_ver (local, name)
736 #else
737 # define libutil_hidden_proto(name, attrs...)
738 # define libutil_hidden_def(name)
739 # define libutil_hidden_weak(name)
740 # define libutil_hidden_ver(local, name)
741 # define libutil_hidden_data_def(name)
742 # define libutil_hidden_data_weak(name)
743 # define libutil_hidden_data_ver(local, name)
744 #endif
745
746 #if defined NOT_IN_libc && defined IS_IN_libcrypt
747 # define libcrypt_hidden_proto(name, attrs...) hidden_proto (name, ##attrs)
748 # define libcrypt_hidden_def(name) hidden_def (name)
749 # define libcrypt_hidden_weak(name) hidden_weak (name)
750 # define libcrypt_hidden_ver(local, name) hidden_ver (local, name)
751 # define libcrypt_hidden_data_def(name) hidden_data_def (name)
752 # define libcrypt_hidden_data_weak(name) hidden_data_weak (name)
753 # define libcrypt_hidden_data_ver(local, name) hidden_data_ver (local, name)
754 #else
755 # define libcrypt_hidden_proto(name, attrs...)
756 # define libcrypt_hidden_def(name)
757 # define libcrypt_hidden_weak(name)
758 # define libcrypt_hidden_ver(local, name)
759 # define libcrypt_hidden_data_def(name)
760 # define libcrypt_hidden_data_weak(name)
761 # define libcrypt_hidden_data_ver(local, name)
762 #endif
763
764 #if defined NOT_IN_libc && defined IS_IN_libpthread
765 # define libpthread_hidden_proto(name, attrs...) hidden_proto (name, ##attrs)
766 # define libpthread_hidden_def(name) hidden_def (name)
767 # define libpthread_hidden_weak(name) hidden_weak (name)
768 # define libpthread_hidden_ver(local, name) hidden_ver (local, name)
769 # define libpthread_hidden_data_def(name) hidden_data_def (name)
770 # define libpthread_hidden_data_weak(name) hidden_data_weak (name)
771 # define libpthread_hidden_data_ver(local, name) hidden_data_ver (local, name)
772 #else
773 # define libpthread_hidden_proto(name, attrs...)
774 # define libpthread_hidden_def(name)
775 # define libpthread_hidden_weak(name)
776 # define libpthread_hidden_ver(local, name)
777 # define libpthread_hidden_data_def(name)
778 # define libpthread_hidden_data_weak(name)
779 # define libpthread_hidden_data_ver(local, name)
780 #endif
781
782 #endif /* libc-symbols.h */