]> git.ipfire.org Git - thirdparty/glibc.git/blame - include/libc-symbols.h
* locale/lc-time.c (_nl_init_era_entries, _nl_get_era_entry,
[thirdparty/glibc.git] / include / libc-symbols.h
CommitLineData
28f540f4
RM
1/* Support macros for making weak and strong aliases for symbols,
2 and for using symbol sets and linker warnings with GNU ld.
7969407a 3 Copyright (C) 1995-1998,2000,2001,2002 Free Software Foundation, Inc.
5290baf0 4 This file is part of the GNU C Library.
28f540f4 5
5290baf0 6 The GNU C Library is free software; you can redistribute it and/or
41bdb6e2
AJ
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.
28f540f4 10
5290baf0
UD
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
41bdb6e2 14 Lesser General Public License for more details.
28f540f4 15
41bdb6e2
AJ
16 You should have received a copy of the GNU Lesser General Public
17 License along with the GNU C Library; if not, write to the Free
18 Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
19 02111-1307 USA. */
28f540f4
RM
20
21#ifndef _LIBC_SYMBOLS_H
5290baf0 22#define _LIBC_SYMBOLS_H 1
28f540f4
RM
23
24/* This file's macros are included implicitly in the compilation of every
25 file in the C library by -imacros.
26
27 We include config.h which is generated by configure.
28 It should define for us the following symbols:
29
c224a18a
RM
30 * HAVE_ASM_SET_DIRECTIVE if we have `.set B, A' instead of `A = B'.
31 * ASM_GLOBAL_DIRECTIVE with `.globl' or `.global'.
b88ac073
RM
32 * ASM_TYPE_DIRECTIVE_PREFIX with `@' or `#' or whatever for .type,
33 or leave it undefined if there is no .type directive.
28f540f4
RM
34 * HAVE_GNU_LD if using GNU ld, with support for weak symbols in a.out,
35 and for symbol set and warning messages extensions in a.out and ELF.
c224a18a
RM
36 * HAVE_ELF if using ELF, which supports weak symbols using `.weak'.
37 * HAVE_ASM_WEAK_DIRECTIVE if we have weak symbols using `.weak'.
38 * HAVE_ASM_WEAKEXT_DIRECTIVE if we have weak symbols using `.weakext'.
28f540f4
RM
39
40 */
28f540f4 41
92777700
RM
42/* This is defined for the compilation of all C library code. features.h
43 tests this to avoid inclusion of stubs.h while compiling the library,
44 before stubs.h has been generated. Some library code that is shared
45 with other packages also tests this symbol to see if it is being
46 compiled as part of the C library. We must define this before including
47 config.h, because it makes some definitions conditional on whether libc
48 itself is being compiled, or just some generator program. */
c709e372 49#define _LIBC 1
92777700 50
d3669add
RM
51/* Enable declarations of GNU extensions, since we are compiling them. */
52#define _GNU_SOURCE 1
ec4b0518
UD
53/* And we also need the data for the reentrant functions. */
54#define _REENTRANT 1
d3669add 55
92777700 56#include <config.h>
28f540f4 57
c224a18a
RM
58/* The symbols in all the user (non-_) macros are C symbols.
59 HAVE_GNU_LD without HAVE_ELF implies a.out. */
28f540f4 60
dfd2257a
UD
61#if defined HAVE_ASM_WEAK_DIRECTIVE || defined HAVE_ASM_WEAKEXT_DIRECTIVE
62# define HAVE_WEAK_SYMBOLS
28f540f4 63#endif
28f540f4
RM
64
65#ifndef __SYMBOL_PREFIX
dfd2257a
UD
66# ifdef NO_UNDERSCORES
67# define __SYMBOL_PREFIX
68# else
69# define __SYMBOL_PREFIX "_"
70# endif
28f540f4
RM
71#endif
72
73#ifndef C_SYMBOL_NAME
dfd2257a
UD
74# ifdef NO_UNDERSCORES
75# define C_SYMBOL_NAME(name) name
76# else
77# define C_SYMBOL_NAME(name) _##name
78# endif
28f540f4
RM
79#endif
80
b15cb495
UD
81#ifndef ASM_LINE_SEP
82# define ASM_LINE_SEP ;
83#endif
84
256ba888
UD
85#ifndef C_SYMBOL_DOT_NAME
86# define C_SYMBOL_DOT_NAME(name) .##name
87#endif
88
428383e8
UD
89#ifndef __ASSEMBLER__
90/* GCC understands weak symbols and aliases; use its interface where
91 possible, instead of embedded assembly language. */
d02907df 92
428383e8 93/* Define ALIASNAME as a strong alias for NAME. */
c62f5cab
GM
94# define strong_alias(name, aliasname) _strong_alias(name, aliasname)
95# define _strong_alias(name, aliasname) \
428383e8
UD
96 extern __typeof (name) aliasname __attribute__ ((alias (#name)));
97
98/* This comes between the return type and function name in
99 a function definition to make that definition weak. */
100# define weak_function __attribute__ ((weak))
101# define weak_const_function __attribute__ ((weak, __const__))
102
103# ifdef HAVE_WEAK_SYMBOLS
104
105/* Define ALIASNAME as a weak alias for NAME.
106 If weak aliases are not available, this defines a strong alias. */
c62f5cab
GM
107# define weak_alias(name, aliasname) _weak_alias (name, aliasname)
108# define _weak_alias(name, aliasname) \
428383e8
UD
109 extern __typeof (name) aliasname __attribute__ ((weak, alias (#name)));
110
111/* Declare SYMBOL as weak undefined symbol (resolved to 0 if not defined). */
ebdf53a7 112# define weak_extern(symbol) _weak_extern (symbol)
428383e8 113# ifdef HAVE_ASM_WEAKEXT_DIRECTIVE
ebdf53a7 114# define _weak_extern(symbol) asm (".weakext " __SYMBOL_PREFIX #symbol);
428383e8 115# else
ebdf53a7 116# define _weak_extern(symbol) asm (".weak " __SYMBOL_PREFIX #symbol);
428383e8
UD
117# endif
118
119# else
120
121# define weak_alias(name, aliasname) strong_alias(name, aliasname)
122# define weak_extern(symbol) /* Nothing. */
123
124# endif
125
126#else /* __ASSEMBLER__ */
127
128# ifdef HAVE_ASM_SET_DIRECTIVE
129# define strong_alias(original, alias) \
b15cb495 130 ASM_GLOBAL_DIRECTIVE C_SYMBOL_NAME (alias) ASM_LINE_SEP \
28f540f4 131 .set C_SYMBOL_NAME (alias),C_SYMBOL_NAME (original)
dfd2257a 132# else
2aa15430
UD
133# ifdef HAVE_ASM_GLOBAL_DOT_NAME
134# define strong_alias(original, alias) \
135 ASM_GLOBAL_DIRECTIVE C_SYMBOL_NAME (alias) ASM_LINE_SEP \
136 C_SYMBOL_NAME (alias) = C_SYMBOL_NAME (original) ASM_LINE_SEP \
137 ASM_GLOBAL_DIRECTIVE C_SYMBOL_DOT_NAME (alias) ASM_LINE_SEP \
138 C_SYMBOL_DOT_NAME (alias) = C_SYMBOL_DOT_NAME (original)
139# else
140# define strong_alias(original, alias) \
b15cb495 141 ASM_GLOBAL_DIRECTIVE C_SYMBOL_NAME (alias) ASM_LINE_SEP \
335aa320 142 C_SYMBOL_NAME (alias) = C_SYMBOL_NAME (original)
2aa15430 143# endif
dfd2257a 144# endif
d02907df 145
428383e8 146# ifdef HAVE_WEAK_SYMBOLS
dfd2257a 147# ifdef HAVE_ASM_WEAKEXT_DIRECTIVE
dfd2257a 148# define weak_alias(original, alias) \
c224a18a 149 .weakext C_SYMBOL_NAME (alias), C_SYMBOL_NAME (original)
dfd2257a 150# define weak_extern(symbol) \
af5b3bc3 151 .weakext C_SYMBOL_NAME (symbol)
c224a18a 152
dfd2257a 153# else /* ! HAVE_ASM_WEAKEXT_DIRECTIVE */
c224a18a 154
2aa15430
UD
155# ifdef HAVE_ASM_GLOBAL_DOT_NAME
156# define weak_alias(original, alias) \
157 .weak C_SYMBOL_NAME (alias) ASM_LINE_SEP \
158 C_SYMBOL_NAME (alias) = C_SYMBOL_NAME (original) ASM_LINE_SEP \
d436a9f7 159 ASM_GLOBAL_DIRECTIVE C_SYMBOL_DOT_NAME (alias) ASM_LINE_SEP \
2aa15430
UD
160 C_SYMBOL_DOT_NAME (alias) = C_SYMBOL_DOT_NAME (original)
161# else
162# define weak_alias(original, alias) \
b15cb495 163 .weak C_SYMBOL_NAME (alias) ASM_LINE_SEP \
28f540f4 164 C_SYMBOL_NAME (alias) = C_SYMBOL_NAME (original)
2aa15430 165# endif
e6964dd4 166
dfd2257a 167# define weak_extern(symbol) \
af5b3bc3 168 .weak C_SYMBOL_NAME (symbol)
d02907df 169
dfd2257a 170# endif /* ! HAVE_ASM_WEAKEXT_DIRECTIVE */
c224a18a 171
428383e8 172# else /* ! HAVE_WEAK_SYMBOLS */
af5b3bc3 173
428383e8
UD
174# define weak_alias(original, alias) strong_alias(original, alias)
175# define weak_extern(symbol) /* Nothing */
176# endif /* ! HAVE_WEAK_SYMBOLS */
af5b3bc3 177
428383e8 178#endif /* __ASSEMBLER__ */
958f803f 179
dfd2257a
UD
180/* On some platforms we can make internal function calls (i.e., calls of
181 functions not exported) a bit faster by using a different calling
182 convention. */
183#ifndef internal_function
184# define internal_function /* empty */
185#endif
28f540f4 186
a8eab8b1
UD
187/* Prepare for the case that `__builtin_expect' is not available. */
188#ifndef HAVE_BUILTIN_EXPECT
189# define __builtin_expect(expr, val) (expr)
190#endif
191
e862aada
UD
192/* Determine the return address. */
193#define RETURN_ADDRESS(nr) \
194 __builtin_extract_return_addr (__builtin_return_address (nr))
195
44c8d1a2
RM
196/* When a reference to SYMBOL is encountered, the linker will emit a
197 warning message MSG. */
28f540f4 198#ifdef HAVE_GNU_LD
dfd2257a 199# ifdef HAVE_ELF
fd26970f
UD
200
201/* We want the .gnu.warning.SYMBOL section to be unallocated. */
dfd2257a
UD
202# ifdef HAVE_ASM_PREVIOUS_DIRECTIVE
203# define __make_section_unallocated(section_string) \
b15cb495 204 asm (".section " section_string "\n\t.previous");
e26dd47f 205# elif defined HAVE_ASM_POPSECTION_DIRECTIVE
dfd2257a 206# define __make_section_unallocated(section_string) \
b15cb495 207 asm (".pushsection " section_string "\n\t.popsection");
dfd2257a
UD
208# else
209# define __make_section_unallocated(section_string)
210# endif
fd26970f 211
b15cb495
UD
212/* Tacking on "\n\t#" to the section name makes gcc put it's bogus
213 section attributes on what looks like a comment to the assembler. */
e26dd47f
UD
214# ifdef HAVE_SECTION_QUOTES
215# define link_warning(symbol, msg) \
216 __make_section_unallocated (".gnu.warning." #symbol) \
217 static const char __evoke_link_warning_##symbol[] \
13176c60
RM
218 __attribute__ ((unused, section (".gnu.warning." #symbol "\"\n\t#\""))) \
219 = msg;
e26dd47f
UD
220# else
221# define link_warning(symbol, msg) \
222 __make_section_unallocated (".gnu.warning." #symbol) \
44c8d1a2 223 static const char __evoke_link_warning_##symbol[] \
13176c60 224 __attribute__ ((unused, section (".gnu.warning." #symbol "\n\t#"))) = msg;
e26dd47f 225# endif
5af3245a
UD
226# else /* Not ELF: a.out */
227# ifdef HAVE_XCOFF
228/* XCOFF does not support .stabs.
229 The native aix linker will remove the .stab and .stabstr sections
230 The gnu linker will have a fatal error if there is a relocation for
231 symbol in the .stab section. Silently disable this macro. */
7969407a 232# define link_warning(symbol, msg)
5af3245a
UD
233# else
234# define link_warning(symbol, msg) \
235 asm (".stabs \"" msg "\",30,0,0,0\n\t" \
236 ".stabs \"" __SYMBOL_PREFIX #symbol "\",1,0,0,0\n");
237# endif /* XCOFF */
dfd2257a 238# endif
28f540f4
RM
239#else
240/* We will never be heard; they will all die horribly. */
dfd2257a 241# define link_warning(symbol, msg)
28f540f4
RM
242#endif
243
244/* A canned warning for sysdeps/stub functions. */
245#define stub_warning(name) \
44c8d1a2
RM
246 link_warning (name, \
247 "warning: " #name " is not implemented and will always fail")
5f9e57ba 248
b88ac073
RM
249
250/* Declare SYMBOL to be TYPE (`function' or `object') and of SIZE bytes,
251 when the assembler supports such declarations (such as in ELF).
252 This is only necessary when defining something in assembly, or playing
253 funny alias games where the size should be other than what the compiler
254 thinks it is. */
255#define declare_symbol(symbol, type, size) \
256 declare_symbol_1 (symbol, type, size)
257#ifdef ASM_TYPE_DIRECTIVE_PREFIX
258# ifdef __ASSEMBLER__
259# define declare_symbol_1(symbol, type, size) \
260 .type C_SYMBOL_NAME (symbol), \
261 declare_symbol_1_paste (ASM_TYPE_DIRECTIVE_PREFIX, type), size
262# define declare_symbol_1_paste(a, b) declare_symbol_1_paste_1 (a,b)
263# define declare_symbol_1_paste_1(a,b) a##b
264# else /* Not __ASSEMBLER__. */
265# define declare_symbol_1(symbol, type, size) \
266 asm (".type " __SYMBOL_PREFIX #symbol \
267 declare_symbol_1_stringify (ASM_TYPE_DIRECTIVE_PREFIX) #type \
268 "\n\t.size " __SYMBOL_PREFIX #symbol ", " #size);
269# define declare_symbol_1_stringify(x) declare_symbol_1_stringify_1 (x)
270# define declare_symbol_1_stringify_1(x) #x
271# endif /* __ASSEMBLER__ */
272#else
273# define declare_symbol_1(symbol, type, size) /* Nothing. */
274#endif
275
276
5f9e57ba 277/*
28f540f4 278\f
5f9e57ba
RM
279*/
280
28f540f4
RM
281#ifdef HAVE_GNU_LD
282
283/* Symbol set support macros. */
284
dfd2257a 285# ifdef HAVE_ELF
28f540f4
RM
286
287/* Make SYMBOL, which is in the text segment, an element of SET. */
dfd2257a 288# define text_set_element(set, symbol) _elf_set_element(set, symbol)
28f540f4 289/* Make SYMBOL, which is in the data segment, an element of SET. */
dfd2257a 290# define data_set_element(set, symbol) _elf_set_element(set, symbol)
28f540f4 291/* Make SYMBOL, which is in the bss segment, an element of SET. */
dfd2257a 292# define bss_set_element(set, symbol) _elf_set_element(set, symbol)
28f540f4
RM
293
294/* These are all done the same way in ELF.
295 There is a new section created for each set. */
b5567b2a 296# ifdef SHARED
53afa8d9
RM
297/* When building a shared library, make the set section writable,
298 because it will need to be relocated at run time anyway. */
dfd2257a 299# define _elf_set_element(set, symbol) \
53afa8d9 300 static const void *__elf_set_##set##_element_##symbol##__ \
d6e2f671 301 __attribute__ ((unused, section (#set))) = &(symbol)
dfd2257a
UD
302# else
303# define _elf_set_element(set, symbol) \
28f540f4 304 static const void *const __elf_set_##set##_element_##symbol##__ \
d6e2f671 305 __attribute__ ((unused, section (#set))) = &(symbol)
dfd2257a 306# endif
28f540f4
RM
307
308/* Define SET as a symbol set. This may be required (it is in a.out) to
309 be able to use the set's contents. */
dfd2257a 310# define symbol_set_define(set) symbol_set_declare(set)
28f540f4
RM
311
312/* Declare SET for use in this module, if defined in another module. */
dfd2257a 313# define symbol_set_declare(set) \
03df72bf
GM
314 extern void *const __start_##set __attribute__ ((__weak__)); \
315 extern void *const __stop_##set __attribute__ ((__weak__)); \
af5b3bc3 316 weak_extern (__start_##set) weak_extern (__stop_##set)
28f540f4
RM
317
318/* Return a pointer (void *const *) to the first element of SET. */
dfd2257a 319# define symbol_set_first_element(set) (&__start_##set)
28f540f4
RM
320
321/* Return true iff PTR (a void *const *) has been incremented
322 past the last element in SET. */
dfd2257a 323# define symbol_set_end_p(set, ptr) ((ptr) >= &__stop_##set)
28f540f4 324
dfd2257a 325# else /* Not ELF: a.out. */
28f540f4 326
5af3245a
UD
327# ifdef HAVE_XCOFF
328/* XCOFF does not support .stabs.
329 The native aix linker will remove the .stab and .stabstr sections
330 The gnu linker will have a fatal error if there is a relocation for
331 symbol in the .stab section. Silently disable these macros. */
7969407a
UD
332# define text_set_element(set, symbol)
333# define data_set_element(set, symbol)
334# define bss_set_element(set, symbol)
5af3245a
UD
335# else
336# define text_set_element(set, symbol) \
337 asm (".stabs \"" __SYMBOL_PREFIX #set "\",23,0,0," __SYMBOL_PREFIX #symbol)
338# define data_set_element(set, symbol) \
339 asm (".stabs \"" __SYMBOL_PREFIX #set "\",25,0,0," __SYMBOL_PREFIX #symbol)
340# define bss_set_element(set, symbol) ?error Must use initialized data.
341# endif /* XCOFF */
dfd2257a 342# define symbol_set_define(set) void *const (set)[1];
03df72bf 343# define symbol_set_declare(set) extern void *const (set)[1];
28f540f4 344
dfd2257a
UD
345# define symbol_set_first_element(set) &(set)[1]
346# define symbol_set_end_p(set, ptr) (*(ptr) == 0)
28f540f4 347
dfd2257a 348# endif /* ELF. */
a2a89dd6
UD
349#else
350/* We cannot do anything in generial. */
351# define text_set_element(set, symbol) asm ("")
352# define data_set_element(set, symbol) asm ("")
353# define bss_set_element(set, symbol) asm ("")
354# define symbol_set_define(set) void *const (set)[1];
355# define symbol_set_declare(set) extern void *const (set)[1];
356
357# define symbol_set_first_element(set) &(set)[1]
358# define symbol_set_end_p(set, ptr) (*(ptr) == 0)
28f540f4
RM
359#endif /* Have GNU ld. */
360
1ea89a40 361#if DO_VERSIONING
ebdf53a7 362# define symbol_version(real, name, version) \
8b943b4a 363 _symbol_version(real, name, version)
ebdf53a7
GM
364# define default_symbol_version(real, name, version) \
365 _default_symbol_version(real, name, version)
366# ifdef __ASSEMBLER__
8b943b4a 367# define _symbol_version(real, name, version) \
da2d1bc5 368 .symver real, name##@##version
8b943b4a 369# define _default_symbol_version(real, name, version) \
da2d1bc5
UD
370 .symver real, name##@##@##version
371# else
8b943b4a 372# define _symbol_version(real, name, version) \
1ea89a40 373 __asm__ (".symver " #real "," #name "@" #version)
8b943b4a 374# define _default_symbol_version(real, name, version) \
f2ea0f5b 375 __asm__ (".symver " #real "," #name "@@" #version)
da2d1bc5 376# endif
1ea89a40
UD
377#else
378# define symbol_version(real, name, version)
da2d1bc5
UD
379# define default_symbol_version(real, name, version) \
380 strong_alias(real, name)
1ea89a40
UD
381#endif
382
e6caf4e1
UD
383#if defined HAVE_VISIBILITY_ATTRIBUTE && defined SHARED
384# define attribute_hidden __attribute__ ((visibility ("hidden")))
385#else
386# define attribute_hidden
387#endif
388
7969407a
UD
389/* Handling on non-exported internal names. We have to do this only
390 for shared code. */
391#ifdef SHARED
cff26a3e 392# define INTUSE(name) name##_internal
e6caf4e1
UD
393# define INTDEF(name) strong_alias (name, name##_internal)
394# define INTVARDEF(name) \
1897bc3f 395 _INTVARDEF (name, name##_internal)
7f0244de
AJ
396# if defined HAVE_VISIBILITY_ATTRIBUTE
397# define _INTVARDEF(name, aliasname) \
100351c3
UD
398 extern __typeof (name) aliasname __attribute__ ((alias (#name), \
399 visibility ("hidden")));
7f0244de
AJ
400# else
401# define _INTVARDEF(name, aliasname) \
402 extern __typeof (name) aliasname __attribute__ ((alias (#name)));
403# endif
e6caf4e1 404# define INTDEF2(name, newname) strong_alias (name, newname##_internal)
1897bc3f 405# define INTVARDEF2(name, newname) _INTVARDEF (name, newname##_internal)
7969407a 406#else
cff26a3e 407# define INTUSE(name) name
7969407a 408# define INTDEF(name)
e6caf4e1 409# define INTVARDEF(name)
77fe0b9c 410# define INTDEF2(name, newname)
1897bc3f 411# define INTVARDEF2(name, newname)
7969407a
UD
412#endif
413
37ba7d66
UD
414/* The following macros are used for PLT bypassing within libc.so
415 (and if needed other libraries similarly).
416 First of all, you need to have the function prototyped somewhere,
417 say in foo/foo.h:
418
419 int foo (int __bar);
420
421 If calls to foo within libc.so should always go to foo defined in libc.so,
422 then in include/foo.h you add:
423
424 libc_hidden_proto (foo)
425
426 line and after the foo function definition:
427
428 int foo (int __bar)
429 {
430 return __bar;
431 }
432 libc_hidden_def (foo)
433
434 or
435
436 int foo (int __bar)
437 {
438 return __bar;
439 }
440 libc_hidden_weak (foo)
441
442 If foo is normally just an alias (strong or weak) of some other function,
443 you should use the normal strong_alias first, then add libc_hidden_def
444 or libc_hidden_weak:
445
446 int baz (int __bar)
447 {
448 return __bar;
449 }
450 strong_alias (baz, foo)
451 libc_hidden_weak (foo)
452
453 If the function should be internal to multiple objects, say ld.so and
454 libc.so, the best way is to use:
455
456 #if !defined NOT_IN_libc || defined IS_IN_rtld
457 hidden_proto (foo)
458 #endif
459
460 in include/foo.h and the normal macros at all function definitions
461 depending on what DSO they belong to.
462
463 If versioned_symbol macro is used to define foo,
464 libc_hidden_ver macro should be used, as in:
465
466 int __real_foo (int __bar)
467 {
468 return __bar;
469 }
470 versioned_symbol (libc, __real_foo, foo, GLIBC_2_1);
471 libc_hidden_ver (__real_foo, foo) */
472
2b29b5ac
UD
473#if defined SHARED && defined DO_VERSIONING \
474 && !defined HAVE_BROKEN_ALIAS_ATTRIBUTE
37ba7d66
UD
475# ifndef __ASSEMBLER__
476# ifdef HAVE_BROKEN_VISIBILITY_ATTRIBUTE
477# define __hidden_proto_hiddenattr
478# else
479# define __hidden_proto_hiddenattr attribute_hidden
480# endif
2b29b5ac 481# define hidden_proto(name) __hidden_proto (name, __GI_##name)
37ba7d66 482# define __hidden_proto(name, internal) \
a585ba22
RM
483 extern __typeof (name) internal; \
484 extern __typeof (name) name __asm__ (__hidden_asmname (#internal)) \
37ba7d66
UD
485 __hidden_proto_hiddenattr;
486# define __hidden_asmname(name) \
487 __hidden_asmname1 (__USER_LABEL_PREFIX__, name)
488# define __hidden_asmname1(prefix, name) __hidden_asmname2(prefix, name)
489# define __hidden_asmname2(prefix, name) #prefix name
490# ifdef HAVE_ASM_SET_DIRECTIVE
491# define __hidden_def1(original, alias) \
492 ASM_GLOBAL_DIRECTIVE C_SYMBOL_NAME (alias) ASM_LINE_SEP \
493 .set C_SYMBOL_NAME (alias), C_SYMBOL_NAME (original)
494# else
495# ifdef HAVE_ASM_GLOBAL_DOT_NAME
496# define __hidden_def1(original, alias) \
497 ASM_GLOBAL_DIRECTIVE C_SYMBOL_NAME (alias) ASM_LINE_SEP \
498 C_SYMBOL_NAME (alias) = C_SYMBOL_NAME (original) ASM_LINE_SEP \
499 ASM_GLOBAL_DIRECTIVE C_SYMBOL_DOT_NAME (alias) ASM_LINE_SEP \
500 C_SYMBOL_DOT_NAME (alias) = C_SYMBOL_DOT_NAME (original)
501# else
502# define __hidden_def1(original, alias) \
503 ASM_GLOBAL_DIRECTIVE C_SYMBOL_NAME (alias) ASM_LINE_SEP \
504 C_SYMBOL_NAME (alias) = C_SYMBOL_NAME (original)
505# endif
506# endif
507# define __hidden_def2(...) #__VA_ARGS__
508# define __hidden_def3(...) __hidden_def2 (__VA_ARGS__)
509# define hidden_def(name) \
510 __asm__ (__hidden_def3 (__hidden_def1 (__GI_##name, name)));
511# define hidden_ver(local, name) \
512 __asm__ (__hidden_def3 (__hidden_def1 (local, __GI_##name)));
513# ifdef HAVE_WEAK_SYMBOLS
514# ifdef HAVE_ASM_WEAKEXT_DIRECTIVE
515# define __hidden_weak1(original, alias) \
516 .weakext C_SYMBOL_NAME (alias), C_SYMBOL_NAME (original)
517# else /* ! HAVE_ASM_WEAKEXT_DIRECTIVE */
518# ifdef HAVE_ASM_GLOBAL_DOT_NAME
519# define __hidden_weak1(original, alias) \
520 .weak C_SYMBOL_NAME (alias) ASM_LINE_SEP \
521 C_SYMBOL_NAME (alias) = C_SYMBOL_NAME (original) ASM_LINE_SEP \
522 ASM_GLOBAL_DIRECTIVE C_SYMBOL_DOT_NAME (alias) ASM_LINE_SEP \
523 C_SYMBOL_DOT_NAME (alias) = C_SYMBOL_DOT_NAME (original)
524# else
525# define __hidden_weak1(original, alias) \
526 .weak C_SYMBOL_NAME (alias) ASM_LINE_SEP \
527 C_SYMBOL_NAME (alias) = C_SYMBOL_NAME (original)
528# endif
529# endif
530# define hidden_weak(name) \
531 __asm__ (__hidden_def3 (__hidden_weak1 (__GI_##name, name)));
532# else
533# define hidden_weak(name) hidden_def (name)
534# endif
535# else
536/* For assembly, we need to do the opposite of what we do in C:
537 in assembly gcc __REDIRECT stuff is not in place, so functions
538 are defined by its normal name and we need to create the
539 __GI_* alias to it, in C __REDIRECT causes the function definition
540 to use __GI_* name and we need to add alias to the real name.
4547dee3
RM
541 There is no reason to use hidden_weak over hidden_def in assembly,
542 but we provide it for consistency with the C usage.
543 hidden_proto doesn't make sense for assembly but the equivalent
544 is to call via the HIDDEN_JUMPTARGET macro einstead of JUMPTARGET. */
545# define hidden_def(name) strong_alias (name, __GI_##name)
546# define hidden_weak(name) hidden_def (name)
37ba7d66 547# define hidden_ver(local, name) strong_alias (local, __GI_##name)
4547dee3 548# define HIDDEN_JUMPTARGET(name) __GI_##name
37ba7d66
UD
549# endif
550#else
4547dee3 551# ifndef __ASSEMBLER__
37ba7d66 552# define hidden_proto(name)
4547dee3
RM
553# else
554# define HIDDEN_JUMPTARGET(name) JUMPTARGET(name)
555# endif /* Not __ASSEMBLER__ */
556# define hidden_weak(name)
37ba7d66
UD
557# define hidden_def(name)
558# define hidden_ver(local, name)
559#endif
560
c5598d47 561#if !defined NOT_IN_libc
37ba7d66
UD
562# define libc_hidden_proto(name) hidden_proto (name)
563# define libc_hidden_def(name) hidden_def (name)
564# define libc_hidden_weak(name) hidden_weak (name)
565# define libc_hidden_ver(local, name) hidden_ver (local, name)
566#else
567# define libc_hidden_proto(name)
568# define libc_hidden_def(name)
569# define libc_hidden_weak(name)
570# define libc_hidden_ver(local, name)
571#endif
572
c5598d47 573#if defined NOT_IN_libc && defined IS_IN_rtld
37ba7d66
UD
574# define rtld_hidden_proto(name) hidden_proto (name)
575# define rtld_hidden_def(name) hidden_def (name)
576# define rtld_hidden_weak(name) hidden_weak (name)
577# define rtld_hidden_ver(local, name) hidden_ver (local, name)
578#else
579# define rtld_hidden_proto(name)
580# define rtld_hidden_def(name)
581# define rtld_hidden_weak(name)
582# define rtld_hidden_ver(local, name)
583#endif
584
c5598d47 585#if defined NOT_IN_libc && defined IS_IN_libm
37ba7d66
UD
586# define libm_hidden_proto(name) hidden_proto (name)
587# define libm_hidden_def(name) hidden_def (name)
588# define libm_hidden_weak(name) hidden_weak (name)
589# define libm_hidden_ver(local, name) hidden_ver (local, name)
590#else
591# define libm_hidden_proto(name)
592# define libm_hidden_def(name)
593# define libm_hidden_weak(name)
594# define libm_hidden_ver(local, name)
595#endif
596
28f540f4 597#endif /* libc-symbols.h */