diff options
| author | George Rimar <grimar@accesssoftek.com> | 2019-03-11 16:10:02 +0000 | 
|---|---|---|
| committer | George Rimar <grimar@accesssoftek.com> | 2019-03-11 16:10:02 +0000 | 
| commit | 33e498b785cf41f9617c813486c2dfe44cf4eca0 (patch) | |
| tree | 1542646508b7b52f1d152c0ef6a08d5fbe07eb84 | |
| parent | c416c52b07f5c14c4548c904bd1426c1208949bc (diff) | |
| download | bcm5719-llvm-33e498b785cf41f9617c813486c2dfe44cf4eca0.tar.gz bcm5719-llvm-33e498b785cf41f9617c813486c2dfe44cf4eca0.zip  | |
[yaml2obj] - Simplify. NFC.
llvm-svn: 355832
| -rw-r--r-- | llvm/tools/yaml2obj/yaml2elf.cpp | 31 | 
1 files changed, 15 insertions, 16 deletions
diff --git a/llvm/tools/yaml2obj/yaml2elf.cpp b/llvm/tools/yaml2obj/yaml2elf.cpp index 3e7234a4963..6bae48bba40 100644 --- a/llvm/tools/yaml2obj/yaml2elf.cpp +++ b/llvm/tools/yaml2obj/yaml2elf.cpp @@ -133,8 +133,7 @@ class ELFState {    const ELFYAML::Object &Doc;    bool buildSectionIndex(); -  bool buildSymbolIndex(std::size_t &StartIndex, -                        const std::vector<ELFYAML::Symbol> &Symbols); +  bool buildSymbolIndex(const ELFYAML::LocalGlobalWeakSymbols &);    void initELFHeader(Elf_Ehdr &Header);    void initProgramHeaders(std::vector<Elf_Phdr> &PHeaders);    bool initSectionHeaders(std::vector<Elf_Shdr> &SHeaders, @@ -779,16 +778,19 @@ template <class ELFT> bool ELFState<ELFT>::buildSectionIndex() {  }  template <class ELFT> -bool -ELFState<ELFT>::buildSymbolIndex(std::size_t &StartIndex, -                                 const std::vector<ELFYAML::Symbol> &Symbols) { -  for (const auto &Sym : Symbols) { -    ++StartIndex; -    if (Sym.Name.empty()) -      continue; -    if (SymN2I.addName(Sym.Name, StartIndex)) { -      WithColor::error() << "Repeated symbol name: '" << Sym.Name << "'.\n"; -      return false; +bool ELFState<ELFT>::buildSymbolIndex( +    const ELFYAML::LocalGlobalWeakSymbols &Symbols) { +  std::size_t I = 0; +  for (const std::vector<ELFYAML::Symbol> &V : +       {Symbols.Local, Symbols.Global, Symbols.Weak}) { +    for (const auto &Sym : V) { +      ++I; +      if (Sym.Name.empty()) +        continue; +      if (SymN2I.addName(Sym.Name, I)) { +        WithColor::error() << "Repeated symbol name: '" << Sym.Name << "'.\n"; +        return false; +      }      }    }    return true; @@ -846,10 +848,7 @@ int ELFState<ELFT>::writeELF(raw_ostream &OS, const ELFYAML::Object &Doc) {    if (!State.buildSectionIndex())      return 1; -  std::size_t StartSymIndex = 0; -  if (!State.buildSymbolIndex(StartSymIndex, Doc.Symbols.Local) || -      !State.buildSymbolIndex(StartSymIndex, Doc.Symbols.Global) || -      !State.buildSymbolIndex(StartSymIndex, Doc.Symbols.Weak)) +  if (!State.buildSymbolIndex(Doc.Symbols))      return 1;    Elf_Ehdr Header;  | 

