| 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-2017 Free Software Foundation, Inc. |
| 4 | This file is part of the GNU C Library. |
| 5 | |
| 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 | |
| 11 | The GNU C Library is distributed in the hope that it will be useful, |
| 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 14 | Lesser General Public License for more details. |
| 15 | |
| 16 | You should have received a copy of the GNU Lesser General Public |
| 17 | License along with the GNU C Library; if not, see |
| 18 | <http://www.gnu.org/licenses/>. */ |
| 19 | |
| 20 | #ifndef _LIBC_SYMBOLS_H |
| 21 | #define _LIBC_SYMBOLS_H 1 |
| 22 | |
| 23 | #define IN_MODULE PASTE_NAME (MODULE_, MODULE_NAME) |
| 24 | #define IS_IN(lib) (IN_MODULE == MODULE_##lib) |
| 25 | |
| 26 | /* Returns true if the current module is a versioned library. Versioned |
| 27 | library names culled from shlib-versions files are assigned a MODULE_* |
| 28 | value lower than MODULE_LIBS_BEGIN. */ |
| 29 | #define IS_IN_LIB (IN_MODULE > MODULE_LIBS_BEGIN) |
| 30 | |
| 31 | #define PASTE_NAME(a,b) PASTE_NAME1 (a,b) |
| 32 | #define PASTE_NAME1(a,b) a##b |
| 33 | |
| 34 | /* This file's macros are included implicitly in the compilation of every |
| 35 | file in the C library by -imacros. |
| 36 | |
| 37 | We include config.h which is generated by configure. |
| 38 | It should define for us the following symbol: |
| 39 | |
| 40 | * HAVE_ASM_SET_DIRECTIVE if we have `.set B, A' instead of `A = B'. |
| 41 | |
| 42 | */ |
| 43 | |
| 44 | /* This is defined for the compilation of all C library code. features.h |
| 45 | tests this to avoid inclusion of stubs.h while compiling the library, |
| 46 | before stubs.h has been generated. Some library code that is shared |
| 47 | with other packages also tests this symbol to see if it is being |
| 48 | compiled as part of the C library. We must define this before including |
| 49 | config.h, because it makes some definitions conditional on whether libc |
| 50 | itself is being compiled, or just some generator program. */ |
| 51 | #define _LIBC 1 |
| 52 | |
| 53 | /* Enable declarations of GNU extensions, since we are compiling them. */ |
| 54 | #define _GNU_SOURCE 1 |
| 55 | |
| 56 | #include <config.h> |
| 57 | |
| 58 | /* Define this for the benefit of portable GNU code that wants to check it. |
| 59 | Code that checks with #if will not #include <config.h> again, since we've |
| 60 | already done it (and this file is implicitly included in every compile, |
| 61 | via -include). Code that checks with #ifdef will #include <config.h>, |
| 62 | but that file should always be idempotent (i.e., it's just #define/#undef |
| 63 | and nothing else anywhere should be changing the macro state it touches), |
| 64 | so it's harmless. */ |
| 65 | #define HAVE_CONFIG_H 0 |
| 66 | |
| 67 | /* Define these macros for the benefit of portable GNU code that wants to check |
| 68 | them. Of course, STDC_HEADERS is never false when building libc! */ |
| 69 | #define 1 |
| 70 | #define HAVE_MBSTATE_T 1 |
| 71 | #define HAVE_MBSRTOWCS 1 |
| 72 | #define HAVE_LIBINTL_H 1 |
| 73 | #define HAVE_WCTYPE_H 1 |
| 74 | #define HAVE_ISWCTYPE 1 |
| 75 | #define ENABLE_NLS 1 |
| 76 | |
| 77 | /* The symbols in all the user (non-_) macros are C symbols. */ |
| 78 | |
| 79 | #ifndef __SYMBOL_PREFIX |
| 80 | # define __SYMBOL_PREFIX |
| 81 | #endif |
| 82 | |
| 83 | #ifndef C_SYMBOL_NAME |
| 84 | # define C_SYMBOL_NAME(name) name |
| 85 | #endif |
| 86 | |
| 87 | #ifndef ASM_LINE_SEP |
| 88 | # define ASM_LINE_SEP ; |
| 89 | #endif |
| 90 | |
| 91 | #ifndef __ASSEMBLER__ |
| 92 | /* GCC understands weak symbols and aliases; use its interface where |
| 93 | possible, instead of embedded assembly language. */ |
| 94 | |
| 95 | /* Define ALIASNAME as a strong alias for NAME. */ |
| 96 | # define strong_alias(name, aliasname) _strong_alias(name, aliasname) |
| 97 | # define _strong_alias(name, aliasname) \ |
| 98 | extern __typeof (name) aliasname __attribute__ ((alias (#name))); |
| 99 | |
| 100 | /* This comes between the return type and function name in |
| 101 | a function definition to make that definition weak. */ |
| 102 | # define weak_function __attribute__ ((weak)) |
| 103 | # define weak_const_function __attribute__ ((weak, __const__)) |
| 104 | |
| 105 | /* Define ALIASNAME as a weak alias for NAME. |
| 106 | If weak aliases are not available, this defines a strong alias. */ |
| 107 | # define weak_alias(name, aliasname) _weak_alias (name, aliasname) |
| 108 | # define _weak_alias(name, aliasname) \ |
| 109 | extern __typeof (name) aliasname __attribute__ ((weak, alias (#name))); |
| 110 | |
| 111 | /* Same as WEAK_ALIAS, but mark symbol as hidden. */ |
| 112 | # define weak_hidden_alias(name, aliasname) \ |
| 113 | _weak_hidden_alias (name, aliasname) |
| 114 | # define _weak_hidden_alias(name, aliasname) \ |
| 115 | extern __typeof (name) aliasname \ |
| 116 | __attribute__ ((weak, alias (#name), __visibility__ ("hidden"))); |
| 117 | |
| 118 | /* Declare SYMBOL as weak undefined symbol (resolved to 0 if not defined). */ |
| 119 | # define weak_extern(symbol) _weak_extern (weak symbol) |
| 120 | # define _weak_extern(expr) _Pragma (#expr) |
| 121 | |
| 122 | /* In shared builds, the expression call_function_static_weak |
| 123 | (FUNCTION-SYMBOL, ARGUMENTS) invokes FUNCTION-SYMBOL (an |
| 124 | identifier) unconditionally, with the (potentially empty) argument |
| 125 | list ARGUMENTS. In static builds, if FUNCTION-SYMBOL has a |
| 126 | definition, the function is invoked as before; if FUNCTION-SYMBOL |
| 127 | is NULL, no call is performed. */ |
| 128 | # ifdef SHARED |
| 129 | # define call_function_static_weak(func, ...) func (__VA_ARGS__) |
| 130 | # else /* !SHARED */ |
| 131 | # define call_function_static_weak(func, ...) \ |
| 132 | ({ \ |
| 133 | extern __typeof__ (func) func weak_function; \ |
| 134 | (func != NULL ? func (__VA_ARGS__) : (void)0); \ |
| 135 | }) |
| 136 | # endif |
| 137 | |
| 138 | #else /* __ASSEMBLER__ */ |
| 139 | |
| 140 | # ifdef HAVE_ASM_SET_DIRECTIVE |
| 141 | # define strong_alias(original, alias) \ |
| 142 | .globl C_SYMBOL_NAME (alias) ASM_LINE_SEP \ |
| 143 | .set C_SYMBOL_NAME (alias),C_SYMBOL_NAME (original) |
| 144 | # define strong_data_alias(original, alias) strong_alias(original, alias) |
| 145 | # else |
| 146 | # define strong_alias(original, alias) \ |
| 147 | .globl C_SYMBOL_NAME (alias) ASM_LINE_SEP \ |
| 148 | C_SYMBOL_NAME (alias) = C_SYMBOL_NAME (original) |
| 149 | # define strong_data_alias(original, alias) strong_alias(original, alias) |
| 150 | # endif |
| 151 | |
| 152 | # define weak_alias(original, alias) \ |
| 153 | .weak C_SYMBOL_NAME (alias) ASM_LINE_SEP \ |
| 154 | C_SYMBOL_NAME (alias) = C_SYMBOL_NAME (original) |
| 155 | |
| 156 | # define weak_extern(symbol) \ |
| 157 | .weak C_SYMBOL_NAME (symbol) |
| 158 | |
| 159 | #endif /* __ASSEMBLER__ */ |
| 160 | |
| 161 | /* On some platforms we can make internal function calls (i.e., calls of |
| 162 | functions not exported) a bit faster by using a different calling |
| 163 | convention. */ |
| 164 | #ifndef internal_function |
| 165 | # define internal_function /* empty */ |
| 166 | #endif |
| 167 | |
| 168 | /* Determine the return address. */ |
| 169 | #define RETURN_ADDRESS(nr) \ |
| 170 | __builtin_extract_return_addr (__builtin_return_address (nr)) |
| 171 | |
| 172 | /* When a reference to SYMBOL is encountered, the linker will emit a |
| 173 | warning message MSG. */ |
| 174 | /* We want the .gnu.warning.SYMBOL section to be unallocated. */ |
| 175 | #define __make_section_unallocated(section_string) \ |
| 176 | asm (".section " section_string "\n\t.previous"); |
| 177 | |
| 178 | /* Tacking on "\n\t#" to the section name makes gcc put it's bogus |
| 179 | section attributes on what looks like a comment to the assembler. */ |
| 180 | #ifdef HAVE_SECTION_QUOTES |
| 181 | # define __sec_comment "\"\n\t#\"" |
| 182 | #else |
| 183 | # define "\n\t#" |
| 184 | #endif |
| 185 | #define link_warning(symbol, msg) \ |
| 186 | __make_section_unallocated (".gnu.warning." #symbol) \ |
| 187 | static const char __evoke_link_warning_##symbol[] \ |
| 188 | __attribute__ ((used, section (".gnu.warning." #symbol __sec_comment))) \ |
| 189 | = msg; |
| 190 | #define libc_freeres_ptr(decl) \ |
| 191 | __make_section_unallocated ("__libc_freeres_ptrs, \"aw\", %nobits") \ |
| 192 | decl __attribute__ ((section ("__libc_freeres_ptrs" __sec_comment))) |
| 193 | #define __libc_freeres_fn_section \ |
| 194 | __attribute__ ((section ("__libc_freeres_fn"))) |
| 195 | |
| 196 | #define libc_freeres_fn(name) \ |
| 197 | static void name (void) __attribute_used__ __libc_freeres_fn_section; \ |
| 198 | text_set_element (__libc_subfreeres, name); \ |
| 199 | static void name (void) |
| 200 | |
| 201 | /* A canned warning for sysdeps/stub functions. */ |
| 202 | #define stub_warning(name) \ |
| 203 | __make_section_unallocated (".gnu.glibc-stub." #name) \ |
| 204 | link_warning (name, #name " is not implemented and will always fail") |
| 205 | |
| 206 | /* Warning for linking functions calling dlopen into static binaries. */ |
| 207 | #ifdef SHARED |
| 208 | #define static_link_warning(name) |
| 209 | #else |
| 210 | #define static_link_warning(name) static_link_warning1(name) |
| 211 | #define static_link_warning1(name) \ |
| 212 | link_warning(name, "Using '" #name "' in statically linked applications \ |
| 213 | requires at runtime the shared libraries from the glibc version used \ |
| 214 | for linking") |
| 215 | #endif |
| 216 | |
| 217 | /* Declare SYMBOL to be TYPE (`function' or `object') of SIZE bytes |
| 218 | alias to ORIGINAL, when the assembler supports such declarations |
| 219 | (such as in ELF). |
| 220 | This is only necessary when defining something in assembly, or playing |
| 221 | funny alias games where the size should be other than what the compiler |
| 222 | thinks it is. */ |
| 223 | #define declare_symbol_alias(symbol, original, type, size) \ |
| 224 | declare_symbol_alias_1 (symbol, original, type, size) |
| 225 | #ifdef __ASSEMBLER__ |
| 226 | # define declare_symbol_alias_1(symbol, original, type, size) \ |
| 227 | strong_alias (original, symbol); \ |
| 228 | .type C_SYMBOL_NAME (symbol), %##type; \ |
| 229 | .size C_SYMBOL_NAME (symbol), size |
| 230 | #else /* Not __ASSEMBLER__. */ |
| 231 | # define declare_symbol_alias_1(symbol, original, type, size) \ |
| 232 | asm (".globl " __SYMBOL_PREFIX #symbol \ |
| 233 | "\n\t" declare_symbol_alias_1_alias (symbol, original) \ |
| 234 | "\n\t.type " __SYMBOL_PREFIX #symbol ", " \ |
| 235 | "%" #type \ |
| 236 | "\n\t.size " __SYMBOL_PREFIX #symbol ", " #size); |
| 237 | # ifdef HAVE_ASM_SET_DIRECTIVE |
| 238 | # define declare_symbol_alias_1_alias(symbol, original) \ |
| 239 | ".set " __SYMBOL_PREFIX #symbol ", " __SYMBOL_PREFIX #original |
| 240 | # else |
| 241 | # define declare_symbol_alias_1_alias(symbol, original) \ |
| 242 | __SYMBOL_PREFIX #symbol " = " __SYMBOL_PREFIX #original |
| 243 | # endif /* HAVE_ASM_SET_DIRECTIVE */ |
| 244 | #endif /* __ASSEMBLER__ */ |
| 245 | |
| 246 | |
| 247 | /* |
| 248 | |
| 249 | */ |
| 250 | |
| 251 | /* Symbol set support macros. */ |
| 252 | |
| 253 | /* Make SYMBOL, which is in the text segment, an element of SET. */ |
| 254 | #define text_set_element(set, symbol) _elf_set_element(set, symbol) |
| 255 | /* Make SYMBOL, which is in the data segment, an element of SET. */ |
| 256 | #define data_set_element(set, symbol) _elf_set_element(set, symbol) |
| 257 | /* Make SYMBOL, which is in the bss segment, an element of SET. */ |
| 258 | #define bss_set_element(set, symbol) _elf_set_element(set, symbol) |
| 259 | |
| 260 | /* These are all done the same way in ELF. |
| 261 | There is a new section created for each set. */ |
| 262 | #ifdef SHARED |
| 263 | /* When building a shared library, make the set section writable, |
| 264 | because it will need to be relocated at run time anyway. */ |
| 265 | # define _elf_set_element(set, symbol) \ |
| 266 | static const void *__elf_set_##set##_element_##symbol##__ \ |
| 267 | __attribute__ ((used, section (#set))) = &(symbol) |
| 268 | #else |
| 269 | # define _elf_set_element(set, symbol) \ |
| 270 | static const void *const __elf_set_##set##_element_##symbol##__ \ |
| 271 | __attribute__ ((used, section (#set))) = &(symbol) |
| 272 | #endif |
| 273 | |
| 274 | /* Define SET as a symbol set. This may be required (it is in a.out) to |
| 275 | be able to use the set's contents. */ |
| 276 | #define symbol_set_define(set) symbol_set_declare(set) |
| 277 | |
| 278 | /* Declare SET for use in this module, if defined in another module. |
| 279 | In a shared library, this is always local to that shared object. |
| 280 | For static linking, the set might be wholly absent and so we use |
| 281 | weak references. */ |
| 282 | #define symbol_set_declare(set) \ |
| 283 | extern char const __start_##set[] __symbol_set_attribute; \ |
| 284 | extern char const __stop_##set[] __symbol_set_attribute; |
| 285 | #ifdef SHARED |
| 286 | # define __symbol_set_attribute attribute_hidden |
| 287 | #else |
| 288 | # define __symbol_set_attribute __attribute__ ((weak)) |
| 289 | #endif |
| 290 | |
| 291 | /* Return a pointer (void *const *) to the first element of SET. */ |
| 292 | #define symbol_set_first_element(set) ((void *const *) (&__start_##set)) |
| 293 | |
| 294 | /* Return true iff PTR (a void *const *) has been incremented |
| 295 | past the last element in SET. */ |
| 296 | #define symbol_set_end_p(set, ptr) ((ptr) >= (void *const *) &__stop_##set) |
| 297 | |
| 298 | /* Use symbol_version_reference to specify the version a symbol |
| 299 | reference should link to. Use symbol_version or |
| 300 | default_symbol_version for the definition of a versioned symbol. |
| 301 | The difference is that the latter is a no-op in non-shared |
| 302 | builds. */ |
| 303 | #ifdef __ASSEMBLER__ |
| 304 | # define symbol_version_reference(real, name, version) \ |
| 305 | .symver real, name##@##version |
| 306 | #else /* !__ASSEMBLER__ */ |
| 307 | # define symbol_version_reference(real, name, version) \ |
| 308 | __asm__ (".symver " #real "," #name "@" #version) |
| 309 | #endif |
| 310 | |
| 311 | #ifdef SHARED |
| 312 | # define symbol_version(real, name, version) \ |
| 313 | symbol_version_reference(real, name, version) |
| 314 | # define default_symbol_version(real, name, version) \ |
| 315 | _default_symbol_version(real, name, version) |
| 316 | # ifdef __ASSEMBLER__ |
| 317 | # define _default_symbol_version(real, name, version) \ |
| 318 | .symver real, name##@##@##version |
| 319 | # else |
| 320 | # define _default_symbol_version(real, name, version) \ |
| 321 | __asm__ (".symver " #real "," #name "@@" #version) |
| 322 | # endif |
| 323 | #else |
| 324 | # define symbol_version(real, name, version) |
| 325 | # define default_symbol_version(real, name, version) \ |
| 326 | strong_alias(real, name) |
| 327 | #endif |
| 328 | |
| 329 | #if defined SHARED || defined LIBC_NONSHARED |
| 330 | # define attribute_hidden __attribute__ ((visibility ("hidden"))) |
| 331 | #else |
| 332 | # define attribute_hidden |
| 333 | #endif |
| 334 | |
| 335 | #define attribute_tls_model_ie __attribute__ ((tls_model ("initial-exec"))) |
| 336 | |
| 337 | #define attribute_relro __attribute__ ((section (".data.rel.ro"))) |
| 338 | |
| 339 | |
| 340 | /* Used to disable stack protection in sensitive places, like ifunc |
| 341 | resolvers and early static TLS init. */ |
| 342 | #ifdef HAVE_CC_NO_STACK_PROTECTOR |
| 343 | # define inhibit_stack_protector \ |
| 344 | __attribute__ ((__optimize__ ("-fno-stack-protector"))) |
| 345 | #else |
| 346 | # define inhibit_stack_protector |
| 347 | #endif |
| 348 | |
| 349 | /* The following macros are used for PLT bypassing within libc.so |
| 350 | (and if needed other libraries similarly). |
| 351 | First of all, you need to have the function prototyped somewhere, |
| 352 | say in foo/foo.h: |
| 353 | |
| 354 | int foo (int __bar); |
| 355 | |
| 356 | If calls to foo within libc.so should always go to foo defined in libc.so, |
| 357 | then in include/foo.h you add: |
| 358 | |
| 359 | libc_hidden_proto (foo) |
| 360 | |
| 361 | line and after the foo function definition: |
| 362 | |
| 363 | int foo (int __bar) |
| 364 | { |
| 365 | return __bar; |
| 366 | } |
| 367 | libc_hidden_def (foo) |
| 368 | |
| 369 | or |
| 370 | |
| 371 | int foo (int __bar) |
| 372 | { |
| 373 | return __bar; |
| 374 | } |
| 375 | libc_hidden_weak (foo) |
| 376 | |
| 377 | Similarly for global data. If references to foo within libc.so should |
| 378 | always go to foo defined in libc.so, then in include/foo.h you add: |
| 379 | |
| 380 | libc_hidden_proto (foo) |
| 381 | |
| 382 | line and after foo's definition: |
| 383 | |
| 384 | int foo = INITIAL_FOO_VALUE; |
| 385 | libc_hidden_data_def (foo) |
| 386 | |
| 387 | or |
| 388 | |
| 389 | int foo = INITIAL_FOO_VALUE; |
| 390 | libc_hidden_data_weak (foo) |
| 391 | |
| 392 | If foo is normally just an alias (strong or weak) to some other function, |
| 393 | you should use the normal strong_alias first, then add libc_hidden_def |
| 394 | or libc_hidden_weak: |
| 395 | |
| 396 | int baz (int __bar) |
| 397 | { |
| 398 | return __bar; |
| 399 | } |
| 400 | strong_alias (baz, foo) |
| 401 | libc_hidden_weak (foo) |
| 402 | |
| 403 | If the function should be internal to multiple objects, say ld.so and |
| 404 | libc.so, the best way is to use: |
| 405 | |
| 406 | #if IS_IN (libc) || IS_IN (rtld) |
| 407 | hidden_proto (foo) |
| 408 | #endif |
| 409 | |
| 410 | in include/foo.h and the normal macros at all function definitions |
| 411 | depending on what DSO they belong to. |
| 412 | |
| 413 | If versioned_symbol macro is used to define foo, |
| 414 | libc_hidden_ver macro should be used, as in: |
| 415 | |
| 416 | int __real_foo (int __bar) |
| 417 | { |
| 418 | return __bar; |
| 419 | } |
| 420 | versioned_symbol (libc, __real_foo, foo, GLIBC_2_1); |
| 421 | libc_hidden_ver (__real_foo, foo) */ |
| 422 | |
| 423 | #if defined SHARED && !defined NO_HIDDEN |
| 424 | # ifndef __ASSEMBLER__ |
| 425 | # define __hidden_proto_hiddenattr(attrs...) \ |
| 426 | __attribute__ ((visibility ("hidden"), ##attrs)) |
| 427 | # define hidden_proto(name, attrs...) \ |
| 428 | __hidden_proto (name, , __GI_##name, ##attrs) |
| 429 | # define hidden_tls_proto(name, attrs...) \ |
| 430 | __hidden_proto (name, __thread, __GI_##name, ##attrs) |
| 431 | # define __hidden_proto(name, thread, internal, attrs...) \ |
| 432 | extern thread __typeof (name) name __asm__ (__hidden_asmname (#internal)) \ |
| 433 | __hidden_proto_hiddenattr (attrs); |
| 434 | # define __hidden_asmname(name) \ |
| 435 | __hidden_asmname1 (__USER_LABEL_PREFIX__, name) |
| 436 | # define __hidden_asmname1(prefix, name) __hidden_asmname2(prefix, name) |
| 437 | # define __hidden_asmname2(prefix, name) #prefix name |
| 438 | # define __hidden_ver1(local, internal, name) \ |
| 439 | extern __typeof (name) __EI_##name __asm__(__hidden_asmname (#internal)); \ |
| 440 | extern __typeof (name) __EI_##name \ |
| 441 | __attribute__((alias (__hidden_asmname (#local)))) |
| 442 | # define hidden_ver(local, name) __hidden_ver1(local, __GI_##name, name); |
| 443 | # define hidden_data_ver(local, name) hidden_ver(local, name) |
| 444 | # define hidden_def(name) __hidden_ver1(__GI_##name, name, name); |
| 445 | # define hidden_data_def(name) hidden_def(name) |
| 446 | # define hidden_weak(name) \ |
| 447 | __hidden_ver1(__GI_##name, name, name) __attribute__((weak)); |
| 448 | # define hidden_data_weak(name) hidden_weak(name) |
| 449 | # define hidden_nolink(name, lib, version) \ |
| 450 | __hidden_nolink1 (__GI_##name, __EI_##name, name, VERSION_##lib##_##version) |
| 451 | # define __hidden_nolink1(local, internal, name, version) \ |
| 452 | __hidden_nolink2 (local, internal, name, version) |
| 453 | # define __hidden_nolink2(local, internal, name, version) \ |
| 454 | extern __typeof (name) internal __attribute__ ((alias (#local))); \ |
| 455 | __hidden_nolink3 (local, internal, #name "@" #version) |
| 456 | # define __hidden_nolink3(local, internal, vername) \ |
| 457 | __asm__ (".symver " #internal ", " vername); |
| 458 | # else |
| 459 | /* For assembly, we need to do the opposite of what we do in C: |
| 460 | in assembly gcc __REDIRECT stuff is not in place, so functions |
| 461 | are defined by its normal name and we need to create the |
| 462 | __GI_* alias to it, in C __REDIRECT causes the function definition |
| 463 | to use __GI_* name and we need to add alias to the real name. |
| 464 | There is no reason to use hidden_weak over hidden_def in assembly, |
| 465 | but we provide it for consistency with the C usage. |
| 466 | hidden_proto doesn't make sense for assembly but the equivalent |
| 467 | is to call via the HIDDEN_JUMPTARGET macro instead of JUMPTARGET. */ |
| 468 | # define hidden_def(name) strong_alias (name, __GI_##name) |
| 469 | # define hidden_weak(name) hidden_def (name) |
| 470 | # define hidden_ver(local, name) strong_alias (local, __GI_##name) |
| 471 | # define hidden_data_def(name) strong_data_alias (name, __GI_##name) |
| 472 | # define hidden_data_weak(name) hidden_data_def (name) |
| 473 | # define hidden_data_ver(local, name) strong_data_alias (local, __GI_##name) |
| 474 | # define HIDDEN_JUMPTARGET(name) __GI_##name |
| 475 | # endif |
| 476 | #else |
| 477 | # ifndef __ASSEMBLER__ |
| 478 | # define hidden_proto(name, attrs...) |
| 479 | # define hidden_tls_proto(name, attrs...) |
| 480 | # else |
| 481 | # define HIDDEN_JUMPTARGET(name) JUMPTARGET(name) |
| 482 | # endif /* Not __ASSEMBLER__ */ |
| 483 | # define hidden_weak(name) |
| 484 | # define hidden_def(name) |
| 485 | # define hidden_ver(local, name) |
| 486 | # define hidden_data_weak(name) |
| 487 | # define hidden_data_def(name) |
| 488 | # define hidden_data_ver(local, name) |
| 489 | # define hidden_nolink(name, lib, version) |
| 490 | #endif |
| 491 | |
| 492 | #if IS_IN (libc) |
| 493 | # define libc_hidden_proto(name, attrs...) hidden_proto (name, ##attrs) |
| 494 | # define libc_hidden_tls_proto(name, attrs...) hidden_tls_proto (name, ##attrs) |
| 495 | # define libc_hidden_def(name) hidden_def (name) |
| 496 | # define libc_hidden_weak(name) hidden_weak (name) |
| 497 | # ifdef LINK_OBSOLETE_RPC |
| 498 | /* libc_hidden_nolink_sunrpc should only get used in sunrpc code. */ |
| 499 | # define libc_hidden_nolink_sunrpc(name, version) hidden_def (name) |
| 500 | # else |
| 501 | # define libc_hidden_nolink_sunrpc(name, version) hidden_nolink (name, libc, version) |
| 502 | # endif |
| 503 | # define libc_hidden_ver(local, name) hidden_ver (local, name) |
| 504 | # define libc_hidden_data_def(name) hidden_data_def (name) |
| 505 | # define libc_hidden_data_weak(name) hidden_data_weak (name) |
| 506 | # define libc_hidden_data_ver(local, name) hidden_data_ver (local, name) |
| 507 | #else |
| 508 | # define libc_hidden_proto(name, attrs...) |
| 509 | # define libc_hidden_tls_proto(name, attrs...) |
| 510 | # define libc_hidden_def(name) |
| 511 | # define libc_hidden_weak(name) |
| 512 | # define libc_hidden_ver(local, name) |
| 513 | # define libc_hidden_data_def(name) |
| 514 | # define libc_hidden_data_weak(name) |
| 515 | # define libc_hidden_data_ver(local, name) |
| 516 | #endif |
| 517 | |
| 518 | #if IS_IN (rtld) |
| 519 | # define rtld_hidden_proto(name, attrs...) hidden_proto (name, ##attrs) |
| 520 | # define rtld_hidden_tls_proto(name, attrs...) hidden_tls_proto (name, ##attrs) |
| 521 | # define rtld_hidden_def(name) hidden_def (name) |
| 522 | # define rtld_hidden_weak(name) hidden_weak (name) |
| 523 | # define rtld_hidden_ver(local, name) hidden_ver (local, name) |
| 524 | # define rtld_hidden_data_def(name) hidden_data_def (name) |
| 525 | # define rtld_hidden_data_weak(name) hidden_data_weak (name) |
| 526 | # define rtld_hidden_data_ver(local, name) hidden_data_ver (local, name) |
| 527 | #else |
| 528 | # define rtld_hidden_proto(name, attrs...) |
| 529 | # define rtld_hidden_tls_proto(name, attrs...) |
| 530 | # define rtld_hidden_def(name) |
| 531 | # define rtld_hidden_weak(name) |
| 532 | # define rtld_hidden_ver(local, name) |
| 533 | # define rtld_hidden_data_def(name) |
| 534 | # define rtld_hidden_data_weak(name) |
| 535 | # define rtld_hidden_data_ver(local, name) |
| 536 | #endif |
| 537 | |
| 538 | #if IS_IN (libm) |
| 539 | # define libm_hidden_proto(name, attrs...) hidden_proto (name, ##attrs) |
| 540 | # define libm_hidden_tls_proto(name, attrs...) hidden_tls_proto (name, ##attrs) |
| 541 | # define libm_hidden_def(name) hidden_def (name) |
| 542 | # define libm_hidden_weak(name) hidden_weak (name) |
| 543 | # define libm_hidden_ver(local, name) hidden_ver (local, name) |
| 544 | # define libm_hidden_data_def(name) hidden_data_def (name) |
| 545 | # define libm_hidden_data_weak(name) hidden_data_weak (name) |
| 546 | # define libm_hidden_data_ver(local, name) hidden_data_ver (local, name) |
| 547 | #else |
| 548 | # define libm_hidden_proto(name, attrs...) |
| 549 | # define libm_hidden_tls_proto(name, attrs...) |
| 550 | # define libm_hidden_def(name) |
| 551 | # define libm_hidden_weak(name) |
| 552 | # define libm_hidden_ver(local, name) |
| 553 | # define libm_hidden_data_def(name) |
| 554 | # define libm_hidden_data_weak(name) |
| 555 | # define libm_hidden_data_ver(local, name) |
| 556 | #endif |
| 557 | |
| 558 | #if IS_IN (libmvec) |
| 559 | # define libmvec_hidden_proto(name, attrs...) hidden_proto (name, ##attrs) |
| 560 | # define libmvec_hidden_tls_proto(name, attrs...) hidden_tls_proto (name, ##attrs) |
| 561 | # define libmvec_hidden_def(name) hidden_def (name) |
| 562 | # define libmvec_hidden_weak(name) hidden_weak (name) |
| 563 | # define libmvec_hidden_ver(local, name) hidden_ver (local, name) |
| 564 | # define libmvec_hidden_data_def(name) hidden_data_def (name) |
| 565 | # define libmvec_hidden_data_weak(name) hidden_data_weak (name) |
| 566 | # define libmvec_hidden_data_ver(local, name) hidden_data_ver (local, name) |
| 567 | #else |
| 568 | # define libmvec_hidden_proto(name, attrs...) |
| 569 | # define libmvec_hidden_tls_proto(name, attrs...) |
| 570 | # define libmvec_hidden_def(name) |
| 571 | # define libmvec_hidden_weak(name) |
| 572 | # define libmvec_hidden_ver(local, name) |
| 573 | # define libmvec_hidden_data_def(name) |
| 574 | # define libmvec_hidden_data_weak(name) |
| 575 | # define libmvec_hidden_data_ver(local, name) |
| 576 | #endif |
| 577 | |
| 578 | #if IS_IN (libresolv) |
| 579 | # define libresolv_hidden_proto(name, attrs...) hidden_proto (name, ##attrs) |
| 580 | # define libresolv_hidden_tls_proto(name, attrs...) \ |
| 581 | hidden_tls_proto (name, ##attrs) |
| 582 | # define libresolv_hidden_def(name) hidden_def (name) |
| 583 | # define libresolv_hidden_weak(name) hidden_weak (name) |
| 584 | # define libresolv_hidden_ver(local, name) hidden_ver (local, name) |
| 585 | # define libresolv_hidden_data_def(name) hidden_data_def (name) |
| 586 | # define libresolv_hidden_data_weak(name) hidden_data_weak (name) |
| 587 | # define libresolv_hidden_data_ver(local, name) hidden_data_ver (local, name) |
| 588 | #else |
| 589 | # define libresolv_hidden_proto(name, attrs...) |
| 590 | # define libresolv_hidden_tls_proto(name, attrs...) |
| 591 | # define libresolv_hidden_def(name) |
| 592 | # define libresolv_hidden_weak(name) |
| 593 | # define libresolv_hidden_ver(local, name) |
| 594 | # define libresolv_hidden_data_def(name) |
| 595 | # define libresolv_hidden_data_weak(name) |
| 596 | # define libresolv_hidden_data_ver(local, name) |
| 597 | #endif |
| 598 | |
| 599 | #if IS_IN (librt) |
| 600 | # define librt_hidden_proto(name, attrs...) hidden_proto (name, ##attrs) |
| 601 | # define librt_hidden_tls_proto(name, attrs...) \ |
| 602 | hidden_tls_proto (name, ##attrs) |
| 603 | # define librt_hidden_def(name) hidden_def (name) |
| 604 | # define librt_hidden_weak(name) hidden_weak (name) |
| 605 | # define librt_hidden_ver(local, name) hidden_ver (local, name) |
| 606 | # define librt_hidden_data_def(name) hidden_data_def (name) |
| 607 | # define librt_hidden_data_weak(name) hidden_data_weak (name) |
| 608 | # define librt_hidden_data_ver(local, name) hidden_data_ver (local, name) |
| 609 | #else |
| 610 | # define librt_hidden_proto(name, attrs...) |
| 611 | # define librt_hidden_tls_proto(name, attrs...) |
| 612 | # define librt_hidden_def(name) |
| 613 | # define librt_hidden_weak(name) |
| 614 | # define librt_hidden_ver(local, name) |
| 615 | # define librt_hidden_data_def(name) |
| 616 | # define librt_hidden_data_weak(name) |
| 617 | # define librt_hidden_data_ver(local, name) |
| 618 | #endif |
| 619 | |
| 620 | #if IS_IN (libdl) |
| 621 | # define libdl_hidden_proto(name, attrs...) hidden_proto (name, ##attrs) |
| 622 | # define libdl_hidden_tls_proto(name, attrs...) \ |
| 623 | hidden_tls_proto (name, ##attrs) |
| 624 | # define libdl_hidden_def(name) hidden_def (name) |
| 625 | # define libdl_hidden_weak(name) hidden_weak (name) |
| 626 | # define libdl_hidden_ver(local, name) hidden_ver (local, name) |
| 627 | # define libdl_hidden_data_def(name) hidden_data_def (name) |
| 628 | # define libdl_hidden_data_weak(name) hidden_data_weak (name) |
| 629 | # define libdl_hidden_data_ver(local, name) hidden_data_ver (local, name) |
| 630 | #else |
| 631 | # define libdl_hidden_proto(name, attrs...) |
| 632 | # define libdl_hidden_tls_proto(name, attrs...) |
| 633 | # define libdl_hidden_def(name) |
| 634 | # define libdl_hidden_weak(name) |
| 635 | # define libdl_hidden_ver(local, name) |
| 636 | # define libdl_hidden_data_def(name) |
| 637 | # define libdl_hidden_data_weak(name) |
| 638 | # define libdl_hidden_data_ver(local, name) |
| 639 | #endif |
| 640 | |
| 641 | #if IS_IN (libnss_files) |
| 642 | # define libnss_files_hidden_proto(name, attrs...) hidden_proto (name, ##attrs) |
| 643 | # define libnss_files_hidden_tls_proto(name, attrs...) \ |
| 644 | hidden_tls_proto (name, ##attrs) |
| 645 | # define libnss_files_hidden_def(name) hidden_def (name) |
| 646 | # define libnss_files_hidden_weak(name) hidden_weak (name) |
| 647 | # define libnss_files_hidden_ver(local, name) hidden_ver (local, name) |
| 648 | # define libnss_files_hidden_data_def(name) hidden_data_def (name) |
| 649 | # define libnss_files_hidden_data_weak(name) hidden_data_weak (name) |
| 650 | # define libnss_files_hidden_data_ver(local, name) hidden_data_ver(local, name) |
| 651 | #else |
| 652 | # define libnss_files_hidden_proto(name, attrs...) |
| 653 | # define libnss_files_hidden_tls_proto(name, attrs...) |
| 654 | # define libnss_files_hidden_def(name) |
| 655 | # define libnss_files_hidden_weak(name) |
| 656 | # define libnss_files_hidden_ver(local, name) |
| 657 | # define libnss_files_hidden_data_def(name) |
| 658 | # define libnss_files_hidden_data_weak(name) |
| 659 | # define libnss_files_hidden_data_ver(local, name) |
| 660 | #endif |
| 661 | |
| 662 | #if IS_IN (libnsl) |
| 663 | # define libnsl_hidden_proto(name, attrs...) hidden_proto (name, ##attrs) |
| 664 | # define libnsl_hidden_tls_proto(name, attrs...) \ |
| 665 | hidden_tls_proto (name, ##attrs) |
| 666 | # define libnsl_hidden_def(name) hidden_def (name) |
| 667 | # define libnsl_hidden_weak(name) hidden_weak (name) |
| 668 | # define libnsl_hidden_ver(local, name) hidden_ver (local, name) |
| 669 | # define libnsl_hidden_data_def(name) hidden_data_def (name) |
| 670 | # define libnsl_hidden_data_weak(name) hidden_data_weak (name) |
| 671 | # define libnsl_hidden_data_ver(local, name) hidden_data_ver (local, name) |
| 672 | #else |
| 673 | # define libnsl_hidden_proto(name, attrs...) |
| 674 | # define libnsl_hidden_tls_proto(name, attrs...) |
| 675 | # define libnsl_hidden_def(name) |
| 676 | # define libnsl_hidden_weak(name) |
| 677 | # define libnsl_hidden_ver(local, name) |
| 678 | # define libnsl_hidden_data_def(name) |
| 679 | # define libnsl_hidden_data_weak(name) |
| 680 | # define libnsl_hidden_data_ver(local, name) |
| 681 | #endif |
| 682 | |
| 683 | #if IS_IN (libnss_nisplus) |
| 684 | # define libnss_nisplus_hidden_proto(name, attrs...) hidden_proto (name, ##attrs) |
| 685 | # define libnss_nisplus_hidden_tls_proto(name, attrs...) \ |
| 686 | hidden_tls_proto (name, ##attrs) |
| 687 | # define libnss_nisplus_hidden_def(name) hidden_def (name) |
| 688 | # define libnss_nisplus_hidden_weak(name) hidden_weak (name) |
| 689 | # define libnss_nisplus_hidden_ver(local, name) hidden_ver (local, name) |
| 690 | # define libnss_nisplus_hidden_data_def(name) hidden_data_def (name) |
| 691 | # define libnss_nisplus_hidden_data_weak(name) hidden_data_weak (name) |
| 692 | # define libnss_nisplus_hidden_data_ver(local, name) hidden_data_ver (local, name) |
| 693 | #else |
| 694 | # define libnss_nisplus_hidden_proto(name, attrs...) |
| 695 | # define libnss_nisplus_hidden_tls_proto(name, attrs...) |
| 696 | # define libnss_nisplus_hidden_def(name) |
| 697 | # define libnss_nisplus_hidden_weak(name) |
| 698 | # define libnss_nisplus_hidden_ver(local, name) |
| 699 | # define libnss_nisplus_hidden_data_def(name) |
| 700 | # define libnss_nisplus_hidden_data_weak(name) |
| 701 | # define libnss_nisplus_hidden_data_ver(local, name) |
| 702 | #endif |
| 703 | |
| 704 | #define libc_hidden_builtin_proto(name, attrs...) libc_hidden_proto (name, ##attrs) |
| 705 | #define libc_hidden_builtin_def(name) libc_hidden_def (name) |
| 706 | #define libc_hidden_builtin_weak(name) libc_hidden_weak (name) |
| 707 | #define libc_hidden_builtin_ver(local, name) libc_hidden_ver (local, name) |
| 708 | #ifdef __ASSEMBLER__ |
| 709 | # define HIDDEN_BUILTIN_JUMPTARGET(name) HIDDEN_JUMPTARGET(name) |
| 710 | #endif |
| 711 | |
| 712 | #if IS_IN (libutil) |
| 713 | # define libutil_hidden_proto(name, attrs...) hidden_proto (name, ##attrs) |
| 714 | # define libutil_hidden_tls_proto(name, attrs...) \ |
| 715 | hidden_tls_proto (name, ##attrs) |
| 716 | # define libutil_hidden_def(name) hidden_def (name) |
| 717 | # define libutil_hidden_weak(name) hidden_weak (name) |
| 718 | # define libutil_hidden_ver(local, name) hidden_ver (local, name) |
| 719 | # define libutil_hidden_data_def(name) hidden_data_def (name) |
| 720 | # define libutil_hidden_data_weak(name) hidden_data_weak (name) |
| 721 | # define libutil_hidden_data_ver(local, name) hidden_data_ver (local, name) |
| 722 | #else |
| 723 | # define libutil_hidden_proto(name, attrs...) |
| 724 | # define libutil_hidden_tls_proto(name, attrs...) |
| 725 | # define libutil_hidden_def(name) |
| 726 | # define libutil_hidden_weak(name) |
| 727 | # define libutil_hidden_ver(local, name) |
| 728 | # define libutil_hidden_data_def(name) |
| 729 | # define libutil_hidden_data_weak(name) |
| 730 | # define libutil_hidden_data_ver(local, name) |
| 731 | #endif |
| 732 | |
| 733 | /* Get some dirty hacks. */ |
| 734 | #include <symbol-hacks.h> |
| 735 | |
| 736 | /* Move compatibility symbols out of the way by placing them all in a |
| 737 | special section. */ |
| 738 | #ifndef __ASSEMBLER__ |
| 739 | # define attribute_compat_text_section \ |
| 740 | __attribute__ ((section (".text.compat"))) |
| 741 | # define attribute_compat_data_section \ |
| 742 | __attribute__ ((section (".data.compat"))) |
| 743 | #else |
| 744 | # define compat_text_section .section ".text.compat", "ax"; |
| 745 | # define compat_data_section .section ".data.compat", "aw"; |
| 746 | #endif |
| 747 | |
| 748 | /* Helper / base macros for indirect function symbols. */ |
| 749 | #define __ifunc_resolver(type_name, name, expr, arg, init, classifier) \ |
| 750 | classifier inhibit_stack_protector void *name##_ifunc (arg) \ |
| 751 | { \ |
| 752 | init (); \ |
| 753 | __typeof (type_name) *res = expr; \ |
| 754 | return res; \ |
| 755 | } |
| 756 | |
| 757 | #ifdef HAVE_GCC_IFUNC |
| 758 | # define __ifunc(type_name, name, expr, arg, init) \ |
| 759 | extern __typeof (type_name) name __attribute__ \ |
| 760 | ((ifunc (#name "_ifunc"))); \ |
| 761 | __ifunc_resolver (type_name, name, expr, arg, init, static) |
| 762 | |
| 763 | # define __ifunc_hidden(type_name, name, expr, arg, init) \ |
| 764 | __ifunc (type_name, name, expr, arg, init) |
| 765 | #else |
| 766 | /* Gcc does not support __attribute__ ((ifunc (...))). Use the old behaviour |
| 767 | as fallback. But keep in mind that the debug information for the ifunc |
| 768 | resolver functions is not correct. It contains the ifunc'ed function as |
| 769 | DW_AT_linkage_name. E.g. lldb uses this field and an inferior function |
| 770 | call of the ifunc'ed function will fail due to "no matching function for |
| 771 | call to ..." because the ifunc'ed function and the resolver function have |
| 772 | different signatures. (Gcc support is disabled at least on a ppc64le |
| 773 | Ubuntu 14.04 system.) */ |
| 774 | |
| 775 | # define __ifunc(type_name, name, expr, arg, init) \ |
| 776 | extern __typeof (type_name) name; \ |
| 777 | void *name##_ifunc (arg) __asm__ (#name); \ |
| 778 | __ifunc_resolver (type_name, name, expr, arg, init,) \ |
| 779 | __asm__ (".type " #name ", %gnu_indirect_function"); |
| 780 | |
| 781 | # define __ifunc_hidden(type_name, name, expr, arg, init) \ |
| 782 | extern __typeof (type_name) __libc_##name; \ |
| 783 | __ifunc (type_name, __libc_##name, expr, arg, init) \ |
| 784 | strong_alias (__libc_##name, name); |
| 785 | #endif /* !HAVE_GCC_IFUNC */ |
| 786 | |
| 787 | /* The following macros are used for indirect function symbols in libc.so. |
| 788 | First of all, you need to have the function prototyped somewhere, |
| 789 | say in foo.h: |
| 790 | |
| 791 | int foo (int __bar); |
| 792 | |
| 793 | If you have an implementation for foo which e.g. uses a special hardware |
| 794 | feature which isn't available on all machines where this libc.so will be |
| 795 | used but decideable if available at runtime e.g. via hwcaps, you can provide |
| 796 | two or multiple implementations of foo: |
| 797 | |
| 798 | int __foo_default (int __bar) |
| 799 | { |
| 800 | return __bar; |
| 801 | } |
| 802 | |
| 803 | int __foo_special (int __bar) |
| 804 | { |
| 805 | return __bar; |
| 806 | } |
| 807 | |
| 808 | If your function foo has no libc_hidden_proto (foo) defined for PLT |
| 809 | bypassing, you can use: |
| 810 | |
| 811 | #define INIT_ARCH() unsigned long int hwcap = __GLRO(dl_hwcap); |
| 812 | |
| 813 | libc_ifunc (foo, (hwcap & HWCAP_SPECIAL) ? __foo_special : __foo_default); |
| 814 | |
| 815 | This will define a resolver function for foo which returns __foo_special or |
| 816 | __foo_default depending on your specified expression. Please note that you |
| 817 | have to define a macro function INIT_ARCH before using libc_ifunc macro as |
| 818 | it is called by the resolver function before evaluating the specified |
| 819 | expression. In this example it is used to prepare the hwcap variable. |
| 820 | The resolver function is assigned to an ifunc'ed symbol foo. Calls to foo |
| 821 | from inside or outside of libc.so will be indirected by a PLT call. |
| 822 | |
| 823 | If your function foo has a libc_hidden_proto (foo) defined for PLT bypassing |
| 824 | and calls to foo within libc.so should always go to one specific |
| 825 | implementation of foo e.g. __foo_default then you have to add: |
| 826 | |
| 827 | __hidden_ver1 (__foo_default, __GI_foo, __foo_default); |
| 828 | |
| 829 | or a tweaked definition of libc_hidden_def macro after the __foo_default |
| 830 | function definition. Calls to foo within libc.so will always go directly to |
| 831 | __foo_default. Calls to foo from outside libc.so will be indirected by a |
| 832 | PLT call to ifunc'ed symbol foo which you have to define in a separate |
| 833 | compile unit: |
| 834 | |
| 835 | #define foo __redirect_foo |
| 836 | #include <foo.h> |
| 837 | #undef foo |
| 838 | |
| 839 | extern __typeof (__redirect_foo) __foo_default attribute_hidden; |
| 840 | extern __typeof (__redirect_foo) __foo_special attribute_hidden; |
| 841 | |
| 842 | libc_ifunc_redirected (__redirect_foo, foo, |
| 843 | (hwcap & HWCAP_SPECIAL) |
| 844 | ? __foo_special |
| 845 | : __foo_default); |
| 846 | |
| 847 | This will define the ifunc'ed symbol foo like above. The redirection of foo |
| 848 | in header file is needed to omit an additional defintion of __GI_foo which |
| 849 | would end in a linker error while linking libc.so. You have to specify |
| 850 | __redirect_foo as first parameter which is used within libc_ifunc_redirected |
| 851 | macro in conjunction with typeof to define the ifunc'ed symbol foo. |
| 852 | |
| 853 | If your function foo has a libc_hidden_proto (foo) defined and calls to foo |
| 854 | within or from outside libc.so should go via ifunc'ed symbol, then you have |
| 855 | to use: |
| 856 | |
| 857 | libc_ifunc_hidden (foo, foo, |
| 858 | (hwcap & HWCAP_SPECIAL) |
| 859 | ? __foo_special |
| 860 | : __foo_default); |
| 861 | libc_hidden_def (foo) |
| 862 | |
| 863 | The first parameter foo of libc_ifunc_hidden macro is used in the same way |
| 864 | as for libc_ifunc_redirected macro. */ |
| 865 | |
| 866 | #define libc_ifunc(name, expr) __ifunc (name, name, expr, void, INIT_ARCH) |
| 867 | |
| 868 | #define libc_ifunc_redirected(redirected_name, name, expr) \ |
| 869 | __ifunc (redirected_name, name, expr, void, INIT_ARCH) |
| 870 | |
| 871 | #define libc_ifunc_hidden(redirected_name, name, expr) \ |
| 872 | __ifunc_hidden (redirected_name, name, expr, void, INIT_ARCH) |
| 873 | |
| 874 | /* The body of the function is supposed to use __get_cpu_features |
| 875 | which will, if necessary, initialize the data first. */ |
| 876 | #define libm_ifunc_init() |
| 877 | #define libm_ifunc(name, expr) \ |
| 878 | __ifunc (name, name, expr, void, libm_ifunc_init) |
| 879 | |
| 880 | /* Add the compiler optimization to inhibit loop transformation to library |
| 881 | calls. This is used to avoid recursive calls in memset and memmove |
| 882 | default implementations. */ |
| 883 | #ifdef HAVE_CC_INHIBIT_LOOP_TO_LIBCALL |
| 884 | # define inhibit_loop_to_libcall \ |
| 885 | __attribute__ ((__optimize__ ("-fno-tree-loop-distribute-patterns"))) |
| 886 | #else |
| 887 | # define inhibit_loop_to_libcall |
| 888 | #endif |
| 889 | |
| 890 | #endif /* libc-symbols.h */ |
| 891 | |