| 1 |
# REQUIRES: zlib |
| 2 |
## Test --compress-debug-sections=zlib and uncompression. |
| 3 |
|
| 4 |
# RUN: yaml2obj %p/Inputs/compress-debug-sections.yaml -o %t.o && llvm-objcopy %t.o |
| 5 |
# RUN: llvm-objcopy --compress-debug-sections=zlib %t.o %t-zlib.o |
| 6 |
# RUN: llvm-objcopy --decompress-debug-sections %t-zlib.o %t-un.o |
| 7 |
# RUN: cmp %t.o %t-un.o |
| 8 |
|
| 9 |
# RUN: llvm-readelf -S -r -x .debug_foo %t-zlib.o | FileCheck %s --check-prefixes=CHECK,COMPRESSED |
| 10 |
# RUN: llvm-readelf -S -r -x .debug_foo %t-un.o | FileCheck %s --check-prefixes=CHECK,UNCOMPRESSED |
| 11 |
|
| 12 |
# CHECK: Name Type Address Off Size ES Flg Lk Inf Al |
| 13 |
# COMPRESSED: .debug_foo PROGBITS 0000000000000000 000040 {{.*}} 00 C 0 0 8 |
| 14 |
# COMPRESSED-NEXT: .notdebug_foo PROGBITS 0000000000000000 {{.*}} 000008 00 0 0 0 |
| 15 |
# COMPRESSED: .debug_alloc PROGBITS 0000000000000000 {{.*}} 000040 00 A 0 0 0 |
| 16 |
# UNCOMPRESSED: .debug_foo PROGBITS 0000000000000000 000040 000008 00 0 0 0 |
| 17 |
# UNCOMPRESSED-NEXT: .notdebug_foo PROGBITS 0000000000000000 {{.*}} 000008 00 0 0 0 |
| 18 |
# UNCOMPRESSED: .debug_alloc PROGBITS 0000000000000000 {{.*}} 000040 00 A 0 0 0 |
| 19 |
|
| 20 |
## Relocations do not change. |
| 21 |
# CHECK: Relocation section '.rela.debug_foo' at offset {{.*}} contains 2 entries: |
| 22 |
# CHECK-NEXT: Offset |
| 23 |
# CHECK-NEXT: 0000000000000001 000000010000000a R_X86_64_32 0000000000000000 .debug_foo + 0 |
| 24 |
# CHECK-NEXT: 0000000000000002 000000020000000a R_X86_64_32 0000000000000000 .notdebug_foo + 0 |
| 25 |
|
| 26 |
# COMPRESSED: Hex dump of section '.debug_foo': |
| 27 |
# COMPRESSED-NEXT: 0x00000000 01000000 {{.*}} 08000000 00000000 |
| 28 |
# COMPRESSED-NEXT: 0x00000010 00000000 00000000 {{.*}} |
| 29 |
|
| 30 |
## --compress-debug-sections does not update a compressed section. |
| 31 |
# RUN: llvm-objcopy --compress-debug-sections=zlib %t-zlib.o %t-zlib-zlib.o |
| 32 |
# RUN: cmp %t-zlib.o %t-zlib-zlib.o |
| 33 |
|
| 34 |
# RUN: yaml2obj %s -o %t-corrupted |
| 35 |
# RUN: not llvm-objcopy --decompress-debug-sections %t-corrupted /dev/null 2>&1 | FileCheck %s -DFILE=%t-corrupted --check-prefix=ERR |
| 36 |
|
| 37 |
# ERR: error: '[[FILE]]': failed to decompress section '.debug_info': zlib error: Z_DATA_ERROR |
| 38 |
|
| 39 |
--- !ELF |
| 40 |
FileHeader: |
| 41 |
Class: ELFCLASS64 |
| 42 |
Data: ELFDATA2LSB |
| 43 |
Type: ET_REL |
| 44 |
Machine: EM_X86_64 |
| 45 |
Sections: |
| 46 |
- Type: SHT_PROGBITS |
| 47 |
Name: .debug_info |
| 48 |
Flags: [ SHF_COMPRESSED ] |
| 49 |
AddressAlign: 8 |
| 50 |
Content: "010000000000000004000000000000000100000000000000ffffffff" |