[llvm] [coff] Don't try to write the obj if the assembler has errors (PR #123007)
Daniel Paoliello via llvm-commits
llvm-commits at lists.llvm.org
Tue Jan 14 20:02:52 PST 2025
https://github.com/dpaoliello created https://github.com/llvm/llvm-project/pull/123007
The ASAN and MSAN tests have been failing after #122777 because some fields are now set in `executePostLayoutBinding` which is skipped by the assembler if it had errors but read in `writeObject`
Since the compilation has failed anyway, skip `writeObject` if the assembler had errors.
>From bbdc737124ba884d3b47d23be820e320753ceb2f Mon Sep 17 00:00:00 2001
From: Daniel Paoliello <danpao at microsoft.com>
Date: Tue, 14 Jan 2025 20:00:11 -0800
Subject: [PATCH] [coff] Don't try to write the obj if the assembler has errors
---
llvm/lib/MC/WinCOFFObjectWriter.cpp | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/llvm/lib/MC/WinCOFFObjectWriter.cpp b/llvm/lib/MC/WinCOFFObjectWriter.cpp
index 39e02d0522bcfb..da0c0661117b28 100644
--- a/llvm/lib/MC/WinCOFFObjectWriter.cpp
+++ b/llvm/lib/MC/WinCOFFObjectWriter.cpp
@@ -1193,6 +1193,11 @@ void WinCOFFObjectWriter::recordRelocation(MCAssembler &Asm,
}
uint64_t WinCOFFObjectWriter::writeObject(MCAssembler &Asm) {
+ // If the assember had an error, then layout will not have completed, so we
+ // cannot write an object file.
+ if (Asm.getContext().hadError())
+ return 0;
+
uint64_t TotalSize = ObjWriter->writeObject(Asm);
if (DwoWriter)
TotalSize += DwoWriter->writeObject(Asm);
More information about the llvm-commits
mailing list