This is the mail archive of the libc-help@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: C Start-Up shared vs static


On Fri, 4 Dec 2009, Carlos O'Donell wrote:
> 
> Something is wrong with your cross-compilers sysroot. Normally the 
> sysroot contains $sysroot/usr/lib/libc.so and the libc.so references 
> libc_nonshared.a and that pulls in the required symbols.

Indeed, you are right:

$ cd /Volumes/cross/arm-none-linux/usr/lib
$ cat libc.so
/* GNU ld script
   Use the shared library, but some functions are only in
   the static library, so try that secondarily.  */
OUTPUT_FORMAT(elf32-littlearm)
GROUP ( /lib/libc.so.6 /usr/lib/libc_nonshared.a  AS_NEEDED ( /lib/ld-linux.so.2 ) )
$ arm-none-linux-nm -g libc_nonshared.a  | head -8

elf-init.oS:
         U _GLOBAL_OFFSET_TABLE_
         U __init_array_end
         U __init_array_start
00000000 T __libc_csu_fini
00000004 T __libc_csu_init
         U _init
$

> You should use a -Wl,-Map,linkermap.txt to see how this all works on
> another target, and compare.

I did on x86_64-redhat-linux, and it was instructive.  Actually, -v is 
also very instructive

$ arm-none-linux-gcc -v -march=armv5te -mtune=xscale -msoft-float  -o hello hello.o
[ ... ]
 /Volumes/cross/usr/libexec/gcc/arm-none-linux/4.3.3/collect2 
--sysroot=/Volumes/cross/arm-none-linux --eh-frame-hdr -dynamic-linker 
/lib/ld-linux.so.2 -X -m armelf_linux -p -o hello 
/Volumes/cross/usr/lib/gcc/arm-none-linux/4.3.3/../../../../arm-none-linux/lib/crt1.o 
/Volumes/cross/usr/lib/gcc/arm-none-linux/4.3.3/../../../../arm-none-linux/lib/crti.o 
/Volumes/cross/usr/lib/gcc/arm-none-linux/4.3.3/crtbegin.o 
-L/Volumes/cross/usr/lib/gcc/arm-none-linux/4.3.3 
-L/Volumes/cross/usr/lib/gcc/arm-none-linux/4.3.3/../../../../arm-none-linux/lib 
-L/Volumes/cross/arm-none-linux/lib 
-L/Volumes/cross/arm-none-linux/usr/lib
hello.o -ldl -lgcc --as-needed -lgcc_s --no-as-needed -lc -lgcc --as-needed -lgcc_s --no-as-needed 
/Volumes/cross/usr/lib/gcc/arm-none-linux/4.3.3/crtend.o 
/Volumes/cross/usr/lib/gcc/arm-none-linux/4.3.3/../../../../arm-none-linux/lib/crtn.o
[ ... ]

Inspired by what I read in the linker script /usr/lib/libc.so.6, I tried 
replacing "-lc" in the command line above with

/Volumes/cross/arm-none-linux/lib/libc.so.6 
/Volumes/cross/arm-none-linux/usr/lib/libc_nonshared.a
--as-needed 
/Volumes/cross/arm-none-linux/lib/ld-linux.so.2
--no-as-needed

This works, and builds an executable that runs on my target system.  So it 
would appear that all the binaries are in the right places, and contain 
the right bits, but the gcc driver routines aren't using them correctly.  
Could this be a problem in gcc specs?

-- 
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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]