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