BusyBox Bug and Patch Tracking
BusyBox
  

Viewing Issue Simple Details Jump to Notes ] View Advanced ] Issue History ] Print ]
ID Category Severity Reproducibility Date Submitted Last Update
0000867 [uClibc] Architecture Specific major always 05-05-06 02:15 05-08-06 20:20
Reporter blurgk View Status public  
Assigned To uClibc
Priority normal Resolution won't fix  
Status closed   Product Version
Summary 0000867: 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
Additional Information
Attached Files

- Relationships

- Notes
(0001346)
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)
 
(0001355)
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.
 
(0001356)
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?)
 
(0001357)
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'
 
(0001358)
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
 
(0001359)
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.
 
(0001360)
psm
05-08-06 07:15

for sure not buildroot is adding this (checked on 20060327 version), I am sure
that something from your cygwin env is doing it.
 
(0001362)
vapier
05-08-06 20:20

cygwin's inability to recognize case difference is your problem

both libc_pthread_init.oS and libc_pthread_init.os need to be generated but since cygwin thinks these are the same file, one clobbers the other

solution: dont use cygwin, use colinux
 

- 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
05-08-06 07:15 psm Note Added: 0001360
05-08-06 20:20 vapier Note Added: 0001362
05-08-06 20:20 vapier Status assigned => closed
05-08-06 20:20 vapier Resolution open => won't fix


Copyright © 2000 - 2006 Mantis Group
Powered by Mantis Bugtracker