Back to index

glibc  2.9
libc-symbols.h
Go to the documentation of this file.
00001 /* Support macros for making weak and strong aliases for symbols,
00002    and for using symbol sets and linker warnings with GNU ld.
00003    Copyright (C) 1995-1998,2000-2003,2004,2005,2006
00004        Free Software Foundation, Inc.
00005    This file is part of the GNU C Library.
00006 
00007    The GNU C Library is free software; you can redistribute it and/or
00008    modify it under the terms of the GNU Lesser General Public
00009    License as published by the Free Software Foundation; either
00010    version 2.1 of the License, or (at your option) any later version.
00011 
00012    The GNU C Library is distributed in the hope that it will be useful,
00013    but WITHOUT ANY WARRANTY; without even the implied warranty of
00014    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00015    Lesser General Public License for more details.
00016 
00017    You should have received a copy of the GNU Lesser General Public
00018    License along with the GNU C Library; if not, write to the Free
00019    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
00020    02111-1307 USA.  */
00021 
00022 #ifndef _LIBC_SYMBOLS_H
00023 #define _LIBC_SYMBOLS_H     1
00024 
00025 /* This file's macros are included implicitly in the compilation of every
00026    file in the C library by -imacros.
00027 
00028    We include config.h which is generated by configure.
00029    It should define for us the following symbols:
00030 
00031    * HAVE_ASM_SET_DIRECTIVE if we have `.set B, A' instead of `A = B'.
00032    * ASM_GLOBAL_DIRECTIVE with `.globl' or `.global'.
00033    * ASM_TYPE_DIRECTIVE_PREFIX with `@' or `#' or whatever for .type,
00034      or leave it undefined if there is no .type directive.
00035    * HAVE_ELF if using ELF, which supports weak symbols using `.weak'.
00036    * HAVE_ASM_WEAK_DIRECTIVE if we have weak symbols using `.weak'.
00037    * HAVE_ASM_WEAKEXT_DIRECTIVE if we have weak symbols using `.weakext'.
00038 
00039    */
00040 
00041 /* This is defined for the compilation of all C library code.  features.h
00042    tests this to avoid inclusion of stubs.h while compiling the library,
00043    before stubs.h has been generated.  Some library code that is shared
00044    with other packages also tests this symbol to see if it is being
00045    compiled as part of the C library.  We must define this before including
00046    config.h, because it makes some definitions conditional on whether libc
00047    itself is being compiled, or just some generator program.  */
00048 #define _LIBC 1
00049 
00050 /* Enable declarations of GNU extensions, since we are compiling them.  */
00051 #define _GNU_SOURCE  1
00052 /* And we also need the data for the reentrant functions.  */
00053 #define _REENTRANT   1
00054 
00055 #include <config.h>
00056 
00057 /* The symbols in all the user (non-_) macros are C symbols.
00058    NO HAVE_ELF implies a.out.  */
00059 
00060 #if defined HAVE_ASM_WEAK_DIRECTIVE || defined HAVE_ASM_WEAKEXT_DIRECTIVE
00061 # define HAVE_WEAK_SYMBOLS
00062 #endif
00063 
00064 #ifndef __SYMBOL_PREFIX
00065 # ifdef NO_UNDERSCORES
00066 #  define __SYMBOL_PREFIX
00067 # else
00068 #  define __SYMBOL_PREFIX "_"
00069 # endif
00070 #endif
00071 
00072 #ifndef C_SYMBOL_NAME
00073 # ifdef NO_UNDERSCORES
00074 #  define C_SYMBOL_NAME(name) name
00075 # else
00076 #  define C_SYMBOL_NAME(name) _##name
00077 # endif
00078 #endif
00079 
00080 #ifndef ASM_LINE_SEP
00081 # define ASM_LINE_SEP ;
00082 #endif
00083 
00084 #ifdef HAVE_ASM_GLOBAL_DOT_NAME
00085 # ifndef C_SYMBOL_DOT_NAME
00086 #  if defined __GNUC__ && defined __GNUC_MINOR__ \
00087       && (__GNUC__ << 16) + __GNUC_MINOR__ >= (3 << 16) + 1
00088 #   define C_SYMBOL_DOT_NAME(name) .name
00089 #  else
00090 #   define C_SYMBOL_DOT_NAME(name) .##name
00091 #  endif
00092 # endif
00093 #endif
00094 
00095 #ifndef __ASSEMBLER__
00096 /* GCC understands weak symbols and aliases; use its interface where
00097    possible, instead of embedded assembly language.  */
00098 
00099 /* Define ALIASNAME as a strong alias for NAME.  */
00100 # define strong_alias(name, aliasname) _strong_alias(name, aliasname)
00101 # define _strong_alias(name, aliasname) \
00102   extern __typeof (name) aliasname __attribute__ ((alias (#name)));
00103 
00104 /* This comes between the return type and function name in
00105    a function definition to make that definition weak.  */
00106 # define weak_function __attribute__ ((weak))
00107 # define weak_const_function __attribute__ ((weak, __const__))
00108 
00109 # ifdef HAVE_WEAK_SYMBOLS
00110 
00111 /* Define ALIASNAME as a weak alias for NAME.
00112    If weak aliases are not available, this defines a strong alias.  */
00113 #  define weak_alias(name, aliasname) _weak_alias (name, aliasname)
00114 #  define _weak_alias(name, aliasname) \
00115   extern __typeof (name) aliasname __attribute__ ((weak, alias (#name)));
00116 
00117 /* Same as WEAK_ALIAS, but mark symbol as hidden.  */
00118 #  define weak_hidden_alias(name, aliasname) \
00119   _weak_hidden_alias (name, aliasname)
00120 #  define _weak_hidden_alias(name, aliasname) \
00121   extern __typeof (name) aliasname \
00122     __attribute__ ((weak, alias (#name), __visibility__ ("hidden")));
00123 
00124 /* Declare SYMBOL as weak undefined symbol (resolved to 0 if not defined).  */
00125 #  define weak_extern(symbol) _weak_extern (weak symbol)
00126 #  define _weak_extern(expr) _Pragma (#expr)
00127 
00128 # else
00129 
00130 #  define weak_alias(name, aliasname) strong_alias(name, aliasname)
00131 #  define weak_hidden_alias(name, aliasname) strong_alias(name, aliasname)
00132 #  define weak_extern(symbol) /* Nothing. */
00133 
00134 # endif
00135 
00136 #else /* __ASSEMBLER__ */
00137 
00138 # ifdef HAVE_ASM_SET_DIRECTIVE
00139 #  ifdef HAVE_ASM_GLOBAL_DOT_NAME
00140 #   define strong_alias(original, alias)                       \
00141   ASM_GLOBAL_DIRECTIVE C_SYMBOL_NAME (alias) ASM_LINE_SEP             \
00142   .set C_SYMBOL_NAME (alias),C_SYMBOL_NAME (original) ASM_LINE_SEP    \
00143   ASM_GLOBAL_DIRECTIVE C_SYMBOL_DOT_NAME (alias) ASM_LINE_SEP         \
00144   .set C_SYMBOL_DOT_NAME (alias),C_SYMBOL_DOT_NAME (original)
00145 #   define strong_data_alias(original, alias)                         \
00146   ASM_GLOBAL_DIRECTIVE C_SYMBOL_NAME (alias) ASM_LINE_SEP             \
00147   .set C_SYMBOL_NAME (alias),C_SYMBOL_NAME (original)
00148 #  else
00149 #   define strong_alias(original, alias)                       \
00150   ASM_GLOBAL_DIRECTIVE C_SYMBOL_NAME (alias) ASM_LINE_SEP             \
00151   .set C_SYMBOL_NAME (alias),C_SYMBOL_NAME (original)
00152 #   define strong_data_alias(original, alias) strong_alias(original, alias)
00153 #  endif
00154 # else
00155 #  ifdef HAVE_ASM_GLOBAL_DOT_NAME
00156 #   define strong_alias(original, alias)                       \
00157   ASM_GLOBAL_DIRECTIVE C_SYMBOL_NAME (alias) ASM_LINE_SEP             \
00158   C_SYMBOL_NAME (alias) = C_SYMBOL_NAME (original) ASM_LINE_SEP              \
00159   ASM_GLOBAL_DIRECTIVE C_SYMBOL_DOT_NAME (alias) ASM_LINE_SEP         \
00160   C_SYMBOL_DOT_NAME (alias) = C_SYMBOL_DOT_NAME (original)
00161 #   define strong_data_alias(original, alias)                         \
00162   ASM_GLOBAL_DIRECTIVE C_SYMBOL_NAME (alias) ASM_LINE_SEP             \
00163   C_SYMBOL_NAME (alias) = C_SYMBOL_NAME (original)
00164 #  else
00165 #   define strong_alias(original, alias)                       \
00166   ASM_GLOBAL_DIRECTIVE C_SYMBOL_NAME (alias) ASM_LINE_SEP             \
00167   C_SYMBOL_NAME (alias) = C_SYMBOL_NAME (original)
00168 #   define strong_data_alias(original, alias) strong_alias(original, alias)
00169 #  endif
00170 # endif
00171 
00172 # ifdef HAVE_WEAK_SYMBOLS
00173 #  ifdef HAVE_ASM_WEAKEXT_DIRECTIVE
00174 #   ifdef HAVE_ASM_GLOBAL_DOT_NAME
00175 #    define weak_alias(original, alias)                               \
00176   .weakext C_SYMBOL_NAME (alias), C_SYMBOL_NAME (original) ASM_LINE_SEP \
00177   .weakext C_SYMBOL_DOT_NAME (alias), C_SYMBOL_DOT_NAME (original)
00178 #   else
00179 #    define weak_alias(original, alias)                               \
00180   .weakext C_SYMBOL_NAME (alias), C_SYMBOL_NAME (original)
00181 #   endif
00182 #   define weak_extern(symbol)                                        \
00183   .weakext C_SYMBOL_NAME (symbol)
00184 
00185 #  else /* ! HAVE_ASM_WEAKEXT_DIRECTIVE */
00186 
00187 #   ifdef HAVE_ASM_GLOBAL_DOT_NAME
00188 #    define weak_alias(original, alias)                               \
00189   .weak C_SYMBOL_NAME (alias) ASM_LINE_SEP                            \
00190   C_SYMBOL_NAME (alias) = C_SYMBOL_NAME (original) ASM_LINE_SEP              \
00191   .weak C_SYMBOL_DOT_NAME (alias) ASM_LINE_SEP                        \
00192   C_SYMBOL_DOT_NAME (alias) = C_SYMBOL_DOT_NAME (original)
00193 #   else
00194 #    define weak_alias(original, alias)                               \
00195   .weak C_SYMBOL_NAME (alias) ASM_LINE_SEP                            \
00196   C_SYMBOL_NAME (alias) = C_SYMBOL_NAME (original)
00197 #   endif
00198 
00199 #   define weak_extern(symbol)                                        \
00200   .weak C_SYMBOL_NAME (symbol)
00201 
00202 #  endif /* ! HAVE_ASM_WEAKEXT_DIRECTIVE */
00203 
00204 # else /* ! HAVE_WEAK_SYMBOLS */
00205 
00206 #  define weak_alias(original, alias) strong_alias(original, alias)
00207 #  define weak_extern(symbol) /* Nothing */
00208 # endif /* ! HAVE_WEAK_SYMBOLS */
00209 
00210 #endif /* __ASSEMBLER__ */
00211 
00212 /* On some platforms we can make internal function calls (i.e., calls of
00213    functions not exported) a bit faster by using a different calling
00214    convention.  */
00215 #ifndef internal_function
00216 # define internal_function  /* empty */
00217 #endif
00218 
00219 /* Prepare for the case that `__builtin_expect' is not available.  */
00220 #ifndef HAVE_BUILTIN_EXPECT
00221 # define __builtin_expect(expr, val) (expr)
00222 #endif
00223 
00224 /* Determine the return address.  */
00225 #define RETURN_ADDRESS(nr) \
00226   __builtin_extract_return_addr (__builtin_return_address (nr))
00227 
00228 /* When a reference to SYMBOL is encountered, the linker will emit a
00229    warning message MSG.  */
00230 #ifdef HAVE_ELF
00231 
00232 /* We want the .gnu.warning.SYMBOL section to be unallocated.  */
00233 # ifdef HAVE_ASM_PREVIOUS_DIRECTIVE
00234 #  define __make_section_unallocated(section_string)    \
00235   asm (".section " section_string "\n\t.previous");
00236 # elif defined HAVE_ASM_POPSECTION_DIRECTIVE
00237 #  define __make_section_unallocated(section_string)    \
00238   asm (".pushsection " section_string "\n\t.popsection");
00239 # else
00240 #  define __make_section_unallocated(section_string)
00241 # endif
00242 
00243 /* Tacking on "\n\t#" to the section name makes gcc put it's bogus
00244    section attributes on what looks like a comment to the assembler.  */
00245 # ifdef HAVE_SECTION_QUOTES
00246 #  define __sec_comment "\"\n\t#\""
00247 # else
00248 #  define __sec_comment "\n\t#"
00249 # endif
00250 # define link_warning(symbol, msg) \
00251   __make_section_unallocated (".gnu.warning." #symbol) \
00252   static const char __evoke_link_warning_##symbol[]     \
00253     __attribute__ ((used, section (".gnu.warning." #symbol __sec_comment))) \
00254     = msg;
00255 # define libc_freeres_ptr(decl) \
00256   __make_section_unallocated ("__libc_freeres_ptrs, \"aw\", %nobits") \
00257   decl __attribute__ ((section ("__libc_freeres_ptrs" __sec_comment)))
00258 # define __libc_freeres_fn_section \
00259   __attribute__ ((section ("__libc_freeres_fn")))
00260 #else /* Not ELF: a.out */
00261 # ifdef HAVE_XCOFF
00262 /* XCOFF does not support .stabs.
00263    The native aix linker will remove the .stab and .stabstr sections
00264    The gnu linker will have a fatal error if there is a relocation for
00265    symbol in the .stab section.  Silently disable this macro.  */
00266 #  define link_warning(symbol, msg)
00267 # else
00268 #  define link_warning(symbol, msg)              \
00269      asm (".stabs \"" msg "\",30,0,0,0\n\t"      \
00270           ".stabs \"" __SYMBOL_PREFIX #symbol "\",1,0,0,0\n");
00271 # endif /* XCOFF */
00272 # define libc_freeres_ptr(decl) decl
00273 # define __libc_freeres_fn_section
00274 #endif
00275 #define libc_freeres_fn(name)      \
00276   static void name (void) __attribute_used__ __libc_freeres_fn_section;      \
00277   text_set_element (__libc_subfreeres, name);                         \
00278   static void name (void)
00279 
00280 /* A canned warning for sysdeps/stub functions.  */
00281 #define       stub_warning(name) \
00282   __make_section_unallocated (".gnu.glibc-stub." #name) \
00283   link_warning (name, \
00284               "warning: " #name " is not implemented and will always fail")
00285 
00286 /* Warning for linking functions calling dlopen into static binaries.  */
00287 #ifdef SHARED
00288 #define static_link_warning(name)
00289 #else
00290 #define static_link_warning(name) static_link_warning1(name)
00291 #define static_link_warning1(name) \
00292   link_warning(name, "Using '" #name "' in statically linked applications \
00293 requires at runtime the shared libraries from the glibc version used \
00294 for linking")
00295 #endif
00296 
00297 /* Declare SYMBOL to be TYPE (`function' or `object') of SIZE bytes
00298    alias to ORIGINAL, when the assembler supports such declarations
00299    (such as in ELF).
00300    This is only necessary when defining something in assembly, or playing
00301    funny alias games where the size should be other than what the compiler
00302    thinks it is.  */
00303 #define declare_symbol_alias(symbol, original, type, size) \
00304   declare_symbol_alias_1 (symbol, original, type, size)
00305 #ifdef ASM_TYPE_DIRECTIVE_PREFIX
00306 # ifdef __ASSEMBLER__
00307 #  define declare_symbol_alias_1(symbol, original, type, size) \
00308     strong_alias (original, symbol); \
00309     .type C_SYMBOL_NAME (symbol), \
00310          declare_symbol_alias_1_paste (ASM_TYPE_DIRECTIVE_PREFIX, type); \
00311     .size C_SYMBOL_NAME (symbol), size
00312 #  define declare_symbol_alias_1_paste(a, b) \
00313   declare_symbol_alias_1_paste_1 (a,b)
00314 #  define declare_symbol_alias_1_paste_1(a,b)    a##b
00315 # else /* Not __ASSEMBLER__.  */
00316 #  define declare_symbol_alias_1(symbol, original, type, size) \
00317     asm (declare_symbol_alias_1_stringify (ASM_GLOBAL_DIRECTIVE) \
00318         " " __SYMBOL_PREFIX #symbol \
00319         "\n\t" declare_symbol_alias_1_alias (symbol, original) \
00320         "\n\t.type " __SYMBOL_PREFIX #symbol ", " \
00321         declare_symbol_alias_1_stringify (ASM_TYPE_DIRECTIVE_PREFIX) #type \
00322         "\n\t.size " __SYMBOL_PREFIX #symbol ", " #size);
00323 #  define declare_symbol_alias_1_stringify(x) \
00324   declare_symbol_alias_1_stringify_1 (x)
00325 #  define declare_symbol_alias_1_stringify_1(x) #x
00326 #  ifdef HAVE_ASM_SET_DIRECTIVE
00327 #   define declare_symbol_alias_1_alias(symbol, original) \
00328         ".set " __SYMBOL_PREFIX #symbol ", " __SYMBOL_PREFIX #original
00329 #  else
00330 #   define declare_symbol_alias_1_alias(symbol, original) \
00331         __SYMBOL_PREFIX #symbol " = " __SYMBOL_PREFIX #original
00332 #  endif /* HAVE_ASM_SET_DIRECTIVE */
00333 # endif /* __ASSEMBLER__ */
00334 #else
00335 # define declare_symbol_1(symbol, type, size) /* Nothing.  */
00336 #endif
00337 
00338 
00339 /*
00340 
00341 */
00342 
00343 /* Symbol set support macros.  */
00344 
00345 #ifdef HAVE_ELF
00346 
00347 /* Make SYMBOL, which is in the text segment, an element of SET.  */
00348 # define text_set_element(set, symbol)    _elf_set_element(set, symbol)
00349 /* Make SYMBOL, which is in the data segment, an element of SET.  */
00350 # define data_set_element(set, symbol)    _elf_set_element(set, symbol)
00351 /* Make SYMBOL, which is in the bss segment, an element of SET.  */
00352 # define bss_set_element(set, symbol)     _elf_set_element(set, symbol)
00353 
00354 /* These are all done the same way in ELF.
00355    There is a new section created for each set.  */
00356 # ifdef SHARED
00357 /* When building a shared library, make the set section writable,
00358    because it will need to be relocated at run time anyway.  */
00359 #  define _elf_set_element(set, symbol) \
00360   static const void *__elf_set_##set##_element_##symbol##__ \
00361     __attribute__ ((used, section (#set))) = &(symbol)
00362 # else
00363 #  define _elf_set_element(set, symbol) \
00364   static const void *const __elf_set_##set##_element_##symbol##__ \
00365     __attribute__ ((used, section (#set))) = &(symbol)
00366 # endif
00367 
00368 /* Define SET as a symbol set.  This may be required (it is in a.out) to
00369    be able to use the set's contents.  */
00370 # define symbol_set_define(set)    symbol_set_declare(set)
00371 
00372 /* Declare SET for use in this module, if defined in another module.
00373    In a shared library, this is always local to that shared object.
00374    For static linking, the set might be wholly absent and so we use
00375    weak references.  */
00376 # define symbol_set_declare(set) \
00377   extern char const __start_##set[] __symbol_set_attribute; \
00378   extern char const __stop_##set[] __symbol_set_attribute;
00379 # ifdef SHARED
00380 #  define __symbol_set_attribute attribute_hidden
00381 # else
00382 #  define __symbol_set_attribute __attribute__ ((weak))
00383 # endif
00384 
00385 /* Return a pointer (void *const *) to the first element of SET.  */
00386 # define symbol_set_first_element(set)    ((void *const *) (&__start_##set))
00387 
00388 /* Return true iff PTR (a void *const *) has been incremented
00389    past the last element in SET.  */
00390 # define symbol_set_end_p(set, ptr) ((ptr) >= (void *const *) &__stop_##set)
00391 
00392 #else  /* Not ELF: a.out.  */
00393 
00394 # ifdef HAVE_XCOFF
00395 /* XCOFF does not support .stabs.
00396    The native aix linker will remove the .stab and .stabstr sections
00397    The gnu linker will have a fatal error if there is a relocation for
00398    symbol in the .stab section.  Silently disable these macros.  */
00399 #  define text_set_element(set, symbol)
00400 #  define data_set_element(set, symbol)
00401 #  define bss_set_element(set, symbol)
00402 # else
00403 #  define text_set_element(set, symbol)   \
00404     asm (".stabs \"" __SYMBOL_PREFIX #set "\",23,0,0," __SYMBOL_PREFIX #symbol)
00405 #  define data_set_element(set, symbol)   \
00406     asm (".stabs \"" __SYMBOL_PREFIX #set "\",25,0,0," __SYMBOL_PREFIX #symbol)
00407 #  define bss_set_element(set, symbol)    ?error Must use initialized data.
00408 # endif /* XCOFF */
00409 # define symbol_set_define(set)    void *const (set)[1];
00410 # define symbol_set_declare(set)   extern void *const (set)[1];
00411 
00412 # define symbol_set_first_element(set)    &(set)[1]
00413 # define symbol_set_end_p(set, ptr)       (*(ptr) == 0)
00414 
00415 #endif /* ELF.  */
00416 
00417 #if DO_VERSIONING
00418 # define symbol_version(real, name, version) \
00419      _symbol_version(real, name, version)
00420 # define default_symbol_version(real, name, version) \
00421      _default_symbol_version(real, name, version)
00422 # ifdef __ASSEMBLER__
00423 #  ifdef HAVE_ASM_GLOBAL_DOT_NAME
00424 #   define _symbol_version(real, name, version) \
00425      .symver real, name##@##version ASM_LINE_SEP               \
00426      .symver C_SYMBOL_DOT_NAME(real), C_SYMBOL_DOT_NAME(name##@##version)
00427 #   define _default_symbol_version(real, name, version) \
00428      .symver real, name##@##@##version ASM_LINE_SEP                   \
00429      .symver C_SYMBOL_DOT_NAME(real), C_SYMBOL_DOT_NAME(name##@##@##version)
00430 #  else
00431 #   define _symbol_version(real, name, version) \
00432      .symver real, name##@##version
00433 #   define _default_symbol_version(real, name, version) \
00434      .symver real, name##@##@##version
00435 #  endif
00436 # else
00437 #  ifdef HAVE_ASM_GLOBAL_DOT_NAME
00438 #   define _symbol_version(real, name, version) \
00439      __asm__ (".symver " #real "," #name "@" #version "\n\t"   \
00440              ".symver ." #real ",." #name "@" #version)
00441 #   define _default_symbol_version(real, name, version) \
00442      __asm__ (".symver " #real "," #name "@@" #version "\n\t"  \
00443              ".symver ." #real ",." #name "@@" #version)
00444 #  else
00445 #   define _symbol_version(real, name, version) \
00446      __asm__ (".symver " #real "," #name "@" #version)
00447 #   define _default_symbol_version(real, name, version) \
00448      __asm__ (".symver " #real "," #name "@@" #version)
00449 #  endif
00450 # endif
00451 #else
00452 # define symbol_version(real, name, version)
00453 # define default_symbol_version(real, name, version) \
00454   strong_alias(real, name)
00455 #endif
00456 
00457 #if defined SHARED || defined LIBC_NONSHARED
00458 # define attribute_hidden __attribute__ ((visibility ("hidden")))
00459 #else
00460 # define attribute_hidden
00461 #endif
00462 
00463 #ifdef HAVE_TLS_MODEL_ATTRIBUTE
00464 # define attribute_tls_model_ie __attribute__ ((tls_model ("initial-exec")))
00465 #else
00466 # define attribute_tls_model_ie
00467 #endif
00468 
00469 #define attribute_relro __attribute__ ((section (".data.rel.ro")))
00470 
00471 /* Handling on non-exported internal names.  We have to do this only
00472    for shared code.  */
00473 #ifdef SHARED
00474 # define INTUSE(name) name##_internal
00475 # define INTDEF(name) strong_alias (name, name##_internal)
00476 # define INTVARDEF(name) \
00477   _INTVARDEF (name, name##_internal)
00478 # define _INTVARDEF(name, aliasname) \
00479   extern __typeof (name) aliasname __attribute__ ((alias (#name), \
00480                                              visibility ("hidden")));
00481 # define INTDEF2(name, newname) strong_alias (name, newname##_internal)
00482 # define INTVARDEF2(name, newname) _INTVARDEF (name, newname##_internal)
00483 #else
00484 # define INTUSE(name) name
00485 # define INTDEF(name)
00486 # define INTVARDEF(name)
00487 # define INTDEF2(name, newname)
00488 # define INTVARDEF2(name, newname)
00489 #endif
00490 
00491 /* The following macros are used for PLT bypassing within libc.so
00492    (and if needed other libraries similarly).
00493    First of all, you need to have the function prototyped somewhere,
00494    say in foo/foo.h:
00495 
00496    int foo (int __bar);
00497 
00498    If calls to foo within libc.so should always go to foo defined in libc.so,
00499    then in include/foo.h you add:
00500 
00501    libc_hidden_proto (foo)
00502 
00503    line and after the foo function definition:
00504 
00505    int foo (int __bar)
00506    {
00507      return __bar;
00508    }
00509    libc_hidden_def (foo)
00510 
00511    or
00512 
00513    int foo (int __bar)
00514    {
00515      return __bar;
00516    }
00517    libc_hidden_weak (foo)
00518 
00519    Similarly for global data.  If references to foo within libc.so should
00520    always go to foo defined in libc.so, then in include/foo.h you add:
00521 
00522    libc_hidden_proto (foo)
00523 
00524    line and after foo's definition:
00525 
00526    int foo = INITIAL_FOO_VALUE;
00527    libc_hidden_data_def (foo)
00528 
00529    or
00530 
00531    int foo = INITIAL_FOO_VALUE;
00532    libc_hidden_data_weak (foo)
00533 
00534    If foo is normally just an alias (strong or weak) to some other function,
00535    you should use the normal strong_alias first, then add libc_hidden_def
00536    or libc_hidden_weak:
00537 
00538    int baz (int __bar)
00539    {
00540      return __bar;
00541    }
00542    strong_alias (baz, foo)
00543    libc_hidden_weak (foo)
00544 
00545    If the function should be internal to multiple objects, say ld.so and
00546    libc.so, the best way is to use:
00547 
00548    #if !defined NOT_IN_libc || defined IS_IN_rtld
00549    hidden_proto (foo)
00550    #endif
00551 
00552    in include/foo.h and the normal macros at all function definitions
00553    depending on what DSO they belong to.
00554 
00555    If versioned_symbol macro is used to define foo,
00556    libc_hidden_ver macro should be used, as in:
00557 
00558    int __real_foo (int __bar)
00559    {
00560      return __bar;
00561    }
00562    versioned_symbol (libc, __real_foo, foo, GLIBC_2_1);
00563    libc_hidden_ver (__real_foo, foo)  */
00564 
00565 #if defined SHARED && defined DO_VERSIONING && !defined NO_HIDDEN
00566 # ifndef __ASSEMBLER__
00567 #  define __hidden_proto_hiddenattr(attrs...) \
00568   __attribute__ ((visibility ("hidden"), ##attrs))
00569 #  define hidden_proto(name, attrs...) \
00570   __hidden_proto (name, __GI_##name, ##attrs)
00571 #  define __hidden_proto(name, internal, attrs...) \
00572   extern __typeof (name) name __asm__ (__hidden_asmname (#internal)) \
00573   __hidden_proto_hiddenattr (attrs);
00574 #  define __hidden_asmname(name) \
00575   __hidden_asmname1 (__USER_LABEL_PREFIX__, name)
00576 #  define __hidden_asmname1(prefix, name) __hidden_asmname2(prefix, name)
00577 #  define __hidden_asmname2(prefix, name) #prefix name
00578 #  define __hidden_ver1(local, internal, name) \
00579   extern __typeof (name) __EI_##name __asm__(__hidden_asmname (#internal)); \
00580   extern __typeof (name) __EI_##name \
00581        __attribute__((alias (__hidden_asmname (#local))))
00582 #  define hidden_ver(local, name)  __hidden_ver1(local, __GI_##name, name);
00583 #  define hidden_data_ver(local, name)    hidden_ver(local, name)
00584 #  define hidden_def(name)         __hidden_ver1(__GI_##name, name, name);
00585 #  define hidden_data_def(name)           hidden_def(name)
00586 #  define hidden_weak(name) \
00587        __hidden_ver1(__GI_##name, name, name) __attribute__((weak));
00588 #  define hidden_data_weak(name)   hidden_weak(name)
00589 # else
00590 /* For assembly, we need to do the opposite of what we do in C:
00591    in assembly gcc __REDIRECT stuff is not in place, so functions
00592    are defined by its normal name and we need to create the
00593    __GI_* alias to it, in C __REDIRECT causes the function definition
00594    to use __GI_* name and we need to add alias to the real name.
00595    There is no reason to use hidden_weak over hidden_def in assembly,
00596    but we provide it for consistency with the C usage.
00597    hidden_proto doesn't make sense for assembly but the equivalent
00598    is to call via the HIDDEN_JUMPTARGET macro instead of JUMPTARGET.  */
00599 #  define hidden_def(name)  strong_alias (name, __GI_##name)
00600 #  define hidden_weak(name) hidden_def (name)
00601 #  define hidden_ver(local, name) strong_alias (local, __GI_##name)
00602 #  define hidden_data_def(name)    strong_data_alias (name, __GI_##name)
00603 #  define hidden_data_weak(name)   hidden_data_def (name)
00604 #  define hidden_data_ver(local, name) strong_data_alias (local, __GI_##name)
00605 #  ifdef HAVE_ASM_GLOBAL_DOT_NAME
00606 #   define HIDDEN_JUMPTARGET(name) .__GI_##name
00607 #  else
00608 #   define HIDDEN_JUMPTARGET(name) __GI_##name
00609 #  endif
00610 # endif
00611 #else
00612 # ifndef __ASSEMBLER__
00613 #  define hidden_proto(name, attrs...)
00614 # else
00615 #  define HIDDEN_JUMPTARGET(name) JUMPTARGET(name)
00616 # endif /* Not  __ASSEMBLER__ */
00617 # define hidden_weak(name)
00618 # define hidden_def(name)
00619 # define hidden_ver(local, name)
00620 # define hidden_data_weak(name)
00621 # define hidden_data_def(name)
00622 # define hidden_data_ver(local, name)
00623 #endif
00624 
00625 #if !defined NOT_IN_libc
00626 # define libc_hidden_proto(name, attrs...) hidden_proto (name, ##attrs)
00627 # define libc_hidden_def(name) hidden_def (name)
00628 # define libc_hidden_weak(name) hidden_weak (name)
00629 # define libc_hidden_ver(local, name) hidden_ver (local, name)
00630 # define libc_hidden_data_def(name) hidden_data_def (name)
00631 # define libc_hidden_data_weak(name) hidden_data_weak (name)
00632 # define libc_hidden_data_ver(local, name) hidden_data_ver (local, name)
00633 #else
00634 # define libc_hidden_proto(name, attrs...)
00635 # define libc_hidden_def(name)
00636 # define libc_hidden_weak(name)
00637 # define libc_hidden_ver(local, name)
00638 # define libc_hidden_data_def(name)
00639 # define libc_hidden_data_weak(name)
00640 # define libc_hidden_data_ver(local, name)
00641 #endif
00642 
00643 #if defined NOT_IN_libc && defined IS_IN_rtld
00644 # define rtld_hidden_proto(name, attrs...) hidden_proto (name, ##attrs)
00645 # define rtld_hidden_def(name) hidden_def (name)
00646 # define rtld_hidden_weak(name) hidden_weak (name)
00647 # define rtld_hidden_ver(local, name) hidden_ver (local, name)
00648 # define rtld_hidden_data_def(name) hidden_data_def (name)
00649 # define rtld_hidden_data_weak(name) hidden_data_weak (name)
00650 # define rtld_hidden_data_ver(local, name) hidden_data_ver (local, name)
00651 #else
00652 # define rtld_hidden_proto(name, attrs...)
00653 # define rtld_hidden_def(name)
00654 # define rtld_hidden_weak(name)
00655 # define rtld_hidden_ver(local, name)
00656 # define rtld_hidden_data_def(name)
00657 # define rtld_hidden_data_weak(name)
00658 # define rtld_hidden_data_ver(local, name)
00659 #endif
00660 
00661 #if defined NOT_IN_libc && defined IS_IN_libm
00662 # define libm_hidden_proto(name, attrs...) hidden_proto (name, ##attrs)
00663 # define libm_hidden_def(name) hidden_def (name)
00664 # define libm_hidden_weak(name) hidden_weak (name)
00665 # define libm_hidden_ver(local, name) hidden_ver (local, name)
00666 # define libm_hidden_data_def(name) hidden_data_def (name)
00667 # define libm_hidden_data_weak(name) hidden_data_weak (name)
00668 # define libm_hidden_data_ver(local, name) hidden_data_ver (local, name)
00669 #else
00670 # define libm_hidden_proto(name, attrs...)
00671 # define libm_hidden_def(name)
00672 # define libm_hidden_weak(name)
00673 # define libm_hidden_ver(local, name)
00674 # define libm_hidden_data_def(name)
00675 # define libm_hidden_data_weak(name)
00676 # define libm_hidden_data_ver(local, name)
00677 #endif
00678 
00679 #if defined NOT_IN_libc && defined IS_IN_libresolv
00680 # define libresolv_hidden_proto(name, attrs...) hidden_proto (name, ##attrs)
00681 # define libresolv_hidden_def(name) hidden_def (name)
00682 # define libresolv_hidden_weak(name) hidden_weak (name)
00683 # define libresolv_hidden_ver(local, name) hidden_ver (local, name)
00684 # define libresolv_hidden_data_def(name) hidden_data_def (name)
00685 # define libresolv_hidden_data_weak(name) hidden_data_weak (name)
00686 # define libresolv_hidden_data_ver(local, name) hidden_data_ver (local, name)
00687 #else
00688 # define libresolv_hidden_proto(name, attrs...)
00689 # define libresolv_hidden_def(name)
00690 # define libresolv_hidden_weak(name)
00691 # define libresolv_hidden_ver(local, name)
00692 # define libresolv_hidden_data_def(name)
00693 # define libresolv_hidden_data_weak(name)
00694 # define libresolv_hidden_data_ver(local, name)
00695 #endif
00696 
00697 #if defined NOT_IN_libc && defined IS_IN_librt
00698 # define librt_hidden_proto(name, attrs...) hidden_proto (name, ##attrs)
00699 # define librt_hidden_def(name) hidden_def (name)
00700 # define librt_hidden_weak(name) hidden_weak (name)
00701 # define librt_hidden_ver(local, name) hidden_ver (local, name)
00702 # define librt_hidden_data_def(name) hidden_data_def (name)
00703 # define librt_hidden_data_weak(name) hidden_data_weak (name)
00704 # define librt_hidden_data_ver(local, name) hidden_data_ver (local, name)
00705 #else
00706 # define librt_hidden_proto(name, attrs...)
00707 # define librt_hidden_def(name)
00708 # define librt_hidden_weak(name)
00709 # define librt_hidden_ver(local, name)
00710 # define librt_hidden_data_def(name)
00711 # define librt_hidden_data_weak(name)
00712 # define librt_hidden_data_ver(local, name)
00713 #endif
00714 
00715 #if defined NOT_IN_libc && defined IS_IN_libdl
00716 # define libdl_hidden_proto(name, attrs...) hidden_proto (name, ##attrs)
00717 # define libdl_hidden_def(name) hidden_def (name)
00718 # define libdl_hidden_weak(name) hidden_weak (name)
00719 # define libdl_hidden_ver(local, name) hidden_ver (local, name)
00720 # define libdl_hidden_data_def(name) hidden_data_def (name)
00721 # define libdl_hidden_data_weak(name) hidden_data_weak (name)
00722 # define libdl_hidden_data_ver(local, name) hidden_data_ver (local, name)
00723 #else
00724 # define libdl_hidden_proto(name, attrs...)
00725 # define libdl_hidden_def(name)
00726 # define libdl_hidden_weak(name)
00727 # define libdl_hidden_ver(local, name)
00728 # define libdl_hidden_data_def(name)
00729 # define libdl_hidden_data_weak(name)
00730 # define libdl_hidden_data_ver(local, name)
00731 #endif
00732 
00733 #if defined NOT_IN_libc && defined IS_IN_libnss_files
00734 # define libnss_files_hidden_proto(name, attrs...) hidden_proto (name, ##attrs)
00735 # define libnss_files_hidden_def(name) hidden_def (name)
00736 # define libnss_files_hidden_weak(name) hidden_weak (name)
00737 # define libnss_files_hidden_ver(local, name) hidden_ver (local, name)
00738 # define libnss_files_hidden_data_def(name) hidden_data_def (name)
00739 # define libnss_files_hidden_data_weak(name) hidden_data_weak (name)
00740 # define libnss_files_hidden_data_ver(local, name) hidden_data_ver(local, name)
00741 #else
00742 # define libnss_files_hidden_proto(name, attrs...)
00743 # define libnss_files_hidden_def(name)
00744 # define libnss_files_hidden_weak(name)
00745 # define libnss_files_hidden_ver(local, name)
00746 # define libnss_files_hidden_data_def(name)
00747 # define libnss_files_hidden_data_weak(name)
00748 # define libnss_files_hidden_data_ver(local, name)
00749 #endif
00750 
00751 #if defined NOT_IN_libc && defined IS_IN_libnsl
00752 # define libnsl_hidden_proto(name, attrs...) hidden_proto (name, ##attrs)
00753 # define libnsl_hidden_def(name) hidden_def (name)
00754 # define libnsl_hidden_weak(name) hidden_weak (name)
00755 # define libnsl_hidden_ver(local, name) hidden_ver (local, name)
00756 # define libnsl_hidden_data_def(name) hidden_data_def (name)
00757 # define libnsl_hidden_data_weak(name) hidden_data_weak (name)
00758 # define libnsl_hidden_data_ver(local, name) hidden_data_ver (local, name)
00759 #else
00760 # define libnsl_hidden_proto(name, attrs...)
00761 # define libnsl_hidden_def(name)
00762 # define libnsl_hidden_weak(name)
00763 # define libnsl_hidden_ver(local, name)
00764 # define libnsl_hidden_data_def(name)
00765 # define libnsl_hidden_data_weak(name)
00766 # define libnsl_hidden_data_ver(local, name)
00767 #endif
00768 
00769 #if defined NOT_IN_libc && defined IS_IN_libnss_nisplus
00770 # define libnss_nisplus_hidden_proto(name, attrs...) hidden_proto (name, ##attrs)
00771 # define libnss_nisplus_hidden_def(name) hidden_def (name)
00772 # define libnss_nisplus_hidden_weak(name) hidden_weak (name)
00773 # define libnss_nisplus_hidden_ver(local, name) hidden_ver (local, name)
00774 # define libnss_nisplus_hidden_data_def(name) hidden_data_def (name)
00775 # define libnss_nisplus_hidden_data_weak(name) hidden_data_weak (name)
00776 # define libnss_nisplus_hidden_data_ver(local, name) hidden_data_ver (local, name)
00777 #else
00778 # define libnss_nisplus_hidden_proto(name, attrs...)
00779 # define libnss_nisplus_hidden_def(name)
00780 # define libnss_nisplus_hidden_weak(name)
00781 # define libnss_nisplus_hidden_ver(local, name)
00782 # define libnss_nisplus_hidden_data_def(name)
00783 # define libnss_nisplus_hidden_data_weak(name)
00784 # define libnss_nisplus_hidden_data_ver(local, name)
00785 #endif
00786 
00787 #ifdef HAVE_BUILTIN_REDIRECTION
00788 # define libc_hidden_builtin_proto(name, attrs...) libc_hidden_proto (name, ##attrs)
00789 # define libc_hidden_builtin_def(name) libc_hidden_def (name)
00790 # define libc_hidden_builtin_weak(name) libc_hidden_weak (name)
00791 # define libc_hidden_builtin_ver(local, name) libc_hidden_ver (local, name)
00792 # ifdef __ASSEMBLER__
00793 #  define HIDDEN_BUILTIN_JUMPTARGET(name) HIDDEN_JUMPTARGET(name)
00794 # endif
00795 #else
00796 # define libc_hidden_builtin_proto(name, attrs...)
00797 # define libc_hidden_builtin_def(name)
00798 # define libc_hidden_builtin_weak(name)
00799 # define libc_hidden_builtin_ver(local, name)
00800 # ifdef __ASSEMBLER__
00801 #  define HIDDEN_BUILTIN_JUMPTARGET(name) JUMPTARGET(name)
00802 # endif
00803 #endif
00804 
00805 #if defined NOT_IN_libc && defined IS_IN_libutil
00806 # define libutil_hidden_proto(name, attrs...) hidden_proto (name, ##attrs)
00807 # define libutil_hidden_def(name) hidden_def (name)
00808 # define libutil_hidden_weak(name) hidden_weak (name)
00809 # define libutil_hidden_ver(local, name) hidden_ver (local, name)
00810 # define libutil_hidden_data_def(name) hidden_data_def (name)
00811 # define libutil_hidden_data_weak(name) hidden_data_weak (name)
00812 # define libutil_hidden_data_ver(local, name) hidden_data_ver (local, name)
00813 #else
00814 # define libutil_hidden_proto(name, attrs...)
00815 # define libutil_hidden_def(name)
00816 # define libutil_hidden_weak(name)
00817 # define libutil_hidden_ver(local, name)
00818 # define libutil_hidden_data_def(name)
00819 # define libutil_hidden_data_weak(name)
00820 # define libutil_hidden_data_ver(local, name)
00821 #endif
00822 
00823 /* Get some dirty hacks.  */
00824 #include <symbol-hacks.h>
00825 
00826 /* Move compatibility symbols out of the way by placing them all in a
00827    special section.  */
00828 #ifndef __ASSEMBLER__
00829 # define attribute_compat_text_section \
00830     __attribute__ ((section (".text.compat")))
00831 # define attribute_compat_data_section \
00832     __attribute__ ((section (".data.compat")))
00833 #else
00834 # define compat_text_section .section ".text.compat", "ax";
00835 # define compat_data_section .section ".data.compat", "aw";
00836 #endif
00837 
00838 #endif /* libc-symbols.h */