[memprof] Remove an unused using directive (#117004)
[llvm-project.git] / lld / test / ELF / gc-sections-retain.s
blob196fc73fa0d430a70d9522bfa7e1190d19bee2c8
1 # REQUIRES: x86
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
13 # CHECK-NEXT: Flags [
14 # CHECK-NEXT: SHF_ALLOC
15 # CHECK-NEXT: SHF_GNU_RETAIN
16 # CHECK-NEXT: ]
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)
23 .global _start
24 _start:
26 .section .retain,"aR",@progbits
27 .quad .foo
29 .section .foo,"a",@progbits
30 .quad 0
32 .ifdef NONALLOC
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
38 .quad .text
39 .endif