diff --git a/lld/Common/ErrorHandler.cpp b/lld/Common/ErrorHandler.cpp --- a/lld/Common/ErrorHandler.cpp +++ b/lld/Common/ErrorHandler.cpp @@ -236,8 +236,8 @@ s.flush(); } -void ErrorHandler::warn(const Twine &msg) { - if (fatalWarnings) { +void ErrorHandler::warn(const Twine &msg, bool neverFatal) { + if (!neverFatal && fatalWarnings) { error(msg); return; } diff --git a/lld/ELF/InputFiles.cpp b/lld/ELF/InputFiles.cpp --- a/lld/ELF/InputFiles.cpp +++ b/lld/ELF/InputFiles.cpp @@ -713,12 +713,13 @@ if (sec.sh_link != 0) this->addrsigSec = &sec; else if (config->icf == ICFLevel::Safe) - warn(toString(this) + - ": --icf=safe conservatively ignores " - "SHT_LLVM_ADDRSIG [index " + - Twine(i) + - "] with sh_link=0 " - "(likely created using objcopy or ld -r)"); + errorHandler().warn(toString(this) + + ": --icf=safe conservatively ignores " + "SHT_LLVM_ADDRSIG [index " + + Twine(i) + + "] with sh_link=0 " + "(likely created using objcopy or ld -r)", + /*neverFatal=*/true); } this->sections[i] = &InputSection::discarded; continue; diff --git a/lld/include/lld/Common/ErrorHandler.h b/lld/include/lld/Common/ErrorHandler.h --- a/lld/include/lld/Common/ErrorHandler.h +++ b/lld/include/lld/Common/ErrorHandler.h @@ -112,7 +112,7 @@ [[noreturn]] void fatal(const Twine &msg); void log(const Twine &msg); void message(const Twine &msg, llvm::raw_ostream &s); - void warn(const Twine &msg); + void warn(const Twine &msg, bool neverFatal = false); raw_ostream &outs(); raw_ostream &errs();