diff options
author | Rafael Espindola <rafael.espindola@gmail.com> | 2013-11-02 21:16:09 +0000 |
---|---|---|
committer | Rafael Espindola <rafael.espindola@gmail.com> | 2013-11-02 21:16:09 +0000 |
commit | bc884fd9f7bdb64d250be639edc8dc85a20a1975 (patch) | |
tree | 7ca35c37e582f10e30efc71b734ba0712a079557 /include/llvm | |
parent | 66b8ec520f84c704e2a7f89dfa9ee1452ef5bc43 (diff) | |
download | llvm-bc884fd9f7bdb64d250be639edc8dc85a20a1975.tar.gz llvm-bc884fd9f7bdb64d250be639edc8dc85a20a1975.tar.bz2 llvm-bc884fd9f7bdb64d250be639edc8dc85a20a1975.tar.xz |
move getSymbolNMTypeChar to the one program that needs it: nm.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@193933 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm')
-rw-r--r-- | include/llvm/Object/COFF.h | 1 | ||||
-rw-r--r-- | include/llvm/Object/ELFObjectFile.h | 77 | ||||
-rw-r--r-- | include/llvm/Object/MachO.h | 1 | ||||
-rw-r--r-- | include/llvm/Object/ObjectFile.h | 9 |
4 files changed, 2 insertions, 86 deletions
diff --git a/include/llvm/Object/COFF.h b/include/llvm/Object/COFF.h index 67cc7c61b7..ec8998c746 100644 --- a/include/llvm/Object/COFF.h +++ b/include/llvm/Object/COFF.h @@ -246,7 +246,6 @@ protected: virtual error_code getSymbolFileOffset(DataRefImpl Symb, uint64_t &Res) const; virtual error_code getSymbolAddress(DataRefImpl Symb, uint64_t &Res) const; virtual error_code getSymbolSize(DataRefImpl Symb, uint64_t &Res) const; - virtual error_code getSymbolNMTypeChar(DataRefImpl Symb, char &Res) const; virtual error_code getSymbolFlags(DataRefImpl Symb, uint32_t &Res) const; virtual error_code getSymbolType(DataRefImpl Symb, SymbolRef::Type &Res) const; virtual error_code getSymbolSection(DataRefImpl Symb, diff --git a/include/llvm/Object/ELFObjectFile.h b/include/llvm/Object/ELFObjectFile.h index 31783d4873..962a3e2a86 100644 --- a/include/llvm/Object/ELFObjectFile.h +++ b/include/llvm/Object/ELFObjectFile.h @@ -61,7 +61,6 @@ protected: virtual error_code getSymbolAddress(DataRefImpl Symb, uint64_t &Res) const; virtual error_code getSymbolAlignment(DataRefImpl Symb, uint32_t &Res) const; virtual error_code getSymbolSize(DataRefImpl Symb, uint64_t &Res) const; - virtual error_code getSymbolNMTypeChar(DataRefImpl Symb, char &Res) const; virtual error_code getSymbolFlags(DataRefImpl Symb, uint32_t &Res) const; virtual error_code getSymbolType(DataRefImpl Symb, SymbolRef::Type &Res) const; @@ -104,8 +103,6 @@ protected: getRelocationValueString(DataRefImpl Rel, SmallVectorImpl<char> &Result) const; -protected: // ELF specific protected members. - const Elf_Sym *getSymbol(DataRefImpl Symb) const; uint64_t getROffset(DataRefImpl Rel) const; StringRef getRelocationTypeName(uint32_t Type) const; @@ -170,6 +167,8 @@ protected: // ELF specific protected members. public: ELFObjectFile(MemoryBuffer *Object, error_code &ec); + const Elf_Sym *getSymbol(DataRefImpl Symb) const; + virtual symbol_iterator begin_symbols() const; virtual symbol_iterator end_symbols() const; @@ -339,78 +338,6 @@ error_code ELFObjectFile<ELFT>::getSymbolSize(DataRefImpl Symb, } template <class ELFT> -error_code ELFObjectFile<ELFT>::getSymbolNMTypeChar(DataRefImpl Symb, - char &Result) const { - const Elf_Sym *ESym = getSymbol(Symb); - const Elf_Shdr *ESec = EF.getSection(ESym); - - char ret = '?'; - - if (ESec) { - switch (ESec->sh_type) { - case ELF::SHT_PROGBITS: - case ELF::SHT_DYNAMIC: - switch (ESec->sh_flags) { - case (ELF::SHF_ALLOC | ELF::SHF_EXECINSTR): - ret = 't'; - break; - case (ELF::SHF_ALLOC | ELF::SHF_WRITE): - ret = 'd'; - break; - case ELF::SHF_ALLOC: - case (ELF::SHF_ALLOC | ELF::SHF_MERGE): - case (ELF::SHF_ALLOC | ELF::SHF_MERGE | ELF::SHF_STRINGS): - ret = 'r'; - break; - } - break; - case ELF::SHT_NOBITS: - ret = 'b'; - } - } - - switch (EF.getSymbolTableIndex(ESym)) { - case ELF::SHN_UNDEF: - if (ret == '?') - ret = 'U'; - break; - case ELF::SHN_ABS: - ret = 'a'; - break; - case ELF::SHN_COMMON: - ret = 'c'; - break; - } - - switch (ESym->getBinding()) { - case ELF::STB_GLOBAL: - ret = ::toupper(ret); - break; - case ELF::STB_WEAK: - if (EF.getSymbolTableIndex(ESym) == ELF::SHN_UNDEF) - ret = 'w'; - else if (ESym->getType() == ELF::STT_OBJECT) - ret = 'V'; - else - ret = 'W'; - } - - if (ret == '?' && ESym->getType() == ELF::STT_SECTION) { - ErrorOr<StringRef> Name = EF.getSymbolName(toELFSymIter(Symb)); - if (!Name) - return Name; - Result = StringSwitch<char>(*Name) - .StartsWith(".debug", 'N') - .StartsWith(".note", 'n') - .Default('?'); - return object_error::success; - } - - Result = ret; - return object_error::success; -} - -template <class ELFT> error_code ELFObjectFile<ELFT>::getSymbolType(DataRefImpl Symb, SymbolRef::Type &Result) const { const Elf_Sym *ESym = getSymbol(Symb); diff --git a/include/llvm/Object/MachO.h b/include/llvm/Object/MachO.h index e91c260803..100613ac8c 100644 --- a/include/llvm/Object/MachO.h +++ b/include/llvm/Object/MachO.h @@ -67,7 +67,6 @@ public: virtual error_code getSymbolSize(DataRefImpl Symb, uint64_t &Res) const; virtual error_code getSymbolType(DataRefImpl Symb, SymbolRef::Type &Res) const; - virtual error_code getSymbolNMTypeChar(DataRefImpl Symb, char &Res) const; virtual error_code getSymbolFlags(DataRefImpl Symb, uint32_t &Res) const; virtual error_code getSymbolSection(DataRefImpl Symb, section_iterator &Res) const; diff --git a/include/llvm/Object/ObjectFile.h b/include/llvm/Object/ObjectFile.h index 0ba4952273..9aea639ef0 100644 --- a/include/llvm/Object/ObjectFile.h +++ b/include/llvm/Object/ObjectFile.h @@ -221,10 +221,6 @@ public: error_code getSize(uint64_t &Result) const; error_code getType(SymbolRef::Type &Result) const; - /// Returns the ascii char that should be displayed in a symbol table dump via - /// nm for this symbol. - error_code getNMTypeChar(char &Result) const; - /// Get symbol flags (bitwise OR of SymbolRef::Flags) error_code getFlags(uint32_t &Result) const; @@ -296,7 +292,6 @@ protected: virtual error_code getSymbolSize(DataRefImpl Symb, uint64_t &Res) const = 0; virtual error_code getSymbolType(DataRefImpl Symb, SymbolRef::Type &Res) const = 0; - virtual error_code getSymbolNMTypeChar(DataRefImpl Symb, char &Res) const = 0; virtual error_code getSymbolFlags(DataRefImpl Symb, uint32_t &Res) const = 0; virtual error_code getSymbolSection(DataRefImpl Symb, @@ -431,10 +426,6 @@ inline error_code SymbolRef::getSize(uint64_t &Result) const { return OwningObject->getSymbolSize(SymbolPimpl, Result); } -inline error_code SymbolRef::getNMTypeChar(char &Result) const { - return OwningObject->getSymbolNMTypeChar(SymbolPimpl, Result); -} - inline error_code SymbolRef::getFlags(uint32_t &Result) const { return OwningObject->getSymbolFlags(SymbolPimpl, Result); } |