13
13
14
14
//@ only-x86_64-fortanix-unknown-sgx
15
15
16
- use run_make_support:: { cmd, cwd, llvm_filecheck, llvm_objdump, regex, set_current_dir, target} ;
16
+ use run_make_support:: {
17
+ cargo, cwd, llvm_filecheck, llvm_objdump, regex, run, set_current_dir, target,
18
+ } ;
17
19
18
20
fn main ( ) {
19
- let main_dir = cwd ( ) ;
20
- set_current_dir ( "enclave" ) ;
21
- // HACK(eddyb) sets `RUSTC_BOOTSTRAP=1` so Cargo can accept nightly features.
22
- // These come from the top-level Rust workspace, that this crate is not a
23
- // member of, but Cargo tries to load the workspace `Cargo.toml` anyway.
24
- cmd ( "cargo" )
25
- . env ( "RUSTC_BOOTSTRAP" , "1" )
26
- . arg ( "-v" )
27
- . arg ( "run" )
28
- . arg ( "--target" )
29
- . arg ( target ( ) )
30
- . run ( ) ;
31
- set_current_dir ( & main_dir) ;
32
- // Rust has various ways of adding code to a binary:
33
- // - Rust code
34
- // - Inline assembly
35
- // - Global assembly
36
- // - C/C++ code compiled as part of Rust crates
37
- // For those different kinds, we do have very small code examples that should be
38
- // mitigated in some way. Mostly we check that ret instructions should no longer be present.
21
+ cargo ( ) . arg ( "-v" ) . arg ( "run" ) . arg ( "--target" ) . arg ( target ( ) ) . current_dir ( "enclave" ) . run ( ) ;
22
+
23
+ // Check that normal rust code has the right mitigations.
39
24
check ( "unw_getcontext" , "unw_getcontext.checks" ) ;
40
25
check ( "__libunwind_Registers_x86_64_jumpto" , "jumpto.checks" ) ;
41
26
42
27
check ( "std::io::stdio::_print::[[:alnum:]]+" , "print.with_frame_pointers.checks" ) ;
43
28
29
+ // Check that rust global assembly has the right mitigations.
44
30
check ( "rust_plus_one_global_asm" , "rust_plus_one_global_asm.checks" ) ;
45
31
32
+ // Check that C code compiled using the `cc` crate has the right mitigations.
46
33
check ( "cc_plus_one_c" , "cc_plus_one_c.checks" ) ;
47
34
check ( "cc_plus_one_c_asm" , "cc_plus_one_c_asm.checks" ) ;
48
35
check ( "cc_plus_one_cxx" , "cc_plus_one_cxx.checks" ) ;
49
36
check ( "cc_plus_one_cxx_asm" , "cc_plus_one_cxx_asm.checks" ) ;
50
37
check ( "cc_plus_one_asm" , "cc_plus_one_asm.checks" ) ;
51
38
39
+ // Check that C++ code compiled using the `cc` crate has the right mitigations.
52
40
check ( "cmake_plus_one_c" , "cmake_plus_one_c.checks" ) ;
53
41
check ( "cmake_plus_one_c_asm" , "cmake_plus_one_c_asm.checks" ) ;
54
42
check ( "cmake_plus_one_c_global_asm" , "cmake_plus_one_c_global_asm.checks" ) ;
@@ -71,8 +59,7 @@ fn check(func_re: &str, mut checks: &str) {
71
59
. input ( "enclave/target/x86_64-fortanix-unknown-sgx/debug/enclave" )
72
60
. args ( & [ "--demangle" , & format ! ( "--disassemble-symbols={func}" ) ] )
73
61
. run ( )
74
- . stdout_utf8 ( ) ;
75
- let dump = dump. as_bytes ( ) ;
62
+ . stdout ( ) ;
76
63
77
64
// Unique case, must succeed at one of two possible tests.
78
65
// This is because frame pointers are optional, and them being enabled requires
0 commit comments