loader path when using a custom glibc

Liviu Ionescu ilg@livius.net
Sun May 10 07:42:22 GMT 2020


I tried to build a standalone gcc in a separate sysroot folder, including a custom glibc.

The build went fine, but the result is not as standalone as I would like, because the resulting elfs still invoke the system loader, and thus use the system libraries, instead of the new glibc.

If I patch the resulting elf and change the loader, it runs properly, with the new glibc shared libraries, but this is not really an option, since I need to use the new compiler in automated builds, where I cannot insert the extra patchelf line.

A -v at link time revealed that gcc still calls collect2 with the system loader `-dynamic-linker /lib64/ld-linux-x86-64.so.2`, and this is passed into the elf.

I tried to apply some patches to gcc, to change the loader path, and I also tried to apply some patches to binutils/ld, to adjust the path to the loader, but they were not very fortunate, since they triggered other errors.

In my opinion, when gcc invokes collect2, if in a sysroot configuration, it should concatenate the sysroot path with the current system loader path, and adjust -dynamic-linker accordingly.

Any thoughts on this?


More information about the Gcc-help mailing list