1//===- SymbolSize.cpp -----------------------------------------------------===// 
  3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 
  4// See https://llvm.org/LICENSE.txt for license information. 
  5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 
  7//===----------------------------------------------------------------------===// 
  20// Orders increasingly by (SectionID, Address). 
  22 if (
A->SectionID != 
B->SectionID)
 
  23 return A->SectionID < 
B->SectionID ? -1 : 1;
 
  24 if (
A->Address != 
B->Address)
 
  25 return A->Address < 
B->Address ? -1 : 1;
 
 
  31 return M->getSectionID(Sec);
 
 
  41 return M->getSymbolSectionID(Sym);
 
  43 return M->getSymbolSectionId(Sym);
 
  45 return M->getSymbolSectionID(Sym);
 
 
  49std::vector<std::pair<SymbolRef, uint64_t>>
 
  51 std::vector<std::pair<SymbolRef, uint64_t>> Ret;
 
  54 auto Syms = E->symbols();
 
  56 Syms = E->getDynamicSymbolIterators();
 
  58 Ret.push_back({Sym, Sym.getSize()});
 
  64 Ret.push_back({Sym, Sym.getSize()});
 
  70 Ret.push_back({Sym, E->getSymbolSize(Sym)});
 
  75 // Collect sorted symbol addresses. Include dummy addresses for the end 
  77 std::vector<SymEntry> Addresses;
 
  83 // TODO: Actually report errors helpfully. 
  95 if (Addresses.empty())
 
  100 // Compute the size as the gap to the next symbol. If multiple symbols have 
  101 // the same address, give both the same size. Because Addresses is sorted, 
  102 // use two pointers to keep track of the current symbol vs. the next symbol 
  103 // that doesn't have the same address for size computation. 
  104 for (
unsigned I = 0, NextI = 0, 
N = Addresses.size() - 1; 
I < 
N; ++
I) {
 
  105 auto &
P = Addresses[
I];
 
  106 if (
P.I == O.symbol_end())
 
  109 // If the next pointer is behind, update it to the next symbol. 
  112 while (NextI < 
N && Addresses[NextI].
Address == 
P.Address)
 
  120 // Assign the sorted symbols in the original order. 
  123 if (
P.I == O.symbol_end())
 
  125 Ret[
P.Number] = {*
P.I, 
P.Address};
 
 
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
 
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
 
static unsigned getSymbolSectionID(const ObjectFile &O, SymbolRef Sym)
 
static unsigned getSectionID(const ObjectFile &O, SectionRef Sec)
 
Tagged union holding either a T or a Error.
 
Error takeError()
Take ownership of the stored error.
 
This class is the base class for all object file types.
 
This is a value type class that represents a single section in the list of sections in the object fil...
 
uint64_t getIndex() const
 
This is a value type class that represents a single symbol in the list of symbols in the object file.
 
Expected< uint64_t > getValue() const
Return the value of the symbol depending on the object this can be an offset or a virtual address.
 
LLVM_ABI int compareAddress(const SymEntry *A, const SymEntry *B)
 
LLVM_ABI std::vector< std::pair< SymbolRef, uint64_t > > computeSymbolSizes(const ObjectFile &O)
 
This is an optimization pass for GlobalISel generic memory operations.
 
decltype(auto) dyn_cast(const From &Val)
dyn_cast<X> - Return the argument parameter cast to the specified type.
 
LLVM_ABI void report_fatal_error(Error Err, bool gen_crash_diag=true)
 
bool isa(const From &Val)
isa<X> - Return true if the parameter to the template is an instance of one of the template type argu...
 
decltype(auto) cast(const From &Val)
cast<X> - Return the argument parameter cast to the specified type.
 
void array_pod_sort(IteratorTy Start, IteratorTy End)
array_pod_sort - This sorts an array with the specified start and end extent.