-
- for (Index = 0; Index < Bytes.size(); Index += Size) {
- MCInst Inst;
-
-# ifndef NDEBUG
- raw_ostream &DebugOut = DebugFlag ? dbgs() : nulls();
-# else
- raw_ostream &DebugOut = nulls();
-# endif
-
- if (DisAsm->getInstruction(Inst, Size, memoryObject, Index, DebugOut)) {
- uint64_t addr;
- if (error(i->getAddress(addr))) break;
- outs() << format("%8x:\t", addr + Index);
- DumpBytes(StringRef(Bytes.data() + Index, Size));
- IP->printInst(&Inst, outs());
- outs() << "\n";
- } else {
- errs() << ToolName << ": warning: invalid instruction encoding\n";
- if (Size == 0)
- Size = 1; // skip illegible bytes
+ uint64_t SectSize;
+ if (error(i->getSize(SectSize))) break;
+
+ // Disassemble symbol by symbol.
+ for (unsigned si = 0, se = Symbols.size(); si != se; ++si) {
+ uint64_t Start = Symbols[si].first;
+ uint64_t End = si == se-1 ? SectSize : Symbols[si + 1].first - 1;
+ outs() << '\n' << Symbols[si].second << ":\n";
+
+#ifndef NDEBUG
+ raw_ostream &DebugOut = DebugFlag ? dbgs() : nulls();
+#else
+ raw_ostream &DebugOut = nulls();
+#endif
+
+ for (Index = Start; Index < End; Index += Size) {
+ MCInst Inst;
+
+ if (DisAsm->getInstruction(Inst, Size, memoryObject, Index,
+ DebugOut, nulls())) {
+ uint64_t addr;
+ if (error(i->getAddress(addr))) break;
+ outs() << format("%8x:\t", addr + Index);
+ DumpBytes(StringRef(Bytes.data() + Index, Size));
+ IP->printInst(&Inst, outs(), "");
+ outs() << "\n";
+ } else {
+ errs() << ToolName << ": warning: invalid instruction encoding\n";
+ if (Size == 0)
+ Size = 1; // skip illegible bytes
+ }