2 ## SHF_GNU_RETAIN is a generic feature defined in the OS specific range. The
3 ## flag marks a section as a GC root.
5 # RUN: llvm-mc -filetype=obj -triple=x86_64 %s -o %t.o
6 # RUN: ld.lld --gc-sections --print-gc-sections %t.o -o %t | count 0
7 # RUN: llvm-readobj -hS %t | FileCheck %s
8 # RUN: ld.lld -r -e _start --gc-sections --print-gc-sections %t.o -o %t.ro | count 0
9 # RUN: llvm-readobj -hS %t.ro | FileCheck %s
11 # CHECK: Name: .retain
12 # CHECK-NEXT: Type: SHT_PROGBITS
14 # CHECK-NEXT: SHF_ALLOC
15 # CHECK-NEXT: SHF_GNU_RETAIN
18 # RUN: llvm-mc -filetype=obj -triple=x86_64 --defsym NONALLOC=1 %s -o %t1.o
19 # RUN: not ld.lld --gc-sections %t1.o -o /dev/null 2>&1 | FileCheck %s --check-prefix=ERR
21 # ERR: error: {{.*}}.o:(.nonalloc): sh_link points to discarded section {{.*}}.o:(.discard)
26 .section .retain,"aR",@progbits
29 .section .foo,"a",@progbits
33 .section .discard,"a",@progbits
35 ## With SHF_GNU_RETAIN, .nonalloc is retained while its linked-to section
36 ## .discard is discarded, so there will be an error.
37 .section .nonalloc,"oR",@progbits,.discard