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