[PATCH 2/2] libstdc++: Move stream initialization into compiled library [PR44952]
Florian Weimer
fweimer@redhat.com
Fri Nov 4 16:57:12 GMT 2022
* Patrick Palka via Gcc-patches:
> This patch moves the global object for constructing the standard streams
> out from <iostream> and into the compiled library on targets that support
> the init_priority attribute. This means that <iostream> no longer
> introduces a separate global constructor in each TU that includes it.
>
> We can do this only if the init_priority attribute is supported because
> we need to force that the stream initialization runs first before any
> user-defined global initializer in programs that that use a static
> libstdc++.a.
I think this breaks initialization of iostreams of shared objects that
are preloaded with LD_PRELOAD. With the constructor, they initialize
iostreams once they are loaded via their own ELF constructors (even
before libstdc++'s ELF constructors run). Without the constructor in
<iostream>, that no longer happens.
Thanks,
Florian
More information about the Libstdc++
mailing list