From 68c994d450e36372e24fec2467fd8567c7d6f7cc Mon Sep 17 00:00:00 2001 From: adombeck Date: Sun, 27 May 2018 01:31:41 +0200 Subject: [PATCH] Add shared_object to test/native (#56) --- LibOS/shim/test/native/Makefile | 7 ++++++- LibOS/shim/test/native/shared_object.c | 12 ++++++++++++ .../shim/test/native/shared_object.manifest.template | 11 +++++++++++ 3 files changed, 29 insertions(+), 1 deletion(-) create mode 100644 LibOS/shim/test/native/shared_object.c create mode 100644 LibOS/shim/test/native/shared_object.manifest.template diff --git a/LibOS/shim/test/native/Makefile b/LibOS/shim/test/native/Makefile index e06c29aa..27fe5609 100644 --- a/LibOS/shim/test/native/Makefile +++ b/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 $@ $< \ diff --git a/LibOS/shim/test/native/shared_object.c b/LibOS/shim/test/native/shared_object.c new file mode 100644 index 00000000..31ef6829 --- /dev/null +++ b/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 + +int main() +{ + printf("Hello world\n"); + return 0; +} diff --git a/LibOS/shim/test/native/shared_object.manifest.template b/LibOS/shim/test/native/shared_object.manifest.template new file mode 100644 index 00000000..9f64d99c --- /dev/null +++ b/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 +