Skip to content

Commit

Permalink
[WIP] Add control flow information to __rust_probestack
Browse files Browse the repository at this point in the history
  • Loading branch information
tmandry committed Dec 4, 2019
1 parent 0df0cf5 commit a5c010a
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion src/probestack.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,18 +43,32 @@
#![cfg(not(windows))] // Windows already has builtins to do this

extern "C" {
pub fn __rust_probestack();
}

#[naked]
#[no_mangle]
#[cfg(all(target_arch = "x86_64", not(feature = "mangled-names")))]
pub unsafe extern "C" fn __rust_probestack() {
pub unsafe extern "C" fn __rust_probestack_wrapper() {
// Our goal here is to touch each page between %rsp+8 and %rsp+8-%rax,
// ensuring that if any pages are unmapped we'll make a page fault.
//
// The ABI here is that the stack frame size is located in `%eax`. Upon
// return we're not supposed to modify `%esp` or `%eax`.
asm!("
.cfi_endproc
.pushsection .text.__rust_probestack
.p2align 4,,15
.globl __rust_probestack
.type __rust_probestack, @function
__rust_probestack:
.cfi_startproc
pushq %rbp
.cfi_def_cfa_offset 16
.cfi_offset rbp, -16
movq %rsp, %rbp
.cfi_def_cfa_register rbp
mov %rax,%r11 // duplicate %rax as we're clobbering %r11
Expand Down Expand Up @@ -93,7 +107,13 @@ pub unsafe extern "C" fn __rust_probestack() {
add %rax,%rsp
leave
.cfi_def_cfa rsp, 8
ret
.cfi_endproc
.size __rust_probestack, . - __rust_probestack
.popsection
.cfi_startproc
" ::: "memory" : "volatile");
::core::intrinsics::unreachable();
}
Expand Down

0 comments on commit a5c010a

Please sign in to comment.