2020-11-03 22:55:49 +09:00
|
|
|
#!/bin/sh
|
2020-03-26 10:51:14 +01:00
|
|
|
set -exuo pipefail
|
|
|
|
|
|
|
|
function build {
|
|
|
|
CRATE=enclave
|
|
|
|
|
|
|
|
mkdir -p $WORK_DIR
|
|
|
|
pushd $WORK_DIR
|
|
|
|
rm -rf $CRATE
|
|
|
|
cp -a $TEST_DIR/enclave .
|
|
|
|
pushd $CRATE
|
|
|
|
echo ${WORK_DIR}
|
|
|
|
# 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.
|
2020-03-26 13:57:37 +01:00
|
|
|
env RUSTC_BOOTSTRAP=1
|
2020-03-26 10:51:14 +01:00
|
|
|
cargo -v run --target $TARGET
|
|
|
|
popd
|
|
|
|
popd
|
|
|
|
}
|
|
|
|
|
|
|
|
function check {
|
|
|
|
local func=$1
|
|
|
|
local checks="${TEST_DIR}/$2"
|
|
|
|
local asm=$(mktemp)
|
|
|
|
local objdump="${BUILD_DIR}/x86_64-unknown-linux-gnu/llvm/build/bin/llvm-objdump"
|
|
|
|
local filecheck="${BUILD_DIR}/x86_64-unknown-linux-gnu/llvm/build/bin/FileCheck"
|
2020-09-25 15:13:55 +02:00
|
|
|
|
|
|
|
${objdump} --disassemble-symbols=${func} --demangle \
|
|
|
|
${WORK_DIR}/enclave/target/x86_64-fortanix-unknown-sgx/debug/enclave > ${asm}
|
2020-03-26 10:51:14 +01:00
|
|
|
${filecheck} --input-file ${asm} ${checks}
|
|
|
|
}
|
|
|
|
|
|
|
|
build
|
|
|
|
|
2020-03-27 16:46:52 +01:00
|
|
|
check unw_getcontext unw_getcontext.checks
|
|
|
|
check "libunwind::Registers_x86_64::jumpto()" jumpto.checks
|
2020-03-26 10:51:14 +01:00
|
|
|
check "std::io::stdio::_print::h87f0c238421c45bc" print.checks
|
2020-09-25 15:13:55 +02:00
|
|
|
check rust_plus_one_global_asm rust_plus_one_global_asm.checks \
|
|
|
|
|| echo "warning: module level assembly currently not hardened"
|
2020-03-27 15:48:10 +01:00
|
|
|
|
2020-03-26 13:57:37 +01:00
|
|
|
check cc_plus_one_c cc_plus_one_c.checks
|
2020-03-26 15:05:43 +01:00
|
|
|
check cc_plus_one_c_asm cc_plus_one_c_asm.checks
|
2020-03-27 11:24:17 +01:00
|
|
|
check cc_plus_one_cxx cc_plus_one_cxx.checks
|
|
|
|
check cc_plus_one_cxx_asm cc_plus_one_cxx_asm.checks
|
2020-09-25 15:13:55 +02:00
|
|
|
check cc_plus_one_asm cc_plus_one_asm.checks \
|
|
|
|
|| echo "warning: the cc crate forwards assembly files to the CC compiler." \
|
2022-08-18 10:13:37 +08:00
|
|
|
"Clang uses its own integrated assembler, which does not include the LVI passes."
|
2020-03-27 14:19:07 +01:00
|
|
|
|
|
|
|
check cmake_plus_one_c cmake_plus_one_c.checks
|
|
|
|
check cmake_plus_one_c_asm cmake_plus_one_c_asm.checks
|
2020-09-25 15:13:55 +02:00
|
|
|
check cmake_plus_one_c_global_asm cmake_plus_one_c_global_asm.checks \
|
|
|
|
|| echo "warning: module level assembly currently not hardened"
|
2020-03-27 14:19:07 +01:00
|
|
|
check cmake_plus_one_cxx cmake_plus_one_cxx.checks
|
|
|
|
check cmake_plus_one_cxx_asm cmake_plus_one_cxx_asm.checks
|
2020-09-25 15:13:55 +02:00
|
|
|
check cmake_plus_one_cxx_global_asm cmake_plus_one_cxx_global_asm.checks \
|
|
|
|
|| echo "warning: module level assembly currently not hardened"
|
2020-03-27 15:48:10 +01:00
|
|
|
check cmake_plus_one_asm cmake_plus_one_asm.checks
|