1# REQUIRES: x86
2# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t.o
3
4## In this test we check that output section types such as
5## COPY, INFO and OVERLAY marks output section as non-allocatable.
6
7# RUN: echo "SECTIONS { .bar : { *(.foo) } };" > %t.script
8# RUN: ld.lld -o %t --script %t.script %t.o
9# RUN: llvm-readobj --sections %t | FileCheck %s --check-prefix=DEFAULT
10# DEFAULT:      Name: .bar
11# DEFAULT:      Type: SHT_PROGBITS
12# DEFAULT-NEXT: Flags [
13# DEFAULT-NEXT:   SHF_ALLOC
14# DEFAULT-NEXT: ]
15
16# RUN: echo "SECTIONS { .bar (COPY) : { *(.foo) } };" > %t.script
17# RUN: ld.lld -o %t --script %t.script %t.o
18# RUN: llvm-readobj --sections %t | FileCheck %s --check-prefix=NONALLOC
19# NONALLOC:      Name: .bar
20# NONALLOC:      Type: SHT_PROGBITS
21# NONALLOC-NEXT: Flags [
22# NONALLOC-NEXT: ]
23
24# RUN: echo "SECTIONS { .bar (INFO) : { *(.foo) } };" > %t.script
25# RUN: ld.lld -o %t --script %t.script %t.o
26# RUN: llvm-readobj --sections %t | FileCheck %s --check-prefix=NONALLOC
27
28# RUN: echo "SECTIONS { .bar (OVERLAY) : { *(.foo) } };" > %t.script
29# RUN: ld.lld -o %t --script %t.script %t.o
30# RUN: llvm-readobj --sections %t | FileCheck %s --check-prefix=NONALLOC
31
32# RUN: echo "SECTIONS { .bar (INFO) : { . += 1; } };" > %t.script
33# RUN: ld.lld -o %t --script %t.script %t.o
34# RUN: llvm-readobj --sections %t | FileCheck %s --check-prefix=NONALLOC
35
36# RUN: echo "SECTIONS { .bar 0x20000 (INFO) : { *(.foo) } };" > %t.script
37# RUN: ld.lld -o %t --script %t.script %t.o
38# RUN: llvm-readobj --sections %t | FileCheck %s --check-prefix=NONALLOC
39
40# RUN: echo "SECTIONS { .bar 0x20000 (BAR) : { *(.foo) } };" > %t.script
41# RUN: not ld.lld -o /dev/null --script %t.script %t.o 2>&1 |\
42# RUN:   FileCheck %s --check-prefix=UNKNOWN
43# UNKNOWN: unknown section directive: BAR
44
45.section .foo,"a",@progbits
46.zero 1
47