static StringRef ToolName;
-bool llvm::error(error_code ec) {
- if (!ec) return false;
+bool llvm::error(error_code EC) {
+ if (!EC)
+ return false;
- outs() << ToolName << ": error reading file: " << ec.message() << ".\n";
+ outs() << ToolName << ": error reading file: " << EC.message() << ".\n";
outs().flush();
return true;
}
}
}
-
- error_code ec;
- for (section_iterator i = Obj->begin_sections(),
- e = Obj->end_sections();
- i != e; i.increment(ec)) {
- if (error(ec)) break;
- bool text;
- if (error(i->isText(text))) break;
- if (!text) continue;
+ error_code EC;
+ for (section_iterator I = Obj->begin_sections(), E = Obj->end_sections();
+ I != E; I.increment(EC)) {
+ if (error(EC))
+ break;
+ bool Text;
+ if (error(I->isText(Text)))
+ break;
+ if (!Text)
+ continue;
uint64_t SectionAddr;
- if (error(i->getAddress(SectionAddr))) break;
+ if (error(I->getAddress(SectionAddr)))
+ break;
// Make a list of all the symbols in this section.
std::vector<std::pair<uint64_t, StringRef> > Symbols;
- for (symbol_iterator si = Obj->begin_symbols(),
- se = Obj->end_symbols();
- si != se; si.increment(ec)) {
+ for (symbol_iterator SI = Obj->begin_symbols(), SE = Obj->end_symbols();
+ SI != SE; SI.increment(EC)) {
bool contains;
- if (!error(i->containsSymbol(*si, contains)) && contains) {
+ if (!error(I->containsSymbol(*SI, contains)) && contains) {
uint64_t Address;
- if (error(si->getAddress(Address))) break;
- if (Address == UnknownAddressOrSize) continue;
+ if (error(SI->getAddress(Address)))
+ break;
+ if (Address == UnknownAddressOrSize)
+ continue;
Address -= SectionAddr;
StringRef Name;
- if (error(si->getName(Name))) break;
+ if (error(SI->getName(Name)))
+ break;
Symbols.push_back(std::make_pair(Address, Name));
}
}
// Make a list of all the relocations for this section.
std::vector<RelocationRef> Rels;
if (InlineRelocs) {
- for (relocation_iterator ri = i->begin_relocations(),
- re = i->end_relocations();
- ri != re; ri.increment(ec)) {
- if (error(ec)) break;
- Rels.push_back(*ri);
+ for (relocation_iterator RI = I->begin_relocations(),
+ RE = I->end_relocations();
+ RI != RE; RI.increment(EC)) {
+ if (error(EC))
+ break;
+ Rels.push_back(*RI);
}
}
std::sort(Rels.begin(), Rels.end(), RelocAddressLess);
StringRef SegmentName = "";
- if (const MachOObjectFile *MachO =
- dyn_cast<const MachOObjectFile>(Obj)) {
- DataRefImpl DR = i->getRawDataRefImpl();
+ if (const MachOObjectFile *MachO = dyn_cast<const MachOObjectFile>(Obj)) {
+ DataRefImpl DR = I->getRawDataRefImpl();
SegmentName = MachO->getSectionFinalSegmentName(DR);
}
StringRef name;
- if (error(i->getName(name))) break;
+ if (error(I->getName(name)))
+ break;
outs() << "Disassembly of section ";
if (!SegmentName.empty())
outs() << SegmentName << ",";
raw_svector_ostream CommentStream(Comments);
StringRef Bytes;
- if (error(i->getContents(Bytes))) break;
+ if (error(I->getContents(Bytes)))
+ break;
StringRefMemoryObject memoryObject(Bytes, SectionAddr);
uint64_t Size;
uint64_t Index;
uint64_t SectSize;
- if (error(i->getSize(SectSize))) break;
+ if (error(I->getSize(SectSize)))
+ break;
std::vector<RelocationRef>::const_iterator rel_cur = Rels.begin();
std::vector<RelocationRef>::const_iterator rel_end = Rels.end();
outs() << '\n' << Symbols[si].second << ":\n";
#ifndef NDEBUG
- raw_ostream &DebugOut = DebugFlag ? dbgs() : nulls();
+ raw_ostream &DebugOut = DebugFlag ? dbgs() : nulls();
#else
- raw_ostream &DebugOut = nulls();
+ raw_ostream &DebugOut = nulls();
#endif
for (Index = Start; Index < End; Index += Size) {
}
static void PrintRelocations(const ObjectFile *o) {
- error_code ec;
+ error_code EC;
for (section_iterator si = o->begin_sections(), se = o->end_sections();
- si != se; si.increment(ec)){
- if (error(ec)) return;
+ si != se; si.increment(EC)) {
+ if (error(EC))
+ return;
if (si->begin_relocations() == si->end_relocations())
continue;
StringRef secname;
outs() << "RELOCATION RECORDS FOR [" << secname << "]:\n";
for (relocation_iterator ri = si->begin_relocations(),
re = si->end_relocations();
- ri != re; ri.increment(ec)) {
- if (error(ec)) return;
+ ri != re; ri.increment(EC)) {
+ if (error(EC))
+ return;
bool hidden;
uint64_t address;
static void PrintSectionHeaders(const ObjectFile *o) {
outs() << "Sections:\n"
"Idx Name Size Address Type\n";
- error_code ec;
+ error_code EC;
unsigned i = 0;
for (section_iterator si = o->begin_sections(), se = o->end_sections();
- si != se; si.increment(ec)) {
- if (error(ec)) return;
+ si != se; si.increment(EC)) {
+ if (error(EC))
+ return;
StringRef Name;
- if (error(si->getName(Name))) return;
+ if (error(si->getName(Name)))
+ return;
uint64_t Address;
if (error(si->getAddress(Address))) return;
uint64_t Size;
}
static void PrintSectionContents(const ObjectFile *o) {
- error_code ec;
- for (section_iterator si = o->begin_sections(),
- se = o->end_sections();
- si != se; si.increment(ec)) {
- if (error(ec)) return;
+ error_code EC;
+ for (section_iterator si = o->begin_sections(), se = o->end_sections();
+ si != se; si.increment(EC)) {
+ if (error(EC))
+ return;
StringRef Name;
StringRef Contents;
uint64_t BaseAddr;
if (const COFFObjectFile *coff = dyn_cast<const COFFObjectFile>(o))
PrintCOFFSymbolTable(coff);
else {
- error_code ec;
- for (symbol_iterator si = o->begin_symbols(),
- se = o->end_symbols(); si != se; si.increment(ec)) {
- if (error(ec)) return;
+ error_code EC;
+ for (symbol_iterator si = o->begin_symbols(), se = o->end_symbols();
+ si != se; si.increment(EC)) {
+ if (error(EC))
+ return;
StringRef Name;
uint64_t Address;
SymbolRef::Type Type;
/// @brief Dump each object file in \a a;
static void DumpArchive(const Archive *a) {
- for (Archive::child_iterator i = a->child_begin(),
- e = a->child_end(); i != e; ++i) {
+ for (Archive::child_iterator i = a->child_begin(), e = a->child_end(); i != e;
+ ++i) {
OwningPtr<Binary> child;
- if (error_code ec = i->getAsBinary(child)) {
+ if (error_code EC = i->getAsBinary(child)) {
// Ignore non-object files.
- if (ec != object_error::invalid_file_type)
- errs() << ToolName << ": '" << a->getFileName() << "': " << ec.message()
+ if (EC != object_error::invalid_file_type)
+ errs() << ToolName << ": '" << a->getFileName() << "': " << EC.message()
<< ".\n";
continue;
}