1*9880d681SAndroid Build Coastguard Worker// Check zlib-gnu style 2*9880d681SAndroid Build Coastguard Worker// RUN: llvm-mc -filetype=obj -compress-debug-sections=zlib-gnu -triple x86_64-pc-linux-gnu < %s -o %t 3*9880d681SAndroid Build Coastguard Worker// RUN: llvm-objdump -s %t | FileCheck --check-prefix=CHECK-GNU-STYLE %s 4*9880d681SAndroid Build Coastguard Worker// RUN: llvm-dwarfdump -debug-dump=str %t | FileCheck --check-prefix=STR %s 5*9880d681SAndroid Build Coastguard Worker// RUN: llvm-mc -filetype=obj -compress-debug-sections=zlib-gnu -triple i386-pc-linux-gnu < %s \ 6*9880d681SAndroid Build Coastguard Worker// RUN: | llvm-readobj -symbols - | FileCheck --check-prefix=386-SYMBOLS-GNU %s 7*9880d681SAndroid Build Coastguard Worker 8*9880d681SAndroid Build Coastguard Worker// Check zlib style 9*9880d681SAndroid Build Coastguard Worker// RUN: llvm-mc -filetype=obj -compress-debug-sections=zlib -triple x86_64-pc-linux-gnu < %s -o %t 10*9880d681SAndroid Build Coastguard Worker// RUN: llvm-objdump -s %t | FileCheck --check-prefix=CHECK-ZLIB-STYLE %s 11*9880d681SAndroid Build Coastguard Worker// RUN: llvm-dwarfdump -debug-dump=str %t | FileCheck --check-prefix=STR %s 12*9880d681SAndroid Build Coastguard Worker// RUN: llvm-mc -filetype=obj -compress-debug-sections=zlib -triple i386-pc-linux-gnu < %s \ 13*9880d681SAndroid Build Coastguard Worker// RUN: | llvm-readobj -symbols - | FileCheck --check-prefix=386-SYMBOLS-ZLIB %s 14*9880d681SAndroid Build Coastguard Worker// RUN: llvm-readobj -sections %t | FileCheck --check-prefix=ZLIB-STYLE-FLAGS %s 15*9880d681SAndroid Build Coastguard Worker 16*9880d681SAndroid Build Coastguard Worker// REQUIRES: zlib 17*9880d681SAndroid Build Coastguard Worker 18*9880d681SAndroid Build Coastguard Worker// Don't compress small sections, such as this simple debug_abbrev example 19*9880d681SAndroid Build Coastguard Worker// CHECK-GNU-STYLE: Contents of section .debug_abbrev: 20*9880d681SAndroid Build Coastguard Worker// CHECK-GNU-STYLE-NOT: ZLIB 21*9880d681SAndroid Build Coastguard Worker// CHECK-GNU-STYLE-NOT: Contents of 22*9880d681SAndroid Build Coastguard Worker 23*9880d681SAndroid Build Coastguard Worker// CHECK-GNU-STYLE: Contents of section .debug_info: 24*9880d681SAndroid Build Coastguard Worker 25*9880d681SAndroid Build Coastguard Worker// CHECK-GNU-STYLE: Contents of section .zdebug_str: 26*9880d681SAndroid Build Coastguard Worker// Check for the 'ZLIB' file magic at the start of the section only 27*9880d681SAndroid Build Coastguard Worker// CHECK-GNU-STYLE-NEXT: ZLIB 28*9880d681SAndroid Build Coastguard Worker// CHECK-GNU-STYLE-NOT: ZLIB 29*9880d681SAndroid Build Coastguard Worker// FIXME: Handle compressing alignment fragments to support compressing debug_frame 30*9880d681SAndroid Build Coastguard Worker// CHECK-GNU-STYLE: Contents of section .debug_frame: 31*9880d681SAndroid Build Coastguard Worker// CHECK-GNU-STYLE-NOT: ZLIB 32*9880d681SAndroid Build Coastguard Worker// CHECK-GNU-STYLE: Contents of 33*9880d681SAndroid Build Coastguard Worker 34*9880d681SAndroid Build Coastguard Worker// Decompress one valid dwarf section just to check that this roundtrips, 35*9880d681SAndroid Build Coastguard Worker// we use .zdebug_str section for that 36*9880d681SAndroid Build Coastguard Worker// STR: perfectly compressable data sample ***************************************** 37*9880d681SAndroid Build Coastguard Worker 38*9880d681SAndroid Build Coastguard Worker// In x86 32 bit named symbols are used for temporary symbols in merge 39*9880d681SAndroid Build Coastguard Worker// sections, so make sure we handle symbols inside compressed sections 40*9880d681SAndroid Build Coastguard Worker// 386-SYMBOLS-GNU: Name: .Linfo_string0 41*9880d681SAndroid Build Coastguard Worker// 386-SYMBOLS-GNU-NOT: } 42*9880d681SAndroid Build Coastguard Worker// 386-SYMBOLS-GNU: Section: .zdebug_str 43*9880d681SAndroid Build Coastguard Worker 44*9880d681SAndroid Build Coastguard Worker// Now check the zlib style output: 45*9880d681SAndroid Build Coastguard Worker 46*9880d681SAndroid Build Coastguard Worker// Don't compress small sections, such as this simple debug_abbrev example 47*9880d681SAndroid Build Coastguard Worker// CHECK-ZLIB-STYLE: Contents of section .debug_abbrev: 48*9880d681SAndroid Build Coastguard Worker// CHECK-ZLIB-STYLE-NOT: ZLIB 49*9880d681SAndroid Build Coastguard Worker// CHECK-ZLIB-STYLE-NOT: Contents of 50*9880d681SAndroid Build Coastguard Worker// CHECK-ZLIB-STYLE: Contents of section .debug_info: 51*9880d681SAndroid Build Coastguard Worker// FIXME: Handle compressing alignment fragments to support compressing debug_frame 52*9880d681SAndroid Build Coastguard Worker// CHECK-ZLIB-STYLE: Contents of section .debug_frame: 53*9880d681SAndroid Build Coastguard Worker// CHECK-ZLIB-STYLE-NOT: ZLIB 54*9880d681SAndroid Build Coastguard Worker// CHECK-ZLIB-STYLE: Contents of 55*9880d681SAndroid Build Coastguard Worker 56*9880d681SAndroid Build Coastguard Worker// Check that debug_line section was not renamed, so it is 57*9880d681SAndroid Build Coastguard Worker// zlib-style, not zlib-gnu one. Check that SHF_COMPRESSED was set. 58*9880d681SAndroid Build Coastguard Worker// ZLIB-STYLE-FLAGS: Section { 59*9880d681SAndroid Build Coastguard Worker// ZLIB-STYLE-FLAGS: Index: 60*9880d681SAndroid Build Coastguard Worker// ZLIB-STYLE-FLAGS: Name: .debug_str 61*9880d681SAndroid Build Coastguard Worker// ZLIB-STYLE-FLAGS-NEXT: Type: SHT_PROGBITS 62*9880d681SAndroid Build Coastguard Worker// ZLIB-STYLE-FLAGS-NEXT: Flags [ 63*9880d681SAndroid Build Coastguard Worker// ZLIB-STYLE-FLAGS-NEXT: SHF_COMPRESSED 64*9880d681SAndroid Build Coastguard Worker 65*9880d681SAndroid Build Coastguard Worker// 386-SYMBOLS-ZLIB: Name: .Linfo_string0 66*9880d681SAndroid Build Coastguard Worker// 386-SYMBOLS-ZLIB-NOT: } 67*9880d681SAndroid Build Coastguard Worker// 386-SYMBOLS-ZLIB: Section: .debug_str 68*9880d681SAndroid Build Coastguard Worker 69*9880d681SAndroid Build Coastguard Worker .section .debug_line,"",@progbits 70*9880d681SAndroid Build Coastguard Worker 71*9880d681SAndroid Build Coastguard Worker .section .debug_abbrev,"",@progbits 72*9880d681SAndroid Build Coastguard Worker.Lsection_abbrev: 73*9880d681SAndroid Build Coastguard Worker .byte 1 # Abbreviation Code 74*9880d681SAndroid Build Coastguard Worker .byte 17 # DW_TAG_compile_unit 75*9880d681SAndroid Build Coastguard Worker .byte 0 # DW_CHILDREN_no 76*9880d681SAndroid Build Coastguard Worker .byte 27 # DW_AT_comp_dir 77*9880d681SAndroid Build Coastguard Worker .byte 14 # DW_FORM_strp 78*9880d681SAndroid Build Coastguard Worker .byte 0 # EOM(1) 79*9880d681SAndroid Build Coastguard Worker .byte 0 # EOM(2) 80*9880d681SAndroid Build Coastguard Worker 81*9880d681SAndroid Build Coastguard Worker .section .debug_info,"",@progbits 82*9880d681SAndroid Build Coastguard Worker .long 12 # Length of Unit 83*9880d681SAndroid Build Coastguard Worker .short 4 # DWARF version number 84*9880d681SAndroid Build Coastguard Worker .long .Lsection_abbrev # Offset Into Abbrev. Section 85*9880d681SAndroid Build Coastguard Worker .byte 8 # Address Size (in bytes) 86*9880d681SAndroid Build Coastguard Worker .byte 1 # Abbrev [1] DW_TAG_compile_unit 87*9880d681SAndroid Build Coastguard Worker .long .Linfo_string0 # DW_AT_comp_dir 88*9880d681SAndroid Build Coastguard Worker 89*9880d681SAndroid Build Coastguard Worker .text 90*9880d681SAndroid Build Coastguard Workerfoo: 91*9880d681SAndroid Build Coastguard Worker .cfi_startproc 92*9880d681SAndroid Build Coastguard Worker .file 1 "Driver.ii" 93*9880d681SAndroid Build Coastguard Worker# pad out the line table to make sure it's big enough to warrant compression 94*9880d681SAndroid Build Coastguard Worker .loc 1 2 0 95*9880d681SAndroid Build Coastguard Worker nop 96*9880d681SAndroid Build Coastguard Worker .loc 1 3 0 97*9880d681SAndroid Build Coastguard Worker nop 98*9880d681SAndroid Build Coastguard Worker .loc 1 4 0 99*9880d681SAndroid Build Coastguard Worker nop 100*9880d681SAndroid Build Coastguard Worker .loc 1 5 0 101*9880d681SAndroid Build Coastguard Worker nop 102*9880d681SAndroid Build Coastguard Worker .loc 1 6 0 103*9880d681SAndroid Build Coastguard Worker nop 104*9880d681SAndroid Build Coastguard Worker .loc 1 7 0 105*9880d681SAndroid Build Coastguard Worker nop 106*9880d681SAndroid Build Coastguard Worker .loc 1 8 0 107*9880d681SAndroid Build Coastguard Worker nop 108*9880d681SAndroid Build Coastguard Worker .cfi_endproc 109*9880d681SAndroid Build Coastguard Worker .cfi_sections .debug_frame 110*9880d681SAndroid Build Coastguard Worker 111*9880d681SAndroid Build Coastguard Worker# Below is the section we will use to check that after compression with llvm-mc, 112*9880d681SAndroid Build Coastguard Worker# llvm-dwarfdump tool will be able to decompress data back and dump it. Data sample 113*9880d681SAndroid Build Coastguard Worker# should be compressable enough, so it is filled with some amount of equal symbols at the end 114*9880d681SAndroid Build Coastguard Worker .section .debug_str,"MS",@progbits,1 115*9880d681SAndroid Build Coastguard Worker.Linfo_string0: 116*9880d681SAndroid Build Coastguard Worker .asciz "perfectly compressable data sample *****************************************" 117