libc-symbols.h 28 KB

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