how to link with old versions of glibc?

Szabolcs Nagy szabolcs.nagy@arm.com
Thu May 21 07:01:07 GMT 2020


The 05/20/2020 16:50, Florian Weimer via Libc-help wrote:
> * Paul Zimmermann:
>
> >        Dear Florian,
> >
> > thank you for your answer. In fact any solution that works (statically or
> > dynamically) is fine for my application.
>
> See the instructions here:
>
>   <https://sourceware.org/glibc/wiki/Testing/Builds#Compile_against_glibc_build_tree>
>
> I'm not sure if this actually works, I would have expected some -L
> arguments as well, so maybe this:
>
> gcc \
>   -Wl,-rpath=${GLIBC}:\
> ${GLIBC}/math:\
> ${GLIBC}/elf:\
> ${GLIBC}/dlfcn:\
> ${GLIBC}/nss:\
> ${GLIBC}/nis:\
> ${GLIBC}/rt:\
> ${GLIBC}/resolv:\
> ${GLIBC}/crypt:\
> ${GLIBC}/nptl:\
> ${GLIBC}/dfp \
> -L ${GLIBC} \
> -L ${GLIBC}/math \
> -L ${GLIBC}/elf \
> -L ${GLIBC}/dlfcn \
> -L ${GLIBC}/nss \
> -L ${GLIBC}/nis \
> -L ${GLIBC}/rt \
> -L ${GLIBC}/resolv \
> -L ${GLIBC}/crypt \
> -L ${GLIBC}/nptl \
> -L ${GLIBC}/dfp \
>   -Wl,--dynamic-linker=${GLIBC}/elf/ld.so \
>>
> Does this help?

note that for crt*.o -L is not enough, i think you
need -B for that.

for runtime lib paths i would prefer if there was
a way to only set the --dynamic-linker and then
ld.so could look at a config file with the paths
at a path relative to itself. (so instead of rpath
the libc paths would be in a file like
$LDSO_ORIGIN/../etc/ld.so.conf)

this e.g. fixes the issue when an executable built
like above loads (or something preloads) a library
that is linked against the older system libc and
makes some older libc dso to be loaded (since that
lib has no rpath and the orig exe which has rpath
did not load that particular libc dso, the old lib
would work fine with the new libc but an old libc
component is incompatible with the new libc)
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