Modernize getELFDynamicSymbolIterators.

* Have it return a iterator_range.
* Remove the global function.
* Rename to getDynamicSymbolIterators.

llvm-svn: 240644
This commit is contained in:
Rafael Espindola 2015-06-25 14:39:35 +00:00
parent c5f28c35c8
commit 1fbc4b86c4
3 changed files with 13 additions and 21 deletions

View File

@ -46,8 +46,7 @@ public:
// and addend or not.
virtual bool hasRelocationAddend(DataRefImpl Rel) const = 0;
virtual std::pair<symbol_iterator, symbol_iterator>
getELFDynamicSymbolIterators() const = 0;
virtual symbol_iterator_range getDynamicSymbolIterators() const = 0;
virtual uint64_t getSectionFlags(SectionRef Sec) const = 0;
virtual uint32_t getSectionType(SectionRef Sec) const = 0;
@ -237,8 +236,7 @@ public:
ELFT::Is64Bits);
}
std::pair<symbol_iterator, symbol_iterator>
getELFDynamicSymbolIterators() const override;
symbol_iterator_range getDynamicSymbolIterators() const override;
bool isRelocatableObject() const override;
};
@ -855,20 +853,15 @@ unsigned ELFObjectFile<ELFT>::getArch() const {
}
template <class ELFT>
std::pair<symbol_iterator, symbol_iterator>
ELFObjectFile<ELFT>::getELFDynamicSymbolIterators() const {
return std::make_pair(dynamic_symbol_begin(), dynamic_symbol_end());
ObjectFile::symbol_iterator_range
ELFObjectFile<ELFT>::getDynamicSymbolIterators() const {
return make_range(dynamic_symbol_begin(), dynamic_symbol_end());
}
template <class ELFT> bool ELFObjectFile<ELFT>::isRelocatableObject() const {
return EF.getHeader()->e_type == ELF::ET_REL;
}
inline std::pair<symbol_iterator, symbol_iterator>
getELFDynamicSymbolIterators(const SymbolicFile *Obj) {
return cast<ELFObjectFileBase>(Obj)->getELFDynamicSymbolIterators();
}
}
}

View File

@ -890,14 +890,14 @@ static void dumpSymbolNamesFromObject(SymbolicFile &Obj, bool printName,
basic_symbol_iterator IBegin = Obj.symbol_begin();
basic_symbol_iterator IEnd = Obj.symbol_end();
if (DynamicSyms) {
if (!Obj.isELF()) {
const auto *E = dyn_cast<ELFObjectFileBase>(&Obj);
if (!E) {
error("File format has no dynamic symbol table", Obj.getFileName());
return;
}
std::pair<symbol_iterator, symbol_iterator> IDyn =
getELFDynamicSymbolIterators(&Obj);
IBegin = IDyn.first;
IEnd = IDyn.second;
auto IDyn = E->getDynamicSymbolIterators();
IBegin = IDyn.begin();
IEnd = IDyn.end();
}
std::string NameBuffer;
raw_string_ostream OS(NameBuffer);

View File

@ -77,10 +77,9 @@ ModuleInfo::ModuleInfo(ObjectFile *Obj, DIContext *DICtx)
bool NoSymbolTable = (Module->symbol_begin() == Module->symbol_end());
if (NoSymbolTable && Module->isELF()) {
// Fallback to dynamic symbol table, if regular symbol table is stripped.
std::pair<symbol_iterator, symbol_iterator> IDyn =
getELFDynamicSymbolIterators(Module);
for (symbol_iterator si = IDyn.first, se = IDyn.second; si != se; ++si) {
addSymbol(*si, OpdExtractor.get(), OpdAddress);
auto IDyn = cast<ELFObjectFileBase>(Module)->getDynamicSymbolIterators();
for (SymbolRef Sym : IDyn) {
addSymbol(Sym, OpdExtractor.get(), OpdAddress);
}
}
}