message: Improved probestack
diff: //!
  //! [The Stack Clash]: https://blog.qualys.com/securitylabs/2017/06/19/the-stack-clash
  +
  +// A declaration for the stack probe function in Rust's standard library, for
  +// catching callstack overflow.
  cfg_if::cfg_if! {
  - if #[cfg(any(
  - target_arch="aarch64",
  - all(
  + if #[cfg(all(
  target_os = "windows",
  target_env = "msvc",
  target_pointer_width = "64"
  - )
  ))] {
  extern "C" {
  pub fn __chkstk();
  }
  - /// The probestack for Windows when compiled with MSVC.
  - /// Also for Aarch64 chipsets.
  - pub const PROBESTACK: unsafe extern "C" fn() = __chkstk;
  + const PROBESTACK: unsafe extern "C" fn() = __chkstk;
  } else if #[cfg(all(target_os = "windows", target_env = "gnu"))] {
  extern "C" {
  // ___chkstk (note the triple underscore) is implemented in compiler-builtins/src/x86_64.rs
  @@ -33,13 +31,18 @@ cfg_if::cfg_if! {
  #[cfg(all(target_os = "windows", target_env = "gnu"))]
  pub fn ___chkstk();
  }
  - /// The probestack for Windows when compiled with GNU
  - pub const PROBESTACK: unsafe extern "C" fn() = ___chkstk;
  + const PROBESTACK: unsafe extern "C" fn() = ___chkstk;
  + } else if #[cfg(not(any(target_arch = "x86_64", target_arch = "x86")))] {
  + // As per
  + // https://github.com/rust-lang/compiler-builtins/blob/cae3e6ea23739166504f9f9fb50ec070097979d4/src/probestack.rs#L39,
  + // LLVM only has stack-probe support on x86-64 and x86. Thus, on any other CPU
  + // architecture, we simply use an empty stack-probe function.
  + extern "C" fn empty_probestack() {}
  + const PROBESTACK: unsafe extern "C" fn() = empty_probestack;
  } else {
  extern "C" {
  pub fn __rust_probestack();
  }
  - /// The default Rust probestack
  - pub static PROBESTACK: unsafe extern "C" fn() = __rust_probestack;
  + static PROBESTACK: unsafe extern "C" fn() = __rust_probestack;
  }
  }
  