diff --git a/lld/ELF/InputSection.h b/lld/ELF/InputSection.h --- a/lld/ELF/InputSection.h +++ b/lld/ELF/InputSection.h @@ -387,7 +387,7 @@ inline bool isDebugSection(const InputSectionBase &sec) { return (sec.flags & llvm::ELF::SHF_ALLOC) == 0 && - (sec.name.startswith(".debug") || sec.name.startswith(".zdebug")); + sec.name.startswith(".debug"); } // The list of all input sections. diff --git a/lld/ELF/InputSection.cpp b/lld/ELF/InputSection.cpp --- a/lld/ELF/InputSection.cpp +++ b/lld/ELF/InputSection.cpp @@ -70,11 +70,9 @@ fatal(toString(this) + ": sh_addralign is not a power of 2"); this->alignment = v; - // In ELF, each section can be compressed by zlib, and if compressed, - // section name may be mangled by appending "z" (e.g. ".zdebug_info"). - // If that's the case, demangle section name so that we can handle a - // section as if it weren't compressed. - if ((flags & SHF_COMPRESSED) || name.startswith(".zdebug")) { + // If SHF_COMPRESSED is set, parse the header. The legacy .zdebug format is no + // longer supported. + if (flags & SHF_COMPRESSED) { if (!zlib::isAvailable()) error(toString(file) + ": contains a compressed section, " + "but zlib is not available"); @@ -204,29 +202,6 @@ // by zlib-compressed data. This function parses a header to initialize // `uncompressedSize` member and remove the header from `rawData`. template void InputSectionBase::parseCompressedHeader() { - // Old-style header - if (!(flags & SHF_COMPRESSED)) { - assert(name.startswith(".zdebug")); - if (!toStringRef(rawData).startswith("ZLIB")) { - error(toString(this) + ": corrupted compressed section header"); - return; - } - rawData = rawData.slice(4); - - if (rawData.size() < 8) { - error(toString(this) + ": corrupted compressed section header"); - return; - } - - uncompressedSize = read64be(rawData.data()); - rawData = rawData.slice(8); - - // Restore the original section name. - // (e.g. ".zdebug_info" -> ".debug_info") - name = saver().save("." + name.substr(2)); - return; - } - flags &= ~(uint64_t)SHF_COMPRESSED; // New-style header diff --git a/lld/docs/ReleaseNotes.rst b/lld/docs/ReleaseNotes.rst --- a/lld/docs/ReleaseNotes.rst +++ b/lld/docs/ReleaseNotes.rst @@ -38,6 +38,8 @@ * ``-d`` is now ignored. * If a prevailing COMDAT group defines STB_WEAK symbol, having a STB_GLOBAL symbol in a non-prevailing group is now rejected with a diagnostic. (`D120626 `_) +* Support for the legacy ``.zdebug`` format has been removed. Run + ``objcopy --decompress-debug-sections`` in case old object files use ``.zdebug``. COFF Improvements ----------------- diff --git a/lld/test/ELF/compressed-debug-input.s b/lld/test/ELF/compressed-debug-input.s --- a/lld/test/ELF/compressed-debug-input.s +++ b/lld/test/ELF/compressed-debug-input.s @@ -22,37 +22,11 @@ # ZLIB-NEXT: EntrySize: 1 # ZLIB-NEXT: } -# RUN: llvm-mc -compress-debug-sections=zlib-gnu -filetype=obj -triple=x86_64-unknown-linux %s -o %t2 -# RUN: llvm-mc -compress-debug-sections=zlib-gnu -filetype=obj -triple=powerpc64-unknown-unknown %s -o %t2-be -# RUN: llvm-readobj --sections %t2 | FileCheck -check-prefix=GNU %s -# RUN: llvm-readobj --sections %t2-be | FileCheck -check-prefix=GNU %s -# GNU: Section { -# GNU: Index: 2 -# GNU: Name: .zdebug_str -# GNU-NEXT: Type: SHT_PROGBITS -# GNU-NEXT: Flags [ -# GNU-NEXT: SHF_MERGE (0x10) -# GNU-NEXT: SHF_STRINGS (0x20) -# GNU-NEXT: ] -# GNU-NEXT: Address: -# GNU-NEXT: Offset: -# GNU-NEXT: Size: -# GNU-NEXT: Link: -# GNU-NEXT: Info: -# GNU-NEXT: AddressAlignment: 1 -# GNU-NEXT: EntrySize: 1 -# GNU-NEXT: } - # RUN: ld.lld --hash-style=sysv %t -o %t.so -shared # RUN: llvm-readobj --sections --section-data %t.so | FileCheck -check-prefix=DATA %s # RUN: ld.lld --hash-style=sysv %t-be -o %t-be.so -shared # RUN: llvm-readobj --sections --section-data %t-be.so | FileCheck -check-prefix=DATA %s -# RUN: ld.lld --hash-style=sysv %t2 -o %t2.so -shared -# RUN: llvm-readobj --sections --section-data %t2.so | FileCheck -check-prefix=DATA %s -# RUN: ld.lld --hash-style=sysv %t2-be -o %t2-be.so -shared -# RUN: llvm-readobj --sections --section-data %t2-be.so | FileCheck -check-prefix=DATA %s - # DATA: Section { # DATA: Index: 6 # DATA: Name: .debug_str diff --git a/lld/test/ELF/relocatable-compressed-input.s b/lld/test/ELF/relocatable-compressed-input.s deleted file mode 100644 --- a/lld/test/ELF/relocatable-compressed-input.s +++ /dev/null @@ -1,45 +0,0 @@ -# REQUIRES: x86, zlib - -# RUN: llvm-mc -compress-debug-sections=zlib-gnu -filetype=obj -triple=x86_64-unknown-linux %s -o %t1 -# RUN: llvm-readobj --sections %t1 | FileCheck -check-prefix=GNU %s -# GNU: Name: .zdebug_str - -# RUN: ld.lld %t1 -o %t2 -r -# RUN: llvm-readobj --sections --section-data %t2 | FileCheck %s - -## Check we uncompress section and remove ".z" prefix specific for zlib-gnu compression. -# CHECK: Section { -# CHECK: Index: -# CHECK: Name: .debug_str -# CHECK-NEXT: Type: SHT_PROGBITS -# CHECK-NEXT: Flags [ -# CHECK-NEXT: SHF_MERGE -# CHECK-NEXT: SHF_STRINGS -# CHECK-NEXT: ] -# CHECK-NEXT: Address: -# CHECK-NEXT: Offset: -# CHECK-NEXT: Size: -# CHECK-NEXT: Link: -# CHECK-NEXT: Info: -# CHECK-NEXT: AddressAlignment: 1 -# CHECK-NEXT: EntrySize: 1 -# CHECK-NEXT: SectionData ( -# CHECK-NEXT: 0000: {{.*}} |unsigned int.cha| -# CHECK-NEXT: 0010: {{.*}} |r.unsigned char.| -# CHECK-NEXT: 0020: {{.*}} |short unsigned i| -# CHECK-NEXT: 0030: {{.*}} |nt.long unsigned| -# CHECK-NEXT: 0040: {{.*}} | int.| -# CHECK-NEXT: ) -# CHECK-NEXT: } - -.section .debug_str,"MS",@progbits,1 -.LASF2: - .string "short unsigned int" -.LASF3: - .string "unsigned int" -.LASF0: - .string "long unsigned int" -.LASF8: - .string "char" -.LASF1: - .string "unsigned char" diff --git a/lld/test/ELF/strip-debug.s b/lld/test/ELF/strip-debug.s --- a/lld/test/ELF/strip-debug.s +++ b/lld/test/ELF/strip-debug.s @@ -11,6 +11,4 @@ # CHECK-NOT: Bar .section .debug_Foo,"",@progbits -.section .zdebug_Bar,"",@progbits -.ascii "ZLIB" .quad 0