public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
* _rtld_global, _rtld_global_ro (and local aliases) as an optimization
@ 2023-06-06 12:14 Florian Weimer
  2023-06-06 19:30 ` Adhemerval Zanella Netto
  0 siblings, 1 reply; 9+ messages in thread
From: Florian Weimer @ 2023-06-06 12:14 UTC (permalink / raw)
  To: libc-alpha

We currently use _rtld_global, _rtld_global_ro to pass information from
ld.so to the other shared objects.  For this purpose, it is convenient
to have everything in two structs because we do not need to add
additional exports.

There is another effect, though.  Due to the local hidden aliases
_rtld_local, _rtld_local_ro in ld.so (similar to
rtld_hidden_proto/rtld_hidden_def, but implemented differently), the
instruction sequence for field access is potentially shorter than it
would be if all these fields were separate global variables (still with
hidden visibility).  On many RISC targets, constructing the address of a
hidden global variable or a struct member needs two instructions.
However, obtaining the address of a different struct member is just one
instruction if you already have the address of another member.

Is this optimization still important?  It's often preferable not to add
new fields to _rtld_global/_rtld_global_ro for data that is internal to
ld.so, to avoid changing the internal GLIBC_PRIVATE ABI.  This helps
with backporting because it enables zero-downtime upgrades.

Thanks,
Florian


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

end of thread, other threads:[~2023-06-07 12:56 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-06-06 12:14 _rtld_global, _rtld_global_ro (and local aliases) as an optimization Florian Weimer
2023-06-06 19:30 ` Adhemerval Zanella Netto
2023-06-07  8:57   ` Florian Weimer
2023-06-07  9:14     ` Andreas Schwab
2023-06-07  9:37       ` Florian Weimer
2023-06-07 12:08         ` Adhemerval Zanella Netto
2023-06-07 12:21           ` Florian Weimer
2023-06-07 12:40             ` Adhemerval Zanella Netto
2023-06-07 12:56               ` Florian Weimer

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