diff options
| author | George Rimar <grimar@accesssoftek.com> | 2019-03-28 10:52:14 +0000 |
|---|---|---|
| committer | George Rimar <grimar@accesssoftek.com> | 2019-03-28 10:52:14 +0000 |
| commit | 4111299584403a9dbea4b8fe69da7514a1e51e89 (patch) | |
| tree | f145906fcc354c41729f6eba4efc8b4da40b130a /llvm/tools | |
| parent | a833c2bd3e8b2695527ba9135512d4a52a16f6bf (diff) | |
| download | bcm5719-llvm-4111299584403a9dbea4b8fe69da7514a1e51e89.tar.gz bcm5719-llvm-4111299584403a9dbea4b8fe69da7514a1e51e89.zip | |
[yaml2obj][obj2yaml] - Teach yaml2obj/obj2yaml tools about STB_GNU_UNIQUE symbols.
yaml2obj/obj2yaml does not support the symbols with STB_GNU_UNIQUE yet.
Currently, obj2yaml fails with llvm_unreachable when met such a symbol.
I faced it when investigated the https://bugs.llvm.org/show_bug.cgi?id=41196.
Differential revision: https://reviews.llvm.org/D59875
llvm-svn: 357158
Diffstat (limited to 'llvm/tools')
| -rw-r--r-- | llvm/tools/obj2yaml/elf2yaml.cpp | 10 | ||||
| -rw-r--r-- | llvm/tools/yaml2obj/yaml2elf.cpp | 19 |
2 files changed, 17 insertions, 12 deletions
diff --git a/llvm/tools/obj2yaml/elf2yaml.cpp b/llvm/tools/obj2yaml/elf2yaml.cpp index 4d94b4bea79..b9cdc123d31 100644 --- a/llvm/tools/obj2yaml/elf2yaml.cpp +++ b/llvm/tools/obj2yaml/elf2yaml.cpp @@ -42,7 +42,7 @@ class ELFDumper { ArrayRef<Elf_Word> ShndxTable; std::error_code dumpSymbols(const Elf_Shdr *Symtab, - ELFYAML::LocalGlobalWeakSymbols &Symbols); + ELFYAML::SymbolsDef &Symbols); std::error_code dumpSymbol(const Elf_Sym *Sym, const Elf_Shdr *SymTab, StringRef StrTable, ELFYAML::Symbol &S); std::error_code dumpCommonSection(const Elf_Shdr *Shdr, ELFYAML::Section &S); @@ -226,9 +226,8 @@ template <class ELFT> ErrorOr<ELFYAML::Object *> ELFDumper<ELFT>::dump() { } template <class ELFT> -std::error_code -ELFDumper<ELFT>::dumpSymbols(const Elf_Shdr *Symtab, - ELFYAML::LocalGlobalWeakSymbols &Symbols) { +std::error_code ELFDumper<ELFT>::dumpSymbols(const Elf_Shdr *Symtab, + ELFYAML::SymbolsDef &Symbols) { if (!Symtab) return std::error_code(); @@ -262,6 +261,9 @@ ELFDumper<ELFT>::dumpSymbols(const Elf_Shdr *Symtab, case ELF::STB_WEAK: Symbols.Weak.push_back(S); break; + case ELF::STB_GNU_UNIQUE: + Symbols.GNUUnique.push_back(S); + break; default: llvm_unreachable("Unknown ELF symbol binding"); } diff --git a/llvm/tools/yaml2obj/yaml2elf.cpp b/llvm/tools/yaml2obj/yaml2elf.cpp index a70b15e49a3..7a8b0cc5a89 100644 --- a/llvm/tools/yaml2obj/yaml2elf.cpp +++ b/llvm/tools/yaml2obj/yaml2elf.cpp @@ -133,7 +133,7 @@ class ELFState { const ELFYAML::Object &Doc; bool buildSectionIndex(); - bool buildSymbolIndex(const ELFYAML::LocalGlobalWeakSymbols &); + bool buildSymbolIndex(const ELFYAML::SymbolsDef &); void initELFHeader(Elf_Ehdr &Header); void initProgramHeaders(std::vector<Elf_Phdr> &PHeaders); bool initSectionHeaders(std::vector<Elf_Shdr> &SHeaders, @@ -362,6 +362,7 @@ void ELFState<ELFT>::initSymtabSectionHeader(Elf_Shdr &SHeader, addSymbols(Symbols.Local, Syms, ELF::STB_LOCAL, Strtab); addSymbols(Symbols.Global, Syms, ELF::STB_GLOBAL, Strtab); addSymbols(Symbols.Weak, Syms, ELF::STB_WEAK, Strtab); + addSymbols(Symbols.GNUUnique, Syms, ELF::STB_GNU_UNIQUE, Strtab); writeArrayData( CBA.getOSAndAlignedOffset(SHeader.sh_offset, SHeader.sh_addralign), @@ -795,11 +796,10 @@ template <class ELFT> bool ELFState<ELFT>::buildSectionIndex() { } template <class ELFT> -bool ELFState<ELFT>::buildSymbolIndex( - const ELFYAML::LocalGlobalWeakSymbols &Symbols) { +bool ELFState<ELFT>::buildSymbolIndex(const ELFYAML::SymbolsDef &Symbols) { std::size_t I = 0; for (const std::vector<ELFYAML::Symbol> &V : - {Symbols.Local, Symbols.Global, Symbols.Weak}) { + {Symbols.Local, Symbols.Global, Symbols.Weak, Symbols.GNUUnique}) { for (const auto &Sym : V) { ++I; if (Sym.Name.empty()) @@ -815,13 +815,15 @@ bool ELFState<ELFT>::buildSymbolIndex( template <class ELFT> void ELFState<ELFT>::finalizeStrings() { auto AddSymbols = [](StringTableBuilder &StrTab, - const ELFYAML::LocalGlobalWeakSymbols &Symbols) { + const ELFYAML::SymbolsDef &Symbols) { for (const auto &Sym : Symbols.Local) StrTab.add(Sym.Name); for (const auto &Sym : Symbols.Global) StrTab.add(Sym.Name); for (const auto &Sym : Symbols.Weak) StrTab.add(Sym.Name); + for (const auto &Sym : Symbols.GNUUnique) + StrTab.add(Sym.Name); }; // Add the regular symbol names to .strtab section. @@ -919,9 +921,10 @@ int ELFState<ELFT>::writeELF(raw_ostream &OS, const ELFYAML::Object &Doc) { } template <class ELFT> bool ELFState<ELFT>::hasDynamicSymbols() const { - return Doc.DynamicSymbols.Global.size() > 0 || - Doc.DynamicSymbols.Weak.size() > 0 || - Doc.DynamicSymbols.Local.size() > 0; + return !Doc.DynamicSymbols.Global.empty() || + !Doc.DynamicSymbols.Weak.empty() || + !Doc.DynamicSymbols.Local.empty() || + !Doc.DynamicSymbols.GNUUnique.empty(); } template <class ELFT> |

