Static linking with a custom glibc version
Szabolcs Nagy
szabolcs.nagy@arm.com
Thu Jun 4 10:33:41 GMT 2020
The 06/04/2020 09:33, Mahmood Naderan wrote:
> >just pass -static to the compiler so it knows what you want
> >
> >for custom glibc you want to pass -B path/to/crtfiles and
> >may be other things too.
>
> Excuse me, I didn't get the second sentence. Is this correct?
>
> $ gcc -c test.c
> $ gcc -o test -Wl,--emit-relocs -Wl,--rpath=/opt/glibc-2.23-install -Wl,--dynamic-linker=/opt/glibc-2.23-staticinstall/lib/ld-2.23.so -static test.o
>
> I now get a 1.3MB file (compared to 9.6KB when -static is not used). But I want to be sure that my custom glibc is embedded in the final binary file.
> You said that I have to use -B for this purpose?
this will link with the host libc crt files not the custom
libc ones. You need some combination of -B --sysroot -isystem
to static link with the custom libc.
you also dont need to use rpath and dynamic-linker options,
those are for dynamic linking only (and likely same for
emit-relocs)
so no, your build command is not correct.
IMPORTANT NOTICE: The contents of this email and any attachments are confidential and may also be privileged. If you are not the intended recipient, please notify the sender immediately and do not disclose the contents to any other person, use it for any purpose, or store or copy the information in any medium. Thank you.
More information about the Libc-help
mailing list