commit ad1cd43a86 eliminated
preprocessor-level omission of references to the init/fini array
symbols from object files going into libc.so. the references are weak,
and the intent was that the linker would resolve them to zero in
libc.so, but instead it leaves undefined references that could be
satisfied at runtime. normally these references would be harmless,
since the code using them does not even get executed, but some older
binutils versions produce a linking error: when linking a program
against libc.so, ld first tries to use the hidden init/fini array
symbols produced by the linker script to satisfy the references in
libc.so, then produces an error because the definitions are hidden.
ideally ld would have already provided definitions of these symbols
when linking libc.so, but the linker script for -shared omits them.
to avoid this situation, the dynamic linker now provides its own dummy
definitions of the init/fini array symbols for libc.so. since they are
hidden, everything binds at ld time and no references remain in the
dynamic symbol table. with modern binutils and --gc-sections, both
the dummy empty array objects and the code referencing them get
dropped at link time, anyway.
the _init and _fini symbols are also switched back to using weak
definitions rather than weak references since the latter behave
somewhat problematically in general, and the weak definition approach
was known to work well.
28 lines
1.0 KiB
C
28 lines
1.0 KiB
C
/* This file is only used if enabled in the build system, in which case it is
|
|
* included automatically via command line options. It is not included
|
|
* explicitly by any source files or other headers. Its purpose is to
|
|
* override default visibilities to reduce the size and performance costs
|
|
* of position-independent code. */
|
|
|
|
#ifndef CRT
|
|
|
|
/* Conceptually, all symbols should be protected, but some toolchains
|
|
* fail to support copy relocations for protected data, so exclude all
|
|
* exported data symbols. */
|
|
|
|
__attribute__((__visibility__("default")))
|
|
extern struct _IO_FILE *const stdin, *const stdout, *const stderr;
|
|
|
|
__attribute__((__visibility__("default")))
|
|
extern int optind, opterr, optopt, optreset, __optreset, getdate_err, h_errno, daylight, __daylight, signgam, __signgam;
|
|
|
|
__attribute__((__visibility__("default")))
|
|
extern long timezone, __timezone;
|
|
|
|
__attribute__((__visibility__("default")))
|
|
extern char *optarg, **environ, **__environ, *tzname[2], *__tzname[2], *__progname, *__progname_full;
|
|
|
|
#pragma GCC visibility push(protected)
|
|
|
|
#endif
|