blob: 0777ee3f9032cedebab226db9cd48270f2c39b7b [file] [log] [blame]
George Rimarc91e38c2016-05-27 12:27:32 +00001// Check zlib-gnu style
2// RUN: llvm-mc -filetype=obj -compress-debug-sections=zlib-gnu -triple x86_64-pc-linux-gnu < %s -o %t
3// RUN: llvm-objdump -s %t | FileCheck --check-prefix=CHECK-GNU-STYLE %s
George Rimard92694e2016-05-24 13:45:29 +00004// RUN: llvm-dwarfdump -debug-dump=str %t | FileCheck --check-prefix=STR %s
George Rimarc91e38c2016-05-27 12:27:32 +00005// RUN: llvm-mc -filetype=obj -compress-debug-sections=zlib-gnu -triple i386-pc-linux-gnu < %s \
6// RUN: | llvm-readobj -symbols - | FileCheck --check-prefix=386-SYMBOLS-GNU %s
7
8// Check zlib style
9// RUN: llvm-mc -filetype=obj -compress-debug-sections=zlib -triple x86_64-pc-linux-gnu < %s -o %t
10// RUN: llvm-objdump -s %t | FileCheck --check-prefix=CHECK-ZLIB-STYLE %s
11// RUN: llvm-dwarfdump -debug-dump=str %t | FileCheck --check-prefix=STR %s
12// RUN: llvm-mc -filetype=obj -compress-debug-sections=zlib -triple i386-pc-linux-gnu < %s \
13// RUN: | llvm-readobj -symbols - | FileCheck --check-prefix=386-SYMBOLS-ZLIB %s
14// RUN: llvm-readobj -sections %t | FileCheck --check-prefix=ZLIB-STYLE-FLAGS %s
David Blaikie4d3b0432014-04-10 21:53:47 +000015
David Blaikieff9a0692014-03-28 17:04:53 +000016// REQUIRES: zlib
17
David Blaikie76d3a3c2014-04-18 21:52:26 +000018// Don't compress small sections, such as this simple debug_abbrev example
George Rimarc91e38c2016-05-27 12:27:32 +000019// CHECK-GNU-STYLE: Contents of section .debug_abbrev:
20// CHECK-GNU-STYLE-NOT: ZLIB
21// CHECK-GNU-STYLE-NOT: Contents of
David Blaikie76d3a3c2014-04-18 21:52:26 +000022
George Rimarc91e38c2016-05-27 12:27:32 +000023// CHECK-GNU-STYLE: Contents of section .debug_info:
David Blaikiedca7c7c2014-03-28 21:48:31 +000024
George Rimarc91e38c2016-05-27 12:27:32 +000025// CHECK-GNU-STYLE: Contents of section .zdebug_str:
Richard Smithb910e562016-05-25 00:14:12 +000026// Check for the 'ZLIB' file magic at the start of the section only
George Rimarc91e38c2016-05-27 12:27:32 +000027// CHECK-GNU-STYLE-NEXT: ZLIB
28// CHECK-GNU-STYLE-NOT: ZLIB
David Blaikie8019bf82014-04-10 21:53:53 +000029// FIXME: Handle compressing alignment fragments to support compressing debug_frame
George Rimarc91e38c2016-05-27 12:27:32 +000030// CHECK-GNU-STYLE: Contents of section .debug_frame:
31// CHECK-GNU-STYLE-NOT: ZLIB
32// CHECK-GNU-STYLE: Contents of
David Blaikie8019bf82014-04-10 21:53:53 +000033
George Rimard92694e2016-05-24 13:45:29 +000034// Decompress one valid dwarf section just to check that this roundtrips,
35// we use .zdebug_str section for that
36// STR: perfectly compressable data sample *****************************************
David Blaikie7400a972014-03-27 20:45:58 +000037
David Blaikiec029ab42014-04-18 21:24:12 +000038// In x86 32 bit named symbols are used for temporary symbols in merge
39// sections, so make sure we handle symbols inside compressed sections
George Rimarc91e38c2016-05-27 12:27:32 +000040// 386-SYMBOLS-GNU: Name: .Linfo_string0
41// 386-SYMBOLS-GNU-NOT: }
42// 386-SYMBOLS-GNU: Section: .zdebug_str
43
44// Now check the zlib style output:
45
46// Don't compress small sections, such as this simple debug_abbrev example
47// CHECK-ZLIB-STYLE: Contents of section .debug_abbrev:
48// CHECK-ZLIB-STYLE-NOT: ZLIB
49// CHECK-ZLIB-STYLE-NOT: Contents of
50// CHECK-ZLIB-STYLE: Contents of section .debug_info:
51// FIXME: Handle compressing alignment fragments to support compressing debug_frame
52// CHECK-ZLIB-STYLE: Contents of section .debug_frame:
53// CHECK-ZLIB-STYLE-NOT: ZLIB
54// CHECK-ZLIB-STYLE: Contents of
55
56// Check that debug_line section was not renamed, so it is
57// zlib-style, not zlib-gnu one. Check that SHF_COMPRESSED was set.
58// ZLIB-STYLE-FLAGS: Section {
59// ZLIB-STYLE-FLAGS: Index:
60// ZLIB-STYLE-FLAGS: Name: .debug_str
61// ZLIB-STYLE-FLAGS-NEXT: Type: SHT_PROGBITS
62// ZLIB-STYLE-FLAGS-NEXT: Flags [
63// ZLIB-STYLE-FLAGS-NEXT: SHF_COMPRESSED
64
65// 386-SYMBOLS-ZLIB: Name: .Linfo_string0
66// 386-SYMBOLS-ZLIB-NOT: }
67// 386-SYMBOLS-ZLIB: Section: .debug_str
David Blaikiec029ab42014-04-18 21:24:12 +000068
David Blaikie7400a972014-03-27 20:45:58 +000069 .section .debug_line,"",@progbits
David Blaikiedca7c7c2014-03-28 21:48:31 +000070
71 .section .debug_abbrev,"",@progbits
David Blaikiec029ab42014-04-18 21:24:12 +000072.Lsection_abbrev:
David Blaikiedca7c7c2014-03-28 21:48:31 +000073 .byte 1 # Abbreviation Code
David Blaikie8019bf82014-04-10 21:53:53 +000074 .byte 17 # DW_TAG_compile_unit
75 .byte 0 # DW_CHILDREN_no
David Blaikiec029ab42014-04-18 21:24:12 +000076 .byte 27 # DW_AT_comp_dir
77 .byte 14 # DW_FORM_strp
David Blaikie8019bf82014-04-10 21:53:53 +000078 .byte 0 # EOM(1)
79 .byte 0 # EOM(2)
David Blaikie76d3a3c2014-04-18 21:52:26 +000080
81 .section .debug_info,"",@progbits
82 .long 12 # Length of Unit
83 .short 4 # DWARF version number
84 .long .Lsection_abbrev # Offset Into Abbrev. Section
85 .byte 8 # Address Size (in bytes)
86 .byte 1 # Abbrev [1] DW_TAG_compile_unit
87 .long .Linfo_string0 # DW_AT_comp_dir
88
David Blaikie7400a972014-03-27 20:45:58 +000089 .text
90foo:
91 .cfi_startproc
92 .file 1 "Driver.ii"
David Blaikie76d3a3c2014-04-18 21:52:26 +000093# pad out the line table to make sure it's big enough to warrant compression
David Blaikie7400a972014-03-27 20:45:58 +000094 .loc 1 2 0
95 nop
David Blaikie76d3a3c2014-04-18 21:52:26 +000096 .loc 1 3 0
97 nop
98 .loc 1 4 0
99 nop
100 .loc 1 5 0
101 nop
102 .loc 1 6 0
103 nop
104 .loc 1 7 0
105 nop
106 .loc 1 8 0
107 nop
David Blaikie7400a972014-03-27 20:45:58 +0000108 .cfi_endproc
109 .cfi_sections .debug_frame
David Blaikiec029ab42014-04-18 21:24:12 +0000110
George Rimard92694e2016-05-24 13:45:29 +0000111# Below is the section we will use to check that after compression with llvm-mc,
112# llvm-dwarfdump tool will be able to decompress data back and dump it. Data sample
113# should be compressable enough, so it is filled with some amount of equal symbols at the end
David Blaikiec029ab42014-04-18 21:24:12 +0000114 .section .debug_str,"MS",@progbits,1
115.Linfo_string0:
George Rimard92694e2016-05-24 13:45:29 +0000116 .asciz "perfectly compressable data sample *****************************************"