Skip to content

Commit 8428090

Browse files
committed
Fix run-make LVI tests
1 parent 2743dc6 commit 8428090

File tree

4 files changed

+38
-25
lines changed

4 files changed

+38
-25
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
CHECK: cc_plus_one_asm
22
CHECK-NEXT: movl
33
CHECK-NEXT: lfence
4-
CHECK-NEXT: inc
5-
CHECK-NEXT: notq (%rsp)
6-
CHECK-NEXT: notq (%rsp)
4+
CHECK-NEXT: incl
5+
CHECK-NEXT: shlq $0, (%rsp)
76
CHECK-NEXT: lfence
87
CHECK-NEXT: retq
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,24 @@
1-
CHECK: libunwind::Registers_x86_64::jumpto
1+
CHECK: __libunwind_Registers_x86_64_jumpto
22
CHECK: lfence
33
CHECK: lfence
44
CHECK: lfence
55
CHECK: lfence
6-
CHECK: shlq $0, (%rsp)
6+
CHECK: lfence
7+
CHECK: lfence
8+
CHECK: lfence
9+
CHECK: lfence
10+
CHECK: lfence
11+
CHECK: lfence
12+
CHECK: lfence
13+
CHECK: lfence
14+
CHECK: lfence
15+
CHECK: lfence
16+
CHECK: lfence
17+
CHECK: lfence
18+
CHECK: lfence
19+
CHECK: lfence
20+
CHECK-NEXT: popq [[REGISTER:%[a-z]+]]
21+
CHECK-NEXT: lfence
22+
CHECK-NEXT: popq [[REGISTER:%[a-z]+]]
723
CHECK-NEXT: lfence
8-
CHECK-NEXT: retq
24+
CHECK-NEXT: jmpq *[[REGISTER]]

tests/run-make/x86_64-fortanix-unknown-sgx-lvi/print.checks

-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,5 @@ CHECK: print
22
CHECK: lfence
33
CHECK: lfence
44
CHECK: lfence
5-
CHECK: popq
65
CHECK: callq 0x{{[[:xdigit:]]*}} <_Unwind_Resume>
76
CHECK-NEXT: ud2

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

+17-18
Original file line numberDiff line numberDiff line change
@@ -20,39 +20,38 @@ function build {
2020
}
2121

2222
function check {
23-
local func=$1
23+
local func_re="$1"
2424
local checks="${TEST_DIR}/$2"
2525
local asm=$(mktemp)
26-
local objdump="${BUILD_DIR}/x86_64-unknown-linux-gnu/llvm/build/bin/llvm-objdump"
27-
local filecheck="${BUILD_DIR}/x86_64-unknown-linux-gnu/llvm/build/bin/FileCheck"
28-
29-
${objdump} --disassemble-symbols=${func} --demangle \
30-
${WORK_DIR}/enclave/target/x86_64-fortanix-unknown-sgx/debug/enclave > ${asm}
26+
local objdump="${LLVM_BIN_DIR}/llvm-objdump"
27+
local filecheck="${LLVM_BIN_DIR}/FileCheck"
28+
local enclave=${WORK_DIR}/enclave/target/x86_64-fortanix-unknown-sgx/debug/enclave
29+
30+
func="$(${objdump} --syms --demangle ${enclave} | \
31+
grep --only-matching -E "[[:blank:]]+${func_re}\$" | \
32+
sed -e 's/^[[:space:]]*//' )"
33+
${objdump} --disassemble-symbols="${func}" --demangle \
34+
${enclave} > ${asm}
3135
${filecheck} --input-file ${asm} ${checks}
3236
}
3337

3438
build
3539

36-
check unw_getcontext unw_getcontext.checks
37-
check "libunwind::Registers_x86_64::jumpto()" jumpto.checks
38-
check "std::io::stdio::_print::h87f0c238421c45bc" print.checks
39-
check rust_plus_one_global_asm rust_plus_one_global_asm.checks \
40-
|| echo "warning: module level assembly currently not hardened"
40+
check "unw_getcontext" unw_getcontext.checks
41+
check "__libunwind_Registers_x86_64_jumpto" jumpto.checks
42+
check 'std::io::stdio::_print::[[:alnum:]]+' print.checks
43+
check rust_plus_one_global_asm rust_plus_one_global_asm.checks
4144

4245
check cc_plus_one_c cc_plus_one_c.checks
4346
check cc_plus_one_c_asm cc_plus_one_c_asm.checks
4447
check cc_plus_one_cxx cc_plus_one_cxx.checks
4548
check cc_plus_one_cxx_asm cc_plus_one_cxx_asm.checks
46-
check cc_plus_one_asm cc_plus_one_asm.checks \
47-
|| echo "warning: the cc crate forwards assembly files to the CC compiler." \
48-
"Clang uses its own integrated assembler, which does not include the LVI passes."
49+
check cc_plus_one_asm cc_plus_one_asm.checks
4950

5051
check cmake_plus_one_c cmake_plus_one_c.checks
5152
check cmake_plus_one_c_asm cmake_plus_one_c_asm.checks
52-
check cmake_plus_one_c_global_asm cmake_plus_one_c_global_asm.checks \
53-
|| echo "warning: module level assembly currently not hardened"
53+
check cmake_plus_one_c_global_asm cmake_plus_one_c_global_asm.checks
5454
check cmake_plus_one_cxx cmake_plus_one_cxx.checks
5555
check cmake_plus_one_cxx_asm cmake_plus_one_cxx_asm.checks
56-
check cmake_plus_one_cxx_global_asm cmake_plus_one_cxx_global_asm.checks \
57-
|| echo "warning: module level assembly currently not hardened"
56+
check cmake_plus_one_cxx_global_asm cmake_plus_one_cxx_global_asm.checks
5857
check cmake_plus_one_asm cmake_plus_one_asm.checks

0 commit comments

Comments
 (0)