Source: glibc
Severity: wishlist
Tags: upstream
X-Debbugs-Cc: [email protected]
The SHT_RELR/DT_RELR format encodes relative relocations in a very efficient
way (quite usually takes just 3% or smaller space).
The size optimization can greatly decrease the virtual memory size of PIE and
shared objects with many R_*_RELATIVE relocations.
E.g. The clang executable's virtual memory size is 8.2% smaller with
SHT_RELR/DT_RELR. The size varies across projects, but I anticipate at least 5%
decrease for most projects.
% ~/projects/bloaty/Release/bloaty clang.pie.relr -- clang.pie
FILE SIZE VM SIZE
-------------- --------------
[NEW] +163Ki [NEW] +163Ki .relr.dyn
+4.9% +32 +5.4% +32 .dynamic
+2.5% +8 [ = ] 0 .shstrtab
-99.5% -13.8Mi -99.5% -13.8Mi .rela.dyn
-8.3% -13.6Mi -8.2% -13.6Mi TOTAL
The SHT_RELR/DT_RELR relocation format requires linker and loader support.
* On the linkder side, ld.lld has supported .relr.dyn/SHT_RELR/DT_RELR
(`--pack-dyn-relocs=relr`) for a long time and the support has been stable
since 2019-09 (after I fixed an address oscillating bug).
* On the loader (glibc ld.so) side, a patch exists
https://sourceware.org/pipermail/libc-alpha/2021-October/131768.html
but lack of GNU ld support may impede its adoption among Linux distributions.
User support is also important to push the patch forward. (ia64 according to
folks isn't an issue. glibc doesn't implement ELFCLASS32 for ia64 AFAICT.)
(
Worth noting that the Linux kernel's arm64 port supports SHT_RELR/DT_RELR since
2019.
ChromeOS has maintained a local glibc patch since around 2018.)
So I file this ticket seeking for support (comment on
https://sourceware.org/bugzilla/show_bug.cgi?id=27924). I hope that with
sufficient attention from users,
someone (e.g. a GNU ld maintainer) will eventually stand up and implement
`--pack-dyn-relocs=relr` for GNU ld
(https://sourceware.org/bugzilla/show_bug.cgi?id=27923).
Even in the absence of GNU ld support, I hope glibc can accept the DT_RELR
patch, so that ld.lld users can use `--pack-dyn-relocs=relr`.
See also Gentoo: https://bugs.gentoo.org/818376 Fedora:
https://bugzilla.redhat.com/show_bug.cgi?id=2014699 Arch Linux:
https://bugs.archlinux.org/task/72433