@@ -155,67 +155,67 @@ static void printAllUnwindCodes(ArrayRef<UnwindCode> UCs) {
155
155
}
156
156
157
157
// Given a symbol sym this functions returns the address and section of it.
158
- static std::error_code
159
- resolveSectionAndAddress ( const COFFObjectFile *Obj, const SymbolRef &Sym,
160
- const coff_section *&ResolvedSection,
161
- uint64_t &ResolvedAddr) {
158
+ static Error resolveSectionAndAddress ( const COFFObjectFile *Obj,
159
+ const SymbolRef &Sym,
160
+ const coff_section *&ResolvedSection,
161
+ uint64_t &ResolvedAddr) {
162
162
Expected<uint64_t > ResolvedAddrOrErr = Sym.getAddress ();
163
163
if (!ResolvedAddrOrErr)
164
- return errorToErrorCode ( ResolvedAddrOrErr.takeError () );
164
+ return ResolvedAddrOrErr.takeError ();
165
165
ResolvedAddr = *ResolvedAddrOrErr;
166
166
Expected<section_iterator> Iter = Sym.getSection ();
167
167
if (!Iter)
168
- return errorToErrorCode ( Iter.takeError () );
168
+ return Iter.takeError ();
169
169
ResolvedSection = Obj->getCOFFSection (**Iter);
170
- return std::error_code ();
170
+ return Error::success ();
171
171
}
172
172
173
173
// Given a vector of relocations for a section and an offset into this section
174
174
// the function returns the symbol used for the relocation at the offset.
175
- static std::error_code resolveSymbol (const std::vector<RelocationRef> &Rels,
175
+ static Error resolveSymbol (const std::vector<RelocationRef> &Rels,
176
176
uint64_t Offset, SymbolRef &Sym) {
177
177
for (auto &R : Rels) {
178
178
uint64_t Ofs = R.getOffset ();
179
179
if (Ofs == Offset) {
180
180
Sym = *R.getSymbol ();
181
- return std::error_code ();
181
+ return Error::success ();
182
182
}
183
183
}
184
- return object_error::parse_failed ;
184
+ return make_error<BinaryError>() ;
185
185
}
186
186
187
187
// Given a vector of relocations for a section and an offset into this section
188
188
// the function resolves the symbol used for the relocation at the offset and
189
189
// returns the section content and the address inside the content pointed to
190
190
// by the symbol.
191
- static std::error_code
191
+ static Error
192
192
getSectionContents (const COFFObjectFile *Obj,
193
193
const std::vector<RelocationRef> &Rels, uint64_t Offset,
194
194
ArrayRef<uint8_t > &Contents, uint64_t &Addr) {
195
195
SymbolRef Sym;
196
- if (std::error_code EC = resolveSymbol (Rels, Offset, Sym))
197
- return EC ;
196
+ if (Error E = resolveSymbol (Rels, Offset, Sym))
197
+ return E ;
198
198
const coff_section *Section;
199
- if (std::error_code EC = resolveSectionAndAddress (Obj, Sym, Section, Addr))
200
- return EC ;
199
+ if (Error E = resolveSectionAndAddress (Obj, Sym, Section, Addr))
200
+ return E ;
201
201
if (std::error_code EC = Obj->getSectionContents (Section, Contents))
202
- return EC ;
203
- return std::error_code ();
202
+ return errorCodeToError (EC) ;
203
+ return Error::success ();
204
204
}
205
205
206
206
// Given a vector of relocations for a section and an offset into this section
207
207
// the function returns the name of the symbol used for the relocation at the
208
208
// offset.
209
- static std::error_code resolveSymbolName (const std::vector<RelocationRef> &Rels,
210
- uint64_t Offset, StringRef &Name) {
209
+ static Error resolveSymbolName (const std::vector<RelocationRef> &Rels,
210
+ uint64_t Offset, StringRef &Name) {
211
211
SymbolRef Sym;
212
- if (std::error_code EC = resolveSymbol (Rels, Offset, Sym))
212
+ if (Error EC = resolveSymbol (Rels, Offset, Sym))
213
213
return EC;
214
214
Expected<StringRef> NameOrErr = Sym.getName ();
215
215
if (!NameOrErr)
216
- return errorToErrorCode ( NameOrErr.takeError () );
216
+ return NameOrErr.takeError ();
217
217
Name = *NameOrErr;
218
- return std::error_code ();
218
+ return Error::success ();
219
219
}
220
220
221
221
static void printCOFFSymbolAddress (llvm::raw_ostream &Out,
@@ -653,7 +653,7 @@ void llvm::printCOFFSymbolTable(const COFFObjectFile *coff) {
653
653
for (unsigned SI = 0 , SE = coff->getNumberOfSymbols (); SI != SE; ++SI) {
654
654
Expected<COFFSymbolRef> Symbol = coff->getSymbol (SI);
655
655
StringRef Name;
656
- error (errorToErrorCode ( Symbol.takeError () ));
656
+ error (Symbol.takeError ());
657
657
error (coff->getSymbolName (*Symbol, Name));
658
658
659
659
outs () << " [" << format (" %2d" , SI) << " ]"
0 commit comments