libc-symbols.h 29 KB

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