} // end namespace LCOMM
-enum class DebugCompressionType {
- DCT_None, // no compression
- DCT_Zlib, // zlib style complession
- DCT_ZlibGnu // zlib-gnu style compression
-};
-
/// This class is intended to be used as a base class for asm
/// properties and features specific to the target.
class MCAsmInfo {
bool PreserveAsmComments;
/// Compress DWARF debug sections. Defaults to no compression.
- DebugCompressionType CompressDebugSections = DebugCompressionType::DCT_None;
+ DebugCompressionType CompressDebugSections = DebugCompressionType::None;
/// True if the integrated assembler should interpret 'a >> b' constant
/// expressions as logical rather than arithmetic.
WinEH, /// Windows Exception Handling
};
+enum class DebugCompressionType {
+ None, /// No compression
+ GNU, /// zlib-gnu style compression
+ Z, /// zlib style complession
+};
+
class StringRef;
class MCTargetOptions {
HonorSignDependentRoundingFPMathOption(false), NoZerosInBSS(false),
GuaranteedTailCallOpt(false), StackSymbolOrdering(true),
EnableFastISel(false), UseInitArray(false),
- DisableIntegratedAS(false), CompressDebugSections(false),
- RelaxELFRelocations(false), FunctionSections(false),
- DataSections(false), UniqueSectionNames(true), TrapUnreachable(false),
- EmulatedTLS(false), EnableIPRA(false) {}
+ DisableIntegratedAS(false), RelaxELFRelocations(false),
+ FunctionSections(false), DataSections(false),
+ UniqueSectionNames(true), TrapUnreachable(false), EmulatedTLS(false),
+ EnableIPRA(false) {}
/// PrintMachineCode - This flag is enabled when the -print-machineinstrs
/// option is specified on the command line, and should enable debugging
unsigned DisableIntegratedAS : 1;
/// Compress DWARF debug sections.
- unsigned CompressDebugSections : 1;
+ DebugCompressionType CompressDebugSections = DebugCompressionType::None;
unsigned RelaxELFRelocations : 1;
TmpAsmInfo->setPreserveAsmComments(Options.MCOptions.PreserveAsmComments);
- if (Options.CompressDebugSections)
- TmpAsmInfo->setCompressDebugSections(DebugCompressionType::DCT_ZlibGnu);
+ TmpAsmInfo->setCompressDebugSections(Options.CompressDebugSections);
TmpAsmInfo->setRelaxELFRelocations(Options.RelaxELFRelocations);
MCSectionELF &Section = static_cast<MCSectionELF &>(Sec);
StringRef SectionName = Section.getSectionName();
+ auto &MC = Asm.getContext();
+ const auto &MAI = MC.getAsmInfo();
+
// Compressing debug_frame requires handling alignment fragments which is
// more work (possibly generalizing MCAssembler.cpp:writeFragment to allow
// for writing to arbitrary buffers) for little benefit.
bool CompressionEnabled =
- Asm.getContext().getAsmInfo()->compressDebugSections() !=
- DebugCompressionType::DCT_None;
+ MAI->compressDebugSections() != DebugCompressionType::None;
if (!CompressionEnabled || !SectionName.startswith(".debug_") ||
SectionName == ".debug_frame") {
Asm.writeSectionData(&Section, Layout);
return;
}
+ assert((MAI->compressDebugSections() == DebugCompressionType::Z ||
+ MAI->compressDebugSections() == DebugCompressionType::GNU) &&
+ "expected zlib or zlib-gnu style compression");
+
SmallVector<char, 128> UncompressedData;
raw_svector_ostream VecOS(UncompressedData);
raw_pwrite_stream &OldStream = getStream();
return;
}
- bool ZlibStyle = Asm.getContext().getAsmInfo()->compressDebugSections() ==
- DebugCompressionType::DCT_Zlib;
+ bool ZlibStyle = MAI->compressDebugSections() == DebugCompressionType::Z;
if (!maybeWriteCompression(UncompressedData.size(), CompressedContents,
ZlibStyle, Sec.getAlignment())) {
getStream() << UncompressedData;
Section.setFlags(Section.getFlags() | ELF::SHF_COMPRESSED);
else
// Add "z" prefix to section name. This is zlib-gnu style.
- Asm.getContext().renameELFSection(&Section,
- (".z" + SectionName.drop_front(1)).str());
+ MC.renameELFSection(&Section, (".z" + SectionName.drop_front(1)).str());
getStream() << CompressedContents;
}
"relax-relocations", cl::init(true),
cl::desc("Emit R_X86_64_GOTPCRELX instead of R_X86_64_GOTPCREL"));
-static cl::opt<DebugCompressionType>
-CompressDebugSections("compress-debug-sections", cl::ValueOptional,
- cl::init(DebugCompressionType::DCT_None),
- cl::desc("Choose DWARF debug sections compression:"),
- cl::values(
- clEnumValN(DebugCompressionType::DCT_None, "none",
- "No compression"),
- clEnumValN(DebugCompressionType::DCT_Zlib, "zlib",
- "Use zlib compression"),
- clEnumValN(DebugCompressionType::DCT_ZlibGnu, "zlib-gnu",
- "Use zlib-gnu compression (deprecated)")));
+static cl::opt<DebugCompressionType> CompressDebugSections(
+ "compress-debug-sections", cl::ValueOptional,
+ cl::init(DebugCompressionType::None),
+ cl::desc("Choose DWARF debug sections compression:"),
+ cl::values(clEnumValN(DebugCompressionType::None, "none", "No compression"),
+ clEnumValN(DebugCompressionType::Z, "zlib",
+ "Use zlib compression"),
+ clEnumValN(DebugCompressionType::GNU, "zlib-gnu",
+ "Use zlib-gnu compression (deprecated)")));
static cl::opt<bool>
ShowInst("show-inst", cl::desc("Show internal instruction representation"));
MAI->setRelaxELFRelocations(RelaxELFRel);
- if (CompressDebugSections != DebugCompressionType::DCT_None) {
+ if (CompressDebugSections != DebugCompressionType::None) {
if (!zlib::isAvailable()) {
errs() << ProgName
<< ": build tools with zlib to enable -compress-debug-sections";