129 lines · plain
1# REQUIRES: x86-registered-target, zlib, zstd2 3# RUN: rm -rf %t && mkdir %t && cd %t4# RUN: llvm-mc -filetype=obj -triple=x86_64 %s -o a.o5## '*0=none' wins because it is the last. '*0' sections are decompressed (if originally compressed) or kept unchanged (if uncompressed).6## No section is named 'nomatch'. The third option is a no-op.7# RUN: llvm-objcopy a.o out --compress-sections='*0=zlib' --compress-sections '*0=none' --compress-sections 'nomatch=none' 2>&1 | count 08# RUN: llvm-readelf -S out | FileCheck %s --check-prefix=CHECK19 10# CHECK1: Name Type Address Off Size ES Flg Lk Inf Al11# CHECK1: .text PROGBITS [[#%x,TEXT:]] [[#%x,]] [[#%x,]] 00 AX 0 0 412# CHECK1: foo0 PROGBITS [[#%x,FOO0:]] [[#%x,]] [[#%x,]] 00 A 0 0 813# CHECK1-NEXT: .relafoo0 RELA [[#%x,]] [[#%x,]] [[#%x,]] 18 I 11 3 814# CHECK1-NEXT: foo1 PROGBITS [[#%x,FOO1:]] [[#%x,]] [[#%x,]] 00 A 0 0 815# CHECK1-NEXT: .relafoo1 RELA [[#%x,]] [[#%x,]] [[#%x,]] 18 I 11 5 816# CHECK1: nonalloc0 PROGBITS 0000000000000000 [[#%x,]] [[#%x,]] 00 0 0 817# CHECK1-NEXT: .relanonalloc0 RELA [[#%x,]] [[#%x,]] [[#%x,]] 18 I 11 7 818# CHECK1-NEXT: nonalloc1 PROGBITS 0000000000000000 [[#%x,]] [[#%x,]] 00 0 0 819# CHECK1-NEXT: .debug_str PROGBITS 0000000000000000 [[#%x,]] [[#%x,]] 01 MS 0 0 120 21## Mixing zlib and zstd.22# RUN: llvm-objcopy a.o out2 --compress-sections '*c0=zlib' --compress-sections .debug_str=zstd23# RUN: llvm-readelf -Sr -x nonalloc0 -x .debug_str out2 2>&1 | FileCheck %s --check-prefix=CHECK224# RUN: llvm-readelf -z -x nonalloc0 -x .debug_str out2 | FileCheck %s --check-prefix=CHECK2DE25 26# CHECK2: Name Type Address Off Size ES Flg Lk Inf Al27# CHECK2: .text PROGBITS [[#%x,TEXT:]] [[#%x,]] [[#%x,]] 00 AX 0 0 428# CHECK2: foo0 PROGBITS [[#%x,FOO0:]] [[#%x,]] [[#%x,]] 00 A 0 0 829# CHECK2-NEXT: .relafoo0 RELA [[#%x,]] [[#%x,]] [[#%x,]] 18 I 11 3 830# CHECK2-NEXT: foo1 PROGBITS [[#%x,FOO1:]] [[#%x,]] [[#%x,]] 00 A 0 0 831# CHECK2-NEXT: .relafoo1 RELA [[#%x,]] [[#%x,]] [[#%x,]] 18 I 11 5 832# CHECK2: nonalloc0 PROGBITS 0000000000000000 [[#%x,]] [[#%x,]] 00 C 0 0 833# CHECK2-NEXT: .relanonalloc0 RELA [[#%x,]] [[#%x,]] [[#%x,]] 18 IC 11 7 834# CHECK2-NEXT: nonalloc1 PROGBITS 0000000000000000 [[#%x,]] [[#%x,]] 00 0 0 835# CHECK2-NEXT: .debug_str PROGBITS 0000000000000000 [[#%x,]] [[#%x,]] 01 MSC 0 0 836 37## llvm-readelf -r doesn't support SHF_COMPRESSED SHT_RELA.38# CHECK2: warning: {{.*}}: unable to read relocations from SHT_RELA section with index 8: section [index 8] has an invalid sh_size ([[#]]) which is not a multiple of its sh_entsize (24)39 40# CHECK2: Hex dump of section 'nonalloc0':41## zlib with ch_size=0x1042# CHECK2-NEXT: 01000000 00000000 10000000 0000000043# CHECK2-NEXT: 08000000 00000000 {{.*}}44# CHECK2: Hex dump of section '.debug_str':45## zstd with ch_size=0x3846# CHECK2-NEXT: 02000000 00000000 38000000 0000000047# CHECK2-NEXT: 01000000 00000000 {{.*}}48 49# CHECK2DE: Hex dump of section 'nonalloc0':50# CHECK2DE-NEXT: 0x00000000 00000000 00000000 00000000 00000000 ................51# CHECK2DE-EMPTY:52# CHECK2DE-NEXT: Hex dump of section '.debug_str':53# CHECK2DE-NEXT: 0x00000000 41414141 41414141 41414141 41414141 AAAAAAAAAAAAAAAA54 55## --decompress-debug-sections takes precedence, even if it is before --compress-sections.56# RUN: llvm-objcopy a.o out3 --decompress-debug-sections --compress-sections .debug_str=zstd57# RUN: llvm-readelf -S out3 | FileCheck %s --check-prefix=CHECK358 59# CHECK3: .debug_str PROGBITS 0000000000000000 [[#%x,]] [[#%x,]] 01 MS 0 0 160 61# RUN: llvm-objcopy a.o out4 --compress-sections '*0=zlib'62# RUN: llvm-readelf -S out4 | FileCheck %s --check-prefix=CHECK463 64# CHECK4: Name Type Address Off Size ES Flg Lk Inf Al65# CHECK4: .text PROGBITS [[#%x,TEXT:]] [[#%x,]] [[#%x,]] 00 AX 0 0 466# CHECK4: foo0 PROGBITS [[#%x,FOO0:]] [[#%x,]] [[#%x,]] 00 AC 0 0 867# CHECK4-NEXT: .relafoo0 RELA [[#%x,]] [[#%x,]] [[#%x,]] 18 IC 11 3 868# CHECK4-NEXT: foo1 PROGBITS [[#%x,FOO1:]] [[#%x,]] [[#%x,]] 00 A 0 0 869# CHECK4-NEXT: .relafoo1 RELA [[#%x,]] [[#%x,]] [[#%x,]] 18 I 11 5 870# CHECK4: nonalloc0 PROGBITS 0000000000000000 [[#%x,]] [[#%x,]] 00 C 0 0 871# CHECK4-NEXT: .relanonalloc0 RELA [[#%x,]] [[#%x,]] [[#%x,]] 18 IC 11 7 872# CHECK4-NEXT: nonalloc1 PROGBITS 0000000000000000 [[#%x,]] [[#%x,]] 00 0 0 873# CHECK4-NEXT: .debug_str PROGBITS 0000000000000000 [[#%x,]] [[#%x,]] 01 MS 0 0 174 75## If a section is already compressed, compression request for another format is ignored.76# RUN: llvm-objcopy a.o out5 --compress-sections 'nonalloc0=zlib'77# RUN: llvm-readelf -x nonalloc0 out5 | FileCheck %s --check-prefix=CHECK578# RUN: llvm-objcopy out5 out5a --compress-sections 'nonalloc0=zstd'79# RUN: cmp out5 out5a80 81# CHECK5: Hex dump of section 'nonalloc0':82## zlib with ch_size=0x1083# CHECK5-NEXT: 01000000 00000000 10000000 0000000084# CHECK5-NEXT: 08000000 00000000 {{.*}}85 86# RUN: not llvm-objcopy --compress-sections=foo a.o out 2>&1 | \87# RUN: FileCheck %s --check-prefix=ERR1 --implicit-check-not=error:88# ERR1: error: --compress-sections: parse error, not 'section-glob=[none|zlib|zstd]'89 90# RUN: llvm-objcopy --compress-sections 'a[=zlib' a.o out 2>&1 | \91# RUN: FileCheck %s --check-prefix=ERR2 --implicit-check-not=error:92# ERR2: warning: invalid glob pattern, unmatched '['93 94# RUN: not llvm-objcopy a.o out --compress-sections='.debug*=zlib-gabi' --compress-sections='.debug*=' 2>&1 | \95# RUN: FileCheck -check-prefix=ERR3 %s96# ERR3: error: invalid or unsupported --compress-sections format: .debug*=zlib-gabi97 98# RUN: not llvm-objcopy a.o out --compress-sections='!.debug*=zlib' 2>&1 | \99# RUN: FileCheck -check-prefix=ERR4 %s100# ERR4: error: --compress-sections: negative pattern is unsupported101 102.globl _start103_start:104 ret105 106.section foo0,"a"107.balign 8108.quad .text-.109.quad .text-.110.section foo1,"a"111.balign 8112.quad .text-.113.quad .text-.114.section nonalloc0,""115.balign 8116.quad .text+1117.quad .text+2118sym0:119.section nonalloc1,""120.balign 8121.quad 42122sym1:123 124.section .debug_str,"MS",@progbits,1125.Linfo_string0:126 .asciz "AAAAAAAAAAAAAAAAAAAAAAAAAAA"127.Linfo_string1:128 .asciz "BBBBBBBBBBBBBBBBBBBBBBBBBBB"129