This fixes the situation described in https://github.com/llvm/llvm-project/issues/53475 with a repro exposed by https://github.com/ROCmSoftwarePlatform/D108850-lld-bug-reproduction
This is purposely just a workaround to unblock users. This could be transplanted to the release/14.x branch if need be. A proper fix will later be provided in D119049
If this is not ELF-specific, seems that it needs to live in lld::cleanup ? If the API (perhaps not intended as an API), we can give it an long discouraging name.