libc-symbols.h 28 KB

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