17 using namespace object;
29 if (A->SectionID != B->SectionID)
30 return A->SectionID - B->SectionID;
31 return A->Address - B->Address;
35 if (
auto *M = dyn_cast<MachOObjectFile>(&O))
36 return M->getSectionID(Sec);
41 if (
auto *M = dyn_cast<MachOObjectFile>(&O))
42 return M->getSymbolSectionID(Sym);
46 std::vector<std::pair<SymbolRef, uint64_t>>
48 std::vector<std::pair<SymbolRef, uint64_t>>
Ret;
50 if (
const auto *E = dyn_cast<ELFObjectFileBase>(&O)) {
51 auto Syms = E->symbols();
52 if (Syms.begin() == Syms.end())
53 Syms = E->getDynamicSymbolIterators();
55 Ret.push_back({Sym, Sym.getSize()});
61 std::vector<SymEntry> Addresses;
70 uint64_t
Address = Sec.getAddress();
71 uint64_t Size = Sec.getSize();
78 for (
unsigned I = 0,
N = Addresses.size() - 1;
I <
N; ++
I) {
79 auto &
P = Addresses[
I];
84 unsigned NextI =
I + 1;
85 while (NextI < N && Addresses[NextI].
Address ==
P.Address)
88 uint64_t Size = Addresses[NextI].Address -
P.Address;
94 for (SymEntry &
P : Addresses) {
97 Ret[
P.Number] = {*
P.I,
P.Address};
static int compareAddress(const SymEntry *A, const SymEntry *B)
This class is the base class for all object file types.
static unsigned getSymbolSectionID(const ObjectFile &O, SymbolRef Sym)
basic_symbol_iterator symbol_begin() const
void array_pod_sort(IteratorTy Start, IteratorTy End)
array_pod_sort - This sorts an array with the specified start and end extent.
section_iterator_range sections() const
static unsigned getSectionID(const ObjectFile &O, SectionRef Sec)
basic_symbol_iterator symbol_end() const
std::vector< std::pair< SymbolRef, uint64_t > > computeSymbolSizes(const ObjectFile &O)
This is a value type class that represents a single symbol in the list of symbols in the object file...
LLVM Value Representation.
uint64_t getValue() const
Return the value of the symbol depending on the object this can be an offset or a virtual address...
This is a value type class that represents a single section in the list of sections in the object fil...