summaryrefslogtreecommitdiffstats
path: root/tests/run-make/x86_64-fortanix-unknown-sgx-lvi/enclave/libcmake_foo
diff options
context:
space:
mode:
Diffstat (limited to 'tests/run-make/x86_64-fortanix-unknown-sgx-lvi/enclave/libcmake_foo')
-rw-r--r--tests/run-make/x86_64-fortanix-unknown-sgx-lvi/enclave/libcmake_foo/CMakeLists.txt33
-rw-r--r--tests/run-make/x86_64-fortanix-unknown-sgx-lvi/enclave/libcmake_foo/src/foo.c26
-rw-r--r--tests/run-make/x86_64-fortanix-unknown-sgx-lvi/enclave/libcmake_foo/src/foo_asm.s7
-rw-r--r--tests/run-make/x86_64-fortanix-unknown-sgx-lvi/enclave/libcmake_foo/src/foo_cxx.cpp29
4 files changed, 95 insertions, 0 deletions
diff --git a/tests/run-make/x86_64-fortanix-unknown-sgx-lvi/enclave/libcmake_foo/CMakeLists.txt b/tests/run-make/x86_64-fortanix-unknown-sgx-lvi/enclave/libcmake_foo/CMakeLists.txt
new file mode 100644
index 000000000..27cdf2ecf
--- /dev/null
+++ b/tests/run-make/x86_64-fortanix-unknown-sgx-lvi/enclave/libcmake_foo/CMakeLists.txt
@@ -0,0 +1,33 @@
+enable_language(C CXX ASM)
+
+set(C_SOURCES
+ src/foo.c
+ )
+
+set_source_files_properties(${C_SOURCES}
+ PROPERTIES
+ LANGUAGE C)
+
+set(CXX_SOURCES
+ src/foo_cxx.cpp
+ )
+
+set_source_files_properties(${CXX_SOURCES}
+ PROPERTIES
+ LANGUAGE CXX)
+
+set(ASM_SOURCES
+ src/foo_asm.s
+ )
+
+set_source_files_properties(${ASM_SOURCES}
+ PROPERTIES
+ LANGUAGE ASM)
+
+set(SOURCES
+ ${C_SOURCES}
+ ${CXX_SOURCES}
+ ${ASM_SOURCES})
+
+add_library(cmake_foo STATIC
+ ${SOURCES})
diff --git a/tests/run-make/x86_64-fortanix-unknown-sgx-lvi/enclave/libcmake_foo/src/foo.c b/tests/run-make/x86_64-fortanix-unknown-sgx-lvi/enclave/libcmake_foo/src/foo.c
new file mode 100644
index 000000000..c3b731a2d
--- /dev/null
+++ b/tests/run-make/x86_64-fortanix-unknown-sgx-lvi/enclave/libcmake_foo/src/foo.c
@@ -0,0 +1,26 @@
+int cmake_plus_one_c(int *arg) {
+ return *arg + 1;
+}
+
+int cmake_plus_one_c_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;
+}
+
+asm(".text\n"
+" .global cmake_plus_one_c_global_asm\n"
+" .type cmake_plus_one_c_global_asm, @function\n"
+"cmake_plus_one_c_global_asm:\n"
+" movl (%rdi), %eax\n"
+" inc %eax\n"
+" retq\n" );
diff --git a/tests/run-make/x86_64-fortanix-unknown-sgx-lvi/enclave/libcmake_foo/src/foo_asm.s b/tests/run-make/x86_64-fortanix-unknown-sgx-lvi/enclave/libcmake_foo/src/foo_asm.s
new file mode 100644
index 000000000..64b6b430e
--- /dev/null
+++ b/tests/run-make/x86_64-fortanix-unknown-sgx-lvi/enclave/libcmake_foo/src/foo_asm.s
@@ -0,0 +1,7 @@
+ .text
+ .global cmake_plus_one_asm
+ .type cmake_plus_one_asm, @function
+cmake_plus_one_asm:
+ movl (%rdi), %eax
+ inc %eax
+ retq
diff --git a/tests/run-make/x86_64-fortanix-unknown-sgx-lvi/enclave/libcmake_foo/src/foo_cxx.cpp b/tests/run-make/x86_64-fortanix-unknown-sgx-lvi/enclave/libcmake_foo/src/foo_cxx.cpp
new file mode 100644
index 000000000..824e2afeb
--- /dev/null
+++ b/tests/run-make/x86_64-fortanix-unknown-sgx-lvi/enclave/libcmake_foo/src/foo_cxx.cpp
@@ -0,0 +1,29 @@
+extern "C" int cmake_plus_one_cxx(int *arg);
+extern "C" int cmake_plus_one_cxx_asm(int *arg);
+
+int cmake_plus_one_cxx(int *arg) {
+ return *arg + 1;
+}
+
+int cmake_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;
+}
+
+asm(".text\n"
+" .global cmake_plus_one_cxx_global_asm\n"
+" .type cmake_plus_one_cxx_global_asm, @function\n"
+"cmake_plus_one_cxx_global_asm:\n"
+" movl (%rdi), %eax\n"
+" inc %eax\n"
+" retq\n" );