naked functions: on windows emit .endef
without the symbol name · rust-lang/rust@c0957ef (original) (raw)
1
1
`//@ add-core-stubs
`
2
``
`-
//@ revisions: linux win macos thumb
`
``
2
`+
//@ revisions: linux win_x86 win_i686 macos thumb
`
3
3
`//
`
4
4
`//@[linux] compile-flags: --target x86_64-unknown-linux-gnu
`
5
5
`//@[linux] needs-llvm-components: x86
`
6
``
`-
//@[win] compile-flags: --target x86_64-pc-windows-gnu
`
7
``
`-
//@[win] needs-llvm-components: x86
`
``
6
`+
//@[win_x86] compile-flags: --target x86_64-pc-windows-gnu
`
``
7
`+
//@[win_x86] needs-llvm-components: x86
`
``
8
`+
//@[win_i686] compile-flags: --target i686-pc-windows-gnu
`
``
9
`+
//@[win_i686] needs-llvm-components: x86
`
8
10
`//@[macos] compile-flags: --target aarch64-apple-darwin
`
9
11
`//@[macos] needs-llvm-components: arm
`
10
12
`//@[thumb] compile-flags: --target thumbv7em-none-eabi
`
`@@ -19,10 +21,11 @@ use minicore::*;
`
19
21
``
20
22
`// linux,win: .intel_syntax
`
21
23
`//
`
22
``
`-
// linux: .pushsection .text.naked_empty,\22ax\22, @progbits
`
23
``
`-
// macos: .pushsection __TEXT,__text,regular,pure_instructions
`
24
``
`-
// win: .pushsection .text.naked_empty,\22xr\22
`
25
``
`-
// thumb: .pushsection .text.naked_empty,\22ax\22, %progbits
`
``
24
`+
// linux: .pushsection .text.naked_empty,\22ax\22, @progbits
`
``
25
`+
// macos: .pushsection __TEXT,__text,regular,pure_instructions
`
``
26
`+
// win_x86: .pushsection .text.naked_empty,\22xr\22
`
``
27
`+
// win_i686: .pushsection .text._naked_empty,\22xr\22
`
``
28
`+
// thumb: .pushsection .text.naked_empty,\22ax\22, %progbits
`
26
29
`//
`
27
30
`// CHECK: .balign 4
`
28
31
`//
`
`@@ -34,10 +37,12 @@ use minicore::*;
`
34
37
`//
`
35
38
`// linux: .type naked_empty, @function
`
36
39
`//
`
37
``
`-
// win: .def naked_empty
`
38
``
`-
// win: .scl 2
`
39
``
`-
// win: .type 32
`
40
``
`-
// win: .endef naked_empty
`
``
40
`+
// win_x86: .def naked_empty
`
``
41
`+
// win_i686: .def _naked_empty
`
``
42
`+
//
`
``
43
`+
// win_x86,win_i686: .scl 2
`
``
44
`+
// win_x86,win_i686: .type 32
`
``
45
`+
// win_x86,win_i686: .endef
`
41
46
`//
`
42
47
`// thumb: .type naked_empty, %function
`
43
48
`// thumb: .thumb
`
`@@ -66,10 +71,11 @@ pub unsafe extern "C" fn naked_empty() {
`
66
71
``
67
72
`// linux,win: .intel_syntax
`
68
73
`//
`
69
``
`-
// linux: .pushsection .text.naked_with_args_and_return,\22ax\22, @progbits
`
70
``
`-
// macos: .pushsection __TEXT,__text,regular,pure_instructions
`
71
``
`-
// win: .pushsection .text.naked_with_args_and_return,\22xr\22
`
72
``
`-
// thumb: .pushsection .text.naked_with_args_and_return,\22ax\22, %progbits
`
``
74
`+
// linux: .pushsection .text.naked_with_args_and_return,\22ax\22, @progbits
`
``
75
`+
// macos: .pushsection __TEXT,__text,regular,pure_instructions
`
``
76
`+
// win_x86: .pushsection .text.naked_with_args_and_return,\22xr\22
`
``
77
`+
// win_i686: .pushsection .text._naked_with_args_and_return,\22xr\22
`
``
78
`+
// thumb: .pushsection .text.naked_with_args_and_return,\22ax\22, %progbits
`
73
79
`//
`
74
80
`// CHECK: .balign 4
`
75
81
`//
`
`@@ -81,18 +87,20 @@ pub unsafe extern "C" fn naked_empty() {
`
81
87
`//
`
82
88
`// linux: .type naked_with_args_and_return, @function
`
83
89
`//
`
84
``
`-
// win: .def naked_with_args_and_return
`
85
``
`-
// win: .scl 2
`
86
``
`-
// win: .type 32
`
87
``
`-
// win: .endef naked_with_args_and_return
`
``
90
`+
// win_x86: .def naked_with_args_and_return
`
``
91
`+
// win_i686: .def _naked_with_args_and_return
`
``
92
`+
//
`
``
93
`+
// win_x86,win_i686: .scl 2
`
``
94
`+
// win_x86,win_i686: .type 32
`
``
95
`+
// win_x86,win_i686: .endef
`
88
96
`//
`
89
97
`// thumb: .type naked_with_args_and_return, %function
`
90
98
`// thumb: .thumb
`
91
99
`// thumb: .thumb_func
`
92
100
`//
`
93
101
`// CHECK-LABEL: naked_with_args_and_return:
`
94
102
`//
`
95
``
`-
// linux, win: lea rax, [rdi + rsi]
`
``
103
`+
// linux, win_x86,win_i686: lea rax, [rdi + rsi]
`
96
104
`// macos: add x0, x0, x1
`
97
105
`// thumb: adds r0, r0, r1
`
98
106
`//
`
`@@ -124,10 +132,10 @@ pub unsafe extern "C" fn naked_with_args_and_return(a: isize, b: isize) -> isize
`
124
132
`}
`
125
133
`}
`
126
134
``
127
``
`-
// linux: .pushsection .text.some_different_name,\22ax\22, @progbits
`
128
``
`-
// macos: .pushsection .text.some_different_name,regular,pure_instructions
`
129
``
`-
// win: .pushsection .text.some_different_name,\22xr\22
`
130
``
`-
// thumb: .pushsection .text.some_different_name,\22ax\22, %progbits
`
``
135
`+
// linux: .pushsection .text.some_different_name,\22ax\22, @progbits
`
``
136
`+
// macos: .pushsection .text.some_different_name,regular,pure_instructions
`
``
137
`+
// win_x86,win_i686: .pushsection .text.some_different_name,\22xr\22
`
``
138
`+
// thumb: .pushsection .text.some_different_name,\22ax\22, %progbits
`
131
139
`// CHECK-LABEL: test_link_section:
`
132
140
`#[no_mangle]
`
133
141
`#[naked]
`
`@@ -139,3 +147,19 @@ pub unsafe extern "C" fn test_link_section() {
`
139
147
`#[cfg(all(target_arch = "arm", target_feature = "thumb-mode"))]
`
140
148
`naked_asm!("bx lr");
`
141
149
`}
`
``
150
+
``
151
`+
// win_x86: .def fastcall_cc
`
``
152
`+
// win_i686: .def @fastcall_cc@4
`
``
153
`+
//
`
``
154
`+
// win_x86,win_i686: .scl 2
`
``
155
`+
// win_x86,win_i686: .type 32
`
``
156
`+
// win_x86,win_i686: .endef
`
``
157
`+
//
`
``
158
`+
// win_x86-LABEL: fastcall_cc:
`
``
159
`+
// win_i686-LABEL: @fastcall_cc@4:
`
``
160
`+
#[cfg(target_os = "windows")]
`
``
161
`+
#[no_mangle]
`
``
162
`+
#[naked]
`
``
163
`+
pub unsafe extern "fastcall" fn fastcall_cc(x: i32) -> i32 {
`
``
164
`+
naked_asm!("ret");
`
``
165
`+
}
`