[llvm] r202264 - Move getELFDynamicSymbolIterators to a public header.
Alexey Samsonov
samsonov at google.com
Wed Feb 26 04:51:19 PST 2014
Author: samsonov
Date: Wed Feb 26 06:51:19 2014
New Revision: 202264
URL: http://llvm.org/viewvc/llvm-project?rev=202264&view=rev
Log:
Move getELFDynamicSymbolIterators to a public header.
Modified:
llvm/trunk/include/llvm/Object/ELFObjectFile.h
llvm/trunk/tools/llvm-nm/llvm-nm.cpp
Modified: llvm/trunk/include/llvm/Object/ELFObjectFile.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Object/ELFObjectFile.h?rev=202264&r1=202263&r2=202264&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Object/ELFObjectFile.h (original)
+++ llvm/trunk/include/llvm/Object/ELFObjectFile.h Wed Feb 26 06:51:19 2014
@@ -1015,6 +1015,25 @@ static inline error_code getELFRelocatio
llvm_unreachable("Object passed to getELFRelocationAddend() is not ELF");
}
+static inline std::pair<symbol_iterator, symbol_iterator>
+getELFDynamicSymbolIterators(SymbolicFile *Obj) {
+ if (const ELF32LEObjectFile *ELF = dyn_cast<ELF32LEObjectFile>(Obj))
+ return std::make_pair(ELF->dynamic_symbol_begin(),
+ ELF->dynamic_symbol_end());
+ if (const ELF64LEObjectFile *ELF = dyn_cast<ELF64LEObjectFile>(Obj))
+ return std::make_pair(ELF->dynamic_symbol_begin(),
+ ELF->dynamic_symbol_end());
+ if (const ELF32BEObjectFile *ELF = dyn_cast<ELF32BEObjectFile>(Obj))
+ return std::make_pair(ELF->dynamic_symbol_begin(),
+ ELF->dynamic_symbol_end());
+ if (const ELF64BEObjectFile *ELF = cast<ELF64BEObjectFile>(Obj))
+ return std::make_pair(ELF->dynamic_symbol_begin(),
+ ELF->dynamic_symbol_end());
+
+ llvm_unreachable(
+ "Object passed to getELFDynamicSymbolIterators() is not ELF");
+}
+
/// This is a generic interface for retrieving GNU symbol version
/// information from an ELFObjectFile.
static inline error_code GetELFSymbolVersion(const ObjectFile *Obj,
Modified: llvm/trunk/tools/llvm-nm/llvm-nm.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-nm/llvm-nm.cpp?rev=202264&r1=202263&r2=202264&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-nm/llvm-nm.cpp (original)
+++ llvm/trunk/tools/llvm-nm/llvm-nm.cpp Wed Feb 26 06:51:19 2014
@@ -462,30 +462,6 @@ static char getNMTypeChar(SymbolicFile *
return Ret;
}
-static void getDynamicSymbolIterators(SymbolicFile *Obj,
- basic_symbol_iterator &Begin,
- basic_symbol_iterator &End) {
- if (ELF32LEObjectFile *ELF = dyn_cast<ELF32LEObjectFile>(Obj)) {
- Begin = ELF->dynamic_symbol_begin();
- End = ELF->dynamic_symbol_end();
- return;
- }
- if (ELF64LEObjectFile *ELF = dyn_cast<ELF64LEObjectFile>(Obj)) {
- Begin = ELF->dynamic_symbol_begin();
- End = ELF->dynamic_symbol_end();
- return;
- }
- if (ELF32BEObjectFile *ELF = dyn_cast<ELF32BEObjectFile>(Obj)) {
- Begin = ELF->dynamic_symbol_begin();
- End = ELF->dynamic_symbol_end();
- return;
- }
- ELF64BEObjectFile *ELF = cast<ELF64BEObjectFile>(Obj);
- Begin = ELF->dynamic_symbol_begin();
- End = ELF->dynamic_symbol_end();
- return;
-}
-
static void dumpSymbolNamesFromObject(SymbolicFile *Obj) {
basic_symbol_iterator IBegin = Obj->symbol_begin();
basic_symbol_iterator IEnd = Obj->symbol_end();
@@ -494,7 +470,10 @@ static void dumpSymbolNamesFromObject(Sy
error("File format has no dynamic symbol table", Obj->getFileName());
return;
}
- getDynamicSymbolIterators(Obj, IBegin, IEnd);
+ std::pair<symbol_iterator, symbol_iterator> IDyn =
+ getELFDynamicSymbolIterators(Obj);
+ IBegin = IDyn.first;
+ IEnd = IDyn.second;
}
std::string NameBuffer;
raw_string_ostream OS(NameBuffer);
More information about the llvm-commits
mailing list