libc-symbols.h 27 KB

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