Hi,

gcc with the -fpic option optimize code like :
__attribute__ ((visibility ("hidden")))
# define weak_function __attribute__ ((weak))

extern void weak_function _stdio_init(void) attribute_hidden;


int main()
{
      if (_stdio_init)
              _stdio_init();

      return 0;
}

to

__attribute__ ((visibility ("hidden")))
# define weak_function __attribute__ ((weak))

extern void weak_function _stdio_init(void) attribute_hidden;


int main()
{
              _stdio_init();

      return 0;
}
This crash if _stdio_init is null (because the linker didn't put it)
Without this patch, it is impossible to static link default config uClibc on 
x86.

diff --git a/libc/misc/internals/__uClibc_main.c 
b/libc/misc/internals/__uClibc_main.c
index 15f49f0..3c52673 100644
--- a/libc/misc/internals/__uClibc_main.c
+++ b/libc/misc/internals/__uClibc_main.c
@@ -68,9 +68,9 @@ extern int *weak_const_function __errno_location(void);
 extern int *weak_const_function __h_errno_location(void);
 //libc_hidden_proto(__h_errno_location)
 
-extern void weak_function _stdio_init(void) attribute_hidden;
+extern void weak_function _stdio_init(void);
 #ifdef __UCLIBC_HAS_LOCALE__
-extern void weak_function _locale_init(void) attribute_hidden;
+extern void weak_function _locale_init(void);
 #endif
 #ifdef __UCLIBC_HAS_THREADS__
 extern void weak_function __pthread_initialize_minimal(void);
diff --git a/libc/stdlib/_atexit.c b/libc/stdlib/_atexit.c
index 0d420d3..7538957 100644
--- a/libc/stdlib/_atexit.c
+++ b/libc/stdlib/_atexit.c
@@ -303,7 +303,7 @@ void __exit_handler(int status)
 #endif
 
 #ifdef L_exit
-extern void weak_function _stdio_term(void) attribute_hidden;
+extern void weak_function _stdio_term(void);
 attribute_hidden void (*__exit_cleanup) (int) = 0;
 __UCLIBC_MUTEX_INIT(__atexit_lock, PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP);
 
diff --git a/libc/stdlib/abort.c b/libc/stdlib/abort.c
index 3cc7963..1cf0679 100644
--- a/libc/stdlib/abort.c
+++ b/libc/stdlib/abort.c
@@ -37,7 +37,7 @@ Cambridge, MA 02139, USA.  */
 #endif
 
 #ifdef __UCLIBC_HAS_STDIO_SHUTDOWN_ON_ABORT__
-extern void weak_function _stdio_term(void) attribute_hidden;
+extern void weak_function _stdio_term(void);
 #endif
 static smallint been_there_done_that = 0;
 
_______________________________________________
uClibc mailing list
[email protected]
http://lists.busybox.net/mailman/listinfo/uclibc

Reply via email to