Skip to content

Commit 036b9e8

Browse files
committed
Add an option to disable the use of the redzone
Disabling the redzone is required in x86-64's kernel mode to avoid interrupts trashing the stack.
1 parent 1704ebb commit 036b9e8

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

src/librustc/driver/config.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -332,6 +332,8 @@ cgoptions!(
332332
"prefer dynamic linking to static linking"),
333333
no_integrated_as: bool = (false, parse_bool,
334334
"use an external assembler rather than LLVM's integrated one"),
335+
no_redzone: bool = (false, parse_bool,
336+
"disable the use of the redzone"),
335337
relocation_model: String = ("pic".to_string(), parse_string,
336338
"choose the relocation model to use (llc -relocation-model for details)"),
337339
metadata: Vec<String> = (Vec::new(), parse_list,

src/librustc/middle/trans/base.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,14 @@ fn decl_fn(ccx: &CrateContext, name: &str, cc: llvm::CallConv,
193193
_ => {}
194194
}
195195

196+
if ccx.tcx.sess.opts.cg.no_redzone {
197+
unsafe {
198+
llvm::LLVMAddFunctionAttribute(llfn,
199+
llvm::FunctionIndex as c_uint,
200+
llvm::NoRedZoneAttribute as uint64_t)
201+
}
202+
}
203+
196204
llvm::SetFunctionCallConv(llfn, cc);
197205
// Function addresses in Rust are never significant, allowing functions to be merged.
198206
llvm::SetUnnamedAddr(llfn, true);

0 commit comments

Comments
 (0)