Skip to content

Commit 7d3c3fd

Browse files
committed
cleaning up code
1 parent 8ca26cc commit 7d3c3fd

File tree

9 files changed

+35
-40
lines changed

9 files changed

+35
-40
lines changed

src/test/assembly/x86_64-fortanix-unknown-sgx-lvi-generic-load.rs

-1
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,3 @@ pub extern fn plus_one(r: &mut u64) {
1515
// CHECK: popq [[REGISTER:%[a-z]+]]
1616
// CHECK-NEXT: lfence
1717
// CHECK-NEXT: jmpq *[[REGISTER]]
18-

src/test/assembly/x86_64-fortanix-unknown-sgx-lvi-generic-ret.rs

-1
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,3 @@ pub extern fn myret() {}
1010
// CHECK: popq [[REGISTER:%[a-z]+]]
1111
// CHECK-NEXT: lfence
1212
// CHECK-NEXT: jmpq *[[REGISTER]]
13-

src/test/assembly/x86_64-fortanix-unknown-sgx-lvi-module-level-assembly.rs

-12
This file was deleted.

src/test/run-make/x86_64-fortanix-unknown-sgx-lvi/enclave/foo.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
int cc_plus_one_c(int *arg) {
32
return *arg + 1;
43
}
@@ -9,7 +8,8 @@ int cc_plus_one_c_asm(int *arg) {
98
asm volatile ( " movl (%1), %0\n"
109
" inc %0\n"
1110
" jmp 1f\n"
12-
" retq\n" // never executed, but a shortcut to determine how the assembler deals with `ret` instructions
11+
" retq\n" // never executed, but a shortcut to determine how
12+
// the assembler deals with `ret` instructions
1313
"1:\n"
1414
: "=r"(value)
1515
: "r"(arg) );

src/test/run-make/x86_64-fortanix-unknown-sgx-lvi/enclave/foo_cxx.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ int cc_plus_one_cxx_asm(int *arg) {
1111
asm volatile ( " movl (%1), %0\n"
1212
" inc %0\n"
1313
" jmp 1f\n"
14-
" retq\n" // never executed, but a shortcut to determine how the assembler deals with `ret` instructions
14+
" retq\n" // never executed, but a shortcut to determine how
15+
// the assembler deals with `ret` instructions
1516
"1:\n"
1617
: "=r"(value)
1718
: "r"(arg) );

src/test/run-make/x86_64-fortanix-unknown-sgx-lvi/enclave/libcmake_foo/src/foo.c

+2-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ int cmake_plus_one_c_asm(int *arg) {
88
asm volatile ( " movl (%1), %0\n"
99
" inc %0\n"
1010
" jmp 1f\n"
11-
" retq\n" // never executed, but a shortcut to determine how the assembler deals with `ret` instructions
11+
" retq\n" // never executed, but a shortcut to determine how
12+
// the assembler deals with `ret` instructions
1213
"1:\n"
1314
: "=r"(value)
1415
: "r"(arg) );

src/test/run-make/x86_64-fortanix-unknown-sgx-lvi/enclave/libcmake_foo/src/foo_cxx.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ int cmake_plus_one_cxx_asm(int *arg) {
1111
asm volatile ( " movl (%1), %0\n"
1212
" inc %0\n"
1313
" jmp 1f\n"
14-
" retq\n" // never executed, but a shortcut to determine how the assembler deals with `ret` instructions
14+
" retq\n" // never executed, but a shortcut to determine how
15+
// the assembler deals with `ret` instructions
1516
"1:\n"
1617
: "=r"(value)
1718
: "r"(arg) );

src/test/run-make/x86_64-fortanix-unknown-sgx-lvi/enclave/src/main.rs

+15-14
Original file line numberDiff line numberDiff line change
@@ -28,20 +28,21 @@ extern {
2828

2929
fn main() {
3030
let value : u32 = 41;
31-
31+
let question = "Answer to the Ultimate Question of Life, the Universe, and Everything:";
32+
3233
unsafe{
33-
println!("Answer to the Ultimate Question of Life, the Universe, and Everything: {}!", rust_plus_one_global_asm(&value));
34-
println!("Answer to the Ultimate Question of Life, the Universe, and Everything: {}!", cc_plus_one_c(&value));
35-
println!("Answer to the Ultimate Question of Life, the Universe, and Everything: {}!", cc_plus_one_c_asm(&value));
36-
println!("Answer to the Ultimate Question of Life, the Universe, and Everything: {}!", cc_plus_one_cxx(&value));
37-
println!("Answer to the Ultimate Question of Life, the Universe, and Everything: {}!", cc_plus_one_cxx_asm(&value));
38-
println!("Answer to the Ultimate Question of Life, the Universe, and Everything: {}!", cc_plus_one_asm(&value));
39-
println!("Answer to the Ultimate Question of Life, the Universe, and Everything: {}!", cmake_plus_one_c(&value));
40-
println!("Answer to the Ultimate Question of Life, the Universe, and Everything: {}!", cmake_plus_one_c_asm(&value));
41-
println!("Answer to the Ultimate Question of Life, the Universe, and Everything: {}!", cmake_plus_one_cxx(&value));
42-
println!("Answer to the Ultimate Question of Life, the Universe, and Everything: {}!", cmake_plus_one_cxx_asm(&value));
43-
println!("Answer to the Ultimate Question of Life, the Universe, and Everything: {}!", cmake_plus_one_c_global_asm(&value));
44-
println!("Answer to the Ultimate Question of Life, the Universe, and Everything: {}!", cmake_plus_one_cxx_global_asm(&value));
45-
println!("Answer to the Ultimate Question of Life, the Universe, and Everything: {}!", cmake_plus_one_asm(&value));
34+
println!("{}: {}!", question,rust_plus_one_global_asm(&value));
35+
println!("{}: {}!", question,cc_plus_one_c(&value));
36+
println!("{}: {}!", question,cc_plus_one_c_asm(&value));
37+
println!("{}: {}!", question,cc_plus_one_cxx(&value));
38+
println!("{}: {}!", question,cc_plus_one_cxx_asm(&value));
39+
println!("{}: {}!", question,cc_plus_one_asm(&value));
40+
println!("{}: {}!", question,cmake_plus_one_c(&value));
41+
println!("{}: {}!", question,cmake_plus_one_c_asm(&value));
42+
println!("{}: {}!", question,cmake_plus_one_cxx(&value));
43+
println!("{}: {}!", question,cmake_plus_one_cxx_asm(&value));
44+
println!("{}: {}!", question,cmake_plus_one_c_global_asm(&value));
45+
println!("{}: {}!", question,cmake_plus_one_cxx_global_asm(&value));
46+
println!("{}: {}!", question,cmake_plus_one_asm(&value));
4647
}
4748
}

src/test/run-make/x86_64-fortanix-unknown-sgx-lvi/script.sh

+12-7
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,9 @@ function check {
2424
local asm=$(mktemp)
2525
local objdump="${BUILD_DIR}/x86_64-unknown-linux-gnu/llvm/build/bin/llvm-objdump"
2626
local filecheck="${BUILD_DIR}/x86_64-unknown-linux-gnu/llvm/build/bin/FileCheck"
27-
28-
${objdump} --disassemble-symbols=${func} --demangle ${WORK_DIR}/enclave/target/x86_64-fortanix-unknown-sgx/debug/enclave > ${asm}
27+
28+
${objdump} --disassemble-symbols=${func} --demangle \
29+
${WORK_DIR}/enclave/target/x86_64-fortanix-unknown-sgx/debug/enclave > ${asm}
2930
${filecheck} --input-file ${asm} ${checks}
3031
}
3132

@@ -34,19 +35,23 @@ build
3435
check unw_getcontext unw_getcontext.checks
3536
check "libunwind::Registers_x86_64::jumpto()" jumpto.checks
3637
check "std::io::stdio::_print::h87f0c238421c45bc" print.checks
37-
check rust_plus_one_global_asm rust_plus_one_global_asm.checks || echo "warning: module level assembly currently not hardened"
38+
check rust_plus_one_global_asm rust_plus_one_global_asm.checks \
39+
|| echo "warning: module level assembly currently not hardened"
3840

3941
check cc_plus_one_c cc_plus_one_c.checks
4042
check cc_plus_one_c_asm cc_plus_one_c_asm.checks
4143
check cc_plus_one_cxx cc_plus_one_cxx.checks
4244
check cc_plus_one_cxx_asm cc_plus_one_cxx_asm.checks
43-
check cc_plus_one_asm cc_plus_one_asm.checks || echo "warning: the cc crate forwards assembly files to the CC compiler.\
44-
Clang uses its own intergrated assembler, which does not include the LVI passes."
45+
check cc_plus_one_asm cc_plus_one_asm.checks \
46+
|| echo "warning: the cc crate forwards assembly files to the CC compiler." \
47+
"Clang uses its own intergrated assembler, which does not include the LVI passes."
4548

4649
check cmake_plus_one_c cmake_plus_one_c.checks
4750
check cmake_plus_one_c_asm cmake_plus_one_c_asm.checks
48-
check cmake_plus_one_c_global_asm cmake_plus_one_c_global_asm.checks || echo "warning: module level assembly currently not hardened"
51+
check cmake_plus_one_c_global_asm cmake_plus_one_c_global_asm.checks \
52+
|| echo "warning: module level assembly currently not hardened"
4953
check cmake_plus_one_cxx cmake_plus_one_cxx.checks
5054
check cmake_plus_one_cxx_asm cmake_plus_one_cxx_asm.checks
51-
check cmake_plus_one_cxx_global_asm cmake_plus_one_cxx_global_asm.checks || echo "warning: module level assembly currently not hardened"
55+
check cmake_plus_one_cxx_global_asm cmake_plus_one_cxx_global_asm.checks \
56+
|| echo "warning: module level assembly currently not hardened"
5257
check cmake_plus_one_asm cmake_plus_one_asm.checks

0 commit comments

Comments
 (0)