Static linking of a custom glibc

Mahmood Naderan nt_mahmood@yahoo.com
Wed Jun 3 12:44:03 GMT 2020


Hi
I would like to statically link my program to a custom glibc version. As you can see below, the following commands are wrong.

$ gcc -c test.c && gcc -o test -Wl,--emit-relocs /opt/glibc-2.23-install/lib/libc.a test.o
/usr/bin/ld: dynamic STT_GNU_IFUNC symbol `strcmp' with pointer equality in `/opt/glibc-2.23-install/lib/libc.a(strcmp.o)' can not be used when making an executable; recompile with -fPIE and relink with -pie
collect2: error: ld returned 1 exit status


$ gcc -fPIE -c test.c && gcc -o test -pie -Wl,--emit-relocs /opt/glibc-2.23-install/lib/libc.a test.o
/usr/bin/ld: /opt/glibc-2.23-install/lib/libc.a(libc-start.o): relocation R_X86_64_32 against `_dl_starting_up' can not be used when making a shared object; recompile with -fPIC
/opt/glibc-2.23-install/lib/libc.a: error adding symbols: Bad value
collect2: error: ld returned 1 exit status


$ gcc -fPIC -c test.c && gcc -o test -pie -Wl,--emit-relocs /opt/glibc-2.23-install/lib/libc.a test.o
/usr/bin/ld: /opt/glibc-2.23-install/lib/libc.a(libc-start.o): relocation R_X86_64_32 against `_dl_starting_up' can not be used when making a shared object; recompile with -fPIC
/opt/glibc-2.23-install/lib/libc.a: error adding symbols: Bad value
collect2: error: ld returned 1 exit status



Regards,
Mahmood


More information about the Gcc-help mailing list