diff options
Diffstat (limited to 'contrib/llvm/tools/llvm-cxxdump/llvm-cxxdump.cpp')
-rw-r--r-- | contrib/llvm/tools/llvm-cxxdump/llvm-cxxdump.cpp | 34 |
1 files changed, 18 insertions, 16 deletions
diff --git a/contrib/llvm/tools/llvm-cxxdump/llvm-cxxdump.cpp b/contrib/llvm/tools/llvm-cxxdump/llvm-cxxdump.cpp index ef42211..c627a66 100644 --- a/contrib/llvm/tools/llvm-cxxdump/llvm-cxxdump.cpp +++ b/contrib/llvm/tools/llvm-cxxdump/llvm-cxxdump.cpp @@ -16,6 +16,7 @@ #include "llvm/ADT/ArrayRef.h" #include "llvm/Object/Archive.h" #include "llvm/Object/ObjectFile.h" +#include "llvm/Object/SymbolSize.h" #include "llvm/Support/Debug.h" #include "llvm/Support/Endian.h" #include "llvm/Support/FileSystem.h" @@ -96,14 +97,12 @@ static bool collectRelocatedSymbols(const ObjectFile *Obj, const object::symbol_iterator RelocSymI = Reloc.getSymbol(); if (RelocSymI == Obj->symbol_end()) continue; - StringRef RelocSymName; - if (error(RelocSymI->getName(RelocSymName))) - return true; - uint64_t Offset; - if (error(Reloc.getOffset(Offset))) + ErrorOr<StringRef> RelocSymName = RelocSymI->getName(); + if (error(RelocSymName.getError())) return true; + uint64_t Offset = Reloc.getOffset(); if (Offset >= SymOffset && Offset < SymEnd) { - *I = RelocSymName; + *I = *RelocSymName; ++I; } } @@ -122,14 +121,12 @@ static bool collectRelocationOffsets( const object::symbol_iterator RelocSymI = Reloc.getSymbol(); if (RelocSymI == Obj->symbol_end()) continue; - StringRef RelocSymName; - if (error(RelocSymI->getName(RelocSymName))) - return true; - uint64_t Offset; - if (error(Reloc.getOffset(Offset))) + ErrorOr<StringRef> RelocSymName = RelocSymI->getName(); + if (error(RelocSymName.getError())) return true; + uint64_t Offset = Reloc.getOffset(); if (Offset >= SymOffset && Offset < SymEnd) - Collection[std::make_pair(SymName, Offset - SymOffset)] = RelocSymName; + Collection[std::make_pair(SymName, Offset - SymOffset)] = *RelocSymName; } } return false; @@ -187,10 +184,16 @@ static void dumpCXXData(const ObjectFile *Obj) { uint8_t BytesInAddress = Obj->getBytesInAddress(); - for (const object::SymbolRef &Sym : Obj->symbols()) { - StringRef SymName; - if (error(Sym.getName(SymName))) + std::vector<std::pair<SymbolRef, uint64_t>> SymAddr = + object::computeSymbolSizes(*Obj); + + for (auto &P : SymAddr) { + object::SymbolRef Sym = P.first; + uint64_t SymSize = P.second; + ErrorOr<StringRef> SymNameOrErr = Sym.getName(); + if (error(SymNameOrErr.getError())) return; + StringRef SymName = *SymNameOrErr; object::section_iterator SecI(Obj->section_begin()); if (error(Sym.getSection(SecI))) return; @@ -207,7 +210,6 @@ static void dumpCXXData(const ObjectFile *Obj) { uint64_t SymAddress; if (error(Sym.getAddress(SymAddress))) return; - uint64_t SymSize = Sym.getSize(); uint64_t SecAddress = Sec.getAddress(); uint64_t SecSize = Sec.getSize(); uint64_t SymOffset = SymAddress - SecAddress; |