forked from OSchip/llvm-project
Remove zlibgnu support in llvm-mc
The feature's been removed from most other tools in LLVM at this point.
This commit is contained in:
parent
6ab7307177
commit
d63ec445ca
|
@ -146,7 +146,7 @@ struct ELFWriter {
|
||||||
|
|
||||||
bool maybeWriteCompression(uint64_t Size,
|
bool maybeWriteCompression(uint64_t Size,
|
||||||
SmallVectorImpl<uint8_t> &CompressedContents,
|
SmallVectorImpl<uint8_t> &CompressedContents,
|
||||||
bool ZLibStyle, unsigned Alignment);
|
unsigned Alignment);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ELFWriter(ELFObjectWriter &OWriter, raw_pwrite_stream &OS,
|
ELFWriter(ELFObjectWriter &OWriter, raw_pwrite_stream &OS,
|
||||||
|
@ -819,9 +819,8 @@ MCSectionELF *ELFWriter::createRelocationSection(MCContext &Ctx,
|
||||||
|
|
||||||
// Include the debug info compression header.
|
// Include the debug info compression header.
|
||||||
bool ELFWriter::maybeWriteCompression(
|
bool ELFWriter::maybeWriteCompression(
|
||||||
uint64_t Size, SmallVectorImpl<uint8_t> &CompressedContents, bool ZLibStyle,
|
uint64_t Size, SmallVectorImpl<uint8_t> &CompressedContents,
|
||||||
unsigned Alignment) {
|
unsigned Alignment) {
|
||||||
if (ZLibStyle) {
|
|
||||||
uint64_t HdrSize =
|
uint64_t HdrSize =
|
||||||
is64Bit() ? sizeof(ELF::Elf32_Chdr) : sizeof(ELF::Elf64_Chdr);
|
is64Bit() ? sizeof(ELF::Elf32_Chdr) : sizeof(ELF::Elf64_Chdr);
|
||||||
if (Size <= HdrSize + CompressedContents.size())
|
if (Size <= HdrSize + CompressedContents.size())
|
||||||
|
@ -840,16 +839,6 @@ bool ELFWriter::maybeWriteCompression(
|
||||||
write(static_cast<ELF::Elf32_Word>(Alignment));
|
write(static_cast<ELF::Elf32_Word>(Alignment));
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
|
||||||
|
|
||||||
// "ZLIB" followed by 8 bytes representing the uncompressed size of the section,
|
|
||||||
// useful for consumers to preallocate a buffer to decompress into.
|
|
||||||
const StringRef Magic = "ZLIB";
|
|
||||||
if (Size <= Magic.size() + sizeof(Size) + CompressedContents.size())
|
|
||||||
return false;
|
|
||||||
W.OS << Magic;
|
|
||||||
support::endian::write(W.OS, Size, support::big);
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ELFWriter::writeSectionData(const MCAssembler &Asm, MCSection &Sec,
|
void ELFWriter::writeSectionData(const MCAssembler &Asm, MCSection &Sec,
|
||||||
|
@ -883,7 +872,7 @@ void ELFWriter::writeSectionData(const MCAssembler &Asm, MCSection &Sec,
|
||||||
|
|
||||||
bool ZlibStyle = MAI->compressDebugSections() == DebugCompressionType::Z;
|
bool ZlibStyle = MAI->compressDebugSections() == DebugCompressionType::Z;
|
||||||
if (!maybeWriteCompression(UncompressedData.size(), CompressedContents,
|
if (!maybeWriteCompression(UncompressedData.size(), CompressedContents,
|
||||||
ZlibStyle, Sec.getAlignment())) {
|
Sec.getAlignment())) {
|
||||||
W.OS << UncompressedData;
|
W.OS << UncompressedData;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,69 +1,48 @@
|
||||||
// REQUIRES: zlib
|
// REQUIRES: zlib
|
||||||
// Check zlib-gnu style
|
|
||||||
// RUN: llvm-mc -filetype=obj -compress-debug-sections=zlib-gnu -triple x86_64-pc-linux-gnu < %s -o %t
|
|
||||||
// RUN: llvm-objdump -s %t | FileCheck --check-prefix=CHECK-GNU-STYLE %s
|
|
||||||
// RUN: llvm-dwarfdump -debug-str %t | FileCheck --check-prefix=STR %s
|
|
||||||
// RUN: llvm-mc -filetype=obj -compress-debug-sections=zlib-gnu -triple i386-pc-linux-gnu --defsym I386=1 %s \
|
|
||||||
// RUN: | llvm-readelf -s - | FileCheck --check-prefix=386-SYMBOLS-GNU %s
|
|
||||||
|
|
||||||
// Check zlib style
|
// Check zlib style
|
||||||
// RUN: llvm-mc -filetype=obj -compress-debug-sections=zlib -triple x86_64-pc-linux-gnu < %s -o %t
|
// RUN: llvm-mc -filetype=obj -compress-debug-sections=zlib -triple x86_64-pc-linux-gnu < %s -o %t
|
||||||
// RUN: llvm-objdump -s %t | FileCheck --check-prefix=CHECK-ZLIB-STYLE %s
|
// RUN: llvm-objdump -s %t | FileCheck %s
|
||||||
// RUN: llvm-dwarfdump -debug-str %t | FileCheck --check-prefix=STR %s
|
// RUN: llvm-dwarfdump -debug-str %t | FileCheck --check-prefix=STR %s
|
||||||
// RUN: llvm-readelf --sections %t | FileCheck --check-prefixes=ZLIB-FLAGS,ZLIB-FLAGS64 %s
|
// RUN: llvm-readelf --sections %t | FileCheck --check-prefixes=FLAGS,FLAGS64 %s
|
||||||
|
|
||||||
// RUN: llvm-mc -filetype=obj -compress-debug-sections=zlib -triple i386-pc-linux-gnu --defsym I386=1 %s -o %t
|
// RUN: llvm-mc -filetype=obj -compress-debug-sections=zlib -triple i386-pc-linux-gnu --defsym I386=1 %s -o %t
|
||||||
// RUN: llvm-readelf -S -s %t | FileCheck --check-prefixes=386-SYMBOLS-ZLIB,ZLIB-FLAGS,ZLIB-FLAGS32 %s
|
// RUN: llvm-readelf -S -s %t | FileCheck --check-prefixes=386-SYMBOLS,FLAGS,FLAGS32 %s
|
||||||
|
|
||||||
// Don't compress small sections, such as this simple debug_abbrev example
|
|
||||||
// CHECK-GNU-STYLE: Contents of section .debug_abbrev:
|
|
||||||
// CHECK-GNU-STYLE-NOT: ZLIB
|
|
||||||
// CHECK-GNU-STYLE-NOT: Contents of
|
|
||||||
|
|
||||||
// CHECK-GNU-STYLE: Contents of section .debug_info:
|
|
||||||
|
|
||||||
// CHECK-GNU-STYLE: Contents of section .zdebug_str:
|
|
||||||
// Check for the 'ZLIB' file magic at the start of the section only
|
|
||||||
// CHECK-GNU-STYLE-NEXT: ZLIB
|
|
||||||
// CHECK-GNU-STYLE-NOT: ZLIB
|
|
||||||
// CHECK-GNU-STYLE: Contents of section
|
|
||||||
|
|
||||||
// Decompress one valid dwarf section just to check that this roundtrips,
|
// Decompress one valid dwarf section just to check that this roundtrips,
|
||||||
// we use .zdebug_str section for that
|
// we use .debug_str section for that
|
||||||
// STR: perfectly compressable data sample *****************************************
|
// STR: perfectly compressable data sample *****************************************
|
||||||
|
|
||||||
|
|
||||||
// Now check the zlib style output:
|
// Now check the zlib style output:
|
||||||
|
|
||||||
// Don't compress small sections, such as this simple debug_abbrev example
|
// Don't compress small sections, such as this simple debug_abbrev example
|
||||||
// CHECK-ZLIB-STYLE: Contents of section .debug_abbrev:
|
// CHECK: Contents of section .debug_abbrev:
|
||||||
// CHECK-ZLIB-STYLE-NOT: ZLIB
|
// CHECK-NOT: ZLIB
|
||||||
// CHECK-ZLIB-STYLE-NOT: Contents of
|
// CHECK-NOT: Contents of
|
||||||
// CHECK-ZLIB-STYLE: Contents of section .debug_info:
|
// CHECK: Contents of section .debug_info:
|
||||||
// FIXME: Handle compressing alignment fragments to support compressing debug_frame
|
// FIXME: Handle compressing alignment fragments to support compressing debug_frame
|
||||||
// CHECK-ZLIB-STYLE: Contents of section .debug_frame:
|
// CHECK: Contents of section .debug_frame:
|
||||||
// CHECK-ZLIB-STYLE-NOT: ZLIB
|
// CHECK-NOT: ZLIB
|
||||||
// CHECK-ZLIB-STYLE: Contents of
|
// CHECK: Contents of
|
||||||
|
|
||||||
# ZLIB-FLAGS: .text PROGBITS [[#%x,]] [[#%x,]] [[#%x,]] 00 AX 0 0 4
|
# FLAGS: .text PROGBITS [[#%x,]] [[#%x,]] [[#%x,]] 00 AX 0 0 4
|
||||||
# ZLIB-FLAGS: .nonalloc PROGBITS [[#%x,]] [[#%x,]] 000226 00 0 0 1
|
# FLAGS: .nonalloc PROGBITS [[#%x,]] [[#%x,]] 000226 00 0 0 1
|
||||||
|
|
||||||
## Check that the large .debug_line and .debug_frame have the SHF_COMPRESSED
|
## Check that the large .debug_line and .debug_frame have the SHF_COMPRESSED
|
||||||
## flag.
|
## flag.
|
||||||
# ZLIB-FLAGS32: .debug_line PROGBITS [[#%x,]] [[#%x,]] [[#%x,]] 00 C 0 0 4
|
# FLAGS32: .debug_line PROGBITS [[#%x,]] [[#%x,]] [[#%x,]] 00 C 0 0 4
|
||||||
# ZLIB-FLAGS32: .debug_abbrev PROGBITS [[#%x,]] [[#%x,]] [[#%x,]] 00 0 0 1
|
# FLAGS32: .debug_abbrev PROGBITS [[#%x,]] [[#%x,]] [[#%x,]] 00 0 0 1
|
||||||
# ZLIB-FLAGS32: .debug_info PROGBITS [[#%x,]] [[#%x,]] [[#%x,]] 00 0 0 1
|
# FLAGS32: .debug_info PROGBITS [[#%x,]] [[#%x,]] [[#%x,]] 00 0 0 1
|
||||||
# ZLIB-FLAGS32: .debug_frame PROGBITS [[#%x,]] [[#%x,]] [[#%x,]] 00 C 0 0 4
|
# FLAGS32: .debug_frame PROGBITS [[#%x,]] [[#%x,]] [[#%x,]] 00 C 0 0 4
|
||||||
|
|
||||||
# ZLIB-FLAGS64: .debug_line PROGBITS [[#%x,]] [[#%x,]] [[#%x,]] 00 C 0 0 8
|
# FLAGS64: .debug_line PROGBITS [[#%x,]] [[#%x,]] [[#%x,]] 00 C 0 0 8
|
||||||
# ZLIB-FLAGS64: .debug_abbrev PROGBITS [[#%x,]] [[#%x,]] [[#%x,]] 00 0 0 1
|
# FLAGS64: .debug_abbrev PROGBITS [[#%x,]] [[#%x,]] [[#%x,]] 00 0 0 1
|
||||||
# ZLIB-FLAGS64: .debug_info PROGBITS [[#%x,]] [[#%x,]] [[#%x,]] 00 0 0 1
|
# FLAGS64: .debug_info PROGBITS [[#%x,]] [[#%x,]] [[#%x,]] 00 0 0 1
|
||||||
# ZLIB-FLAGS64: .debug_frame PROGBITS [[#%x,]] [[#%x,]] [[#%x,]] 00 C 0 0 8
|
# FLAGS64: .debug_frame PROGBITS [[#%x,]] [[#%x,]] [[#%x,]] 00 C 0 0 8
|
||||||
|
|
||||||
# 386-SYMBOLS-ZLIB: Symbol table '.symtab'
|
# 386-SYMBOLS: Symbol table '.symtab'
|
||||||
# 386-SYMBOLS-ZLIB: .debug_str
|
# 386-SYMBOLS: .debug_str
|
||||||
# 386-SYMBOLS-GNU: Symbol table '.symtab'
|
|
||||||
# 386-SYMBOLS-GNU: .zdebug_str
|
|
||||||
|
|
||||||
## Don't compress a section not named .debug_*.
|
## Don't compress a section not named .debug_*.
|
||||||
.section .nonalloc,"",@progbits
|
.section .nonalloc,"",@progbits
|
||||||
|
|
|
@ -77,9 +77,7 @@ static cl::opt<DebugCompressionType> CompressDebugSections(
|
||||||
cl::desc("Choose DWARF debug sections compression:"),
|
cl::desc("Choose DWARF debug sections compression:"),
|
||||||
cl::values(clEnumValN(DebugCompressionType::None, "none", "No compression"),
|
cl::values(clEnumValN(DebugCompressionType::None, "none", "No compression"),
|
||||||
clEnumValN(DebugCompressionType::Z, "zlib",
|
clEnumValN(DebugCompressionType::Z, "zlib",
|
||||||
"Use zlib compression"),
|
"Use zlib compression")),
|
||||||
clEnumValN(DebugCompressionType::GNU, "zlib-gnu",
|
|
||||||
"Use zlib-gnu compression (deprecated)")),
|
|
||||||
cl::cat(MCCategory));
|
cl::cat(MCCategory));
|
||||||
|
|
||||||
static cl::opt<bool>
|
static cl::opt<bool>
|
||||||
|
|
Loading…
Reference in New Issue