summarylogtreecommitdiffstats
diff options
context:
space:
mode:
authorJon Gjengset2015-11-12 18:25:52 -0500
committerJon Gjengset2015-11-12 18:25:55 -0500
commitbcf35fa95e06f352deb9f6f051915b2a8b976022 (patch)
tree560cd00aef03a05fdfb4e729ea2d6a02d24adeb8
parent581ada35ce8cee418d6c093436f63a3a53924ea6 (diff)
downloadaur-bcf35fa95e06f352deb9f6f051915b2a8b976022.tar.gz
Fix package following JanusSGX rewrite
See sslab-gatech/opensgx@95a6d31da8825c10ba7776d2126904b3ca36a365
-rw-r--r--.SRCINFO10
-rw-r--r--PKGBUILD65
-rw-r--r--demo-include-sgx.patch13
-rw-r--r--opensgx-bin-paths.patch42
-rwxr-xr-xsgx-compile39
-rw-r--r--sgx-h-paths.patch143
6 files changed, 46 insertions, 266 deletions
diff --git a/.SRCINFO b/.SRCINFO
index c6c88bcfd064..a2a9dd0e0894 100644
--- a/.SRCINFO
+++ b/.SRCINFO
@@ -1,6 +1,6 @@
pkgbase = opensgx-git
pkgdesc = an open platform for Intel SGX
- pkgver = r43.57cf92c
+ pkgver = r47.40f48bf
pkgrel = 1
url = https://github.com/sslab-gatech/opensgx/
arch = x86_64
@@ -8,20 +8,16 @@ pkgbase = opensgx-git
makedepends = git
source = opensgx-git::git+https://github.com/sslab-gatech/opensgx.git
source = opensgx-bin-paths.patch
- source = demo-include-sgx.patch
source = opensgx-compile.patch
source = sgx-qemu-path.patch
- source = sgx-h-paths.patch
source = test-sh.patch
source = sgx-compile
md5sums = SKIP
- md5sums = 58999f0f6a15026bf3f1a6c853f4f723
- md5sums = 6284157d5a2a1ce6ab44ca3577ab9eb2
+ md5sums = 4caf85f42c36ff31994539ad64e9ec26
md5sums = e862b28b09581142af78369c6c65ce66
md5sums = 9ac0fa0ddae6d0e70f18992894bd1205
- md5sums = e65b4d1335c29babacaa0d5dbcbffe3a
md5sums = 48523504a8c9c6b4fc9175d143d87bf1
- md5sums = 2a5dd594a15d21ef549f3efe2b3ae406
+ md5sums = 1ff291421c523bacf735d1aa69a56661
pkgname = opensgx-git
diff --git a/PKGBUILD b/PKGBUILD
index 365221c4ed5e..2aee3375eeb5 100644
--- a/PKGBUILD
+++ b/PKGBUILD
@@ -1,6 +1,6 @@
# Maintainer: Jon Gjengset <jon@thesquareplanet.com>
pkgname=opensgx-git
-pkgver=r43.57cf92c
+pkgver=r47.40f48bf
pkgrel=1
pkgdesc="an open platform for Intel SGX"
arch=('x86_64')
@@ -13,21 +13,17 @@ install=
source=(
'opensgx-git::git+https://github.com/sslab-gatech/opensgx.git'
'opensgx-bin-paths.patch'
- 'demo-include-sgx.patch'
'opensgx-compile.patch'
'sgx-qemu-path.patch'
- 'sgx-h-paths.patch'
'test-sh.patch'
'sgx-compile'
)
md5sums=('SKIP'
- '58999f0f6a15026bf3f1a6c853f4f723'
- '6284157d5a2a1ce6ab44ca3577ab9eb2'
+ '4caf85f42c36ff31994539ad64e9ec26'
'e862b28b09581142af78369c6c65ce66'
'9ac0fa0ddae6d0e70f18992894bd1205'
- 'e65b4d1335c29babacaa0d5dbcbffe3a'
'48523504a8c9c6b4fc9175d143d87bf1'
- '2a5dd594a15d21ef549f3efe2b3ae406')
+ '1ff291421c523bacf735d1aa69a56661')
pkgver() {
cd "$srcdir/$pkgname"
@@ -43,50 +39,27 @@ prepare() {
msg2 "Fix binary paths in opensgx executable"
patch -Np1 -i '../opensgx-bin-paths.patch'
- msg2 "Fix sgx header paths"
- patch -Np1 -i '../sgx-h-paths.patch'
- test -d user/include/sgx || mkdir user/include/sgx
- mv user/include/*.h user/include/sgx
-
- test -L user/include/polarssl || mv user/include/polarssl user/include/sgx/
-
- cd user/include
- ln -sfn sgx/* ./
- test -L qemu || ln -sfn ../../../qemu/target-i386/ sgx/qemu
- cd ../../
-
msg2 "Make opensgx use sgx-compile"
patch -Np1 -i '../opensgx-compile.patch'
msg2 "Make test.sh use system sgx"
patch -Np1 -i '../test-sh.patch'
- msg2 "Make hello.c use <sgx.h>"
- patch -Np1 -i '../demo-include-sgx.patch'
-
msg2 "Configure QEMU"
- cd qemu
- ./configure-arch
+ cd qemu && ./configure-arch
}
build() {
cd "$srcdir/$pkgname"
msg2 "Build QEMU"
- cd qemu
- make
+ make -C qemu
- msg2 "Build PolarSSL"
- cd ../user/polarssl_sgx
- make
-
- cd ..
- msg2 "Make .os needed for .sgx compilation"
- make -dn demo/hello.sgx | grep 'Considering target file' | awk '{print $4}' | sed -e "s/'//g" -e 's/\.$//' | grep '\.o' | grep -v demo | xargs make
- make sgx.lds
+ msg2 "Build libsgx"
+ make -C libsgx
msg2 "Build userspace utilities"
- make
+ make -C user
}
package() {
@@ -95,27 +68,31 @@ package() {
# Binaries
install -d "$pkgdir/usr/bin"
install -m755 ./{sgx,sgx-dbg,opensgx} -t "$pkgdir/usr/bin/"
- install -m755 user/{sgx-tool,sgx-test-runtime,sgx-runtime} -t "$pkgdir/usr/bin/"
+ install -m755 user/{sgx-tool,sgx-runtime} -t "$pkgdir/usr/bin/"
install -Dm755 qemu/x86_64-linux-user/qemu-x86_64 "$pkgdir/usr/share/sgx/qemu"
install -m755 "$srcdir/sgx-compile" -t "$pkgdir/usr/bin/"
# Libraries
cd user
install -d "$pkgdir/usr/lib/sgx"
- all=$(make -dn demo/hello.sgx | grep 'Considering target file' | awk '{print $4}' | sed -e "s/'//g" -e 's/\.$//' | grep '\.o' | grep -v demo)
+ all=$(make -dn demo/hello.sgx | grep 'Considering target file' | awk '{print $4}' | sed -e "s/'//g" -e 's/\.$//' | grep '\.a' | grep -v demo)
for f in $all; do
- install -Dm644 "$f" -t "$pkgdir/usr/lib/sgx/$(dirname "$f")"
+ install -Dm644 "$f" "$pkgdir/usr/lib/sgx/$(basename "$f")"
done
cd ..
install -Dm644 "user/sgx.lds" "$pkgdir/usr/lib/sgx"
# Headers
- install -d "$pkgdir/usr/include/sgx/polarssl"
- install -d "$pkgdir/usr/include/sgx/qemu"
- install -m644 user/include/*.h -t "$pkgdir/usr/include/sgx"
- install -m644 user/include/polarssl/*.h -t "$pkgdir/usr/include/sgx/polarssl"
- install -m644 qemu/target-i386/*.h -t "$pkgdir/usr/include/sgx/qemu"
- mv "$pkgdir/usr/include/sgx/sgx-lib.h" "$pkgdir/usr/include/sgx.h"
+ install -d "$pkgdir/usr/include/sgx"
+ install -m644 libsgx/include/*.h -t "$pkgdir/usr/include/sgx"
+ install -m644 user/share/include/*.h -t "$pkgdir/usr/include/sgx"
+
+ # Fix header prefixes
+ for f in "$pkgdir/usr/include/sgx"/*.h; do
+ sed -i -e 's@#include <sgx-@#include <sgx/@g' "$f"
+ b="$(basename "$f")"
+ mv "$f" "$(dirname "$f")"/"${b#sgx-}"
+ done
}
# vim:set ts=2 sw=2 et:
diff --git a/demo-include-sgx.patch b/demo-include-sgx.patch
deleted file mode 100644
index 4dc7723094a1..000000000000
--- a/demo-include-sgx.patch
+++ /dev/null
@@ -1,13 +0,0 @@
-diff --git a/user/demo/hello.c b/user/demo/hello.c
-index 131c2e1..a47241c 100644
---- a/user/demo/hello.c
-+++ b/user/demo/hello.c
-@@ -19,7 +19,7 @@
-
- // hello world
-
--#include <sgx-lib.h>
-+#include <sgx.h>
-
- void enclave_main()
- {
diff --git a/opensgx-bin-paths.patch b/opensgx-bin-paths.patch
index 012be528b3c9..a01cad79a1cf 100644
--- a/opensgx-bin-paths.patch
+++ b/opensgx-bin-paths.patch
@@ -1,14 +1,13 @@
diff --git a/opensgx b/opensgx
-index b467c8b..1f617c3 100755
+index b90ff87..b28d02d 100755
--- a/opensgx
+++ b/opensgx
-@@ -1,14 +1,7 @@
+@@ -1,13 +1,7 @@
#! /bin/bash
-ROOT=$(dirname "$0")
-SGXTOOL=$ROOT/user/sgx-tool
-SGX=$ROOT/sgx
-DEVICEKEY=$ROOT/user/conf/device.key
--SGXTESTRUNTIME=$ROOT/user/sgx-test-runtime
-SGXRUNTIME=$ROOT/user/sgx-runtime
-
key_gen() {
@@ -18,34 +17,26 @@ index b467c8b..1f617c3 100755
}
compile_code() {
-@@ -48,7 +41,7 @@ run_enclave() {
- array=($entry)
- entry=${array[0]}
+@@ -21,15 +15,15 @@ compile_code() {
+ }
-- $SGX $SGXRUNTIME $1 $size $offset $code_start $code_end $data_start $data_end $entry $2
-+ sgx "$(which sgx-runtime)" $1 $size $offset $code_start $code_end $data_start $data_end $entry $2
+ run_enclave() {
+- $SGX $SGXRUNTIME $1 $2
++ sgx "$(which sgx-runtime)" $1 $2
}
run_enclave_with_icount() {
-@@ -78,7 +71,7 @@ run_enclave_with_icount() {
- array=($entry)
- entry=${array[0]}
-
-- $SGX -i $SGXRUNTIME $1 $size $offset $code_start $code_end $data_start $data_end $entry $2
-+ sgx -i "$(which sgx-runtime)" $1 $size $offset $code_start $code_end $data_start $data_end $entry $2
+- $SGX -i $SGXRUNTIME $1 $2
++ sgx -i "$(which sgx-runtime)" $1 $2
}
measure() {
-@@ -116,7 +109,7 @@ measure() {
- DE="--data_end="
- EN="--entry="
-
-- $SGXTOOL -m $1 $SZ$size $CO$offset $CS$code_start $CE$code_end $DS$data_start $DE$data_end $EN$entry
-+ sgx-tool -m $1 $SZ$size $CO$offset $CS$code_start $CE$code_end $DS$data_start $DE$data_end $EN$entry
+- $SGXTOOL -m $1
++ sgx-tool -m $1
}
sign() {
-@@ -131,10 +124,10 @@ sign() {
+@@ -44,10 +38,10 @@ sign() {
touch $CONF
measure $1 > $MEASURE
@@ -60,12 +51,3 @@ index b467c8b..1f617c3 100755
rm $MEASURE $SIG $TOKEN
}
-@@ -166,7 +159,7 @@ loading() {
- array=($entry)
- entry=${array[0]}
-
-- $SGX $SGXTESTRUNTIME $1 $size $offset $code_start $code_end $data_start $data_end $entry
-+ sgx "$(which sgx-test-runtime)" $1 $size $offset $code_start $code_end $data_start $data_end $entry
- }
-
- case "$1" in
diff --git a/sgx-compile b/sgx-compile
index 76c3f3d3850e..2d83389dcffe 100755
--- a/sgx-compile
+++ b/sgx-compile
@@ -1,21 +1,5 @@
#!/bin/bash
-loader=$(mktemp -p /tmp sgx-XXXXXXXX.lds)
-sed \
--e "/ENCT_START/,/ENCT_END/{ /ENCT_START/{p; i \\
- O_TEXT_SEGMENTS \\
- /usr/lib/sgx/polarssl_sgx/*.o(.text) \\
- /usr/lib/sgx/lib/*.o(.text) \\
- /usr/lib/sgx/*(.enc_text) \\
- /usr/lib/sgx/*Lib.o(.text)
-}; /ENCT_END/p; d }" \
--e "/ENCD_START/,/ENCD_END/{ /ENCD_START/{p; i \\
- O_DATA_SEGMENTS \\
- /usr/lib/sgx/polarssl_sgx/*.o(.data .data.rel.local .bss .rodata COMMON) \\
- /usr/lib/sgx/lib/*.o(.data .data.rel.local .bss .rodata COMMON) \\
- /usr/lib/sgx/*(.enc_data) \\
- /usr/lib/sgx/*Lib.o(.data .data.rel.local .bss .rodata COMMON)
-}; /ENCD_END/p; d }" /usr/lib/sgx/sgx.lds > "$loader"
-
+# SGX needs the .os to be present to continue
args=()
for a in "$@"; do
if [ ! -e "$a" ]; then
@@ -27,22 +11,19 @@ for a in "$@"; do
continue
fi
- # Compile all .cs into .os so they can be included in .enc_data/.enc_text
- cc -c -g -Wall -pedantic -Wno-unused-function -std=gnu1x -fno-stack-protector -fvisibility=hidden -o "${a%.c}.o" "$a"
+ # Compile all .cs into .os so they can be included by the LDS
+ cc -c -g -Wall -pedantic -Wno-unused-function -std=gnu11 -fno-stack-protector -fvisibility=hidden -o "${a%.c}.o" "$a"
end=$?
if [ $end -ne 0 ]; then
exit $end
fi
-
- sed -i \
- -e "/O_TEXT_SEGMENTS/i \\
- ${a%.c}.o(.text)" \
- -e "/O_DATA_SEGMENTS/i \\
- ${a%.c}.o(.data .data.rel.local .bss .rodata COMMON)" "$loader"
args=("${args[@]}" "${a%.c}.o")
done
-sed -i -e '/O_TEXT_SEGMENTS/d' -e '/O_DATA_SEGMENTS/d' "$loader"
-
-find /usr/lib/sgx/ -type f -iname '*.o' -print0 | xargs -0 cc -g -Wall -pedantic -Wno-unused-function -std=gnu1x -fno-stack-protector -fvisibility=hidden "-Wl,-T,$loader" "${args[@]}"
-rm "$loader"
+# Now link (with the .os in the current directory)
+find /usr/lib/sgx/ -type f -iname '*.a' -print0 \
+ | xargs -0 \
+ cc \
+ -g -Wall -pedantic -Wno-unused-function -std=gnu11 \
+ -fno-stack-protector -static -fPIC -fvisibility=hidden \
+ -static -nostdlib "-Wl,-T,/usr/lib/sgx/sgx.lds" "${args[@]}"
diff --git a/sgx-h-paths.patch b/sgx-h-paths.patch
deleted file mode 100644
index 119ec001ca90..000000000000
--- a/sgx-h-paths.patch
+++ /dev/null
@@ -1,143 +0,0 @@
-diff --git a/user/include/sgx-crypto.h b/user/include/sgx-crypto.h
-index 446a29e..b4244d8 100644
---- a/user/include/sgx-crypto.h
-+++ b/user/include/sgx-crypto.h
-@@ -19,7 +19,7 @@
-
- #pragma once
-
--#include <sgx.h>
-+#include <sgx/sgx.h>
-
- #define STRING_ECREATE 0x0045544145524345
- #define STRING_EADD 0x0000000044444145
-diff --git a/user/include/sgx-kern-epc.h b/user/include/sgx-kern-epc.h
-index 7f1abad..a5630c9 100644
---- a/user/include/sgx-kern-epc.h
-+++ b/user/include/sgx-kern-epc.h
-@@ -20,7 +20,7 @@
- #pragma once
-
- #define SGX_KERNEL
--#include <sgx.h>
-+#include <sgx/sgx.h>
-
- #define EPC_ADDR 0x40008000
-
-diff --git a/user/include/sgx-kern.h b/user/include/sgx-kern.h
-index 78406b1..57d93eb 100644
---- a/user/include/sgx-kern.h
-+++ b/user/include/sgx-kern.h
-@@ -19,7 +19,7 @@
-
- #pragma once
-
--#include <sgx.h>
-+#include <sgx/sgx.h>
-
- typedef enum {
- MT_SECS,
-diff --git a/user/include/sgx-lib.h b/user/include/sgx-lib.h
-index 2b0a010..cd0a59e 100644
---- a/user/include/sgx-lib.h
-+++ b/user/include/sgx-lib.h
-@@ -19,10 +19,10 @@
-
- #pragma once
-
--#include <sgx.h>
--#include <sgx-user.h>
--#include <sgx-kern.h>
--#include <sgx-trampoline.h>
-+#include <sgx/sgx.h>
-+#include <sgx/sgx-user.h>
-+#include <sgx/sgx-kern.h>
-+#include <sgx/sgx-trampoline.h>
- #include <stdarg.h>
-
- #include <netinet/in.h>
-diff --git a/user/include/sgx-signature.h b/user/include/sgx-signature.h
-index 884b26a..29c2be5 100644
---- a/user/include/sgx-signature.h
-+++ b/user/include/sgx-signature.h
-@@ -19,7 +19,7 @@
-
- #pragma once
-
--#include <sgx.h>
-+#include <sgx/sgx.h>
-
- #define STRING_ECREATE 0x0045544145524345
- #define STRING_EADD 0x0000000044444145
-diff --git a/user/include/sgx-trampoline.h b/user/include/sgx-trampoline.h
-index 5149fdc..45a39f6 100644
---- a/user/include/sgx-trampoline.h
-+++ b/user/include/sgx-trampoline.h
-@@ -24,7 +24,7 @@
- #include <inttypes.h>
- #include <err.h>
- #include <assert.h>
--#include <sgx.h>
-+#include <sgx/sgx.h>
- #include <sys/socket.h>
-
- //about a page
-diff --git a/user/include/sgx-user.h b/user/include/sgx-user.h
-index 7033ec1..ee32b1c 100644
---- a/user/include/sgx-user.h
-+++ b/user/include/sgx-user.h
-@@ -19,7 +19,7 @@
-
- #pragma once
-
--#include <sgx.h>
-+#include <sgx/sgx.h>
-
- int cur_keid;
-
-diff --git a/user/include/sgx-utils.h b/user/include/sgx-utils.h
-index 2b6f28c..1f217b2 100644
---- a/user/include/sgx-utils.h
-+++ b/user/include/sgx-utils.h
-@@ -19,7 +19,7 @@
-
- #pragma once
-
--#include <sgx.h>
-+#include <sgx/sgx.h>
-
- //#define NUM_BYTES 8
- //#define ENCLAVE_OFFSET 0x20004000
-diff --git a/user/include/sgx.h b/user/include/sgx.h
-index 1a5094c..582a8a1 100644
---- a/user/include/sgx.h
-+++ b/user/include/sgx.h
-@@ -24,19 +24,18 @@
- #include <stdint.h>
-
- // polarssl related headers
--#include <polarssl/ctr_drbg.h>
--#include <polarssl/entropy.h>
--#include <polarssl/rsa.h>
--#include <polarssl/sha1.h>
--#include <polarssl/sha256.h>
--#include <polarssl/aes_cmac128.h>
--#include <polarssl/dhm.h>
-+#include <sgx/polarssl/ctr_drbg.h>
-+#include <sgx/polarssl/entropy.h>
-+#include <sgx/polarssl/rsa.h>
-+#include <sgx/polarssl/sha1.h>
-+#include <sgx/polarssl/sha256.h>
-+#include <sgx/polarssl/aes_cmac128.h>
-+#include <sgx/polarssl/dhm.h>
-
- #define OPENSGX_ABI_VERSION 1
- #define SGX_USERLIB
--#include "../../qemu/target-i386/sgx.h"
--
--#include "../../qemu/target-i386/crypto.h"
-+#include <sgx/qemu/sgx.h>
-+#include <sgx/qemu/crypto.h>
-
- typedef struct {
- uint32_t oeax;