112 lines · plain
1# REQUIRES: x86, zlib, zstd2 3# RUN: rm -rf %t && mkdir %t && cd %t4# RUN: llvm-mc -filetype=obj -triple=x86_64 %s -o a.o5# RUN: ld.lld -pie a.o -o out --compress-sections '*0=zlib' --compress-sections '*0=none' --compress-sections 'nomatch=none'6# RUN: llvm-readelf -SrsX out | FileCheck %s --check-prefix=CHECK17 8# CHECK1: Name Type Address Off Size ES Flg Lk Inf Al9# CHECK1: foo0 PROGBITS [[#%x,FOO0:]] [[#%x,]] [[#%x,]] 00 A 0 0 810# CHECK1-NEXT: foo1 PROGBITS [[#%x,FOO1:]] [[#%x,]] [[#%x,]] 00 A 0 0 811# CHECK1-NEXT: .text PROGBITS [[#%x,TEXT:]] [[#%x,]] [[#%x,]] 00 AX 0 0 412# CHECK1: nonalloc0 PROGBITS 0000000000000000 [[#%x,]] [[#%x,]] 00 0 0 813# CHECK1-NEXT: nonalloc1 PROGBITS 0000000000000000 [[#%x,]] [[#%x,]] 00 0 0 814# CHECK1-NEXT: smallc0 PROGBITS 0000000000000000 [[#%x,]] [[#%x,]] 00 0 0 815# CHECK1-NEXT: .debug_str PROGBITS 0000000000000000 [[#%x,]] [[#%x,]] 01 MS 0 0 116 17# CHECK1: 0000000000000090 0 NOTYPE LOCAL DEFAULT [[#]] (nonalloc0) sym018# CHECK1: 0000000000000088 0 NOTYPE LOCAL DEFAULT [[#]] (nonalloc1) sym119 20# RUN: ld.lld -pie a.o --compress-sections '*c0=zlib' --compress-sections .debug_str=zstd:3 -o out221# RUN: llvm-readelf -SrsX -x nonalloc0 -x .debug_str out2 | FileCheck %s --check-prefix=CHECK222 23# CHECK2: Name Type Address Off Size ES Flg Lk Inf Al24# CHECK2: foo0 PROGBITS [[#%x,FOO0:]] [[#%x,]] [[#%x,]] 00 A 0 0 825# CHECK2-NEXT: foo1 PROGBITS [[#%x,FOO1:]] [[#%x,]] [[#%x,]] 00 A 0 0 826# CHECK2-NEXT: .text PROGBITS [[#%x,TEXT:]] [[#%x,]] [[#%x,]] 00 AX 0 0 427# CHECK2: nonalloc0 PROGBITS 0000000000000000 [[#%x,]] [[#%x,]] 00 C 0 0 128# CHECK2-NEXT: nonalloc1 PROGBITS 0000000000000000 [[#%x,]] 000088 00 0 0 829# CHECK2-NEXT: smallc0 PROGBITS 0000000000000000 [[#%x,]] 00000c 00 0 0 130# CHECK2-NEXT: .debug_str PROGBITS 0000000000000000 [[#%x,]] [[#%x,]] 01 MSC 0 0 131 32# CHECK2: 0000000000000090 0 NOTYPE LOCAL DEFAULT [[#]] (nonalloc0) sym033# CHECK2: 0000000000000088 0 NOTYPE LOCAL DEFAULT [[#]] (nonalloc1) sym134 35# CHECK2: Hex dump of section 'nonalloc0':36## zlib with ch_size=0x9037# CHECK2-NEXT: 01000000 00000000 90000000 0000000038# CHECK2-NEXT: 01000000 00000000 {{.*}}39# CHECK2: Hex dump of section '.debug_str':40## zstd with ch_size=0x3841# CHECK2-NEXT: 02000000 00000000 38000000 0000000042# CHECK2-NEXT: 01000000 00000000 {{.*}}43 44## --compress-sections takes precedence.45# RUN: ld.lld a.o --compress-sections .debug_str=zstd --compress-debug-sections=none -o out346# RUN: llvm-readelf -S out3 | FileCheck %s --check-prefix=CHECK347 48# CHECK3: .debug_str PROGBITS 0000000000000000 [[#%x,]] [[#%x,]] 01 MSC 0 0 149 50# RUN: not ld.lld a.o --compress-sections '*0=zlib' 2>&1 | \51# RUN: FileCheck %s --check-prefix=ERR-ALLOC --implicit-check-not=error:52# ERR-ALLOC: error: --compress-sections: section 'foo0' with the SHF_ALLOC flag cannot be compressed53 54# RUN: not ld.lld --compress-sections=foo a.o 2>&1 | \55# RUN: FileCheck %s --check-prefix=ERR1 --implicit-check-not=error:56# ERR1: error: --compress-sections: parse error, not 'section-glob=[none|zlib|zstd]'57 58# RUN: not ld.lld --compress-sections 'a[=zlib' a.o 2>&1 | \59# RUN: FileCheck %s --check-prefix=ERR2 --implicit-check-not=error:60# ERR2: error: --compress-sections: invalid glob pattern, unmatched '['61 62# RUN: not ld.lld a.o --compress-sections='.debug*=zlib-gabi' --compress-sections='.debug*=' 2>&1 | \63# RUN: FileCheck -check-prefix=ERR3 %s64# ERR3: unknown --compress-sections value: zlib-gabi65# ERR3-NEXT: --compress-sections: parse error, not 'section-glob=[none|zlib|zstd]'66 67# RUN: not ld.lld a.o --compress-sections='a=zlib:' --compress-sections='a=zlib:-1' 2>&1 | \68# RUN: FileCheck %s --check-prefix=ERR4 --implicit-check-not=error:69# ERR4: error: --compress-sections: expected a non-negative integer compression level, but got ''70# ERR4: error: --compress-sections: expected a non-negative integer compression level, but got '-1'71 72## Invalid compression level for zlib.73# RUN: not ld.lld a.o --compress-sections='.debug*=zlib:99' 2>&1 | \74# RUN: FileCheck %s --check-prefix=ERR6 --implicit-check-not=error:75# ERR6: error: --compress-sections: deflateInit2 returned -276 77.globl _start78_start:79 ret80 81.section foo0,"a"82.balign 883.quad .text-.84.quad .text-.85.space 12886.section foo1,"a"87.balign 888.quad .text-.89.quad .text-.90.space 12891.section nonalloc0,""92.balign 893.quad .text+194.quad .text+295.space 12896sym0:97.section nonalloc1,""98.balign 899.quad 42100.space 128101sym1:102 103.section smallc0,""104.balign 8105.space 12106 107.section .debug_str,"MS",@progbits,1108.Linfo_string0:109 .asciz "AAAAAAAAAAAAAAAAAAAAAAAAAAA"110.Linfo_string1:111 .asciz "BBBBBBBBBBBBBBBBBBBBBBBBBBB"112