forked from OSchip/llvm-project
Remove 'z' in .zdebug when decompressing a section.
When decompressing a compressed debug section, we drop SHF_COMPRESSED flag but we didn't drop "z" in ".zdebug" section name. This patch does that for consistency. This change also fixes the issue that .zdebug_gnu_pubnames are not dropped when we are creating a .gdb_index section. llvm-svn: 324949
This commit is contained in:
parent
f7854b669a
commit
3cd48fb124
|
|
@ -181,17 +181,26 @@ void InputSectionBase::maybeDecompress() {
|
||||||
if (DecompressBuf || !Decompressor::isCompressedELFSection(Flags, Name))
|
if (DecompressBuf || !Decompressor::isCompressedELFSection(Flags, Name))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
// Decompress a section.
|
||||||
Decompressor Dec = check(Decompressor::create(Name, toStringRef(Data),
|
Decompressor Dec = check(Decompressor::create(Name, toStringRef(Data),
|
||||||
Config->IsLE, Config->Is64));
|
Config->IsLE, Config->Is64));
|
||||||
|
|
||||||
size_t Size = Dec.getDecompressedSize();
|
size_t Size = Dec.getDecompressedSize();
|
||||||
DecompressBuf.reset(new char[Size]());
|
DecompressBuf.reset(new char[Size + Name.size()]());
|
||||||
if (Error E = Dec.decompress({DecompressBuf.get(), Size}))
|
if (Error E = Dec.decompress({DecompressBuf.get(), Size}))
|
||||||
fatal(toString(this) +
|
fatal(toString(this) +
|
||||||
": decompress failed: " + llvm::toString(std::move(E)));
|
": decompress failed: " + llvm::toString(std::move(E)));
|
||||||
|
|
||||||
Data = makeArrayRef((uint8_t *)DecompressBuf.get(), Size);
|
Data = makeArrayRef((uint8_t *)DecompressBuf.get(), Size);
|
||||||
Flags &= ~(uint64_t)SHF_COMPRESSED;
|
Flags &= ~(uint64_t)SHF_COMPRESSED;
|
||||||
|
|
||||||
|
// A section name may have been altered if compressed. If that's
|
||||||
|
// the case, restore the original name. (i.e. ".zdebug_" -> ".debug_")
|
||||||
|
if (Name.startswith(".zdebug")) {
|
||||||
|
DecompressBuf[Size] = '.';
|
||||||
|
memcpy(&DecompressBuf[Size + 1], Name.data() + 2, Name.size() - 2);
|
||||||
|
Name = StringRef(&DecompressBuf[Size], Name.size() - 1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
InputSection *InputSectionBase::getLinkOrderDep() const {
|
InputSection *InputSectionBase::getLinkOrderDep() const {
|
||||||
|
|
|
||||||
|
|
@ -88,11 +88,6 @@ private:
|
||||||
} // anonymous namespace
|
} // anonymous namespace
|
||||||
|
|
||||||
StringRef elf::getOutputSectionName(InputSectionBase *S) {
|
StringRef elf::getOutputSectionName(InputSectionBase *S) {
|
||||||
// ".zdebug_" is a prefix for ZLIB-compressed sections.
|
|
||||||
// Because we decompressed input sections, we want to remove 'z'.
|
|
||||||
if (S->Name.startswith(".zdebug_"))
|
|
||||||
return Saver.save("." + S->Name.substr(2));
|
|
||||||
|
|
||||||
if (Config->Relocatable)
|
if (Config->Relocatable)
|
||||||
return S->Name;
|
return S->Name;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
.text
|
.text
|
||||||
.Ltext0:
|
.Ltext0:
|
||||||
.globl main2
|
.globl aaaaaaaaaaaaaaaa
|
||||||
.type main2, @function
|
.type aaaaaaaaaaaaaaaa, @function
|
||||||
main2:
|
aaaaaaaaaaaaaaaa:
|
||||||
nop
|
nop
|
||||||
nop
|
nop
|
||||||
.Letext0:
|
.Letext0:
|
||||||
|
|
@ -59,7 +59,7 @@ main2:
|
||||||
.long 0x33
|
.long 0x33
|
||||||
.long 0x18
|
.long 0x18
|
||||||
.byte 0x30
|
.byte 0x30
|
||||||
.string "main2"
|
.string "aaaaaaaaaaaaaaaa"
|
||||||
.long 0
|
.long 0
|
||||||
|
|
||||||
.section .debug_gnu_pubtypes,"",@progbits
|
.section .debug_gnu_pubtypes,"",@progbits
|
||||||
|
|
|
||||||
|
|
@ -2,8 +2,18 @@
|
||||||
# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t1.o
|
# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t1.o
|
||||||
# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %p/Inputs/gdb-index.s -o %t2.o
|
# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %p/Inputs/gdb-index.s -o %t2.o
|
||||||
# RUN: ld.lld --gdb-index %t1.o %t2.o -o %t
|
# RUN: ld.lld --gdb-index %t1.o %t2.o -o %t
|
||||||
# RUN: llvm-dwarfdump -gdb-index %t | FileCheck %s
|
|
||||||
# RUN: llvm-objdump -d %t | FileCheck %s --check-prefix=DISASM
|
# RUN: llvm-objdump -d %t | FileCheck %s --check-prefix=DISASM
|
||||||
|
# RUN: llvm-dwarfdump -gdb-index %t | FileCheck %s --check-prefix=DWARF
|
||||||
|
# RUN: llvm-readelf -sections %t | FileCheck %s --check-prefix=SECTION
|
||||||
|
|
||||||
|
# RUN: llvm-mc -compress-debug-sections=zlib-gnu -filetype=obj -triple=x86_64-pc-linux \
|
||||||
|
# RUN: %p/Inputs/gdb-index.s -o %t2.o
|
||||||
|
# RUN: ld.lld --gdb-index %t1.o %t2.o -o %t
|
||||||
|
|
||||||
|
# RUN: llvm-objdump -d %t | FileCheck %s --check-prefix=DISASM
|
||||||
|
# RUN: llvm-dwarfdump -gdb-index %t | FileCheck %s --check-prefix=DWARF
|
||||||
|
# RUN: llvm-readelf -sections %t | FileCheck %s --check-prefix=SECTION
|
||||||
|
|
||||||
# DISASM: Disassembly of section .text:
|
# DISASM: Disassembly of section .text:
|
||||||
# DISASM: entrypoint:
|
# DISASM: entrypoint:
|
||||||
|
|
@ -11,29 +21,31 @@
|
||||||
# DISASM-CHECK: 201001: cc int3
|
# DISASM-CHECK: 201001: cc int3
|
||||||
# DISASM-CHECK: 201002: cc int3
|
# DISASM-CHECK: 201002: cc int3
|
||||||
# DISASM-CHECK: 201003: cc int3
|
# DISASM-CHECK: 201003: cc int3
|
||||||
# DISASM: main2:
|
# DISASM: aaaaaaaaaaaaaaaa:
|
||||||
# DISASM-CHECK: 201004: 90 nop
|
# DISASM-CHECK: 201004: 90 nop
|
||||||
# DISASM-CHECK: 201005: 90 nop
|
# DISASM-CHECK: 201005: 90 nop
|
||||||
|
|
||||||
# CHECK: .gnu_index contents:
|
# DWARF: .gnu_index contents:
|
||||||
# CHECK-NEXT: Version = 7
|
# DWARF-NEXT: Version = 7
|
||||||
# CHECK: CU list offset = 0x18, has 2 entries:
|
# DWARF: CU list offset = 0x18, has 2 entries:
|
||||||
# CHECK-NEXT: 0: Offset = 0x0, Length = 0x34
|
# DWARF-NEXT: 0: Offset = 0x0, Length = 0x34
|
||||||
# CHECK-NEXT: 1: Offset = 0x34, Length = 0x34
|
# DWARF-NEXT: 1: Offset = 0x34, Length = 0x34
|
||||||
# CHECK: Address area offset = 0x38, has 2 entries:
|
# DWARF: Address area offset = 0x38, has 2 entries:
|
||||||
# CHECK-NEXT: Low/High address = [0x201000, 0x201001) (Size: 0x1), CU id = 0
|
# DWARF-NEXT: Low/High address = [0x201000, 0x201001) (Size: 0x1), CU id = 0
|
||||||
# CHECK-NEXT: Low/High address = [0x201004, 0x201006) (Size: 0x2), CU id = 1
|
# DWARF-NEXT: Low/High address = [0x201004, 0x201006) (Size: 0x2), CU id = 1
|
||||||
# CHECK: Symbol table offset = 0x60, size = 1024, filled slots:
|
# DWARF: Symbol table offset = 0x60, size = 1024, filled slots:
|
||||||
# CHECK-NEXT: 754: Name offset = 0x27, CU vector offset = 0x8
|
# DWARF-NEXT: 512: Name offset = 0x2b, CU vector offset = 0x14
|
||||||
# CHECK-NEXT: String name: int, CU vector index: 1
|
# DWARF-NEXT: String name: aaaaaaaaaaaaaaaa, CU vector index: 2
|
||||||
# CHECK-NEXT: 822: Name offset = 0x1c, CU vector offset = 0x0
|
# DWARF-NEXT: 754: Name offset = 0x27, CU vector offset = 0x8
|
||||||
# CHECK-NEXT: String name: entrypoint, CU vector index: 0
|
# DWARF-NEXT: String name: int, CU vector index: 1
|
||||||
# CHECK-NEXT: 956: Name offset = 0x2b, CU vector offset = 0x14
|
# DWARF-NEXT: 822: Name offset = 0x1c, CU vector offset = 0x0
|
||||||
# CHECK-NEXT: String name: main2, CU vector index: 2
|
# DWARF-NEXT: String name: entrypoint, CU vector index: 0
|
||||||
# CHECK: Constant pool offset = 0x2060, has 3 CU vectors:
|
# DWARF: Constant pool offset = 0x2060, has 3 CU vectors:
|
||||||
# CHECK-NEXT: 0(0x0): 0x30000000
|
# DWARF-NEXT: 0(0x0): 0x30000000
|
||||||
# CHECK-NEXT: 1(0x8): 0x90000000 0x90000001
|
# DWARF-NEXT: 1(0x8): 0x90000000 0x90000001
|
||||||
# CHECK-NEXT: 2(0x14): 0x30000001
|
# DWARF-NEXT: 2(0x14): 0x30000001
|
||||||
|
|
||||||
|
# SECTION-NOT: debug_gnu_pubnames
|
||||||
|
|
||||||
# RUN: ld.lld --gdb-index --no-gdb-index %t1.o %t2.o -o %t2
|
# RUN: ld.lld --gdb-index --no-gdb-index %t1.o %t2.o -o %t2
|
||||||
# RUN: llvm-readobj -sections %t2 | FileCheck -check-prefix=NOGDB %s
|
# RUN: llvm-readobj -sections %t2 | FileCheck -check-prefix=NOGDB %s
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue