Skip to content

Commit ac2165f

Browse files
authored
[coff] Don't try to write the obj if the assembler has errors (llvm#123007)
The ASAN and MSAN tests have been failing after llvm#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.
1 parent 943b212 commit ac2165f

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

llvm/lib/MC/WinCOFFObjectWriter.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1193,6 +1193,11 @@ void WinCOFFObjectWriter::recordRelocation(MCAssembler &Asm,
11931193
}
11941194

11951195
uint64_t WinCOFFObjectWriter::writeObject(MCAssembler &Asm) {
1196+
// If the assember had an error, then layout will not have completed, so we
1197+
// cannot write an object file.
1198+
if (Asm.getContext().hadError())
1199+
return 0;
1200+
11961201
uint64_t TotalSize = ObjWriter->writeObject(Asm);
11971202
if (DwoWriter)
11981203
TotalSize += DwoWriter->writeObject(Asm);

0 commit comments

Comments
 (0)