rts/linker/PEi386: Make libc++ linkage work
This fixes quite a few issues in the RTS linker which prevented the the loading of #21618 (closed):
- It turns out that PE objects may have multiple
.ctors
/.dtors
sections but the linker had assumed that there was only one. - We previously failed to run initializers and destructors in order of their priorities, potentially leading to memory safety issues in foreign code (#21847 (closed) ). Currently we only fix this in the PEi386 linker.
- The exception table unregistration logic in the PEi386 linker passed the wrong handle to
RtlDeleteFunctionTable
, leading to #21354 (closed). - We failed to statically link against
libc++
on Windows, leading to #21435 (closed) - Previously the ELF linker would silently fail to run initializers of objects produced by GCC 6 due to a GCC bug; work around this
- Previously we failed to respect the finalization semantics specified by the C++ ABI, leading to segmentation faults on Darwin after unloading object code
In addition, we fix #20494 (closed) since C++ code relies rather critically on destructors.
Fixes #21618 (closed)
Edited by Ben Gamari