1
1
# REQUIRES: aarch64
2
+ ## Test the Guarded Control Stack (GCS) feature.
3
+ ## Naming convention: *-s.s files enable GCS.
2
4
# 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
5
+ # RUN: llvm-mc -filetype=obj -triple=aarch64 f1-s .s -o f1-s .o
6
+ # RUN: llvm-mc -filetype=obj -triple=aarch64 f2 .s -o f2 .o
7
+ # RUN: llvm-mc -filetype=obj -triple=aarch64 f2-s .s -o f2-s .o
8
+ # RUN: llvm-mc -filetype=obj -triple=aarch64 f3 .s -o f3 .o
9
+ # RUN: llvm-mc -filetype=obj -triple=aarch64 f3-s .s -o f3-s .o
8
10
9
11
## GCS should be enabled when it's enabled in all inputs or when it's forced on.
10
12
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
13
+ # RUN: ld.lld f1-s.o f2-s.o f3-s.o -o out --fatal-warnings
14
+ # RUN: llvm-readelf -n out | FileCheck --check-prefix GCS %s
15
+ # RUN: ld.lld f1-s.o f2.o f3-s.o -o out.force -z gcs=always --fatal-warnings
16
+ # RUN: llvm-readelf -n out.force | FileCheck --check-prefix GCS %s
17
+ # RUN: ld.lld f2-s.o f3.o --shared -o out.force.so -z gcs=never -z gcs=always --fatal-warnings
18
+ # RUN: llvm-readelf -n out.force.so | FileCheck --check-prefix GCS %s
21
19
22
20
# GCS: Properties: aarch64 feature: GCS
23
21
24
22
## GCS should not be enabled if it's not enabled in at least one input.
25
23
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
24
+ # RUN: ld.lld f1-s .o f2 .o f3-s .o -o out.no --fatal-warnings
25
+ # RUN: llvm-readelf -n out.no | count 0
26
+ # RUN: ld.lld f2-s .o f3 .o --shared -o out.no .so
29
27
30
28
## GCS should be disabled with gcs=never, even if GCS is present in all inputs.
31
29
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
30
+ # RUN: ld.lld f1-s.o f2-s.o f3-s.o -z gcs=always -z gcs=never -o out.never --fatal-warnings
31
+ # RUN: llvm-readelf -n out.never | count 0
36
32
37
33
## gcs-report should report any input files that don't have the gcs property.
38
34
39
- # RUN: ld.lld func1-gcs.o func2.o func3-gcs.o -z gcs-report=warning 2>&1 | FileCheck --check-prefix=REPORT-WARN %s
40
- # RUN: ld.lld func1-gcs.o func2.o func3-gcs.o -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 -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 -z gcs-report=error 2>&1 | FileCheck --check-prefix=REPORT-ERROR %s
43
- # RUN: not ld.lld func2-gcs.o func3.o --shared -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 -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 -z gcs-report=warning 2>&1 | count 0
46
- # RUN: ld.lld func1-gcs.o func2-gcs.o func3-gcs.o -z gcs-report=warning -z gcs=always 2>&1 | count 0
47
- # RUN: ld.lld func1-gcs.o func2-gcs.o func3-gcs.o -z gcs-report=warning -z gcs=never 2>&1 | count 0
35
+ # RUN: ld.lld f1-s.o f2.o f3-s.o -z gcs-report=warning 2>&1 | FileCheck --check-prefix=REPORT-WARN %s
36
+ # RUN: ld.lld f1-s.o f2.o f3-s.o -z gcs-report=warning -z gcs=always 2>&1 | FileCheck --check-prefix=REPORT-WARN %s
37
+ # RUN: ld.lld f1-s.o f2.o f3-s.o -z gcs-report=warning -z gcs=never 2>&1 | FileCheck --check-prefix=REPORT-WARN %s
38
+ # RUN: not ld.lld f2-s.o f3.o --shared -z gcs-report=error 2>&1 | FileCheck --check-prefix=REPORT-ERROR %s
39
+ # RUN: ld.lld f1-s.o f2-s.o f3-s.o -z gcs-report=warning -z gcs=always 2>&1 | count 0
48
40
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
41
+ # REPORT-WARN: warning: f2.o: -z gcs-report: file does not have GNU_PROPERTY_AARCH64_FEATURE_1_GCS property
42
+ # REPORT-WARN-NOT: {{.}}
43
+ # REPORT-ERROR: error: f3.o: -z gcs-report: file does not have GNU_PROPERTY_AARCH64_FEATURE_1_GCS property
44
+ # REPORT-ERROR-NOT: {{.}}
51
45
52
46
## gcs-report-dynamic should report any dynamic objects that does not have the gcs property. This also ensures the inhertance from gcs-report is working correctly.
53
47
54
- # RUN: ld.lld func1-gcs.o func3-gcs.o no-gcs.so force-gcs.so -z gcs-report=warning -z gcs=always 2>&1 | FileCheck --check-prefix=REPORT-WARN-DYNAMIC %s
55
- # RUN: ld.lld func1-gcs.o func3-gcs.o no-gcs.so force-gcs.so -z gcs-report=error -z gcs=always 2>&1 | FileCheck --check-prefix=REPORT-WARN-DYNAMIC %s
56
- # RUN: ld.lld func1-gcs.o func3-gcs.o no-gcs.so force-gcs.so -z gcs-report-dynamic=warning -z gcs=always 2>&1 | FileCheck --check-prefix=REPORT-WARN-DYNAMIC %s
57
- # RUN: not ld.lld func1-gcs.o func3-gcs.o no-gcs.so force-gcs.so -z gcs-report-dynamic=error -z gcs=always 2>&1 | FileCheck --check-prefix=REPORT-ERROR-DYNAMIC %s
58
- # RUN: ld.lld func1-gcs.o func3-gcs.o force-gcs.so -z gcs-report-dynamic=warning -z gcs=always 2>&1 | count 0
59
- # RUN: ld.lld func1-gcs.o func3-gcs.o force-gcs.so -z gcs-report-dynamic=error -z gcs=always 2>&1 | count 0
48
+ # RUN: ld.lld f1-s.o f3-s.o out.no.so out.force.so -z gcs-report=warning -z gcs=always 2>&1 | FileCheck --check-prefix=REPORT-WARN-DYNAMIC %s
49
+ # RUN: ld.lld f1-s.o f3-s.o out.no.so out.force.so -z gcs-report=error -z gcs=always 2>&1 | FileCheck --check-prefix=REPORT-WARN-DYNAMIC %s
50
+ # RUN: ld.lld f1-s.o f3-s.o out.no.so out.force.so -z gcs-report-dynamic=warning -z gcs=always 2>&1 | FileCheck --check-prefix=REPORT-WARN-DYNAMIC %s
51
+ # RUN: not ld.lld f1-s.o f3-s.o out.no.so out.force.so -z gcs-report-dynamic=error -z gcs=always 2>&1 | FileCheck --check-prefix=REPORT-ERROR-DYNAMIC %s
52
+ # RUN: ld.lld f1-s.o f3-s.o out.force.so -z gcs-report-dynamic=error -z gcs=always 2>&1 | count 0
60
53
61
- # REPORT-WARN-DYNAMIC: warning: no-gcs .so: GCS is required by -z gcs, but this shared library lacks the necessary property note. The dynamic loader might not enable GCS or refuse to load the program unless all shared library dependencies have the GCS marking.
62
- # REPORT-WARN-DYNAMIC-NOT: warning:
63
- # REPORT-ERROR-DYNAMIC: error: no-gcs .so: GCS is required by -z gcs, but this shared library lacks the necessary property note. The dynamic loader might not enable GCS or refuse to load the program unless all shared library dependencies have the GCS marking.
54
+ # REPORT-WARN-DYNAMIC: warning: out.no .so: GCS is required by -z gcs, but this shared library lacks the necessary property note. The dynamic loader might not enable GCS or refuse to load the program unless all shared library dependencies have the GCS marking.
55
+ # REPORT-WARN-DYNAMIC-NOT: {{.}}
56
+ # REPORT-ERROR-DYNAMIC: error: out.no .so: GCS is required by -z gcs, but this shared library lacks the necessary property note. The dynamic loader might not enable GCS or refuse to load the program unless all shared library dependencies have the GCS marking.
64
57
# REPORT-ERROR-DYNAMIC-NOT: error:
65
58
66
59
## An invalid gcs option should give an error
67
- # RUN: not ld.lld func1-gcs .o func2-gcs.o func3-gcs.o - z gcs=nonsense -z gcs-report=nonsense -z gcs-report-dynamic=nonsense 2>&1 | FileCheck --check-prefix=INVALID %s
60
+ # RUN: not ld.lld f1-s .o - z gcs=x -z gcs-report=x -z gcs-report-dynamic=x 2>&1 | FileCheck --check-prefix=INVALID %s
68
61
69
- # INVALID: error: unknown -z gcs= value: nonsense
70
- # INVALID: error: unknown -z gcs-report= value: nonsense
71
- # INVALID: error: unknown -z gcs-report-dynamic= value: nonsense
62
+ # INVALID: error: unknown -z gcs= value: x
63
+ # INVALID: error: unknown -z gcs-report= value: x
64
+ # INVALID: error: unknown -z gcs-report-dynamic= value: x
72
65
73
- #--- func1-gcs .s
66
+ #--- f1-s .s
74
67
.section ".note.gnu.property" , "a"
75
68
.long 4
76
69
.long 0x10
84
77
85
78
.text
86
79
.globl _start
87
- .type func1 ,%function
88
- func1 :
89
- bl func2
80
+ .type f1 ,%function
81
+ f1 :
82
+ bl f2
90
83
ret
91
84
92
- #--- func2.s
93
-
85
+ #--- f2.s
94
86
.text
95
- .globl func2
96
- .type func2 ,@function
97
- func2 :
98
- .globl func3
99
- .type func3 , @function
100
- bl func3
87
+ .globl f2
88
+ .type f2 ,@function
89
+ f2 :
90
+ .globl f3
91
+ .type f3 , @function
92
+ bl f3
101
93
ret
102
94
103
- #--- func2-gcs.s
104
-
95
+ #--- f2-s.s
105
96
.section ".note.gnu.property" , "a"
106
97
.long 4
107
98
.long 0x10
@@ -114,24 +105,22 @@ func2:
114
105
.long 0
115
106
116
107
.text
117
- .globl func2
118
- .type func2 ,@function
119
- func2 :
120
- .globl func3
121
- .type func3 , @function
122
- bl func3
108
+ .globl f2
109
+ .type f2 ,@function
110
+ f2 :
111
+ .globl f3
112
+ .type f3 , @function
113
+ bl f3
123
114
ret
124
115
125
- #--- func3.s
126
-
116
+ #--- f3.s
127
117
.text
128
- .globl func3
129
- .type func3 ,@function
130
- func3 :
118
+ .globl f3
119
+ .type f3 ,@function
120
+ f3 :
131
121
ret
132
122
133
- #--- func3-gcs.s
134
-
123
+ #--- f3-s.s
135
124
.section ".note.gnu.property" , "a"
136
125
.long 4
137
126
.long 0x10
@@ -144,7 +133,7 @@ func3:
144
133
.long 0
145
134
146
135
.text
147
- .globl func3
148
- .type func3 ,@function
149
- func3 :
136
+ .globl f3
137
+ .type f3 ,@function
138
+ f3 :
150
139
ret
0 commit comments