--- /dev/null
+CHECK: cc_plus_one_cxx
+CHECK: lfence
+CHECK: popq
+CHECK-NEXT: popq [[REGISTER:%[a-z]+]]
+CHECK-NEXT: lfence
+CHECK-NEXT: jmpq *[[REGISTER]]
--- /dev/null
+CHECK: cc_plus_one_cxx_asm
+CHECK: lfence
+CHECK: lfence
+CHECK: lfence
+CHECK: movl
+CHECK: lfence
+CHECK: lfence
+CHECK-NEXT: incl
+CHECK-NEXT: jmp 0x{{[[:xdigit:]]+}} <cc_plus_one_cxx_asm+0x{{[[:xdigit:]]+}}>
+CHECK-NEXT: shlq $0, (%rsp)
+CHECK-NEXT: lfence
+CHECK-NEXT: retq
+CHECK: popq
+CHECK-NEXT: popq [[REGISTER:%[a-z]+]]
+CHECK-NEXT: lfence
+CHECK-NEXT: jmpq *[[REGISTER]]
cc::Build::new()
.file("foo.c")
.compile("foo_c");
+
+ cc::Build::new()
+ .cpp(true)
+ .cpp_set_stdlib(None)
+ .file("foo_cxx.cpp")
+ .compile("foo_cxx");
}
--- /dev/null
+extern "C" int cc_plus_one_cxx(int *arg);
+extern "C" int cc_plus_one_cxx_asm(int *arg);
+
+int cc_plus_one_cxx(int *arg) {
+ return *arg + 1;
+}
+
+int cc_plus_one_cxx_asm(int *arg) {
+ int value = 0;
+
+ asm volatile ( " movl (%1), %0\n"
+ " inc %0\n"
+ " jmp 1f\n"
+ " retq\n" // never executed, but a shortcut to determine how the assembler deals with `ret` instructions
+ "1:\n"
+ : "=r"(value)
+ : "r"(arg) );
+
+ return value;
+}
extern {
fn cc_plus_one_c(arg : &u32) -> u32;
fn cc_plus_one_c_asm(arg : &u32) -> u32;
+ fn cc_plus_one_cxx(arg : &u32) -> u32;
+ fn cc_plus_one_cxx_asm(arg : &u32) -> u32;
}
fn main() {
unsafe{
println!("Answer to the Ultimate Question of Life, the Universe, and Everything: {}!", cc_plus_one_c(&value));
println!("Answer to the Ultimate Question of Life, the Universe, and Everything: {}!", cc_plus_one_c_asm(&value));
+ println!("Answer to the Ultimate Question of Life, the Universe, and Everything: {}!", cc_plus_one_cxx(&value));
+ println!("Answer to the Ultimate Question of Life, the Universe, and Everything: {}!", cc_plus_one_cxx_asm(&value));
}
}
cp -a $TEST_DIR/enclave .
pushd $CRATE
echo ${WORK_DIR}
+ hardening_flags="-mlvi-hardening -mllvm -x86-lvi-load-inline-asm"
# HACK(eddyb) sets `RUSTC_BOOTSTRAP=1` so Cargo can accept nightly features.
# These come from the top-level Rust workspace, that this crate is not a
# member of, but Cargo tries to load the workspace `Cargo.toml` anyway.
check "std::io::stdio::_print::h87f0c238421c45bc" print.checks
check cc_plus_one_c cc_plus_one_c.checks
check cc_plus_one_c_asm cc_plus_one_c_asm.checks
+check cc_plus_one_cxx cc_plus_one_cxx.checks
+check cc_plus_one_cxx_asm cc_plus_one_cxx_asm.checks