diff --git a/lld/ELF/LinkerScript.cpp b/lld/ELF/LinkerScript.cpp index a03e21c555037a..5bb977d6882bcb 100644 --- a/lld/ELF/LinkerScript.cpp +++ b/lld/ELF/LinkerScript.cpp @@ -802,6 +802,8 @@ void LinkerScript::addOrphanSections() { void LinkerScript::diagnoseOrphanHandling() const { llvm::TimeTraceScope timeScope("Diagnose orphan sections"); + if (config->orphanHandling == OrphanHandlingPolicy::Place) + return; for (const InputSectionBase *sec : orphanSections) { // Input SHT_REL[A] retained by --emit-relocs are ignored by // computeInputSections(). Don't warn/error. @@ -812,7 +814,7 @@ void LinkerScript::diagnoseOrphanHandling() const { StringRef name = getOutputSectionName(sec); if (config->orphanHandling == OrphanHandlingPolicy::Error) error(toString(sec) + " is being placed in '" + name + "'"); - else if (config->orphanHandling == OrphanHandlingPolicy::Warn) + else warn(toString(sec) + " is being placed in '" + name + "'"); } }