14
14
#include " llvm/MC/MCDisassembler/MCDisassembler.h"
15
15
#include " llvm/MC/MCSubtargetInfo.h"
16
16
#include " llvm/Object/Archive.h"
17
+ #include " llvm/Object/ObjectFile.h"
17
18
#include " llvm/Support/Compiler.h"
18
19
#include " llvm/Support/DataTypes.h"
19
20
#include " llvm/Support/FormattedStream.h"
@@ -64,59 +65,6 @@ extern bool UnwindInfo;
64
65
65
66
extern StringSet<> FoundSectionSet;
66
67
67
- typedef std::function<bool (llvm::object::SectionRef const &)> FilterPredicate;
68
-
69
- // / A filtered iterator for SectionRefs that skips sections based on some given
70
- // / predicate.
71
- class SectionFilterIterator {
72
- public:
73
- SectionFilterIterator (FilterPredicate P,
74
- llvm::object::section_iterator const &I,
75
- llvm::object::section_iterator const &E)
76
- : Predicate(std::move(P)), Iterator(I), End(E) {
77
- ScanPredicate ();
78
- }
79
- const llvm::object::SectionRef &operator *() const { return *Iterator; }
80
- SectionFilterIterator &operator ++() {
81
- ++Iterator;
82
- ScanPredicate ();
83
- return *this ;
84
- }
85
- bool operator !=(SectionFilterIterator const &Other) const {
86
- return Iterator != Other.Iterator ;
87
- }
88
-
89
- private:
90
- void ScanPredicate () {
91
- while (Iterator != End && !Predicate (*Iterator)) {
92
- ++Iterator;
93
- }
94
- }
95
- FilterPredicate Predicate;
96
- llvm::object::section_iterator Iterator;
97
- llvm::object::section_iterator End;
98
- };
99
-
100
- // / Creates an iterator range of SectionFilterIterators for a given Object and
101
- // / predicate.
102
- class SectionFilter {
103
- public:
104
- SectionFilter (FilterPredicate P, llvm::object::ObjectFile const &O)
105
- : Predicate(std::move(P)), Object(O) {}
106
- SectionFilterIterator begin () {
107
- return SectionFilterIterator (Predicate, Object.section_begin (),
108
- Object.section_end ());
109
- }
110
- SectionFilterIterator end () {
111
- return SectionFilterIterator (Predicate, Object.section_end (),
112
- Object.section_end ());
113
- }
114
-
115
- private:
116
- FilterPredicate Predicate;
117
- llvm::object::ObjectFile const &Object;
118
- };
119
-
120
68
// Various helper functions.
121
69
122
70
// / Creates a SectionFilter with a standard predicate that conditionally skips
@@ -125,8 +73,8 @@ class SectionFilter {
125
73
// / Idx is an optional output parameter that keeps track of which section index
126
74
// / this is. This may be different than the actual section number, as some
127
75
// / sections may be filtered (e.g. symbol tables).
128
- SectionFilter ToolSectionFilter (llvm::object::ObjectFile const &O,
129
- uint64_t *Idx = nullptr );
76
+ object:: SectionFilter ToolSectionFilter (const llvm::object::ObjectFile &O,
77
+ uint64_t *Idx = nullptr );
130
78
131
79
bool isRelocAddressLess (object::RelocationRef A, object::RelocationRef B);
132
80
void printRelocations (const object::ObjectFile *O);
0 commit comments