public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* ld: -z rel and -z relr
@ 2020-05-15  7:04 Fangrui Song
  2020-05-24 20:58 ` Fangrui Song
  0 siblings, 1 reply; 2+ messages in thread
From: Fangrui Song @ 2020-05-15  7:04 UTC (permalink / raw)
  To: binutils; +Cc: Roland McGrath

Many dynamic relocations have zero addend. IFAIK GLOB_DAT,
J[U]MP_SLOT and COPY always have 0 addend. An absolute relocation type
(R_X86_64_64 R_PPC64_ADDR64) can have non-0 addend but that is rare.

(Some other relocation types: DTPOFF/DTPMOD, but they are few)

I can understand that for object files, RELA is generally favorable
(though I'd like to know your thoughts). However, I wonder, if the
dyanmic loader supports REL, should we have a mode, -z rel, to generate
REL outstanding relocation types? The downside may be random access
reads (while with pure RELA, ld.so can blast out a bunch of writes).

The benefit will be the code size savings. I understand that many ld.so
implementations don't support REL and RELA at the same time (FreeBSD
rtld and glibc; happy to be proved wrong ;-) ), but musl ld.so supports
REL+RELA out of the box. There may be PLT complexty for these ld.so
implementations which can't support both at the same time:)

-----

R_*_RELATIVE have non-zero relocation types but they can be compressed
in a better format: RELR https://groups.google.com/forum/#!topic/generic-abi/9OO5vhxb00Y
I suspect it is strictly superior to Firefox
https://wiki.mozilla.org/Elfhack but I haven't actually looked into Firefox (probably because I don't use it...)

If GNU ld intends to support RELR, -z relr may be a good option name. I
think -z is nice because -z is reserved for ELF specific options.)

(Yes, I know LLD has --pack-dyn-relocs (since July 2018, before my
serious involvement into LLD), but if we can achieve some agreement
here, maybe LLD can add an alias.)

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-05-24 20:58 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-15  7:04 ld: -z rel and -z relr Fangrui Song
2020-05-24 20:58 ` Fangrui Song

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).