public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* Counting static __cxa_atexit calls
@ 2022-08-23 11:58 Florian Weimer
  2022-08-23 12:28 ` Nick Clifton
  2022-08-23 13:40 ` Michael Matz
  0 siblings, 2 replies; 7+ messages in thread
From: Florian Weimer @ 2022-08-23 11:58 UTC (permalink / raw)
  To: binutils; +Cc: gcc, libc-alpha

We currently have a latent bug in glibc where C++ constructor calls can
fail if they have static or thread storage duration and a non-trivial
destructor.  The reason is that __cxa_atexit (and
__cxa_thread_atexit_impl) may have to allocate memory.  We can avoid
that if we know how many such static calls exist in an object (for C++,
the compiler will never emit these calls repeatedly in a loop).  Then we
can allocate the resources beforehand, either during process and thread
start, or when dlopen is called and new objects are loaded.

What would be the most ELF-flavored way to implement this?  After the
final link, I expect that the count (or counts, we need a separate
counter for thread-local storage) would show up under a new dynamic tag
in the dynamic segment.  This is actually a very good fit because older
loaders will just ignore it.  But the question remains what GCC should
emit into assembler & object files, so that the link editor can compute
the total count from that.

Thanks,
Florian


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

end of thread, other threads:[~2022-08-24 15:25 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-08-23 11:58 Counting static __cxa_atexit calls Florian Weimer
2022-08-23 12:28 ` Nick Clifton
2022-08-23 13:40 ` Michael Matz
2022-08-24 12:06   ` Florian Weimer
2022-08-24 12:53     ` Michael Matz
2022-08-24 14:31       ` Florian Weimer
2022-08-24 15:25         ` Michael Matz

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