gcc 64bit libc.a not compile with -fPIC
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
gcc-4.7 (Ubuntu) |
Invalid
|
Undecided
|
Unassigned |
Bug Description
I have problem link libgcc into a static linked .so
it only happens when linking 64bit module with `-m64`
Ubuntu 64bit 12.10 gcc 4.7
also failed on Ubuntu 64bit 12.04 gcc 4.6
32bit no problem
$gcc -fPIC -c -o hello.o hello.c -m32
$gcc -shared -m32 hello.o -o libhello.so -static-libgcc -Wl,-Bstatic -lc
$ ldd libhello.so
statically linked
64bit failed
$ make
gcc -fPIC -c -o hello.o hello.c
gcc -shared -m64 hello.o -o libhello.so -static-libgcc -Wl,-Bstatic -lc
/usr/bin/ld: /usr/lib/
/usr/
collect2: error: ld returned 1 exit status
make: *** [libhello.so] Error 1
hello.c
#include <stdio.h>
int f(){
FILE *out = fopen("/tmp/x.log", "wb");
fclose(out);
return 1;
}
Makefile
all: libhello.so
libhello.so: hello.o
gcc -shared -m64 hello.o -o libhello.so -static-libgcc -Wl,-Bstatic -lc
hello.o: hello.c
gcc -fPIC -c -o hello.o hello.c
clean:
rm -f hello.o libhello.so
affects: | ubuntu → gcc-4.7 (Ubuntu) |
i first asked this on stackoverflow
http:// stackoverflow. com/questions/ 15072196/ why-cant- link-64bit- static- libgcc- on-ubuntu
but now i think it might be something wrong with libc.a on ubuntu