LLVM: lib/Object/SymbolSize.cpp Source File (original) (raw)

1

2

3

4

5

6

7

8

16

17using namespace llvm;

18using namespace object;

19

20

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;

26 return 0;

27}

28

31 return M->getSectionID(Sec);

37}

38

41 return M->getSymbolSectionID(Sym);

43 return M->getSymbolSectionId(Sym);

45 return M->getSymbolSectionID(Sym);

47}

48

49std::vector<std::pair<SymbolRef, uint64_t>>

51 std::vector<std::pair<SymbolRef, uint64_t>> Ret;

52

54 auto Syms = E->symbols();

55 if (Syms.empty())

56 Syms = E->getDynamicSymbolIterators();

58 Ret.push_back({Sym, Sym.getSize()});

59 return Ret;

60 }

61

64 Ret.push_back({Sym, Sym.getSize()});

65 return Ret;

66 }

67

69 for (SymbolRef Sym : E->symbols()) {

70 Ret.push_back({Sym, E->getSymbolSize(Sym)});

71 }

72 return Ret;

73 }

74

75

76

77 std::vector Addresses;

78 unsigned SymNum = 0;

79 for (symbol_iterator I = O.symbol_begin(), E = O.symbol_end(); I != E; ++I) {

82 if (!ValueOrErr)

83

85 Addresses.push_back({I, *ValueOrErr, SymNum, getSymbolSectionID(O, Sym)});

86 ++SymNum;

87 }

91 Addresses.push_back(

93 }

94

95 if (Addresses.empty())

96 return Ret;

97

99

100

101

102

103

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())

107 continue;

108

109

110 if (NextI <= I) {

111 NextI = I + 1;

112 while (NextI < N && Addresses[NextI].Address == P.Address)

113 ++NextI;

114 }

115

116 uint64_t Size = Addresses[NextI].Address - P.Address;

117 P.Address = Size;

118 }

119

120

121 Ret.resize(SymNum);

123 if (P.I == O.symbol_end())

124 continue;

125 Ret[P.Number] = {*P.I, P.Address};

126 }

127 return Ret;

128}

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)

Definition SymbolSize.cpp:39

static unsigned getSectionID(const ObjectFile &O, SectionRef Sec)

Definition SymbolSize.cpp:29

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)

Definition SymbolSize.cpp:21

LLVM_ABI std::vector< std::pair< SymbolRef, uint64_t > > computeSymbolSizes(const ObjectFile &O)

Definition SymbolSize.cpp:50

This is an optimization pass for GlobalISel generic memory operations.

decltype(auto) dyn_cast(const From &Val)

dyn_cast - 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 - 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 - 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.