diff options
| author | Rui Ueyama <ruiu@google.com> | 2017-10-08 02:54:42 +0000 |
|---|---|---|
| committer | Rui Ueyama <ruiu@google.com> | 2017-10-08 02:54:42 +0000 |
| commit | 656be311740744ad0a051b58dd080d1fe10aaf82 (patch) | |
| tree | db93610734defe650e8d1baa0c72c1dcdbefc378 /lld/ELF/LinkerScript.cpp | |
| parent | 872235743d8f18d08e5275a7a839bb7198d2029f (diff) | |
| download | bcm5719-llvm-656be311740744ad0a051b58dd080d1fe10aaf82.tar.gz bcm5719-llvm-656be311740744ad0a051b58dd080d1fe10aaf82.zip | |
Make a helper function a non-member function. NFC.
llvm-svn: 315167
Diffstat (limited to 'lld/ELF/LinkerScript.cpp')
| -rw-r--r-- | lld/ELF/LinkerScript.cpp | 33 |
1 files changed, 16 insertions, 17 deletions
diff --git a/lld/ELF/LinkerScript.cpp b/lld/ELF/LinkerScript.cpp index 952a2ba945e..fcb1f847272 100644 --- a/lld/ELF/LinkerScript.cpp +++ b/lld/ELF/LinkerScript.cpp @@ -871,27 +871,26 @@ ExprValue LinkerScript::getSymbolValue(const Twine &Loc, StringRef S) { 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; -} |

