libc-symbols.h 27 KB

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