[uClibc 0000867]: Undefined references to _dl_app_fini_array and _dl_app_init_array when trying to link statically with uclibc

bugs at busybox.net bugs at busybox.net
Mon May 8 14:04:59 UTC 2006


A NOTE has been added to this issue. 
====================================================================== 
http://busybox.net/bugs/view.php?id=867 
====================================================================== 
Reported By:                blurgk
Assigned To:                uClibc
====================================================================== 
Project:                    uClibc
Issue ID:                   867
Category:                   Architecture Specific
Reproducibility:            always
Severity:                   major
Priority:                   normal
Status:                     assigned
====================================================================== 
Date Submitted:             05-05-2006 02:15 PDT
Last Modified:              05-08-2006 07:04 PDT
====================================================================== 
Summary:                    Undefined references to _dl_app_fini_array and
_dl_app_init_array when trying to link statically with uclibc
Description: 
I get undefined references when I try to link a program statically to
uclibc:

$ cat test.c 
#include <stdio.h>

int main (void)
{
        printf ("Hello\n");
        return 0;
}

$ arm-linux-gcc test.c -o test -static
/usr/src/buildroot-20060308/build_arm/staging_dir/lib/gcc/arm-linux-uclibc/3.4.5/../../../../arm-linux-uclibc/lib/libc.a(__uClibc_main.os):
In function `__GI___uClibc_fini':
__uClibc_main.c:(.text+0x13c): undefined reference to
`_dl_app_fini_array'
/usr/src/buildroot-20060308/build_arm/staging_dir/lib/gcc/arm-linux-uclibc/3.4.5/../../../../arm-linux-uclibc/lib/libc.a(__uClibc_main.os):
In function `__uClibc_main':
__uClibc_main.c:(.text+0x2e0): undefined reference to
`_dl_app_init_array'
collect2: ld returned 1 exit status

====================================================================== 

---------------------------------------------------------------------- 
 psm - 05-05-06 03:59  
---------------------------------------------------------------------- 
run gcc w/ -v and provide that output, your toolchain seems to work
incorrectly
_dl_app_*_array does not have to be in libc.a (only in libc.so) and
shouldn't
be used for static linking. readelf -s libc.a | more, search for
__uClibc_main
and see if _dl_app_*_array appear there (and see if __uClibc_main.os or
.oS was
added to the archive) 

---------------------------------------------------------------------- 
 blurgk - 05-08-06 05:03  
---------------------------------------------------------------------- 
Thanks for your help.

$ arm-linux-gcc -v
Reading specs from
/usr/src/buildroot-20060308/build_arm/staging_dir/lib/gcc/arm-linux-uclibc/3.4.5/specs
Configured with:
/usr/src/buildroot-20060308/toolchain_build_arm/gcc-3.4.5/configure
--prefix=/usr/src/buildroot-20060308/build_arm/staging_dir
--build=i386-pc-cygwin --host=i386-pc-cygwin --target=arm-linux-uclibc
--enable-languages=c,c++ --enable-shared --disable-__cxa_atexit
--enable-target-optspace --with-gnu-ld --disable-nls --disable-threads
--enable-multilib
Thread model: single
gcc version 3.4.5

Readelf tells me that _dl_app_init_array and _dl_app_fini_array are in
libc.a, and yes __uClibc_main.os was added the archive. 

---------------------------------------------------------------------- 
 psm - 05-08-06 05:31  
---------------------------------------------------------------------- 
those shouldn't be in __uClibc_main.os (only in __uClibc_main.oS and it
can
happen only if that file was compiled w/ -DSHARED (that is incorrect,
probably
your toolchain -cygwin? added that?) 

---------------------------------------------------------------------- 
 blurgk - 05-08-06 05:58  
---------------------------------------------------------------------- 
If I delete __uClibc_main.os in libc/misc/internals and rebuild uClibc from
its main directory (just 'make') it works and the symbols are not included.
How could I check my toolchain for this, where is it defined?

Actually I get the same kind of errors with pthread:
/usr/src/buildroot-20060308/build_arm/staging_dir/lib/gcc/arm-linux-uclibc/3.4.5/../../../../arm-linux-uclibc/lib/libc.a(libc_pthread_init.os):
In function `__libc_pthread_init':
libc_pthread_init.c:(.text+0x30): undefined reference to
`__libc_pthread_functions'
/usr/src/buildroot-20060308/build_arm/staging_dir/lib/gcc/arm-linux-uclibc/3.4.5/../../../../arm-linux-uclibc/lib/libc.a(__uClibc_main.os):
In function `__GI___uClibc_fini':
__uClibc_main.c:(.text+0x13c): undefined reference to
`_dl_app_fini_array'
/usr/src/buildroot-20060308/build_arm/staging_dir/lib/gcc/arm-linux-uclibc/3.4.5/../../../../arm-linux-uclibc/lib/libc.a(__uClibc_main.os):
In function `__uClibc_main':
__uClibc_main.c:(.text+0x2e0): undefined reference to
`_dl_app_init_array'
/usr/src/buildroot-20060308/build_arm/staging_dir/lib/gcc/arm-linux-uclibc/3.4.5/../../../../arm-linux-uclibc/lib/libc.a(rpc_thread.os):
In function `__rpc_thread_destroy':
rpc_thread.c:(.text+0xd0): undefined reference to
`__libc_pthread_functions'
/usr/src/buildroot-20060308/build_arm/staging_dir/lib/gcc/arm-linux-uclibc/3.4.5/../../../../arm-linux-uclibc/lib/libc.a(rpc_thread.os):
In function `rpc_thread_multi':
rpc_thread.c:(.text+0x12c): undefined reference to
`__libc_pthread_functions'
/usr/src/buildroot-20060308/build_arm/staging_dir/lib/gcc/arm-linux-uclibc/3.4.5/../../../../arm-linux-uclibc/lib/libc.a(rpc_thread.os):
In function `__rpc_thread_variables':
rpc_thread.c:(.text+0x27c): undefined reference to
`__libc_pthread_functions'
collect2: ld returned 1 exit status

(only this after libc.a is fixed:)
/usr/src/buildroot-20060308/build_arm/staging_dir/lib/gcc/arm-linux-uclibc/3.4.5/../../../../arm-linux-uclibc/lib/libc.a(libc_pthread_init.os):
In function `__libc_pthread_init':
libc_pthread_init.c:(.text+0x30): undefined reference to
`__libc_pthread_functions'
/usr/src/buildroot-20060308/build_arm/staging_dir/lib/gcc/arm-linux-uclibc/3.4.5/../../../../arm-linux-uclibc/lib/libc.a(rpc_thread.os):
In function `__rpc_thread_destroy':
rpc_thread.c:(.text+0xd0): undefined reference to
`__libc_pthread_functions'
/usr/src/buildroot-20060308/build_arm/staging_dir/lib/gcc/arm-linux-uclibc/3.4.5/../../../../arm-linux-uclibc/lib/libc.a(rpc_thread.os):
In function `rpc_thread_multi':
rpc_thread.c:(.text+0x12c): undefined reference to
`__libc_pthread_functions'
/usr/src/buildroot-20060308/build_arm/staging_dir/lib/gcc/arm-linux-uclibc/3.4.5/../../../../arm-linux-uclibc/lib/libc.a(rpc_thread.os):
In function `__rpc_thread_variables':
rpc_thread.c:(.text+0x27c): undefined reference to
`__libc_pthread_functions' 

---------------------------------------------------------------------- 
 psm - 05-08-06 06:39  
---------------------------------------------------------------------- 
__libc_pthread_functions missing is the same, the file was compiled w/
-DSHARED
you can add make V=1 to make the compile lines visible or run CC="your-gcc
-v" to see more, I have no idea where -DSHARED crept in 

---------------------------------------------------------------------- 
 blurgk - 05-08-06 07:04  
---------------------------------------------------------------------- 
Yes, I had to rebuild rpc_thread.os and libc_pthread_init.os the same way
to have working static libraries (libc.a and libpthread.a). So there would
be a difference between running make in the uClibc directory and when
buildroot runs make. 

Issue History 
Date Modified   Username       Field                    Change               
====================================================================== 
05-05-06 02:15  blurgk         New Issue                                    
05-05-06 02:15  blurgk         Status                   new => assigned     
05-05-06 02:15  blurgk         Assigned To               => uClibc          
05-05-06 03:59  psm            Note Added: 0001346                          
05-08-06 05:03  blurgk         Note Added: 0001355                          
05-08-06 05:31  psm            Note Added: 0001356                          
05-08-06 05:58  blurgk         Note Added: 0001357                          
05-08-06 06:39  psm            Note Added: 0001358                          
05-08-06 07:04  blurgk         Note Added: 0001359                          
======================================================================




More information about the uClibc-cvs mailing list