@@ -349,6 +349,7 @@ bool objdump::UnwindInfo;
349
349
static bool Wide;
350
350
std::string objdump::Prefix;
351
351
uint32_t objdump::PrefixStrip;
352
+ static bool QuietDisasm = false ;
352
353
353
354
DebugVarsFormat objdump::DbgVariables = DVDisabled;
354
355
@@ -1374,6 +1375,8 @@ static uint64_t dumpARMELFData(uint64_t SectionAddr, uint64_t Index,
1374
1375
return 1 ;
1375
1376
}
1376
1377
1378
+ static raw_ostream &disasmOuts () { return QuietDisasm ? nulls () : outs (); }
1379
+
1377
1380
static void dumpELFData (uint64_t SectionAddr, uint64_t Index, uint64_t End,
1378
1381
ArrayRef<uint8_t > Bytes) {
1379
1382
// print out data up to 8 bytes at a time in hex and ascii
@@ -1383,9 +1386,9 @@ static void dumpELFData(uint64_t SectionAddr, uint64_t Index, uint64_t End,
1383
1386
1384
1387
for (; Index < End; ++Index) {
1385
1388
if (NumBytes == 0 )
1386
- outs () << format (" %8" PRIx64 " :" , SectionAddr + Index);
1389
+ disasmOuts () << format (" %8" PRIx64 " :" , SectionAddr + Index);
1387
1390
Byte = Bytes.slice (Index)[0 ];
1388
- outs () << format (" %02x" , Byte );
1391
+ disasmOuts () << format (" %02x" , Byte );
1389
1392
AsciiData[NumBytes] = isPrint (Byte ) ? Byte : ' .' ;
1390
1393
1391
1394
uint8_t IndentOffset = 0 ;
@@ -1400,9 +1403,9 @@ static void dumpELFData(uint64_t SectionAddr, uint64_t Index, uint64_t End,
1400
1403
}
1401
1404
if (NumBytes == 8 ) {
1402
1405
AsciiData[8 ] = ' \0 ' ;
1403
- outs () << std::string (IndentOffset, ' ' ) << " " ;
1404
- outs () << reinterpret_cast <char *>(AsciiData);
1405
- outs () << ' \n ' ;
1406
+ disasmOuts () << std::string (IndentOffset, ' ' ) << " " ;
1407
+ disasmOuts () << reinterpret_cast <char *>(AsciiData);
1408
+ disasmOuts () << ' \n ' ;
1406
1409
NumBytes = 0 ;
1407
1410
}
1408
1411
}
@@ -2089,10 +2092,10 @@ disassembleObject(ObjectFile &Obj, const ObjectFile &DbgObj,
2089
2092
2090
2093
if (!PrintedSection) {
2091
2094
PrintedSection = true ;
2092
- outs () << " \n Disassembly of section " ;
2095
+ disasmOuts () << " \n Disassembly of section " ;
2093
2096
if (!SegmentName.empty ())
2094
- outs () << SegmentName << " ," ;
2095
- outs () << SectionName << " :\n " ;
2097
+ disasmOuts () << SegmentName << " ," ;
2098
+ disasmOuts () << SectionName << " :\n " ;
2096
2099
}
2097
2100
2098
2101
bool PrintedLabel = false ;
@@ -2104,22 +2107,24 @@ disassembleObject(ObjectFile &Obj, const ObjectFile &DbgObj,
2104
2107
const StringRef SymbolName = SymNamesHere[i];
2105
2108
2106
2109
if (!PrintedLabel) {
2107
- outs () << ' \n ' ;
2110
+ disasmOuts () << ' \n ' ;
2108
2111
PrintedLabel = true ;
2109
2112
}
2110
2113
if (LeadingAddr)
2111
- outs () << format (Is64Bits ? " %016" PRIx64 " " : " %08" PRIx64 " " ,
2112
- SectionAddr + Start + VMAAdjustment);
2114
+ disasmOuts () << format (Is64Bits ? " %016" PRIx64 " "
2115
+ : " %08" PRIx64 " " ,
2116
+ SectionAddr + Start + VMAAdjustment);
2113
2117
if (Obj.isXCOFF () && SymbolDescription) {
2114
- outs () << getXCOFFSymbolDescription (Symbol, SymbolName) << " :\n " ;
2118
+ disasmOuts () << getXCOFFSymbolDescription (Symbol, SymbolName)
2119
+ << " :\n " ;
2115
2120
} else
2116
- outs () << ' <' << SymbolName << " >:\n " ;
2121
+ disasmOuts () << ' <' << SymbolName << " >:\n " ;
2117
2122
}
2118
2123
2119
2124
// Don't print raw contents of a virtual section. A virtual section
2120
2125
// doesn't have any contents in the file.
2121
2126
if (Section.isVirtual ()) {
2122
- outs () << " ...\n " ;
2127
+ disasmOuts () << " ...\n " ;
2123
2128
continue ;
2124
2129
}
2125
2130
@@ -2156,17 +2161,17 @@ disassembleObject(ObjectFile &Obj, const ObjectFile &DbgObj,
2156
2161
do {
2157
2162
StringRef Line;
2158
2163
std::tie (Line, ErrMsg) = ErrMsg.split (' \n ' );
2159
- outs () << DT->Context ->getAsmInfo ()->getCommentString ()
2160
- << " error decoding " << SymNamesHere[SHI] << " : " << Line
2161
- << ' \n ' ;
2164
+ disasmOuts () << DT->Context ->getAsmInfo ()->getCommentString ()
2165
+ << " error decoding " << SymNamesHere[SHI] << " : "
2166
+ << Line << ' \n ' ;
2162
2167
} while (!ErrMsg.empty ());
2163
2168
2164
2169
if (Size ) {
2165
- outs () << DT->Context ->getAsmInfo ()->getCommentString ()
2166
- << " decoding failed region as bytes\n " ;
2170
+ disasmOuts () << DT->Context ->getAsmInfo ()->getCommentString ()
2171
+ << " decoding failed region as bytes\n " ;
2167
2172
for (uint64_t I = 0 ; I < Size ; ++I)
2168
- outs () << " \t .byte\t " << format_hex (Bytes[I], 1 , /* Upper= */ true )
2169
- << ' \n ' ;
2173
+ disasmOuts () << " \t .byte\t "
2174
+ << format_hex (Bytes[I], 1 , /* Upper= */ true ) << ' \n ' ;
2170
2175
}
2171
2176
}
2172
2177
@@ -2203,7 +2208,7 @@ disassembleObject(ObjectFile &Obj, const ObjectFile &DbgObj,
2203
2208
Symbols[SI - 1 ].XCOFFSymInfo .StorageMappingClass &&
2204
2209
(*Symbols[SI - 1 ].XCOFFSymInfo .StorageMappingClass == XCOFF::XMC_PR);
2205
2210
2206
- formatted_raw_ostream FOS (outs ());
2211
+ formatted_raw_ostream FOS (disasmOuts ());
2207
2212
2208
2213
std::unordered_map<uint64_t , std::string> AllLabels;
2209
2214
std::unordered_map<uint64_t , std::vector<BBAddrMapLabel>> BBAddrMapLabels;
@@ -2551,6 +2556,7 @@ disassembleObject(ObjectFile &Obj, const ObjectFile &DbgObj,
2551
2556
set_difference (DisasmSymbolSet, FoundDisasmSymbolSet);
2552
2557
for (StringRef Sym : MissingDisasmSymbolSet.keys ())
2553
2558
reportWarning (" failed to disassemble missing symbol " + Sym, FileName);
2559
+ QuietDisasm = false ;
2554
2560
}
2555
2561
2556
2562
static void disassembleObject (ObjectFile *Obj, bool InlineRelocs) {
0 commit comments