LLVM: lib/ObjCopy/COFF/COFFObject.cpp Source File (original) (raw)

1

2

3

4

5

6

7

8

11

12namespace llvm {

14namespace coff {

15

16using namespace object;

17

19 for (Symbol S : NewSymbols) {

20 S.UniqueId = NextSymbolUniqueId++;

21 S.OriginalRawIndex = NextSymbolOriginalIndex;

22 NextSymbolOriginalIndex += 1 + S.Sym.NumberOfAuxSymbols;

23 Symbols.emplace_back(S);

24 }

25 updateSymbols();

26}

27

28void Object::updateSymbols() {

30 for (Symbol &Sym : Symbols)

31 SymbolMap[Sym.UniqueId] = &Sym;

32}

33

35 return SymbolMap.lookup(UniqueId);

36}

37

43 if (!ShouldRemove) {

45 return false;

46 }

47 return *ShouldRemove;

48 });

49

50 updateSymbols();

51 return Errs;

52}

53

55 for (Symbol &Sym : Symbols)

56 Sym.Referenced = false;

57 for (const Section &Sec : Sections) {

58 for (const Relocation &R : Sec.Relocs) {

59 auto It = SymbolMap.find(R.Target);

60 if (It == SymbolMap.end())

62 "relocation target %zu not found", R.Target);

63 It->second->Referenced = true;

64 }

65 }

67}

68

70 for (Section S : NewSections) {

71 S.UniqueId = NextSectionUniqueId++;

72 Sections.emplace_back(S);

73 }

74 updateSections();

75}

76

77void Object::updateSections() {

79 size_t Index = 1;

80 for (Section &S : Sections) {

81 SectionMap[S.UniqueId] = &S;

82 S.Index = Index++;

83 }

84}

85

87 return SectionMap.lookup(UniqueId);

88}

89

92 auto RemoveAssociated = [&AssociatedSections](const Section &Sec) {

93 return AssociatedSections.contains(Sec.UniqueId);

94 };

95 do {

99 if (Remove)

101 return Remove;

102 });

103

104 AssociatedSections.clear();

106 Symbols, [&RemovedSections, &AssociatedSections](const Symbol &Sym) {

107

108

109

110

114 });

116 } while (!AssociatedSections.empty());

117 updateSections();

118 updateSymbols();

119}

120

122 for (Section &Sec : Sections) {

123 if (ToTruncate(Sec)) {

124 Sec.clearContents();

125 Sec.Relocs.clear();

126 Sec.Header.SizeOfRawData = 0;

127 }

128 }

129}

130

131}

132}

133}

ReachingDefInfo InstSet & ToRemove

This file defines the DenseSet and SmallDenseSet classes.

ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...

Implements a dense probed hash-table based set.

Lightweight error class with error context and mandatory checking.

static ErrorSuccess success()

Create a success value.

Tagged union holding either a T or a Error.

Error takeError()

Take ownership of the stored error.

std::pair< iterator, bool > insert(const ValueT &V)

bool contains(const_arg_type_t< ValueT > V) const

Check if the set contains the given element.

An efficient, type-erasing, non-owning reference to a callable.

This is an optimization pass for GlobalISel generic memory operations.

Error createStringError(std::error_code EC, char const *Fmt, const Ts &... Vals)

Create formatted StringError object.

Error joinErrors(Error E1, Error E2)

Concatenate errors.

void erase_if(Container &C, UnaryPredicate P)

Provide a container algorithm similar to C++ Library Fundamentals v2's erase_if which is equivalent t...

void truncateSections(function_ref< bool(const Section &)> ToTruncate)

Definition COFFObject.cpp:121

const Symbol * findSymbol(size_t UniqueId) const

Definition COFFObject.cpp:34

const Section * findSection(ssize_t UniqueId) const

Definition COFFObject.cpp:86

void addSections(ArrayRef< Section > NewSections)

Definition COFFObject.cpp:69

void removeSections(function_ref< bool(const Section &)> ToRemove)

Definition COFFObject.cpp:90

void addSymbols(ArrayRef< Symbol > NewSymbols)

Definition COFFObject.cpp:18

Error removeSymbols(function_ref< Expected< bool >(const Symbol &)> ToRemove)

Definition COFFObject.cpp:38

Error markSymbols()

Definition COFFObject.cpp:54

ssize_t AssociativeComdatTargetSectionId