]> git.lizzy.rs Git - rust.git/commitdiff
Add an option to disable the use of the redzone
authorJohn Kåre Alsaker <john.kare.alsaker@gmail.com>
Wed, 16 Jul 2014 11:35:50 +0000 (13:35 +0200)
committerJohn Kåre Alsaker <john.kare.alsaker@gmail.com>
Wed, 16 Jul 2014 11:35:50 +0000 (13:35 +0200)
Disabling the redzone is required in x86-64's kernel mode to avoid interrupts trashing the stack.

src/librustc/driver/config.rs
src/librustc/middle/trans/base.rs

index 345877d9ab6c47beea8f81694eeccb00af7c462b..3a59c2bbcc350b09a59709b6f6f4d2956c802431 100644 (file)
@@ -332,6 +332,8 @@ fn parse_list(slot: &mut Vec<String>, v: Option<&str>)
         "prefer dynamic linking to static linking"),
     no_integrated_as: bool = (false, parse_bool,
         "use an external assembler rather than LLVM's integrated one"),
+    no_redzone: bool = (false, parse_bool,
+        "disable the use of the redzone"),
     relocation_model: String = ("pic".to_string(), parse_string,
          "choose the relocation model to use (llc -relocation-model for details)"),
     metadata: Vec<String> = (Vec::new(), parse_list,
index 6bcc9b9b745b7f5e438842de8b7bbcb9774c4a6e..3ca188cf2813afbdcae39d8e35cda3dd7aa235a7 100644 (file)
@@ -193,6 +193,14 @@ fn decl_fn(ccx: &CrateContext, name: &str, cc: llvm::CallConv,
         _ => {}
     }
 
+    if ccx.tcx.sess.opts.cg.no_redzone {
+        unsafe {
+            llvm::LLVMAddFunctionAttribute(llfn,
+                                           llvm::FunctionIndex as c_uint,
+                                           llvm::NoRedZoneAttribute as uint64_t)
+        }
+    }
+
     llvm::SetFunctionCallConv(llfn, cc);
     // Function addresses in Rust are never significant, allowing functions to be merged.
     llvm::SetUnnamedAddr(llfn, true);