diff options
-rw-r--r-- | include/features.h | 29 | ||||
-rw-r--r-- | libc/misc/internals/__uClibc_main.c | 35 |
2 files changed, 42 insertions, 22 deletions
diff --git a/include/features.h b/include/features.h index 22795e0b3..562dca91f 100644 --- a/include/features.h +++ b/include/features.h @@ -333,28 +333,31 @@ /* Some nice features only work properly with ELF */ #if defined _LIBC && defined HAVE_ELF +/* Define ALIASNAME as a weak alias for NAME. */ # define weak_alias(name, aliasname) _weak_alias (name, aliasname) +# define _weak_alias(name, aliasname) \ + extern __typeof (name) aliasname __attribute__ ((weak, alias (#name))); +/* Define ALIASNAME as a strong alias for NAME. */ +# define strong_alias(name, aliasname) _strong_alias(name, aliasname) +# define _strong_alias(name, aliasname) \ + extern __typeof (name) aliasname __attribute__ ((alias (#name))); +/* This comes between the return type and function name in + * a function definition to make that definition weak. */ +# define weak_function __attribute__ ((weak)) +/* Tacking on "\n\t#" to the section name makes gcc put it's bogus + * section attributes on what looks like a comment to the assembler. */ # define link_warning(symbol, msg) \ asm (".section " ".gnu.warning." #symbol "\n\t.previous"); \ static const char __evoke_link_warning_##symbol[] \ __attribute__ ((section (".gnu.warning." #symbol "\n\t#"))) = msg; -# define _weak_alias(name, aliasname) \ - extern __typeof (name) aliasname __attribute__ ((weak, alias (#name))); -/* -# define _weak_alias(name, aliasname) \ - asm(".global " C_SYMBOL_PREFIX #name ";" \ - ".weak " C_SYMBOL_PREFIX #aliasname ";" \ - C_SYMBOL_PREFIX #aliasname "=" C_SYMBOL_PREFIX #name ";"); -*/ -# define weak_symbol(name) \ - asm(".weak " C_SYMBOL_PREFIX #name ";"); #else -# define weak_alias(name, aliasname) _weak_alias (name, aliasname) +# define strong_alias(name, aliasname) _strong_alias (name, aliasname) +# define weak_alias(name, aliasname) _strong_alias (name, aliasname) +# define _strong_alias(name, aliasname) \ + __asm__(".global _" #aliasname "\n.set _" #aliasname ",_" #name); # define link_warning(symbol, msg) \ asm (".stabs \"" msg "\",30,0,0,0\n\t" \ ".stabs \"" #symbol "\",1,0,0,0\n"); -# define _weak_alias(name, aliasname) \ - __asm__(".global _" #aliasname "\n.set _" #aliasname ",_" #name); #endif /* --- this is added to integrate linuxthreads */ diff --git a/libc/misc/internals/__uClibc_main.c b/libc/misc/internals/__uClibc_main.c index ad17d7940..b6addb9c8 100644 --- a/libc/misc/internals/__uClibc_main.c +++ b/libc/misc/internals/__uClibc_main.c @@ -19,19 +19,22 @@ */ extern int main(int argc, char **argv, char **envp); -extern void __uClibc_empty_func(void); void __uClibc_main(int argc, char **argv, char **envp) __attribute__ ((__noreturn__)); + + #ifdef HAVE_ELF weak_alias(__environ, environ); -weak_symbol(__init_stdio); -weak_symbol(__stdio_close_all); -#endif - +extern void weak_function __init_stdio(void); +extern void weak_function __stdio_close_all(void); +extern void weak_function __pthread_initialize_minimal (void); +#else extern void __init_stdio(void); extern void __stdio_close_all(void); +extern void __pthread_initialize_minimal (void); +#endif typedef void (*vfuncp) (void); vfuncp __uClibc_cleanup = __stdio_close_all; @@ -47,6 +50,19 @@ void __uClibc_main(int argc, char **argv, char **envp) */ __environ = envp; + /* Initialize the thread library at least a bit so at least + * errno will be properly setup */ + if (__pthread_initialize_minimal) + __pthread_initialize_minimal (); + +#if 0 + /* Some security at this point. Prevent starting a SUID binary + * where the standard file descriptors are not opened. We have + * to do this only for statically linked applications since + * otherwise the dynamic loader did the work already. */ + if (__builtin_expect (__libc_enable_secure, 0)) + __libc_check_standard_fds (); +#endif /* * Initialize stdio here. In the static library case, this will * be bypassed if not needed because of the weak alias above. @@ -85,11 +101,12 @@ char **__environ = 0; * NOTE!!! This is only true for the _static_ case!!! */ +weak_alias(__environ, environ); +#if 0 void __uClibc_empty_func(void) { } - -weak_alias(__environ, environ); -/*weak_alias(__uClibc_empty_func, __init_stdio);*/ -/*weak_alias(__uClibc_empty_func, __stdio_close_all);*/ +weak_alias(__uClibc_empty_func, __init_stdio); +weak_alias(__uClibc_empty_func, __stdio_close_all); +#endif #endif |