Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 818376 - [toolchain] Adopt SHT_RELR/DT_RELR relative relocation format
Summary: [toolchain] Adopt SHT_RELR/DT_RELR relative relocation format
Status: UNCONFIRMED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal enhancement (vote)
Assignee: Gentoo Toolchain Maintainers
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-10-15 21:56 UTC by emacsray
Modified: 2021-11-05 23:47 UTC (History)
4 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description emacsray 2021-10-15 21:56:52 UTC
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.

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 this format since 2019.)

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).

Reproducible: Always
Comment 1 Tee KOBAYASHI 2021-10-15 22:56:59 UTC
What can be done on Gentoo side?

Personally it would be nice to have it supported by ld.bfd in the future to be usable on Android 12 (https://github.com/termux/termux-packages/issues/7382).
Comment 2 emacsray 2021-10-16 01:16:59 UTC
(In reply to Tee KOBAYASHI from comment #1)
> What can be done on Gentoo side?
> 
> Personally it would be nice to have it supported by ld.bfd in the future to
> be usable on Android 12
> (https://github.com/termux/termux-packages/issues/7382).

Android and Chrome OS have been using ld.lld --pack-dyn-relocs=relr for quite some time. The feature I want to push forward is glibc's DT_RELR support. Distributions' support will be great...

I'll also add a note that RELR is more efficient than Firefox's ELF hack and may render it unneeded (https://glandium.org/blog/?p=1177)