libc-symbols.h 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729
  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. #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\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\t#\""
  241. #else
  242. # define __sec_comment "\n\t#"
  243. #endif
  244. /* When a reference to SYMBOL is encountered, the linker will emit a
  245. warning message MSG. */
  246. #if defined(__cris__) || defined(__vax__)
  247. # define link_warning(symbol, msg)
  248. #else
  249. # define link_warning(symbol, msg) \
  250. __make_section_unallocated (".gnu.warning." #symbol) \
  251. static const char __evoke_link_warning_##symbol[] \
  252. __attribute__ ((used, section (".gnu.warning." #symbol __sec_comment))) \
  253. = msg;
  254. #endif
  255. /* Handling on non-exported internal names. We have to do this only
  256. for shared code. */
  257. #ifdef SHARED
  258. # define INTUSE(name) name##_internal
  259. # define INTDEF(name) strong_alias (name, name##_internal)
  260. # define INTVARDEF(name) \
  261. _INTVARDEF (name, name##_internal)
  262. # if defined HAVE_VISIBILITY_ATTRIBUTE
  263. # define _INTVARDEF(name, aliasname) \
  264. extern __typeof (name) aliasname __attribute__ ((alias (#name), \
  265. visibility ("hidden")));
  266. # else
  267. # define _INTVARDEF(name, aliasname) \
  268. extern __typeof (name) aliasname __attribute__ ((alias (#name)));
  269. # endif
  270. # define INTDEF2(name, newname) strong_alias (name, newname##_internal)
  271. # define INTVARDEF2(name, newname) _INTVARDEF (name, newname##_internal)
  272. #else
  273. # define INTUSE(name) name
  274. # define INTDEF(name)
  275. # define INTVARDEF(name)
  276. # define INTDEF2(name, newname)
  277. # define INTVARDEF2(name, newname)
  278. #endif
  279. /* The following macros are used for PLT bypassing within libc.so
  280. (and if needed other libraries similarly).
  281. First of all, you need to have the function prototyped somewhere,
  282. say in foo/foo.h:
  283. int foo (int __bar);
  284. If calls to foo within libc.so should always go to foo defined in libc.so,
  285. then in include/foo.h you add:
  286. libc_hidden_proto (foo)
  287. line and after the foo function definition:
  288. int foo (int __bar)
  289. {
  290. return __bar;
  291. }
  292. libc_hidden_def (foo)
  293. or
  294. int foo (int __bar)
  295. {
  296. return __bar;
  297. }
  298. libc_hidden_weak (foo)
  299. Similarly for global data. If references to foo within libc.so should
  300. always go to foo defined in libc.so, then in include/foo.h you add:
  301. libc_hidden_proto (foo)
  302. line and after foo's definition:
  303. int foo = INITIAL_FOO_VALUE;
  304. libc_hidden_data_def (foo)
  305. or
  306. int foo = INITIAL_FOO_VALUE;
  307. libc_hidden_data_weak (foo)
  308. If foo is normally just an alias (strong or weak) to some other function,
  309. you should use the normal strong_alias first, then add libc_hidden_def
  310. or libc_hidden_weak:
  311. int baz (int __bar)
  312. {
  313. return __bar;
  314. }
  315. strong_alias (baz, foo)
  316. libc_hidden_weak (foo)
  317. If the function should be internal to multiple objects, say ld.so and
  318. libc.so, the best way is to use:
  319. #if !defined NOT_IN_libc || defined IS_IN_rtld
  320. hidden_proto (foo)
  321. #endif
  322. in include/foo.h and the normal macros at all function definitions
  323. depending on what DSO they belong to.
  324. If versioned_symbol macro is used to define foo,
  325. libc_hidden_ver macro should be used, as in:
  326. int __real_foo (int __bar)
  327. {
  328. return __bar;
  329. }
  330. versioned_symbol (libc, __real_foo, foo, GLIBC_2_1);
  331. libc_hidden_ver (__real_foo, foo) */
  332. /* uClibc specific (the above comment was copied from glibc):
  333. * a. when ppc64 will be supported, we need changes to support:
  334. * strong_data_alias (used by asm hidden_data_def)
  335. * b. libc_hidden_proto(foo) should be added after the header having foo's prototype
  336. * or after extern foo... to all source files that should use the internal version
  337. * of foo within libc, even to the file defining foo itself, libc_hidden_def does
  338. * not hide __GI_foo itself, although the name suggests it (hiding is done exclusively
  339. * by libc_hidden_proto). The reasoning to have it after the header w/ foo's prototype is
  340. * to get first the __REDIRECT from original header and then create the __GI_foo alias
  341. * c. no versioning support, hidden[_data]_ver are noop
  342. * d. hidden_def() in asm is _hidden_strong_alias (not strong_alias) */
  343. /* Arrange to hide uClibc internals */
  344. #if defined __GNUC__ && defined __GNUC_MINOR__ && \
  345. ( __GNUC__ >= 3 && __GNUC_MINOR__ >= 3 ) || __GNUC__ >= 4
  346. # define attribute_hidden __attribute__ ((visibility ("hidden")))
  347. # define __hidden_proto_hiddenattr(attrs...) __attribute__ ((visibility ("hidden"), ##attrs))
  348. #else
  349. # define attribute_hidden
  350. # define __hidden_proto_hiddenattr(attrs...)
  351. #endif
  352. #if /*!defined STATIC &&*/ !defined __BCC__
  353. # ifndef __ASSEMBLER__
  354. # define hidden_proto(name, attrs...) __hidden_proto (name, __GI_##name, ##attrs)
  355. # define __hidden_proto(name, internal, attrs...) \
  356. extern __typeof (name) name __asm__ (__hidden_asmname (#internal)) \
  357. __hidden_proto_hiddenattr (attrs);
  358. # define __hidden_asmname(name) __hidden_asmname1 (__USER_LABEL_PREFIX__, name)
  359. # define __hidden_asmname1(prefix, name) __hidden_asmname2(prefix, name)
  360. # define __hidden_asmname2(prefix, name) #prefix name
  361. # define __hidden_ver1(local, internal, name) \
  362. extern __typeof (name) __EI_##name __asm__(__hidden_asmname (#internal)); \
  363. extern __typeof (name) __EI_##name __attribute__((alias (__hidden_asmname1 (,#local))))
  364. # define hidden_ver(local, name) __hidden_ver1(local, __GI_##name, name);
  365. # define hidden_data_ver(local, name) hidden_ver(local, name)
  366. # define hidden_def(name) __hidden_ver1(__GI_##name, name, name);
  367. # define hidden_data_def(name) hidden_def(name)
  368. # define hidden_weak(name) \
  369. __hidden_ver1(__GI_##name, name, name) __attribute__((weak));
  370. # define hidden_data_weak(name) hidden_weak(name)
  371. # else /* __ASSEMBLER__ */
  372. # ifdef HAVE_ASM_SET_DIRECTIVE
  373. # ifdef HAVE_ASM_GLOBAL_DOT_NAME
  374. # define _hidden_strong_alias(original, alias) \
  375. ASM_GLOBAL_DIRECTIVE C_SYMBOL_NAME (alias) ASM_LINE_SEP \
  376. .hidden C_SYMBOL_NAME (alias) ASM_LINE_SEP \
  377. .set C_SYMBOL_NAME (alias),C_SYMBOL_NAME (original) ASM_LINE_SEP \
  378. ASM_GLOBAL_DIRECTIVE C_SYMBOL_DOT_NAME (alias) ASM_LINE_SEP \
  379. .hidden C_SYMBOL_DOT_NAME (alias) ASM_LINE_SEP \
  380. .set C_SYMBOL_DOT_NAME (alias),C_SYMBOL_DOT_NAME (original)
  381. # else
  382. # define _hidden_strong_alias(original, alias) \
  383. ASM_GLOBAL_DIRECTIVE C_SYMBOL_NAME (alias) ASM_LINE_SEP \
  384. .hidden C_SYMBOL_NAME (alias) ASM_LINE_SEP \
  385. .set C_SYMBOL_NAME (alias),C_SYMBOL_NAME (original)
  386. # endif
  387. # else
  388. # ifdef HAVE_ASM_GLOBAL_DOT_NAME
  389. # define _hidden_strong_alias(original, alias) \
  390. ASM_GLOBAL_DIRECTIVE C_SYMBOL_NAME (alias) ASM_LINE_SEP \
  391. .hidden C_SYMBOL_NAME (alias) ASM_LINE_SEP \
  392. C_SYMBOL_NAME (alias) = C_SYMBOL_NAME (original) ASM_LINE_SEP \
  393. ASM_GLOBAL_DIRECTIVE C_SYMBOL_DOT_NAME (alias) ASM_LINE_SEP \
  394. .hidden C_SYMBOL_DOT_NAME (alias) ASM_LINE_SEP \
  395. C_SYMBOL_DOT_NAME (alias) = C_SYMBOL_DOT_NAME (original)
  396. # else
  397. # define _hidden_strong_alias(original, alias) \
  398. ASM_GLOBAL_DIRECTIVE C_SYMBOL_NAME (alias) ASM_LINE_SEP \
  399. .hidden C_SYMBOL_NAME (alias) ASM_LINE_SEP \
  400. C_SYMBOL_NAME (alias) = C_SYMBOL_NAME (original)
  401. # endif
  402. # endif
  403. # ifdef HAVE_ASM_GLOBAL_DOT_NAME
  404. # define _hidden_weak_alias(original, alias) \
  405. .hidden C_SYMBOL_NAME (alias) ASM_LINE_SEP \
  406. .hidden C_SYMBOL_DOT_NAME (alias) ASM_LINE_SEP \
  407. weak_alias(original, alias)
  408. # else
  409. # define _hidden_weak_alias(original, alias) \
  410. .hidden C_SYMBOL_NAME (alias) ASM_LINE_SEP \
  411. weak_alias(original, alias)
  412. # endif
  413. /* For assembly, we need to do the opposite of what we do in C:
  414. in assembly gcc __REDIRECT stuff is not in place, so functions
  415. are defined by its normal name and we need to create the
  416. __GI_* alias to it, in C __REDIRECT causes the function definition
  417. to use __GI_* name and we need to add alias to the real name.
  418. There is no reason to use hidden_weak over hidden_def in assembly,
  419. but we provide it for consistency with the C usage.
  420. hidden_proto doesn't make sense for assembly but the equivalent
  421. is to call via the HIDDEN_JUMPTARGET macro instead of JUMPTARGET. */
  422. # define hidden_def(name) _hidden_strong_alias (name, __GI_##name)
  423. # define hidden_weak(name) _hidden_weak_alias (name, __GI_##name)
  424. # define hidden_ver(local, name) strong_alias (local, __GI_##name)
  425. # define hidden_data_def(name) _hidden_strong_alias (name, __GI_##name)
  426. # define hidden_data_weak(name) _hidden_weak_alias (name, __GI_##name)
  427. # define hidden_data_ver(local, name) strong_data_alias (local, __GI_##name)
  428. # ifdef HAVE_ASM_GLOBAL_DOT_NAME
  429. # define HIDDEN_JUMPTARGET(name) .__GI_##name
  430. # else
  431. # define HIDDEN_JUMPTARGET(name) __GI_##name
  432. # endif
  433. # endif /* __ASSEMBLER__ */
  434. #else /* SHARED */
  435. # ifndef __ASSEMBLER__
  436. # define hidden_proto(name, attrs...)
  437. # else
  438. # define HIDDEN_JUMPTARGET(name) name
  439. # endif /* Not __ASSEMBLER__ */
  440. # define hidden_weak(name)
  441. # define hidden_def(name)
  442. # define hidden_ver(local, name)
  443. # define hidden_data_weak(name)
  444. # define hidden_data_def(name)
  445. # define hidden_data_ver(local, name)
  446. #endif /* SHARED */
  447. /* uClibc does not support versioning yet. */
  448. #define versioned_symbol(lib, local, symbol, version) /* weak_alias(local, symbol) */
  449. #undef hidden_ver
  450. #define hidden_ver(local, name) /* strong_alias(local, __GI_##name) */
  451. #undef hidden_data_ver
  452. #define hidden_data_ver(local, name) /* strong_alias(local,__GI_##name) */
  453. #if !defined NOT_IN_libc
  454. # define libc_hidden_proto(name, attrs...) hidden_proto (name, ##attrs)
  455. # define libc_hidden_def(name) hidden_def (name)
  456. # define libc_hidden_weak(name) hidden_weak (name)
  457. # define libc_hidden_ver(local, name) hidden_ver (local, name)
  458. # define libc_hidden_data_def(name) hidden_data_def (name)
  459. # define libc_hidden_data_weak(name) hidden_data_weak (name)
  460. # define libc_hidden_data_ver(local, name) hidden_data_ver (local, name)
  461. #else
  462. # define libc_hidden_proto(name, attrs...)
  463. # define libc_hidden_def(name)
  464. # define libc_hidden_weak(name)
  465. # define libc_hidden_ver(local, name)
  466. # define libc_hidden_data_def(name)
  467. # define libc_hidden_data_weak(name)
  468. # define libc_hidden_data_ver(local, name)
  469. #endif
  470. #if defined NOT_IN_libc && defined IS_IN_rtld
  471. # define rtld_hidden_proto(name, attrs...) hidden_proto (name, ##attrs)
  472. # define rtld_hidden_def(name) hidden_def (name)
  473. # define rtld_hidden_weak(name) hidden_weak (name)
  474. # define rtld_hidden_ver(local, name) hidden_ver (local, name)
  475. # define rtld_hidden_data_def(name) hidden_data_def (name)
  476. # define rtld_hidden_data_weak(name) hidden_data_weak (name)
  477. # define rtld_hidden_data_ver(local, name) hidden_data_ver (local, name)
  478. #else
  479. # define rtld_hidden_proto(name, attrs...)
  480. # define rtld_hidden_def(name)
  481. # define rtld_hidden_weak(name)
  482. # define rtld_hidden_ver(local, name)
  483. # define rtld_hidden_data_def(name)
  484. # define rtld_hidden_data_weak(name)
  485. # define rtld_hidden_data_ver(local, name)
  486. #endif
  487. #if defined NOT_IN_libc && defined IS_IN_libm
  488. # define libm_hidden_proto(name, attrs...) hidden_proto (name, ##attrs)
  489. # define libm_hidden_def(name) hidden_def (name)
  490. # define libm_hidden_weak(name) hidden_weak (name)
  491. # define libm_hidden_ver(local, name) hidden_ver (local, name)
  492. # define libm_hidden_data_def(name) hidden_data_def (name)
  493. # define libm_hidden_data_weak(name) hidden_data_weak (name)
  494. # define libm_hidden_data_ver(local, name) hidden_data_ver (local, name)
  495. #else
  496. # define libm_hidden_proto(name, attrs...)
  497. # define libm_hidden_def(name)
  498. # define libm_hidden_weak(name)
  499. # define libm_hidden_ver(local, name)
  500. # define libm_hidden_data_def(name)
  501. # define libm_hidden_data_weak(name)
  502. # define libm_hidden_data_ver(local, name)
  503. #endif
  504. #if defined NOT_IN_libc && defined IS_IN_libresolv
  505. # define libresolv_hidden_proto(name, attrs...) hidden_proto (name, ##attrs)
  506. # define libresolv_hidden_def(name) hidden_def (name)
  507. # define libresolv_hidden_weak(name) hidden_weak (name)
  508. # define libresolv_hidden_ver(local, name) hidden_ver (local, name)
  509. # define libresolv_hidden_data_def(name) hidden_data_def (name)
  510. # define libresolv_hidden_data_weak(name) hidden_data_weak (name)
  511. # define libresolv_hidden_data_ver(local, name) hidden_data_ver (local, name)
  512. #else
  513. # define libresolv_hidden_proto(name, attrs...)
  514. # define libresolv_hidden_def(name)
  515. # define libresolv_hidden_weak(name)
  516. # define libresolv_hidden_ver(local, name)
  517. # define libresolv_hidden_data_def(name)
  518. # define libresolv_hidden_data_weak(name)
  519. # define libresolv_hidden_data_ver(local, name)
  520. #endif
  521. #if defined NOT_IN_libc && defined IS_IN_librt
  522. # define librt_hidden_proto(name, attrs...) hidden_proto (name, ##attrs)
  523. # define librt_hidden_def(name) hidden_def (name)
  524. # define librt_hidden_weak(name) hidden_weak (name)
  525. # define librt_hidden_ver(local, name) hidden_ver (local, name)
  526. # define librt_hidden_data_def(name) hidden_data_def (name)
  527. # define librt_hidden_data_weak(name) hidden_data_weak (name)
  528. # define librt_hidden_data_ver(local, name) hidden_data_ver (local, name)
  529. #else
  530. # define librt_hidden_proto(name, attrs...)
  531. # define librt_hidden_def(name)
  532. # define librt_hidden_weak(name)
  533. # define librt_hidden_ver(local, name)
  534. # define librt_hidden_data_def(name)
  535. # define librt_hidden_data_weak(name)
  536. # define librt_hidden_data_ver(local, name)
  537. #endif
  538. #if defined NOT_IN_libc && defined IS_IN_libdl
  539. # define libdl_hidden_proto(name, attrs...) hidden_proto (name, ##attrs)
  540. # define libdl_hidden_def(name) hidden_def (name)
  541. # define libdl_hidden_weak(name) hidden_weak (name)
  542. # define libdl_hidden_ver(local, name) hidden_ver (local, name)
  543. # define libdl_hidden_data_def(name) hidden_data_def (name)
  544. # define libdl_hidden_data_weak(name) hidden_data_weak (name)
  545. # define libdl_hidden_data_ver(local, name) hidden_data_ver (local, name)
  546. #else
  547. # define libdl_hidden_proto(name, attrs...)
  548. # define libdl_hidden_def(name)
  549. # define libdl_hidden_weak(name)
  550. # define libdl_hidden_ver(local, name)
  551. # define libdl_hidden_data_def(name)
  552. # define libdl_hidden_data_weak(name)
  553. # define libdl_hidden_data_ver(local, name)
  554. #endif
  555. #if defined NOT_IN_libc && defined IS_IN_libintl
  556. # define libintl_hidden_proto(name, attrs...) hidden_proto (name, ##attrs)
  557. # define libintl_hidden_def(name) hidden_def (name)
  558. # define libintl_hidden_weak(name) hidden_weak (name)
  559. # define libintl_hidden_ver(local, name) hidden_ver (local, name)
  560. # define libintl_hidden_data_def(name) hidden_data_def (name)
  561. # define libintl_hidden_data_weak(name) hidden_data_weak (name)
  562. # define libintl_hidden_data_ver(local, name) hidden_data_ver(local, name)
  563. #else
  564. # define libintl_hidden_proto(name, attrs...)
  565. # define libintl_hidden_def(name)
  566. # define libintl_hidden_weak(name)
  567. # define libintl_hidden_ver(local, name)
  568. # define libintl_hidden_data_def(name)
  569. # define libintl_hidden_data_weak(name)
  570. # define libintl_hidden_data_ver(local, name)
  571. #endif
  572. #if defined NOT_IN_libc && defined IS_IN_libnsl
  573. # define libnsl_hidden_proto(name, attrs...) hidden_proto (name, ##attrs)
  574. # define libnsl_hidden_def(name) hidden_def (name)
  575. # define libnsl_hidden_weak(name) hidden_weak (name)
  576. # define libnsl_hidden_ver(local, name) hidden_ver (local, name)
  577. # define libnsl_hidden_data_def(name) hidden_data_def (name)
  578. # define libnsl_hidden_data_weak(name) hidden_data_weak (name)
  579. # define libnsl_hidden_data_ver(local, name) hidden_data_ver (local, name)
  580. #else
  581. # define libnsl_hidden_proto(name, attrs...)
  582. # define libnsl_hidden_def(name)
  583. # define libnsl_hidden_weak(name)
  584. # define libnsl_hidden_ver(local, name)
  585. # define libnsl_hidden_data_def(name)
  586. # define libnsl_hidden_data_weak(name)
  587. # define libnsl_hidden_data_ver(local, name)
  588. #endif
  589. #if defined NOT_IN_libc && defined IS_IN_libutil
  590. # define libutil_hidden_proto(name, attrs...) hidden_proto (name, ##attrs)
  591. # define libutil_hidden_def(name) hidden_def (name)
  592. # define libutil_hidden_weak(name) hidden_weak (name)
  593. # define libutil_hidden_ver(local, name) hidden_ver (local, name)
  594. # define libutil_hidden_data_def(name) hidden_data_def (name)
  595. # define libutil_hidden_data_weak(name) hidden_data_weak (name)
  596. # define libutil_hidden_data_ver(local, name) hidden_data_ver (local, name)
  597. #else
  598. # define libutil_hidden_proto(name, attrs...)
  599. # define libutil_hidden_def(name)
  600. # define libutil_hidden_weak(name)
  601. # define libutil_hidden_ver(local, name)
  602. # define libutil_hidden_data_def(name)
  603. # define libutil_hidden_data_weak(name)
  604. # define libutil_hidden_data_ver(local, name)
  605. #endif
  606. #if defined NOT_IN_libc && defined IS_IN_libcrypt
  607. # define libcrypt_hidden_proto(name, attrs...) hidden_proto (name, ##attrs)
  608. # define libcrypt_hidden_def(name) hidden_def (name)
  609. # define libcrypt_hidden_weak(name) hidden_weak (name)
  610. # define libcrypt_hidden_ver(local, name) hidden_ver (local, name)
  611. # define libcrypt_hidden_data_def(name) hidden_data_def (name)
  612. # define libcrypt_hidden_data_weak(name) hidden_data_weak (name)
  613. # define libcrypt_hidden_data_ver(local, name) hidden_data_ver (local, name)
  614. #else
  615. # define libcrypt_hidden_proto(name, attrs...)
  616. # define libcrypt_hidden_def(name)
  617. # define libcrypt_hidden_weak(name)
  618. # define libcrypt_hidden_ver(local, name)
  619. # define libcrypt_hidden_data_def(name)
  620. # define libcrypt_hidden_data_weak(name)
  621. # define libcrypt_hidden_data_ver(local, name)
  622. #endif
  623. #if defined NOT_IN_libc && defined IS_IN_libpthread
  624. # define libpthread_hidden_proto(name, attrs...) hidden_proto (name, ##attrs)
  625. # define libpthread_hidden_def(name) hidden_def (name)
  626. # define libpthread_hidden_weak(name) hidden_weak (name)
  627. # define libpthread_hidden_ver(local, name) hidden_ver (local, name)
  628. # define libpthread_hidden_data_def(name) hidden_data_def (name)
  629. # define libpthread_hidden_data_weak(name) hidden_data_weak (name)
  630. # define libpthread_hidden_data_ver(local, name) hidden_data_ver (local, name)
  631. #else
  632. # define libpthread_hidden_proto(name, attrs...)
  633. # define libpthread_hidden_def(name)
  634. # define libpthread_hidden_weak(name)
  635. # define libpthread_hidden_ver(local, name)
  636. # define libpthread_hidden_data_def(name)
  637. # define libpthread_hidden_data_weak(name)
  638. # define libpthread_hidden_data_ver(local, name)
  639. #endif
  640. #endif /* libc-symbols.h */