Static linking with a custom glibc version

Mahmood Naderan nt_mahmood@yahoo.com
Wed Jun 3 12:11:13 GMT 2020


Hi
    
I use the following command to link my simple C program to a custom glibc
$ gcc -c test.c 
$ gcc -o test -Wl,--emit-relocs \ 
      -Wl,--rpath=/opt/glibc-2.23-install \
      -Wl,--dynamic-linker=/opt/glibc-2.23-install/lib/ld-2.23.so \
      test.o

Then I see
$ ldd test
        linux-vdso.so.1 =>  (0x00007ffe4b17d000)
        libc.so.6 => /opt/glibc-2.23-install/libc.so.6 (0x00007f6348478000)
        /opt/glibc-2.23-install/lib/ld-2.23.so => /lib64/ld-linux-x86-64.so.2 (0x00007f6348819000)

Now, I want to build a static binary, but the following command are not correct
$ gcc -o test -Wl,--emit-relocs -l/opt/glibc-2.23-install/lib/ld-2.23.so test.o
or
$ gcc -o test -Wl,--emit-relocs \ 
      -Wl,--rpath=/opt/glibc-2.23-install \
      -Wl,--dynamic-linker=/opt/glibc-2.23-install/lib/ld-2.23.so \
      -Wl,-Bstatic test.o

Any way to fix that? 


Regards,
Mahmood


More information about the Libc-help mailing list