Home | History | Annotate | Download | only in ELF
      1 // 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
      4 // RUN: llvm-dwarfdump -debug-dump=str %t | FileCheck --check-prefix=STR %s
      5 // 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
     15 
     16 // REQUIRES: zlib
     17 
     18 // Don't compress small sections, such as this simple debug_abbrev example
     19 // CHECK-GNU-STYLE: Contents of section .debug_abbrev:
     20 // CHECK-GNU-STYLE-NOT: ZLIB
     21 // CHECK-GNU-STYLE-NOT: Contents of
     22 
     23 // CHECK-GNU-STYLE: Contents of section .debug_info:
     24 
     25 // CHECK-GNU-STYLE: Contents of section .zdebug_str:
     26 // Check for the 'ZLIB' file magic at the start of the section only
     27 // CHECK-GNU-STYLE-NEXT: ZLIB
     28 // CHECK-GNU-STYLE-NOT: ZLIB
     29 // FIXME: Handle compressing alignment fragments to support compressing debug_frame
     30 // CHECK-GNU-STYLE: Contents of section .debug_frame:
     31 // CHECK-GNU-STYLE-NOT: ZLIB
     32 // CHECK-GNU-STYLE: Contents of
     33 
     34 // 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 *****************************************
     37 
     38 // In x86 32 bit named symbols are used for temporary symbols in merge
     39 // sections, so make sure we handle symbols inside compressed sections
     40 // 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
     68 
     69 	.section	.debug_line,"",@progbits
     70 
     71 	.section	.debug_abbrev,"",@progbits
     72 .Lsection_abbrev:
     73 	.byte	1                       # Abbreviation Code
     74 	.byte	17                      # DW_TAG_compile_unit
     75 	.byte	0                       # DW_CHILDREN_no
     76 	.byte	27                      # DW_AT_comp_dir
     77 	.byte	14                      # DW_FORM_strp
     78 	.byte	0                       # EOM(1)
     79 	.byte	0                       # EOM(2)
     80 
     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 
     89 	.text
     90 foo:
     91 	.cfi_startproc
     92 	.file 1 "Driver.ii"
     93 # pad out the line table to make sure it's big enough to warrant compression
     94 	.loc 1 2 0
     95         nop
     96 	.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
    108 	.cfi_endproc
    109 	.cfi_sections .debug_frame
    110 
    111 # 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
    114 	.section        .debug_str,"MS",@progbits,1
    115 .Linfo_string0:
    116         .asciz  "perfectly compressable data sample *****************************************"
    117