From e03ba023482bf492caaa1e3e4945f9847cfaec15 Mon Sep 17 00:00:00 2001 From: Rui Ueyama Date: Sun, 8 Oct 2017 03:52:15 +0000 Subject: [PATCH] Rename ignoreInterpSection -> needsInterpSection. This should improve consistency. Also added comment. llvm-svn: 315169 --- lld/ELF/LinkerScript.cpp | 15 +++++++++------ lld/ELF/LinkerScript.h | 2 +- lld/ELF/Writer.cpp | 2 +- 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/lld/ELF/LinkerScript.cpp b/lld/ELF/LinkerScript.cpp index 78c14d08d79b..591e6ffabb29 100644 --- a/lld/ELF/LinkerScript.cpp +++ b/lld/ELF/LinkerScript.cpp @@ -841,15 +841,18 @@ std::vector LinkerScript::createPhdrs() { return Ret; } -bool LinkerScript::ignoreInterpSection() { - // Ignore .interp section in case we have PHDRS specification - // and PT_INTERP isn't listed. +// Returns true if we should emit an .interp section. +// +// We usually do. But if PHDRS commands are given, and +// no PT_INTERP is there, there's no place to emit an +// .interp, so we don't do that in that case. +bool LinkerScript::needsInterpSection() { if (Opt.PhdrsCommands.empty()) - return false; + return true; for (PhdrsCommand &Cmd : Opt.PhdrsCommands) if (Cmd.Type == PT_INTERP) - return false; - return true; + return true; + return false; } ExprValue LinkerScript::getSymbolValue(const Twine &Loc, StringRef S) { diff --git a/lld/ELF/LinkerScript.h b/lld/ELF/LinkerScript.h index 425cf33c8067..96552e250ffc 100644 --- a/lld/ELF/LinkerScript.h +++ b/lld/ELF/LinkerScript.h @@ -248,7 +248,7 @@ public: void adjustSectionsAfterSorting(); std::vector createPhdrs(); - bool ignoreInterpSection(); + bool needsInterpSection(); bool shouldKeep(InputSectionBase *S); void assignOffsets(OutputSection *Sec); diff --git a/lld/ELF/Writer.cpp b/lld/ELF/Writer.cpp index 73d87e479d37..928889302471 100644 --- a/lld/ELF/Writer.cpp +++ b/lld/ELF/Writer.cpp @@ -117,7 +117,7 @@ StringRef elf::getOutputSectionName(StringRef Name) { static bool needsInterpSection() { return !SharedFiles.empty() && !Config->DynamicLinker.empty() && - !Script->ignoreInterpSection(); + Script->needsInterpSection(); } template void elf::writeResult() { Writer().run(); }