musl now has DT_RELR support in https://git.musl-libc.org/cgit/musl/commit/?id=d32dadd60efb9d3b255351a3b532f8e4c3dd0db1 (so it will be in the next release)
glibc added it in https://github.com/bminor/glibc/commit/e895cff59aa562cad83fa0fdd187bfe4b45312d5 , in the 2.36 release
binutils supports setting this at link time (
-z pack-relative-relocs) since 2.38. ld.lld added it in LLVM 15 (soon to be available). (prior to 15, it has it via
there is a lot written about this new linker feature here: https://maskray.me/blog/2021-10-31-relative-relocations-and-relr . it has all the info you might want to know. (do read it!)
this issue is a proposal to enable this by default (via either LDFLAGS in abuild.conf or some form of binutils/lld default cmdline editing, former preferred). it would have to wait for the next musl release (or that patch can be backported, i have verified it works (if the support doesn't work, the binaries with RELR sections segfault instantly in the loader))
the main benefits are size. practically everything shrinks 5-8% in size with no gotcha. see the linked article for more details.
the main issue would be time travel compatibility. without backporting the musl patch to stable releases, or first waiting until things within reason all have the support (prior to toggling the linker flag), people using binaries from edge on stable would just have them segfault. we don't support this (mixing edge with stable), obviously, but practically everyone ends up doing it (much to my annoyance). so, i think it would be best to backport it one release (3.16) and then have it in 3.17 naturally and toggle it then for edge (after 3.17), or, alternatively, toggle it for edge before 3.17 if we backport the patches earlier. all the times can change depending on when musl makes a release , unless we backport it early
i have not tested if this feature is secretly broken outside of x86_64- maybe the other arches aren't ready for it.
overall, it's a free optimisation without much downside, that relies on relatively-new libc loading support. i don't see a reason to not enable it by default once musl supports it.
the time-travel issue needs more consideration- see some discussion in https://github.com/llvm/llvm-project/issues/53775 for instance. not sure if we can also implement a lockout