From cf0fb69b3d489cd0aebaa2d759b2d2c0c4e230b1 Mon Sep 17 00:00:00 2001 From: _ov4 Date: Mon, 19 Oct 2026 10:51:13 +0000 Subject: fix(driver): normalize MinGW JIT archive symbol definitions Make absolute-zero pure virtual fallbacks local and compute runtime archive interfaces from normalized objects so ORC definitions match JITLink. Co-Authored-By: Claude Opus 5.5 --- tools/driver/MinGWCOFF.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'tools/driver/MinGWCOFF.h') diff --git a/tools/driver/MinGWCOFF.h b/tools/driver/MinGWCOFF.h index 186d981..555dcc8 100644 --- a/tools/driver/MinGWCOFF.h +++ b/tools/driver/MinGWCOFF.h @@ -50,6 +50,7 @@ normalizeMinGWObject(std::unique_ptr Buffer) { struct Association { size_t Offset; int32_t Parent; }; SmallVector Associations; SmallVector PureVirtualReferences; + SmallVector PureVirtualFallbacks; for (const auto &Symbol : COFF->symbols()) { auto Sym = COFF->getCOFFSymbol(Symbol); if (auto *Weak = Sym.getWeakExternal()) { @@ -68,6 +69,13 @@ normalizeMinGWObject(std::unique_ptr Buffer) { ? offsetof(object::coff_symbol32, StorageClass) : offsetof(object::coff_symbol16, StorageClass); PureVirtualReferences.push_back(Offset); + size_t FallbackOffset = + reinterpret_cast(Fallback->getRawPtr()) - + Buffer->getBufferStart(); + FallbackOffset += Fallback->isBigObj() + ? offsetof(object::coff_symbol32, StorageClass) + : offsetof(object::coff_symbol16, StorageClass); + PureVirtualFallbacks.push_back(FallbackOffset); } } } @@ -118,6 +126,10 @@ normalizeMinGWObject(std::unique_ptr Buffer) { // entry count intact so the remaining symbol indices do not move. for (size_t Offset : PureVirtualReferences) Copy->getBufferStart()[Offset] = COFF::IMAGE_SYM_CLASS_EXTERNAL; + // Only the now-unused weak auxiliary record references the fallback. + // Keep it local so archive interfaces do not advertise a global definition. + for (size_t Offset : PureVirtualFallbacks) + Copy->getBufferStart()[Offset] = COFF::IMAGE_SYM_CLASS_STATIC; return std::unique_ptr(std::move(Copy)); } -- cgit v1.3.1-4-g156e