libc-symbols.h 28 KB

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