Skip to content

Commit 0928138

Browse files
committed
add note about why this function is unsafe
1 parent a548e1f commit 0928138

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

compiler-builtins/src/probestack.rs

+6
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@
5252
// Our goal here is to touch each page between %rsp+8 and %rsp+8-%rax,
5353
// ensuring that if any pages are unmapped we'll make a page fault.
5454
//
55+
// This function is unsafe because it uses a custom ABI, it does not actually match `extern "C"`.
56+
//
5557
// The ABI here is that the stack frame size is located in `%rax`. Upon
5658
// return we're not supposed to modify `%rsp` or `%rax`.
5759
#[cfg(target_arch = "x86_64")]
@@ -141,6 +143,8 @@ pub unsafe extern "C" fn __rust_probestack() {
141143
// that on Unix we're expected to restore everything as it was, this
142144
// function basically can't tamper with anything.
143145
//
146+
// This function is unsafe because it uses a custom ABI, it does not actually match `extern "C"`.
147+
//
144148
// The ABI here is the same as x86_64, except everything is 32-bits large.
145149
#[unsafe(naked)]
146150
#[no_mangle]
@@ -186,6 +190,8 @@ pub unsafe extern "C" fn __rust_probestack() {
186190
// probestack function will also do things like _chkstk in MSVC.
187191
// So we need to sub %ax %sp in probestack when arch is x86.
188192
//
193+
// This function is unsafe because it uses a custom ABI, it does not actually match `extern "C"`.
194+
//
189195
// REF: Rust commit(74e80468347)
190196
// rust\src\llvm-project\llvm\lib\Target\X86\X86FrameLowering.cpp: 805
191197
// Comments in LLVM:

0 commit comments

Comments
 (0)