[llvm] [coff] Don't try to write the obj if the assembler has errors (PR #123007)
via llvm-commits
llvm-commits at lists.llvm.org
Tue Jan 14 20:03:30 PST 2025
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-mc
Author: Daniel Paoliello (dpaoliello)
<details>
<summary>Changes</summary>
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.
---
Full diff: https://github.com/llvm/llvm-project/pull/123007.diff
1 Files Affected:
- (modified) llvm/lib/MC/WinCOFFObjectWriter.cpp (+5)
``````````diff
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);
``````````
</details>
https://github.com/llvm/llvm-project/pull/123007
More information about the llvm-commits
mailing list