early stage ldso: remove symbolic references via error handling function
authorRich Felker <dalias@aerifal.cx>
Tue, 19 Jul 2022 23:00:53 +0000 (19:00 -0400)
committerRich Felker <dalias@aerifal.cx>
Tue, 19 Jul 2022 23:00:53 +0000 (19:00 -0400)
commitd16d7b10997e6f1c224c3de01b43868f0ce2cc3d
tree5965ae45c5154b9ad86034dcefd25dcbecdafb71
parent63c67053a3e42e9dff788de432f82ff07d4d772a
early stage ldso: remove symbolic references via error handling function

while the error handling function should not be reached in stage 2
(assuming ldso itself was linked correctly), this was not statically
determinate from the compiler's perspective, and in theory a compiler
performing LTO could lift the TLS references (errno and other things)
out of the printf-family functions called in a stage where TLS is not
yet initialized.

instead, perform the call via a static-storage, internal-linkage
function pointer which will be set to a no-op function until the stage
where the real error handling function should be reachable.

inspired by commit 63c67053a3e42e9dff788de432f82ff07d4d772a.
ldso/dynlink.c