Skip to content

Commit a5c010a

Browse files
committed
[WIP] Add control flow information to __rust_probestack
1 parent 0df0cf5 commit a5c010a

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

src/probestack.rs

+21-1
Original file line numberDiff line numberDiff line change
@@ -43,18 +43,32 @@
4343
4444
#![cfg(not(windows))] // Windows already has builtins to do this
4545

46+
extern "C" {
47+
pub fn __rust_probestack();
48+
}
49+
4650
#[naked]
4751
#[no_mangle]
4852
#[cfg(all(target_arch = "x86_64", not(feature = "mangled-names")))]
49-
pub unsafe extern "C" fn __rust_probestack() {
53+
pub unsafe extern "C" fn __rust_probestack_wrapper() {
5054
// Our goal here is to touch each page between %rsp+8 and %rsp+8-%rax,
5155
// ensuring that if any pages are unmapped we'll make a page fault.
5256
//
5357
// The ABI here is that the stack frame size is located in `%eax`. Upon
5458
// return we're not supposed to modify `%esp` or `%eax`.
5559
asm!("
60+
.cfi_endproc
61+
.pushsection .text.__rust_probestack
62+
.p2align 4,,15
63+
.globl __rust_probestack
64+
.type __rust_probestack, @function
65+
__rust_probestack:
66+
.cfi_startproc
5667
pushq %rbp
68+
.cfi_def_cfa_offset 16
69+
.cfi_offset rbp, -16
5770
movq %rsp, %rbp
71+
.cfi_def_cfa_register rbp
5872
5973
mov %rax,%r11 // duplicate %rax as we're clobbering %r11
6074
@@ -93,7 +107,13 @@ pub unsafe extern "C" fn __rust_probestack() {
93107
add %rax,%rsp
94108
95109
leave
110+
.cfi_def_cfa rsp, 8
96111
ret
112+
.cfi_endproc
113+
114+
.size __rust_probestack, . - __rust_probestack
115+
.popsection
116+
.cfi_startproc
97117
" ::: "memory" : "volatile");
98118
::core::intrinsics::unreachable();
99119
}

0 commit comments

Comments
 (0)