xref: /llvm-project/lld/test/ELF/aarch64-feature-gcs.s (revision cfeb25cd7e92d5e854aa92034f18da2e5fa3e27a)
1# REQUIRES: aarch64
2# RUN: rm -rf %t && split-file %s %t && cd %t
3# RUN: llvm-mc -filetype=obj -triple=aarch64-linux-gnu func1-gcs.s -o func1-gcs.o
4# RUN: llvm-mc -filetype=obj -triple=aarch64-linux-gnu func2.s -o func2.o
5# RUN: llvm-mc -filetype=obj -triple=aarch64-linux-gnu func2-gcs.s -o func2-gcs.o
6# RUN: llvm-mc -filetype=obj -triple=aarch64-linux-gnu func3.s -o func3.o
7# RUN: llvm-mc -filetype=obj -triple=aarch64-linux-gnu func3-gcs.s -o func3-gcs.o
8
9## GCS should be enabled when it's enabled in all inputs or when it's forced on.
10
11# RUN: ld.lld func1-gcs.o func2-gcs.o func3-gcs.o -o gcs
12# RUN: llvm-readelf -n gcs | FileCheck --check-prefix GCS %s
13# RUN: ld.lld func1-gcs.o func3-gcs.o --shared -o gcs.so
14# RUN: llvm-readelf -n gcs.so | FileCheck --check-prefix GCS %s
15# RUN: ld.lld func1-gcs.o func2.o func3-gcs.o -o force-gcs -z gcs=always
16# RUN: llvm-readelf -n force-gcs | FileCheck --check-prefix GCS %s
17# RUN: ld.lld func2-gcs.o func3.o --shared -o force-gcs.so -z gcs=always
18# RUN: llvm-readelf -n force-gcs.so | FileCheck --check-prefix GCS %s
19# RUN: ld.lld func2-gcs.o func3.o --shared -o force-gcs2.so -z gcs=never -z gcs=always
20# RUN: llvm-readelf -n force-gcs2.so | FileCheck --check-prefix GCS %s
21
22# GCS: Properties:    aarch64 feature: GCS
23
24## GCS should not be enabled if it's not enabled in at least one input.
25
26# RUN: ld.lld func1-gcs.o func2.o func3-gcs.o -o no-gcs
27# RUN: llvm-readelf -n no-gcs | count 0
28# RUN: ld.lld func2-gcs.o func3.o --shared -o no-gcs.so
29
30## GCS should be disabled with gcs=never, even if GCS is present in all inputs.
31
32# RUN: ld.lld func1-gcs.o func2-gcs.o func3-gcs.o -z gcs=never -o never-gcs
33# RUN: llvm-readelf -n never-gcs | count 0
34# RUN: ld.lld func1-gcs.o func2-gcs.o func3-gcs.o -z gcs=always -z gcs=never -o never-gcs2
35# RUN: llvm-readelf -n never-gcs2 | count 0
36
37## gcs-report should report any input files that don't have the gcs property.
38
39# RUN: ld.lld func1-gcs.o func2.o func3-gcs.o -o /dev/null -z gcs-report=warning 2>&1 | FileCheck --check-prefix=REPORT-WARN %s
40# RUN: ld.lld func1-gcs.o func2.o func3-gcs.o -o /dev/null -z gcs-report=warning -z gcs=always 2>&1 | FileCheck --check-prefix=REPORT-WARN %s
41# RUN: ld.lld func1-gcs.o func2.o func3-gcs.o -o /dev/null -z gcs-report=warning -z gcs=never 2>&1 | FileCheck --check-prefix=REPORT-WARN %s
42# RUN: not ld.lld func2-gcs.o func3.o --shared -o /dev/null -z gcs-report=error 2>&1 | FileCheck --check-prefix=REPORT-ERROR %s
43# RUN: not ld.lld func2-gcs.o func3.o --shared -o /dev/null -z gcs-report=error -z gcs=always 2>&1 | FileCheck --check-prefix=REPORT-ERROR %s
44# RUN: not ld.lld func2-gcs.o func3.o --shared -o /dev/null -z gcs-report=error -z gcs=never 2>&1 | FileCheck --check-prefix=REPORT-ERROR %s
45# RUN: ld.lld func1-gcs.o func2-gcs.o func3-gcs.o -o /dev/null -z gcs-report=warning 2>&1 | count 0
46# RUN: ld.lld func1-gcs.o func2-gcs.o func3-gcs.o -o /dev/null -z gcs-report=warning -z gcs=always 2>&1 | count 0
47# RUN: ld.lld func1-gcs.o func2-gcs.o func3-gcs.o -o /dev/null -z gcs-report=warning -z gcs=never 2>&1 | count 0
48
49# REPORT-WARN: warning: func2.o: -z gcs-report: file does not have GNU_PROPERTY_AARCH64_FEATURE_1_GCS property
50# REPORT-ERROR: error: func3.o: -z gcs-report: file does not have GNU_PROPERTY_AARCH64_FEATURE_1_GCS property
51
52## An invalid gcs option should give an error
53# RUN: not ld.lld func1-gcs.o func2-gcs.o func3-gcs.o -z gcs=nonsense 2>&1 | FileCheck --check-prefix=INVALID %s
54
55# INVALID: error: unknown -z gcs= value: nonsense
56
57#--- func1-gcs.s
58.section ".note.gnu.property", "a"
59.long 4
60.long 0x10
61.long 0x5
62.asciz "GNU"
63
64.long 0xc0000000 // GNU_PROPERTY_AARCH64_FEATURE_1_AND
65.long 4
66.long 4          // GNU_PROPERTY_AARCH64_FEATURE_1_GCS
67.long 0
68
69.text
70.globl _start
71.type func1,%function
72func1:
73  bl func2
74  ret
75
76#--- func2.s
77
78.text
79.globl func2
80.type func2,@function
81func2:
82  .globl func3
83  .type func3, @function
84  bl func3
85  ret
86
87#--- func2-gcs.s
88
89.section ".note.gnu.property", "a"
90.long 4
91.long 0x10
92.long 0x5
93.asciz "GNU"
94
95.long 0xc0000000 // GNU_PROPERTY_AARCH64_FEATURE_1_AND
96.long 4
97.long 4          // GNU_PROPERTY_AARCH64_FEATURE_1_GCS
98.long 0
99
100.text
101.globl func2
102.type func2,@function
103func2:
104  .globl func3
105  .type func3, @function
106  bl func3
107  ret
108
109#--- func3.s
110
111.text
112.globl func3
113.type func3,@function
114func3:
115  ret
116
117#--- func3-gcs.s
118
119.section ".note.gnu.property", "a"
120.long 4
121.long 0x10
122.long 0x5
123.asciz "GNU"
124
125.long 0xc0000000 // GNU_PROPERTY_AARCH64_FEATURE_1_AND
126.long 4
127.long 4          // GNU_PROPERTY_AARCH64_FEATURE_1_GCS
128.long 0
129
130.text
131.globl func3
132.type func3,@function
133func3:
134  ret
135