1# REQUIRES: x86 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). 5 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 9 10# CHECK: Name Type Address Off Size ES Flg Lk Inf Al 11# CHECK: .group GROUP 0000000000000000 {{.*}} 000014 04 {{[1-9]}} [[#]] 4 12 13# CHECK: COMDAT group section [{{.*}}] `.group' [abc] contains 4 sections: 14# CHECK-NEXT: Name 15# CHECK-NEXT: .rodata.bar 16# CHECK-NEXT: .rodata.foo 17# CHECK-NEXT: .text.bar 18# CHECK-NEXT: .text.foo 19 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 24 25# SCRIPT1: Name Type Address Off Size ES Flg Lk Inf Al 26# SCRIPT1: .group GROUP 0000000000000000 {{.*}} 00000c 04 {{[1-9]}} [[#]] 4 27 28# SCRIPT1: COMDAT group section [{{.*}}] `.group' [abc] contains 2 sections: 29# SCRIPT1-NEXT: Name 30# SCRIPT1-NEXT: .rodata 31# SCRIPT1-NEXT: .text 32 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 36 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 40 41# SCRIPT2: COMDAT group section [{{.*}}] `.group' [abc] contains 2 sections: 42# SCRIPT2-NEXT: Name 43# SCRIPT2-NEXT: .text.bar 44# SCRIPT2-NEXT: .text.foo 45 46.weak abc 47abc: 48 49.section .rodata.bar,"aG",@progbits,abc,comdat 50.byte 42 51.section .rodata.foo,"aG",@progbits,abc,comdat 52.byte 42 53 54.section .text.bar,"axG",@progbits,abc,comdat 55.quad 42 56.section .text.foo,"axG",@progbits,abc,comdat 57.long 42 58