Browse Source

Add shared_object to test/native (#56)

adombeck 5 years ago
parent
commit
68c994d450

+ 6 - 1
LibOS/shim/test/native/Makefile

@@ -1,4 +1,4 @@
-special_executables = static pie
+special_executables = static pie shared_object
 c_executables = $(filter-out $(special_executables),$(patsubst %.c,%,$(wildcard *.c)))
 cxx_executables = $(patsubst %.cpp,%,$(wildcard *.cpp))
 manifests = $(patsubst %.template,%,$(wildcard *.manifest.template)) manifest
@@ -27,6 +27,11 @@ static: %: %.c
 	@$(CC) $(CFLAGS) -o $@ -static $< \
 	$(shell echo $@ | sed 's/^[^\.]*//g' | sed 's/\./ -l/g')
 
+shared_object: %: %.c
+	@echo [ $@ ]
+	@$(CC) $(CFLAGS) -o $@ -fPIC -pie $< \
+	$(shell echo $@ | sed 's/^[^\.]*//g' | sed 's/\./ -l/g')
+
 pie: %: %.c
 	@echo [ $@ ]
 	@$(CC) $(CFLAGS) -fPIC --pie -o $@ $< \

+ 12 - 0
LibOS/shim/test/native/shared_object.c

@@ -0,0 +1,12 @@
+/* -*- mode:c; c-file-style:"k&r"; c-basic-offset: 4; tab-width:4; indent-tabs-mode:nil; mode:auto-fill; fill-column:78; -*- */
+/* vim: set ts=4 sw=4 et tw=78 fo=cqt wm=0: */
+
+/* a simple helloworld test */
+
+#include <stdio.h>
+
+int main()
+{
+    printf("Hello world\n");
+    return 0;
+}

+ 11 - 0
LibOS/shim/test/native/shared_object.manifest.template

@@ -0,0 +1,11 @@
+loader.preload = file:$(SHIMPATH)
+loader.env.LD_LIBRARY_PATH = /lib
+loader.debug_type = inline
+
+fs.mount.lib.type = chroot
+fs.mount.lib.path = /lib
+fs.mount.lib.uri = file:$(LIBCDIR)
+
+sgx.trusted_files.ld = file:$(LIBCDIR)/ld-linux-x86-64.so.2
+sgx.trusted_files.libc = file:$(LIBCDIR)/libc.so.6
+