[lld] r315167 - Make a helper function a non-member function. NFC.
Rui Ueyama via llvm-commits
llvm-commits at lists.llvm.org
Sat Oct 7 19:54:43 PDT 2017
Author: ruiu
Date: Sat Oct 7 19:54:42 2017
New Revision: 315167
URL: http://llvm.org/viewvc/llvm-project?rev=315167&view=rev
Log:
Make a helper function a non-member function. NFC.
Modified:
lld/trunk/ELF/LinkerScript.cpp
lld/trunk/ELF/LinkerScript.h
Modified: lld/trunk/ELF/LinkerScript.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/LinkerScript.cpp?rev=315167&r1=315166&r2=315167&view=diff
==============================================================================
--- lld/trunk/ELF/LinkerScript.cpp (original)
+++ lld/trunk/ELF/LinkerScript.cpp Sat Oct 7 19:54:42 2017
@@ -871,27 +871,26 @@ ExprValue LinkerScript::getSymbolValue(c
return 0;
}
+// Returns the index of the segment named Name.
+static Optional<size_t> getPhdrIndex(ArrayRef<PhdrsCommand> Vec,
+ StringRef Name) {
+ for (size_t I = 0; I < Vec.size(); ++I)
+ if (Vec[I].Name == Name)
+ return I;
+ return None;
+}
+
// Returns indices of ELF headers containing specific section. Each index is a
// zero based number of ELF header listed within PHDRS {} script block.
std::vector<size_t> LinkerScript::getPhdrIndices(OutputSection *Cmd) {
std::vector<size_t> Ret;
- for (StringRef PhdrName : Cmd->Phdrs)
- if (Optional<size_t> Idx = getPhdrIndex(Cmd->Location, PhdrName))
+
+ for (StringRef S : Cmd->Phdrs) {
+ if (Optional<size_t> Idx = getPhdrIndex(Opt.PhdrsCommands, S))
Ret.push_back(*Idx);
+ else if (S != "NONE")
+ error(Cmd->Location + ": section header '" + S +
+ "' is not listed in PHDRS");
+ }
return Ret;
}
-
-// Returns the index of the segment named PhdrName if found otherwise
-// NoPhdr. When not found, if PhdrName is not the special case value 'NONE'
-// (which can be used to explicitly specify that a section isn't assigned to a
-// segment) then error.
-Optional<size_t> LinkerScript::getPhdrIndex(const Twine &Loc,
- StringRef PhdrName) {
- for (size_t I = 0; I < Opt.PhdrsCommands.size(); ++I)
- if (Opt.PhdrsCommands[I].Name == PhdrName)
- return I;
-
- if (PhdrName != "NONE")
- error(Loc + ": section header '" + PhdrName + "' is not listed in PHDRS");
- return None;
-}
Modified: lld/trunk/ELF/LinkerScript.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/LinkerScript.h?rev=315167&r1=315166&r2=315167&view=diff
==============================================================================
--- lld/trunk/ELF/LinkerScript.h (original)
+++ lld/trunk/ELF/LinkerScript.h Sat Oct 7 19:54:42 2017
@@ -217,7 +217,6 @@ class LinkerScript final {
std::vector<InputSectionBase *> createInputSectionList(OutputSection &Cmd);
std::vector<size_t> getPhdrIndices(OutputSection *Sec);
- llvm::Optional<size_t> getPhdrIndex(const Twine &Loc, StringRef PhdrName);
MemoryRegion *findMemoryRegion(OutputSection *Sec);
More information about the llvm-commits
mailing list