1 ## Check that group members are retained or discarded as a unit.
5 # RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t.o
6 # RUN: ld.lld %t.o --gc-sections -o %t
7 # RUN: llvm-readelf -s %t | FileCheck %s
9 # RUN: echo ".global __start___data; __start___data:" > %t2.s
10 # RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %t2.s -o %t2.o
11 # RUN: ld.lld -shared %t2.o --soname=t2 -o %t2.so
12 # RUN: ld.lld %t.o --gc-sections -o %t2 %t2.so
13 # RUN: llvm-readelf -s %t2 | FileCheck %s
15 ## The referenced __data is retained.
16 # CHECK: [[#%x,ADDR:]] {{.*}} __start___data
17 # CHECK: [[#ADDR + 8]] {{.*}} __stop___data
18 ## __libc_atexit is retained even if there is no reference, as a workaround for
19 ## glibc<2.34 (BZ #27492).
20 # CHECK: [[#%x,ADDR:]] {{.*}} __start___libc_atexit
21 # CHECK: [[#ADDR + 8]] {{.*}} __stop___libc_atexit
26 ## If -z nostart-stop-gc, sections whose names are C identifiers are retained by
27 ## __start_/__stop_ references.
28 # RUN: ld.lld %t.o %t2.so --gc-sections -z nostart-stop-gc -o %t3
29 # RUN: llvm-readelf -s %t3 | FileCheck %s --check-prefix=NOGC
30 # NOGC: [[#%x,ADDR:]] {{.*}} __start___data
31 # NOGC: [[#ADDR + 16]] {{.*}} __stop___data
35 .weak __start___libc_atexit
36 .weak __stop___libc_atexit
38 .section .text,"ax",@progbits
41 .quad __start___data - .
42 .quad __stop___data - .
43 .quad __start___libc_atexit - .
44 .quad __stop___libc_atexit - .
47 .section __data,"axG",@progbits,f
50 .section .text.f,"axG",@progbits,f
55 .section __data,"axG",@progbits,g
58 .section .text.g,"axG",@progbits,g
63 .section __libc_atexit,"a",@progbits