@@ -40,29 +40,24 @@ cl::list<std::string> InputFilenames(cl::Positional,
40
40
cl::ZeroOrMore);
41
41
} // namespace opts
42
42
43
- static int ReturnValue = EXIT_SUCCESS;
44
-
45
43
namespace llvm {
46
44
47
- static bool error (std::error_code EC) {
45
+ static void error (std::error_code EC) {
48
46
if (!EC)
49
- return false ;
50
-
51
- ReturnValue = EXIT_FAILURE;
47
+ return ;
52
48
outs () << " \n Error reading file: " << EC.message () << " .\n " ;
53
49
outs ().flush ();
54
- return true ;
50
+ exit ( 1 ) ;
55
51
}
56
52
57
53
} // namespace llvm
58
54
59
55
static void reportError (StringRef Input, StringRef Message) {
60
56
if (Input == " -" )
61
57
Input = " <stdin>" ;
62
-
63
58
errs () << Input << " : " << Message << " \n " ;
64
59
errs ().flush ();
65
- ReturnValue = EXIT_FAILURE ;
60
+ exit ( 1 ) ;
66
61
}
67
62
68
63
static void reportError (StringRef Input, std::error_code EC) {
@@ -84,7 +79,7 @@ static SmallVectorImpl<SectionRef> &getRelocSections(const ObjectFile *Obj,
84
79
return SectionRelocMap[Sec];
85
80
}
86
81
87
- static bool collectRelocatedSymbols (const ObjectFile *Obj,
82
+ static void collectRelocatedSymbols (const ObjectFile *Obj,
88
83
const SectionRef &Sec, uint64_t SecAddress,
89
84
uint64_t SymAddress, uint64_t SymSize,
90
85
StringRef *I, StringRef *E) {
@@ -98,19 +93,17 @@ static bool collectRelocatedSymbols(const ObjectFile *Obj,
98
93
if (RelocSymI == Obj->symbol_end ())
99
94
continue ;
100
95
ErrorOr<StringRef> RelocSymName = RelocSymI->getName ();
101
- if (error (RelocSymName.getError ()))
102
- return true ;
96
+ error (RelocSymName.getError ());
103
97
uint64_t Offset = Reloc.getOffset ();
104
98
if (Offset >= SymOffset && Offset < SymEnd) {
105
99
*I = *RelocSymName;
106
100
++I;
107
101
}
108
102
}
109
103
}
110
- return false ;
111
104
}
112
105
113
- static bool collectRelocationOffsets (
106
+ static void collectRelocationOffsets (
114
107
const ObjectFile *Obj, const SectionRef &Sec, uint64_t SecAddress,
115
108
uint64_t SymAddress, uint64_t SymSize, StringRef SymName,
116
109
std::map<std::pair<StringRef, uint64_t >, StringRef> &Collection) {
@@ -122,14 +115,12 @@ static bool collectRelocationOffsets(
122
115
if (RelocSymI == Obj->symbol_end ())
123
116
continue ;
124
117
ErrorOr<StringRef> RelocSymName = RelocSymI->getName ();
125
- if (error (RelocSymName.getError ()))
126
- return true ;
118
+ error (RelocSymName.getError ());
127
119
uint64_t Offset = Reloc.getOffset ();
128
120
if (Offset >= SymOffset && Offset < SymEnd)
129
121
Collection[std::make_pair (SymName, Offset - SymOffset)] = *RelocSymName;
130
122
}
131
123
}
132
- return false ;
133
124
}
134
125
135
126
static void dumpCXXData (const ObjectFile *Obj) {
@@ -191,12 +182,10 @@ static void dumpCXXData(const ObjectFile *Obj) {
191
182
object::SymbolRef Sym = P.first ;
192
183
uint64_t SymSize = P.second ;
193
184
ErrorOr<StringRef> SymNameOrErr = Sym.getName ();
194
- if (error (SymNameOrErr.getError ()))
195
- return ;
185
+ error (SymNameOrErr.getError ());
196
186
StringRef SymName = *SymNameOrErr;
197
187
object::section_iterator SecI (Obj->section_begin ());
198
- if (error (Sym.getSection (SecI)))
199
- return ;
188
+ error (Sym.getSection (SecI));
200
189
// Skip external symbols.
201
190
if (SecI == Obj->section_end ())
202
191
continue ;
@@ -205,11 +194,9 @@ static void dumpCXXData(const ObjectFile *Obj) {
205
194
if (Sec.isBSS () || Sec.isVirtual ())
206
195
continue ;
207
196
StringRef SecContents;
208
- if (error (Sec.getContents (SecContents)))
209
- return ;
197
+ error (Sec.getContents (SecContents));
210
198
ErrorOr<uint64_t > SymAddressOrErr = Sym.getAddress ();
211
- if (error (SymAddressOrErr.getError ()))
212
- return ;
199
+ error (SymAddressOrErr.getError ());
213
200
uint64_t SymAddress = *SymAddressOrErr;
214
201
uint64_t SecAddress = Sec.getAddress ();
215
202
uint64_t SecSize = Sec.getSize ();
@@ -239,9 +226,7 @@ static void dumpCXXData(const ObjectFile *Obj) {
239
226
COL.Data = ArrayRef<little32_t >(
240
227
reinterpret_cast <const little32_t *>(SymContents.data ()), 3 );
241
228
StringRef *I = std::begin (COL.Symbols ), *E = std::end (COL.Symbols );
242
- if (collectRelocatedSymbols (Obj, Sec, SecAddress, SymAddress, SymSize, I,
243
- E))
244
- return ;
229
+ collectRelocatedSymbols (Obj, Sec, SecAddress, SymAddress, SymSize, I, E);
245
230
COLs[SymName] = COL;
246
231
}
247
232
// Class hierarchy descriptors in the MS-ABI start with '??_R3'
@@ -250,9 +235,7 @@ static void dumpCXXData(const ObjectFile *Obj) {
250
235
CHD.Data = ArrayRef<little32_t >(
251
236
reinterpret_cast <const little32_t *>(SymContents.data ()), 3 );
252
237
StringRef *I = std::begin (CHD.Symbols ), *E = std::end (CHD.Symbols );
253
- if (collectRelocatedSymbols (Obj, Sec, SecAddress, SymAddress, SymSize, I,
254
- E))
255
- return ;
238
+ collectRelocatedSymbols (Obj, Sec, SecAddress, SymAddress, SymSize, I, E);
256
239
CHDs[SymName] = CHD;
257
240
}
258
241
// Class hierarchy descriptors in the MS-ABI start with '??_R2'
@@ -268,9 +251,7 @@ static void dumpCXXData(const ObjectFile *Obj) {
268
251
BCD.Data = ArrayRef<little32_t >(
269
252
reinterpret_cast <const little32_t *>(SymContents.data ()) + 1 , 5 );
270
253
StringRef *I = std::begin (BCD.Symbols ), *E = std::end (BCD.Symbols );
271
- if (collectRelocatedSymbols (Obj, Sec, SecAddress, SymAddress, SymSize, I,
272
- E))
273
- return ;
254
+ collectRelocatedSymbols (Obj, Sec, SecAddress, SymAddress, SymSize, I, E);
274
255
BCDs[SymName] = BCD;
275
256
}
276
257
// Type descriptors in the MS-ABI start with '??_R0'
@@ -283,9 +264,7 @@ static void dumpCXXData(const ObjectFile *Obj) {
283
264
TD.AlwaysZero = *reinterpret_cast <const little32_t *>(DataPtr);
284
265
TD.MangledName = SymContents.drop_front (BytesInAddress * 2 );
285
266
StringRef *I = std::begin (TD.Symbols ), *E = std::end (TD.Symbols );
286
- if (collectRelocatedSymbols (Obj, Sec, SecAddress, SymAddress, SymSize, I,
287
- E))
288
- return ;
267
+ collectRelocatedSymbols (Obj, Sec, SecAddress, SymAddress, SymSize, I, E);
289
268
TDs[SymName] = TD;
290
269
}
291
270
// Throw descriptors in the MS-ABI start with '_TI'
@@ -316,9 +295,7 @@ static void dumpCXXData(const ObjectFile *Obj) {
316
295
CT.VirtualBaseAdjustmentOffset = DataPtr[4 ];
317
296
CT.Size = DataPtr[5 ];
318
297
StringRef *I = std::begin (CT.Symbols ), *E = std::end (CT.Symbols );
319
- if (collectRelocatedSymbols (Obj, Sec, SecAddress, SymAddress, SymSize, I,
320
- E))
321
- return ;
298
+ collectRelocatedSymbols (Obj, Sec, SecAddress, SymAddress, SymSize, I, E);
322
299
CTs[SymName] = CT;
323
300
}
324
301
// Construction vtables in the Itanium ABI start with '_ZTT' or '__ZTT'.
@@ -569,5 +546,5 @@ int main(int argc, const char *argv[]) {
569
546
std::for_each (opts::InputFilenames.begin (), opts::InputFilenames.end (),
570
547
dumpInput);
571
548
572
- return ReturnValue ;
549
+ return EXIT_SUCCESS ;
573
550
}
0 commit comments