C Start-Up shared vs static

Charles Coldwell coldwell@frank.harvard.edu
Fri Dec 4 13:48:00 GMT 2009


                                                                                                                                            
I built glibc-2.8 for an arm-none-linux host using a gcc-4.3                                                                                
cross-compiler on a i386-apple-darwin9 host.  When I try to build                                                                           
executables, the following two symbols are unresolved:                                                                                      
                                                                                                                                            
/Volumes/cross/usr/lib/gcc/arm-none-linux/4.3.3/../../../../arm-none-linux/lib/crt1.o:                                                      
In function `_start':                                                                                                                       
init.c:(.text+0x2c): undefined reference to `__libc_csu_fini'                                                                               
init.c:(.text+0x34): undefined reference to `__libc_csu_init'                                                                               
                                                                                                                                            
I traced this down to the following.  The actual references to these                                                                        
symbols occur in                                                                                                                            
                                                                                                                                            
glibc-ports-2.8/sysdeps/arm/elf/start.S                                                                                                     
                                                                                                                                            
which just loads their addresses into some registers in preparation for                                                                     
calling __libc_start_main.                                                                                                                  
                                                                                                                                            
The symbols are defined in                                                                                                                  
                                                                                                                                            
glibc-2.8/csu/elf-init.c                                                                                                                    
                                                                                                                                            
but this file is not included in the shared library /lib/libc-2.8.so                                                                        
because of line 33 of glibc-2.8/csu/Makefile which contains                                                                                 
                                                                                                                                            
static-only-routines = elf-init                                                                                                             
                                                                                                                                            
IOW, the definitions of __libc_csu_fini and __libc_csu_init are only                                                                        
included in /usr/lib/libc.a                                                                                                                 
                                                                                                                                            
$ arm-none-linux-nm -g libc.a | egrep __libc_csu_                                                                                           
00000000 T __libc_csu_fini                                                                                                                  
00000040 T __libc_csu_init                                                                                                                  
                                                                                                                                            
but not in /lib/libc-2.8.so                                                                                                                 
                                                                                                                                            
$ arm-none-linux-nm -g libc-2.8.so | grep __libc_csu_                                                                                       
$                                                                                                                                           
                                                                                                                                            
So it seems to me there is a problem with including                                                                                         
                                                                                                                                            
glibc-ports-2.8/sysdeps/arm/elf/start.S                                                                                                     
                                                                                                                                            
in both the shared and static libraries but including                                                                                       
                                                                                                                                            
glibc-2.8/csu/elf-init.c                                                                                                                    
                                                                                                                                            
in only the static library.  What is the correct thing to do in this                                                                        
situation?                                                                                                                                  

-- 
Charles M. Coldwell, W1CMC
"Turn on, log in, tune out"
Winchester, Massachusetts, New England (FN42kk)

GPG ID:  852E052F
GPG FPR: 77E5 2B51 4907 F08A 7E92  DE80 AFA9 9A8F 852E 052F



More information about the Libc-help mailing list