The latter part of https://sourceware.org/pipermail/binutils/2020-May/111086.html Position independent executables and shared objects with -Bsymbolic/-Bsymbolic-functions may have many relative relocations (instead of absolute relocations (e.g. R_X86_64_64)). Relative relocations can be packed in a compact format to save a lot of space. See the last few messages on https://groups.google.com/g/generic-abi/c/bX460iggiKg DT_RELR has support in the Linux kernel (arch/arm64/Kconfig ARCH_HAS_RELR) since 2019 https://git.kernel.org/linus/5cf896fb6be3effd9aea455b22213e27be8bdb1d
Thanks for sharing and instructing https://mqdirections.com/
[hjl@gnu-cfl-2 tmp]$ gcc -pie -fPIE -O2 tst-relr.c -Wl,--pack-dyn-relocs=relr -fuse-ld=lld [hjl@gnu-cfl-2 tmp]$ ./a.out Segmentation fault (core dumped) [hjl@gnu-cfl-2 tmp]$ Given that the current lld implementation generates broken binaries for existing glibc without any warning at run-time, we need a different linker command line option to implement it properly so that the new binary will fail to run on glibc without DT_RELR support at run-time. We can do "-z relr=glibc" which generates DT_RELR and adds a glibc version dependency against the first version of glibc with DT_RELR support.
(In reply to H.J. Lu from comment #2) > > We can do "-z relr=glibc" which generates DT_RELR and adds a > glibc version dependency against the first version of glibc > with DT_RELR support. Here is the proposal: https://sourceware.org/pipermail/binutils/2021-October/118292.html
We need an updated proposal without mysterious crashes. One option is that the linker should bump EI_ABIVERSION when generating DT_RELR.
Fixed for i386 and x86-64 by commit 72aa81732b3aff00e5bf1f69bb794513b3b37464 Author: H.J. Lu <hjl.tools@gmail.com> Date: Wed Jan 5 19:21:45 2022 -0800 ld: Add glibc dependency for DT_RELR When DT_RELR is enabled, to avoid random run-time crash with older glibc binaries without DT_RELR support, add a GLIBC_ABI_DT_RELR symbol version, which is provided by glibc with DT_RELR support, dependency on the shared C library if it provides a GLIBC_2.XX symbol version.
Also supported on powerpc64