From ab276f359bd4614e8b8dbf30fcd7b2e2edee6502 Mon Sep 17 00:00:00 2001 From: Lucas Steuernagel Date: Mon, 19 Dec 2022 18:11:53 -0300 Subject: [PATCH] [SOL] Fix bug in LLD Signed-off-by: Lucas Steuernagel --- lld/Common/ErrorHandler.cpp | 6 ++++++ lld/ELF/Driver.cpp | 1 + lld/MachO/Driver.cpp | 1 + lld/include/lld/Common/ErrorHandler.h | 1 + 4 files changed, 9 insertions(+) diff --git a/lld/Common/ErrorHandler.cpp b/lld/Common/ErrorHandler.cpp index 4e3a1bc31ade50..81cdcb2557f79d 100644 --- a/lld/Common/ErrorHandler.cpp +++ b/lld/Common/ErrorHandler.cpp @@ -51,6 +51,12 @@ void ErrorHandler::flushStreams() { errs().flush(); } +void ErrorHandler::handleEarlyExit() { + if (!exitEarly) { + cleanupCallback(); + } +} + ErrorHandler &lld::errorHandler() { return context().e; } void lld::error(const Twine &msg) { errorHandler().error(msg); } diff --git a/lld/ELF/Driver.cpp b/lld/ELF/Driver.cpp index d7b1d0e7d4c8ae..17e4583619b8b2 100644 --- a/lld/ELF/Driver.cpp +++ b/lld/ELF/Driver.cpp @@ -154,6 +154,7 @@ bool link(ArrayRef args, llvm::raw_ostream &stdoutOS, elf::ctx.driver.linkerMain(args); + ctx->e.handleEarlyExit(); return errorCount() == 0; } } // namespace elf diff --git a/lld/MachO/Driver.cpp b/lld/MachO/Driver.cpp index ce7f6d567b613b..e30423b7942d45 100644 --- a/lld/MachO/Driver.cpp +++ b/lld/MachO/Driver.cpp @@ -1968,6 +1968,7 @@ bool link(ArrayRef argsArr, llvm::raw_ostream &stdoutOS, for (const auto &warning : missingAutolinkWarnings) warn(warning); + ctx->e.handleEarlyExit(); return errorCount() == 0; } } // namespace macho diff --git a/lld/include/lld/Common/ErrorHandler.h b/lld/include/lld/Common/ErrorHandler.h index 0b69bb6202b32c..12f600760a79f0 100644 --- a/lld/include/lld/Common/ErrorHandler.h +++ b/lld/include/lld/Common/ErrorHandler.h @@ -117,6 +117,7 @@ class ErrorHandler { raw_ostream &outs(); raw_ostream &errs(); void flushStreams(); + void handleEarlyExit(); std::unique_ptr outputBuffer;