libc-symbols.h 27 KB

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