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