[llvm] r240646 - Use computeSymbolSizes in llvm-symbolize.
Rafael Espindola
rafael.espindola at gmail.com
Thu Jun 25 08:06:38 PDT 2015
Author: rafael
Date: Thu Jun 25 10:06:38 2015
New Revision: 240646
URL: http://llvm.org/viewvc/llvm-project?rev=240646&view=rev
Log:
Use computeSymbolSizes in llvm-symbolize.
Modified:
llvm/trunk/lib/Object/SymbolSize.cpp
llvm/trunk/tools/llvm-symbolizer/LLVMSymbolize.cpp
llvm/trunk/tools/llvm-symbolizer/LLVMSymbolize.h
Modified: llvm/trunk/lib/Object/SymbolSize.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Object/SymbolSize.cpp?rev=240646&r1=240645&r2=240646&view=diff
==============================================================================
--- llvm/trunk/lib/Object/SymbolSize.cpp (original)
+++ llvm/trunk/lib/Object/SymbolSize.cpp Thu Jun 25 10:06:38 2015
@@ -52,7 +52,10 @@ llvm::object::computeSymbolSizes(const O
std::vector<std::pair<SymbolRef, uint64_t>> Ret;
if (const auto *E = dyn_cast<ELFObjectFileBase>(&O)) {
- for (SymbolRef Sym : E->symbols())
+ auto Syms = E->symbols();
+ if (Syms.begin() == Syms.end())
+ Syms = E->getDynamicSymbolIterators();
+ for (SymbolRef Sym : Syms)
Ret.push_back({Sym, E->getSymbolSize(Sym)});
return Ret;
}
Modified: llvm/trunk/tools/llvm-symbolizer/LLVMSymbolize.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-symbolizer/LLVMSymbolize.cpp?rev=240646&r1=240645&r2=240646&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-symbolizer/LLVMSymbolize.cpp (original)
+++ llvm/trunk/tools/llvm-symbolizer/LLVMSymbolize.cpp Thu Jun 25 10:06:38 2015
@@ -19,6 +19,7 @@
#include "llvm/DebugInfo/PDB/PDBContext.h"
#include "llvm/Object/ELFObjectFile.h"
#include "llvm/Object/MachO.h"
+#include "llvm/Object/SymbolSize.h"
#include "llvm/Support/Casting.h"
#include "llvm/Support/Compression.h"
#include "llvm/Support/DataExtractor.h"
@@ -71,21 +72,14 @@ ModuleInfo::ModuleInfo(ObjectFile *Obj,
}
}
}
- for (const SymbolRef &Symbol : Module->symbols()) {
- addSymbol(Symbol, OpdExtractor.get(), OpdAddress);
- }
- bool NoSymbolTable = (Module->symbol_begin() == Module->symbol_end());
- if (NoSymbolTable && Module->isELF()) {
- // Fallback to dynamic symbol table, if regular symbol table is stripped.
- auto IDyn = cast<ELFObjectFileBase>(Module)->getDynamicSymbolIterators();
- for (SymbolRef Sym : IDyn) {
- addSymbol(Sym, OpdExtractor.get(), OpdAddress);
- }
- }
+ std::vector<std::pair<SymbolRef, uint64_t>> Symbols =
+ computeSymbolSizes(*Module);
+ for (auto &P : Symbols)
+ addSymbol(P.first, P.second, OpdExtractor.get(), OpdAddress);
}
-void ModuleInfo::addSymbol(const SymbolRef &Symbol, DataExtractor *OpdExtractor,
- uint64_t OpdAddress) {
+void ModuleInfo::addSymbol(const SymbolRef &Symbol, uint64_t SymbolSize,
+ DataExtractor *OpdExtractor, uint64_t OpdAddress) {
SymbolRef::Type SymbolType;
if (error(Symbol.getType(SymbolType)))
return;
@@ -107,13 +101,6 @@ void ModuleInfo::addSymbol(const SymbolR
OpdExtractor->isValidOffsetForAddress(OpdOffset32))
SymbolAddress = OpdExtractor->getAddress(&OpdOffset32);
}
- uint64_t SymbolSize;
- // Onyl ELF has a size for every symbol so assume that symbol occupies the
- // memory range up to the following symbol.
- if (auto *E = dyn_cast<ELFObjectFileBase>(Module))
- SymbolSize = E->getSymbolSize(Symbol);
- else
- SymbolSize = 0;
StringRef SymbolName;
if (error(Symbol.getName(SymbolName)))
return;
Modified: llvm/trunk/tools/llvm-symbolizer/LLVMSymbolize.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-symbolizer/LLVMSymbolize.h?rev=240646&r1=240645&r2=240646&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-symbolizer/LLVMSymbolize.h (original)
+++ llvm/trunk/tools/llvm-symbolizer/LLVMSymbolize.h Thu Jun 25 10:06:38 2015
@@ -119,7 +119,7 @@ private:
uint64_t &Size) const;
// For big-endian PowerPC64 ELF, OpdAddress is the address of the .opd
// (function descriptor) section and OpdExtractor refers to its contents.
- void addSymbol(const SymbolRef &Symbol,
+ void addSymbol(const SymbolRef &Symbol, uint64_t SymbolSize,
DataExtractor *OpdExtractor = nullptr,
uint64_t OpdAddress = 0);
ObjectFile *Module;
More information about the llvm-commits
mailing list