mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-06-25 00:24:26 +00:00
Use computeSymbolSizes in llvm-symbolize.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@240646 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@ -52,7 +52,10 @@ llvm::object::computeSymbolSizes(const ObjectFile &O) {
|
|||||||
std::vector<std::pair<SymbolRef, uint64_t>> Ret;
|
std::vector<std::pair<SymbolRef, uint64_t>> Ret;
|
||||||
|
|
||||||
if (const auto *E = dyn_cast<ELFObjectFileBase>(&O)) {
|
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)});
|
Ret.push_back({Sym, E->getSymbolSize(Sym)});
|
||||||
return Ret;
|
return Ret;
|
||||||
}
|
}
|
||||||
|
@ -19,6 +19,7 @@
|
|||||||
#include "llvm/DebugInfo/PDB/PDBContext.h"
|
#include "llvm/DebugInfo/PDB/PDBContext.h"
|
||||||
#include "llvm/Object/ELFObjectFile.h"
|
#include "llvm/Object/ELFObjectFile.h"
|
||||||
#include "llvm/Object/MachO.h"
|
#include "llvm/Object/MachO.h"
|
||||||
|
#include "llvm/Object/SymbolSize.h"
|
||||||
#include "llvm/Support/Casting.h"
|
#include "llvm/Support/Casting.h"
|
||||||
#include "llvm/Support/Compression.h"
|
#include "llvm/Support/Compression.h"
|
||||||
#include "llvm/Support/DataExtractor.h"
|
#include "llvm/Support/DataExtractor.h"
|
||||||
@ -71,21 +72,14 @@ ModuleInfo::ModuleInfo(ObjectFile *Obj, DIContext *DICtx)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (const SymbolRef &Symbol : Module->symbols()) {
|
std::vector<std::pair<SymbolRef, uint64_t>> Symbols =
|
||||||
addSymbol(Symbol, OpdExtractor.get(), OpdAddress);
|
computeSymbolSizes(*Module);
|
||||||
}
|
for (auto &P : Symbols)
|
||||||
bool NoSymbolTable = (Module->symbol_begin() == Module->symbol_end());
|
addSymbol(P.first, P.second, OpdExtractor.get(), OpdAddress);
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ModuleInfo::addSymbol(const SymbolRef &Symbol, DataExtractor *OpdExtractor,
|
void ModuleInfo::addSymbol(const SymbolRef &Symbol, uint64_t SymbolSize,
|
||||||
uint64_t OpdAddress) {
|
DataExtractor *OpdExtractor, uint64_t OpdAddress) {
|
||||||
SymbolRef::Type SymbolType;
|
SymbolRef::Type SymbolType;
|
||||||
if (error(Symbol.getType(SymbolType)))
|
if (error(Symbol.getType(SymbolType)))
|
||||||
return;
|
return;
|
||||||
@ -107,13 +101,6 @@ void ModuleInfo::addSymbol(const SymbolRef &Symbol, DataExtractor *OpdExtractor,
|
|||||||
OpdExtractor->isValidOffsetForAddress(OpdOffset32))
|
OpdExtractor->isValidOffsetForAddress(OpdOffset32))
|
||||||
SymbolAddress = OpdExtractor->getAddress(&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;
|
StringRef SymbolName;
|
||||||
if (error(Symbol.getName(SymbolName)))
|
if (error(Symbol.getName(SymbolName)))
|
||||||
return;
|
return;
|
||||||
|
@ -119,7 +119,7 @@ private:
|
|||||||
uint64_t &Size) const;
|
uint64_t &Size) const;
|
||||||
// For big-endian PowerPC64 ELF, OpdAddress is the address of the .opd
|
// For big-endian PowerPC64 ELF, OpdAddress is the address of the .opd
|
||||||
// (function descriptor) section and OpdExtractor refers to its contents.
|
// (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,
|
DataExtractor *OpdExtractor = nullptr,
|
||||||
uint64_t OpdAddress = 0);
|
uint64_t OpdAddress = 0);
|
||||||
ObjectFile *Module;
|
ObjectFile *Module;
|
||||||
|
Reference in New Issue
Block a user