2 ## Test that SHT_GROUP sections are retained in relocatable output. The content
3 ## may be rewritten because group members may change their indices. Additionally,
4 ## group member may be combined or discarded (e.g. /DISCARD/ or --gc-sections).
6 # RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o
7 # RUN: ld.lld -r %t.o %t.o -o %t.ro
8 # RUN: llvm-readelf -g -S %t.ro | FileCheck %s
10 # CHECK: Name Type Address Off Size ES Flg Lk Inf Al
11 # CHECK: .group GROUP 0000000000000000 {{.*}} 000014 04 {{[1-9]}} [[#]] 4
13 # CHECK: COMDAT group section [{{.*}}] `.group' [abc] contains 4 sections:
15 # CHECK-NEXT: .rodata.bar
16 # CHECK-NEXT: .rodata.foo
17 # CHECK-NEXT: .text.bar
18 # CHECK-NEXT: .text.foo
20 ## Rewrite SHT_GROUP content if some members are combined.
21 # RUN: echo 'SECTIONS { .rodata : {*(.rodata.*)} .text : {*(.text.*)} }' > %t1.lds
22 # RUN: ld.lld -r -T %t1.lds %t.o %t.o -o %t1.ro
23 # RUN: llvm-readelf -g -S %t1.ro | FileCheck %s --check-prefix=SCRIPT1
25 # SCRIPT1: Name Type Address Off Size ES Flg Lk Inf Al
26 # SCRIPT1: .group GROUP 0000000000000000 {{.*}} 00000c 04 {{[1-9]}} [[#]] 4
28 # SCRIPT1: COMDAT group section [{{.*}}] `.group' [abc] contains 2 sections:
30 # SCRIPT1-NEXT: .rodata
33 # RUN: echo 'SECTIONS { /DISCARD/ : {*(.rodata.*)} }' > %t2.lds
34 # RUN: ld.lld -r -T %t2.lds %t.o %t.o -o %t2.ro
35 # RUN: llvm-readelf -g -S %t2.ro | FileCheck %s --check-prefix=SCRIPT2
37 ## Handle discarded group members.
38 # SCRIPT2: [Nr] Name Type Address Off Size ES Flg Lk Inf Al
39 # SCRIPT2: [ 2] .group GROUP 0000000000000000 {{.*}} 00000c 04 {{[1-9]}} [[#]] 4
41 # SCRIPT2: COMDAT group section [{{.*}}] `.group' [abc] contains 2 sections:
43 # SCRIPT2-NEXT: .text.bar
44 # SCRIPT2-NEXT: .text.foo
49 .section .rodata.bar,"aG",@progbits,abc,comdat
51 .section .rodata.foo,"aG",@progbits,abc,comdat
54 .section .text.bar,"axG",@progbits,abc,comdat
56 .section .text.foo,"axG",@progbits,abc,comdat