198
225
# ifdef HAVE_ASM_SET_DIRECTIVE
199
226
# ifdef HAVE_ASM_GLOBAL_DOT_NAME
200
# define strong_alias(original, alias) \
201
ASM_GLOBAL_DIRECTIVE C_SYMBOL_NAME (alias) ASM_LINE_SEP \
202
.set C_SYMBOL_NAME (alias),C_SYMBOL_NAME (original) ASM_LINE_SEP \
203
ASM_GLOBAL_DIRECTIVE C_SYMBOL_DOT_NAME (alias) ASM_LINE_SEP \
204
.set C_SYMBOL_DOT_NAME (alias),C_SYMBOL_DOT_NAME (original)
205
# define strong_data_alias(original, alias) \
206
ASM_GLOBAL_DIRECTIVE C_SYMBOL_NAME (alias) ASM_LINE_SEP \
207
.set C_SYMBOL_NAME (alias),C_SYMBOL_NAME (original)
227
# define strong_alias(original, alias) \
228
ASM_GLOBAL_DIRECTIVE C_SYMBOL_NAME(alias) ASM_LINE_SEP \
229
.set C_SYMBOL_NAME(alias),C_SYMBOL_NAME(original) ASM_LINE_SEP \
230
ASM_GLOBAL_DIRECTIVE C_SYMBOL_DOT_NAME(alias) ASM_LINE_SEP \
231
.set C_SYMBOL_DOT_NAME(alias),C_SYMBOL_DOT_NAME(original)
232
# define strong_data_alias(original, alias) \
233
ASM_GLOBAL_DIRECTIVE C_SYMBOL_NAME(alias) ASM_LINE_SEP \
234
.set C_SYMBOL_NAME(alias),C_SYMBOL_NAME(original)
209
# define strong_alias(original, alias) \
210
ASM_GLOBAL_DIRECTIVE C_SYMBOL_NAME (alias) ASM_LINE_SEP \
211
.set C_SYMBOL_NAME (alias),C_SYMBOL_NAME (original)
236
# define strong_alias(original, alias) \
237
ASM_GLOBAL_DIRECTIVE C_SYMBOL_NAME(alias) ASM_LINE_SEP \
238
.set C_SYMBOL_NAME(alias),C_SYMBOL_NAME(original)
212
239
# define strong_data_alias(original, alias) strong_alias(original, alias)
215
242
# ifdef HAVE_ASM_GLOBAL_DOT_NAME
216
# define strong_alias(original, alias) \
217
ASM_GLOBAL_DIRECTIVE C_SYMBOL_NAME (alias) ASM_LINE_SEP \
218
C_SYMBOL_NAME (alias) = C_SYMBOL_NAME (original) ASM_LINE_SEP \
219
ASM_GLOBAL_DIRECTIVE C_SYMBOL_DOT_NAME (alias) ASM_LINE_SEP \
220
C_SYMBOL_DOT_NAME (alias) = C_SYMBOL_DOT_NAME (original)
221
# define strong_data_alias(original, alias) \
222
ASM_GLOBAL_DIRECTIVE C_SYMBOL_NAME (alias) ASM_LINE_SEP \
223
C_SYMBOL_NAME (alias) = C_SYMBOL_NAME (original)
243
# define strong_alias(original, alias) \
244
ASM_GLOBAL_DIRECTIVE C_SYMBOL_NAME(alias) ASM_LINE_SEP \
245
C_SYMBOL_NAME(alias) = C_SYMBOL_NAME(original) ASM_LINE_SEP \
246
ASM_GLOBAL_DIRECTIVE C_SYMBOL_DOT_NAME(alias) ASM_LINE_SEP \
247
C_SYMBOL_DOT_NAME(alias) = C_SYMBOL_DOT_NAME(original)
248
# define strong_data_alias(original, alias) \
249
ASM_GLOBAL_DIRECTIVE C_SYMBOL_NAME(alias) ASM_LINE_SEP \
250
C_SYMBOL_NAME(alias) = C_SYMBOL_NAME(original)
225
# define strong_alias(original, alias) \
226
ASM_GLOBAL_DIRECTIVE C_SYMBOL_NAME (alias) ASM_LINE_SEP \
227
C_SYMBOL_NAME (alias) = C_SYMBOL_NAME (original)
252
# define strong_alias(original, alias) \
253
ASM_GLOBAL_DIRECTIVE C_SYMBOL_NAME(alias) ASM_LINE_SEP \
254
C_SYMBOL_NAME(alias) = C_SYMBOL_NAME(original)
228
255
# define strong_data_alias(original, alias) strong_alias(original, alias)
232
259
# ifdef HAVE_WEAK_SYMBOLS
233
260
# ifdef HAVE_ASM_WEAKEXT_DIRECTIVE
234
261
# ifdef HAVE_ASM_GLOBAL_DOT_NAME
235
# define weak_alias(original, alias) \
236
.weakext C_SYMBOL_NAME (alias), C_SYMBOL_NAME (original) ASM_LINE_SEP \
237
.weakext C_SYMBOL_DOT_NAME (alias), C_SYMBOL_DOT_NAME (original)
262
# define weak_alias(original, alias) \
263
.weakext C_SYMBOL_NAME(alias),C_SYMBOL_NAME(original) ASM_LINE_SEP \
264
.weakext C_SYMBOL_DOT_NAME(alias),C_SYMBOL_DOT_NAME(original)
239
# define weak_alias(original, alias) \
240
.weakext C_SYMBOL_NAME (alias), C_SYMBOL_NAME (original)
266
# define weak_alias(original, alias) \
267
.weakext C_SYMBOL_NAME(alias),C_SYMBOL_NAME(original)
242
# define weak_extern(symbol) \
243
.weakext C_SYMBOL_NAME (symbol)
269
# define weak_extern(symbol) \
270
.weakext C_SYMBOL_NAME(symbol)
245
272
# else /* ! HAVE_ASM_WEAKEXT_DIRECTIVE */
247
274
# ifdef HAVE_ASM_SET_DIRECTIVE
248
275
# ifdef HAVE_ASM_GLOBAL_DOT_NAME
249
# define weak_alias(original, alias) \
250
.weak C_SYMBOL_NAME (alias) ASM_LINE_SEP \
251
.set C_SYMBOL_NAME (alias), C_SYMBOL_NAME (original) ASM_LINE_SEP \
252
.weak C_SYMBOL_DOT_NAME (alias) ASM_LINE_SEP \
253
.set C_SYMBOL_DOT_NAME (alias), C_SYMBOL_DOT_NAME (original)
276
# define weak_alias(original, alias) \
277
.weak C_SYMBOL_NAME(alias) ASM_LINE_SEP \
278
.set C_SYMBOL_NAME(alias),C_SYMBOL_NAME(original) ASM_LINE_SEP \
279
.weak C_SYMBOL_DOT_NAME(alias) ASM_LINE_SEP \
280
.set C_SYMBOL_DOT_NAME(alias),C_SYMBOL_DOT_NAME(original)
255
# define weak_alias(original, alias) \
256
.weak C_SYMBOL_NAME (alias) ASM_LINE_SEP \
257
.set C_SYMBOL_NAME (alias), C_SYMBOL_NAME (original)
282
# define weak_alias(original, alias) \
283
.weak C_SYMBOL_NAME(alias) ASM_LINE_SEP \
284
.set C_SYMBOL_NAME(alias),C_SYMBOL_NAME(original)
259
286
# else /* ! HAVE_ASM_SET_DIRECTIVE */
260
287
# ifdef HAVE_ASM_GLOBAL_DOT_NAME
261
# define weak_alias(original, alias) \
262
.weak C_SYMBOL_NAME (alias) ASM_LINE_SEP \
263
C_SYMBOL_NAME (alias) = C_SYMBOL_NAME (original) ASM_LINE_SEP \
264
.weak C_SYMBOL_DOT_NAME (alias) ASM_LINE_SEP \
265
C_SYMBOL_DOT_NAME (alias) = C_SYMBOL_DOT_NAME (original)
288
# define weak_alias(original, alias) \
289
.weak C_SYMBOL_NAME(alias) ASM_LINE_SEP \
290
C_SYMBOL_NAME(alias) = C_SYMBOL_NAME(original) ASM_LINE_SEP \
291
.weak C_SYMBOL_DOT_NAME(alias) ASM_LINE_SEP \
292
C_SYMBOL_DOT_NAME(alias) = C_SYMBOL_DOT_NAME(original)
267
# define weak_alias(original, alias) \
268
.weak C_SYMBOL_NAME (alias) ASM_LINE_SEP \
269
C_SYMBOL_NAME (alias) = C_SYMBOL_NAME (original)
294
# define weak_alias(original, alias) \
295
.weak C_SYMBOL_NAME(alias) ASM_LINE_SEP \
296
C_SYMBOL_NAME(alias) = C_SYMBOL_NAME(original)
272
# define weak_extern(symbol) \
273
.weak C_SYMBOL_NAME (symbol)
299
# define weak_extern(symbol) \
300
.weak C_SYMBOL_NAME(symbol)
275
302
# endif /* ! HAVE_ASM_WEAKEXT_DIRECTIVE */
401
427
If versioned_symbol macro is used to define foo,
402
428
libc_hidden_ver macro should be used, as in:
404
int __real_foo (int __bar)
430
int __real_foo(int __bar) {
408
versioned_symbol (libc, __real_foo, foo, GLIBC_2_1);
409
libc_hidden_ver (__real_foo, foo) */
433
versioned_symbol(libc, __real_foo, foo, GLIBC_2_1);
434
libc_hidden_ver(__real_foo, foo)
411
437
/* uClibc specific (the above comment was copied from glibc):
412
* a. when ppc64 will be supported, we need changes to support:
439
* when ppc64 will be supported, we need changes to support
413
440
* strong_data_alias (used by asm hidden_data_def)
414
* b. libc_hidden_proto(foo) should be added after the header having foo's prototype
415
* or after extern foo... to all source files that should use the internal version
416
* of foo within libc, even to the file defining foo itself, libc_hidden_def does
417
* not hide __GI_foo itself, although the name suggests it (hiding is done exclusively
418
* by libc_hidden_proto). The reasoning to have it after the header w/ foo's prototype is
419
* to get first the __REDIRECT from original header and then create the __GI_foo alias
420
* c. no versioning support, hidden[_data]_ver are noop
421
* d. hidden_def() in asm is _hidden_strong_alias (not strong_alias) */
423
/* Arrange to hide uClibc internals */
424
#if (defined __GNUC__ && \
425
(defined __GNUC_MINOR__ && ( __GNUC__ >= 3 && __GNUC_MINOR__ >= 3 ) \
426
|| __GNUC__ >= 4)) || defined __ICC
442
* no versioning support, hidden[_data]_ver are noop
444
* hidden_def() in asm is _hidden_strong_alias (not strong_alias)
446
* libc_hidden_proto(foo) should be added after declaration
447
* in the header, or after extern foo... in all source files
448
* (this is discouraged).
449
* libc_hidden_def does not hide __GI_foo itself, although the name
450
* suggests it (hiding is done exclusively by libc_hidden_proto).
453
* The reasoning to have it after the header w/ foo's prototype is
454
* to get first the __REDIRECT from original header and then create
457
* Hunt for references which still go through PLT (example for x86):
458
* build shared lib, then disassemble it and search for <xxx@plt>:
459
* $ objdump -drx libuClibc-*.so >disasm.txt
460
* $ grep -F '@plt>:' disasm.txt
462
* In uclibc, malloc/free and related functions should be called
463
* through PLT (making it possible to use alternative malloc),
464
* and possibly some __pthread_xxx functions can be called through PLT
465
* (why?). The rest should not use PLT.
468
#if (defined __GNUC__ && defined __GNUC_MINOR__ \
469
&& (( __GNUC__ >= 3 && __GNUC_MINOR__ >= 3) || __GNUC__ >= 4) \
427
471
# define attribute_hidden __attribute__ ((visibility ("hidden")))
472
# define attribute_protected __attribute__ ((visibility ("protected")))
428
473
# define __hidden_proto_hiddenattr(attrs...) __attribute__ ((visibility ("hidden"), ##attrs))
430
475
# define attribute_hidden
476
# define attribute_protected
431
477
# define __hidden_proto_hiddenattr(attrs...)
434
480
#if /*!defined STATIC &&*/ !defined __BCC__
435
482
# ifndef __ASSEMBLER__
436
# define hidden_proto(name, attrs...) __hidden_proto (name, __GI_##name, ##attrs)
483
# define hidden_proto(name, attrs...) __hidden_proto(name, __GI_##name, ##attrs)
437
484
# define __hidden_proto(name, internal, attrs...) \
438
extern __typeof (name) name __asm__ (__hidden_asmname (#internal)) \
439
__hidden_proto_hiddenattr (attrs);
485
extern __typeof (name) name __asm__ (__hidden_asmname (#internal)) \
486
__hidden_proto_hiddenattr (attrs);
440
487
# define __hidden_asmname(name) __hidden_asmname1 (__USER_LABEL_PREFIX__, name)
441
488
# define __hidden_asmname1(prefix, name) __hidden_asmname2(prefix, name)
442
489
# define __hidden_asmname2(prefix, name) #prefix name
443
490
# define __hidden_ver1(local, internal, name) \
444
extern __typeof (name) __EI_##name __asm__(__hidden_asmname (#internal)); \
445
extern __typeof (name) __EI_##name __attribute__((alias (__hidden_asmname1 (,#local))))
491
extern __typeof (name) __EI_##name __asm__(__hidden_asmname (#internal)); \
492
extern __typeof (name) __EI_##name __attribute__((alias (__hidden_asmname1 (,#local))))
446
493
# define hidden_ver(local, name) __hidden_ver1(local, __GI_##name, name);
447
494
# define hidden_data_ver(local, name) hidden_ver(local, name)
448
495
# define hidden_def(name) __hidden_ver1(__GI_##name, name, name);
449
496
# define hidden_data_def(name) hidden_def(name)
450
# define hidden_weak(name) \
497
# define hidden_weak(name) \
451
498
__hidden_ver1(__GI_##name, name, name) __attribute__((weak));
452
499
# define hidden_data_weak(name) hidden_weak(name)
454
501
# else /* __ASSEMBLER__ */
455
# ifdef HAVE_ASM_SET_DIRECTIVE
456
# ifdef HAVE_ASM_GLOBAL_DOT_NAME
457
# define _hidden_strong_alias(original, alias) \
458
ASM_GLOBAL_DIRECTIVE C_SYMBOL_NAME (alias) ASM_LINE_SEP \
459
.hidden C_SYMBOL_NAME (alias) ASM_LINE_SEP \
460
.set C_SYMBOL_NAME (alias),C_SYMBOL_NAME (original) ASM_LINE_SEP \
461
ASM_GLOBAL_DIRECTIVE C_SYMBOL_DOT_NAME (alias) ASM_LINE_SEP \
462
.hidden C_SYMBOL_DOT_NAME (alias) ASM_LINE_SEP \
463
.set C_SYMBOL_DOT_NAME (alias),C_SYMBOL_DOT_NAME (original)
465
# define _hidden_strong_alias(original, alias) \
466
ASM_GLOBAL_DIRECTIVE C_SYMBOL_NAME (alias) ASM_LINE_SEP \
467
.hidden C_SYMBOL_NAME (alias) ASM_LINE_SEP \
468
.set C_SYMBOL_NAME (alias),C_SYMBOL_NAME (original)
471
# ifdef HAVE_ASM_GLOBAL_DOT_NAME
472
# define _hidden_strong_alias(original, alias) \
473
ASM_GLOBAL_DIRECTIVE C_SYMBOL_NAME (alias) ASM_LINE_SEP \
474
.hidden C_SYMBOL_NAME (alias) ASM_LINE_SEP \
475
C_SYMBOL_NAME (alias) = C_SYMBOL_NAME (original) ASM_LINE_SEP \
476
ASM_GLOBAL_DIRECTIVE C_SYMBOL_DOT_NAME (alias) ASM_LINE_SEP \
477
.hidden C_SYMBOL_DOT_NAME (alias) ASM_LINE_SEP \
478
C_SYMBOL_DOT_NAME (alias) = C_SYMBOL_DOT_NAME (original)
480
# define _hidden_strong_alias(original, alias) \
481
ASM_GLOBAL_DIRECTIVE C_SYMBOL_NAME (alias) ASM_LINE_SEP \
482
.hidden C_SYMBOL_NAME (alias) ASM_LINE_SEP \
483
C_SYMBOL_NAME (alias) = C_SYMBOL_NAME (original)
487
# ifdef HAVE_ASM_GLOBAL_DOT_NAME
488
# define _hidden_weak_alias(original, alias) \
489
.hidden C_SYMBOL_NAME (alias) ASM_LINE_SEP \
490
.hidden C_SYMBOL_DOT_NAME (alias) ASM_LINE_SEP \
491
weak_alias(original, alias)
493
# define _hidden_weak_alias(original, alias) \
494
.hidden C_SYMBOL_NAME (alias) ASM_LINE_SEP \
495
weak_alias(original, alias)
503
# ifdef HAVE_ASM_SET_DIRECTIVE
504
# ifdef HAVE_ASM_GLOBAL_DOT_NAME
505
# define _hidden_strong_alias(original, alias) \
506
ASM_GLOBAL_DIRECTIVE C_SYMBOL_NAME(alias) ASM_LINE_SEP \
507
.hidden C_SYMBOL_NAME(alias) ASM_LINE_SEP \
508
.set C_SYMBOL_NAME(alias),C_SYMBOL_NAME(original) ASM_LINE_SEP \
509
ASM_GLOBAL_DIRECTIVE C_SYMBOL_DOT_NAME(alias) ASM_LINE_SEP \
510
.hidden C_SYMBOL_DOT_NAME(alias) ASM_LINE_SEP \
511
.set C_SYMBOL_DOT_NAME(alias),C_SYMBOL_DOT_NAME(original)
513
# define _hidden_strong_alias(original, alias) \
514
ASM_GLOBAL_DIRECTIVE C_SYMBOL_NAME(alias) ASM_LINE_SEP \
515
.hidden C_SYMBOL_NAME(alias) ASM_LINE_SEP \
516
.set C_SYMBOL_NAME(alias),C_SYMBOL_NAME(original)
518
# else /* dont have .set directive */
519
# ifdef HAVE_ASM_GLOBAL_DOT_NAME
520
# define _hidden_strong_alias(original, alias) \
521
ASM_GLOBAL_DIRECTIVE C_SYMBOL_NAME(alias) ASM_LINE_SEP \
522
.hidden C_SYMBOL_NAME(alias) ASM_LINE_SEP \
523
C_SYMBOL_NAME(alias) = C_SYMBOL_NAME(original) ASM_LINE_SEP \
524
ASM_GLOBAL_DIRECTIVE C_SYMBOL_DOT_NAME(alias) ASM_LINE_SEP \
525
.hidden C_SYMBOL_DOT_NAME(alias) ASM_LINE_SEP \
526
C_SYMBOL_DOT_NAME(alias) = C_SYMBOL_DOT_NAME(original)
528
# define _hidden_strong_alias(original, alias) \
529
ASM_GLOBAL_DIRECTIVE C_SYMBOL_NAME(alias) ASM_LINE_SEP \
530
.hidden C_SYMBOL_NAME(alias) ASM_LINE_SEP \
531
C_SYMBOL_NAME(alias) = C_SYMBOL_NAME(original)
535
# ifdef HAVE_ASM_GLOBAL_DOT_NAME
536
# define _hidden_weak_alias(original, alias) \
537
.hidden C_SYMBOL_NAME(alias) ASM_LINE_SEP \
538
.hidden C_SYMBOL_DOT_NAME(alias) ASM_LINE_SEP \
539
weak_alias(original, alias)
541
# define _hidden_weak_alias(original, alias) \
542
.hidden C_SYMBOL_NAME(alias) ASM_LINE_SEP \
543
weak_alias(original, alias)
498
546
/* For assembly, we need to do the opposite of what we do in C: