You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesatee.apache.org by di...@apache.org on 2019/11/12 16:45:06 UTC

[mesatee-sgx] branch v1.1.0-beta updated: Update on preview

This is an automated email from the ASF dual-hosted git repository.

dingyu pushed a commit to branch v1.1.0-beta
in repository https://gitbox.apache.org/repos/asf/mesatee-sgx.git


The following commit(s) were added to refs/heads/v1.1.0-beta by this push:
     new 182dfcd  Update on preview
182dfcd is described below

commit 182dfcde363190e25f659e9440c812cb9fe2fc80
Author: Yu Ding <di...@gmail.com>
AuthorDate: Tue Nov 12 08:44:53 2019 -0800

    Update on preview
---
 common/inc/assert.h                                |   4 +-
 common/inc/complex.h                               |  14 +-
 common/inc/ctype.h                                 |   2 +-
 common/inc/dirent.h                                |  10 +-
 common/inc/endian.h                                |   2 +-
 common/inc/errno.h                                 |   6 +-
 common/inc/float.h                                 |   4 +-
 common/inc/iso646.h                                |   4 +-
 common/inc/limits.h                                |   6 +-
 common/inc/math.h                                  |   2 +-
 common/inc/mbusafecrt.h                            |   2 +-
 common/inc/netdb.h                                 |  37 ++
 common/inc/poll.h                                  |   6 +-
 common/inc/pthread.h                               |  12 +-
 common/inc/pwd.h                                   |  18 +-
 common/inc/setjmp.h                                |   4 +-
 common/inc/stdarg.h                                |   6 +-
 common/inc/stdbool.h                               |   2 +-
 common/inc/stddef.h                                |   6 +-
 common/inc/stdint.h                                |   4 +-
 common/inc/stdio.h                                 |   6 +-
 common/inc/stdlib.h                                |   6 +-
 common/inc/string.h                                |   6 +-
 common/inc/sys/_types.h                            |  40 +-
 common/inc/sys/cdefs.h                             |  14 +-
 common/inc/sys/endian.h                            |   2 +-
 common/inc/sys/epoll.h                             |  16 +-
 common/inc/sys/ieee.h                              |  20 +-
 common/inc/sys/sockaddr.h                          |   6 +-
 common/inc/sys/socket.h                            |  20 +-
 common/inc/sys/stat.h                              | 184 +++----
 common/inc/sys/stdint.h                            |   2 +-
 common/inc/sys/struct_timespec.h                   |   4 +-
 common/inc/sys/types.h                             |   6 +-
 common/inc/sys/uio.h                               |   4 +-
 common/inc/time.h                                  |   6 +-
 common/inc/unistd.h                                |   6 +-
 common/inc/wchar.h                                 |   4 +-
 common/inc/wctype.h                                |   6 +-
 dockerfile/Dockerfile.centos7.nightly              |   6 +-
 edl/sgx_net.edl                                    |   7 +-
 samplecode/backtrace/enclave/Xargo.toml            |  38 +-
 samplecode/crypto/enclave/Xargo.toml               |  38 +-
 samplecode/db-proxy/db-proxy/enclave/Xargo.toml    |  34 +-
 samplecode/file/enclave/Xargo.toml                 |  38 +-
 samplecode/hello-regex/enclave/Xargo.toml          |  38 +-
 .../hello-rust-vscode-debug/enclave/Xargo.toml     |  38 +-
 samplecode/hello-rust/enclave/Xargo.toml           |  39 +-
 samplecode/helloworld/enclave/Xargo.toml           |  38 +-
 samplecode/http_req/enclave/Xargo.toml             |  38 +-
 samplecode/hugemem/enclave/Xargo.toml              |  38 +-
 samplecode/kvdb-memdb/enclave/Xargo.toml           |  38 +-
 samplecode/localattestation/attestation/Xargo.toml |  38 +-
 samplecode/localattestation/enclave1/Xargo.toml    |  38 +-
 samplecode/localattestation/enclave2/Xargo.toml    |  38 +-
 samplecode/localattestation/enclave3/Xargo.toml    |  38 +-
 samplecode/logger/enclave/Xargo.toml               |  38 +-
 samplecode/machine-learning/enclave/Xargo.toml     |  38 +-
 samplecode/mio/client/enclave/Xargo.toml           |  38 +-
 samplecode/mio/server/enclave/Xargo.toml           |  38 +-
 samplecode/mutual-ra/enclave/Xargo.toml            |  38 +-
 samplecode/net2/enclave/Xargo.toml                 |  38 +-
 samplecode/pcl/encrypted-hello/enclave/Xargo.toml  |  38 +-
 samplecode/pcl/pcl-seal/enclave/Xargo.toml         |  38 +-
 samplecode/protobuf/enclave/Xargo.toml             |  38 +-
 samplecode/psi/SMCServer/enclave/Xargo.toml        |  38 +-
 .../Application/enclave/Xargo.toml                 |  38 +-
 samplecode/sealeddata/enclave/Xargo.toml           |  38 +-
 samplecode/secretsharing/enclave/Xargo.toml        |  38 +-
 samplecode/serialize/enclave/Xargo.toml            |  38 +-
 samplecode/sgx-cov/enclave/Xargo.toml              |  40 +-
 samplecode/sgxcounter/enclave/Xargo.toml           |  38 +-
 samplecode/sgxtime/enclave/Xargo.toml              |  38 +-
 .../static-data-distribution/enclave/Xargo.toml    |  39 +-
 samplecode/switchless/enclave/Xargo.toml           |  38 +-
 samplecode/tcmalloc/enclave/Xargo.toml             |  38 +-
 samplecode/thread/enclave/Xargo.toml               |  38 +-
 samplecode/tls/tlsclient/enclave/Xargo.toml        |  38 +-
 samplecode/tls/tlsserver/enclave/Xargo.toml        |  38 +-
 samplecode/tr-mpc/tr-mpc-server/enclave/Xargo.toml |  45 +-
 samplecode/ue-ra/ue-ra-server/enclave/Xargo.toml   |  38 +-
 samplecode/unit-test/enclave/Cargo.toml            |   2 +-
 samplecode/unit-test/enclave/Xargo.toml            |  40 +-
 samplecode/wasmi/enclave/Xargo.toml                |  38 +-
 .../zlib-lazy-static-sample/enclave/Xargo.toml     |  38 +-
 sgx_alloc/Cargo.toml                               |   3 -
 sgx_alloc/src/lib.rs                               |  24 +-
 sgx_libc/src/lib.rs                                |   1 +
 sgx_libc/src/linux/x86_64/mod.rs                   |   2 +-
 sgx_libc/src/linux/x86_64/ocall.rs                 | 124 +++++
 sgx_libc/src/macros.rs                             | 132 ++++-
 {sgx_alloc => sgx_no_tstd}/Cargo.toml              |  10 +-
 sgx_no_tstd/LICENSE                                | 613 +++++++++++++++++++++
 sgx_no_tstd/Readme.md                              |   3 +
 sgx_tstd/src/rt.rs => sgx_no_tstd/build.rs         |  48 +-
 sgx_no_tstd/src/lib.rs                             | 117 ++++
 sgx_tseal/src/internal.rs                          |  16 -
 sgx_tstd/Cargo.toml                                |   1 +
 sgx_tstd/src/lib.rs                                |   7 -
 sgx_tstd/src/net/addr.rs                           |  39 +-
 sgx_tstd/src/net/mod.rs                            |   2 -
 sgx_tstd/src/rt.rs                                 |  18 +-
 sgx_tstd/src/sync/mod.rs                           |   1 +
 sgx_tstd/src/sys/mod.rs                            |   1 +
 sgx_tstd/src/sys/net.rs                            |  33 +-
 sgx_tstd/src/sys/thread.rs                         |  15 +-
 sgx_tstd/src/sys_common/mod.rs                     |   1 +
 sgx_tstd/src/sys_common/net.rs                     |  92 +++-
 sgx_tstd/src/thread/mod.rs                         |  24 +-
 sgx_types/src/error.rs                             | 231 ++++++--
 sgx_types/src/function.rs                          | 130 ++++-
 sgx_types/src/lib.rs                               |   1 +
 sgx_types/src/types.rs                             | 103 +++-
 sgx_unwind/Cargo.toml                              |   3 -
 sgx_unwind/lib.rs                                  |   1 -
 sgx_unwind/libunwind.rs                            |   4 +-
 sgx_urts/src/lib.rs                                |   1 +
 sgx_tstd/src/rt.rs => sgx_urts/src/net.rs          |  41 +-
 sgx_ustdc/env.c                                    |  11 +-
 sgx_urts/src/lib.rs => sgx_ustdc/net.c             |  38 +-
 xargo/sgx_tstd/Cargo.toml                          |   1 +
 121 files changed, 2848 insertions(+), 1211 deletions(-)

diff --git a/common/inc/assert.h b/common/inc/assert.h
index 82489e8..a153995 100644
--- a/common/inc/assert.h
+++ b/common/inc/assert.h
@@ -1,5 +1,5 @@
-/*	$OpenBSD: assert.h,v 1.12 2006/01/31 10:53:51 hshoexer Exp $	*/
-/*	$NetBSD: assert.h,v 1.6 1994/10/26 00:55:44 cgd Exp $	*/
+/*  $OpenBSD: assert.h,v 1.12 2006/01/31 10:53:51 hshoexer Exp $    */
+/*  $NetBSD: assert.h,v 1.6 1994/10/26 00:55:44 cgd Exp $           */
 
 /*-
  * Copyright (c) 1992, 1993
diff --git a/common/inc/complex.h b/common/inc/complex.h
index 93fe495..904cb31 100644
--- a/common/inc/complex.h
+++ b/common/inc/complex.h
@@ -1,4 +1,4 @@
-/*	$OpenBSD: complex.h,v 1.3 2010/07/24 22:17:03 guenther Exp $	*/
+/*  $OpenBSD: complex.h,v 1.3 2010/07/24 22:17:03 guenther Exp $    */
 /*
  * Copyright (c) 2008 Martynas Venckus <ma...@openbsd.org>
  *
@@ -16,7 +16,7 @@
  */
 
 #ifndef _COMPLEX_H_
-#define	_COMPLEX_H_
+#define _COMPLEX_H_
 
 #include <sys/cdefs.h>
 
@@ -25,18 +25,18 @@
  */
 #ifdef __GNUC__
 #if __STDC_VERSION__ < 199901
-#define _Complex	__complex__
+#define _Complex    __complex__
 #endif
-#define _Complex_I	1.0fi
+#define _Complex_I  1.0fi
 #elif defined(lint)
-#define _Complex_I	1.0fi
+#define _Complex_I  1.0fi
 #endif
 
-#define complex		_Complex
+#define complex     _Complex
 
 /* XXX switch to _Imaginary_I */
 #undef I
-#define I		_Complex_I
+#define I           _Complex_I
 
 __BEGIN_DECLS
 /*
diff --git a/common/inc/ctype.h b/common/inc/ctype.h
index 1408447..4449d74 100644
--- a/common/inc/ctype.h
+++ b/common/inc/ctype.h
@@ -34,7 +34,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- *	@(#)ctype.h	5.3 (Berkeley) 4/3/91
+ *  @(#)ctype.h 5.3 (Berkeley) 4/3/91
  */
 
 #ifndef _CTYPE_H_
diff --git a/common/inc/dirent.h b/common/inc/dirent.h
index b3b85e8..9beff85 100644
--- a/common/inc/dirent.h
+++ b/common/inc/dirent.h
@@ -29,7 +29,7 @@ struct dirent
 #endif
     unsigned short int d_reclen;
     unsigned char d_type;
-    char d_name[256];		/* We must not include limits.h! */
+    char d_name[256];       /* We must not include limits.h! */
 };
 
 //#ifdef __USE_LARGEFILE64
@@ -39,11 +39,11 @@ struct dirent64
     __off64_t d_off;
     unsigned short int d_reclen;
     unsigned char d_type;
-    char d_name[256];		/* We must not include limits.h! */
+    char d_name[256];       /* We must not include limits.h! */
 };
 //#endif
 
-#define d_fileno	d_ino	/* Backwards compatibility.  */
+#define d_fileno	d_ino   /* Backwards compatibility.  */
 
 #undef  _DIRENT_HAVE_D_NAMLEN
 #define _DIRENT_HAVE_D_RECLEN
@@ -52,8 +52,8 @@ struct dirent64
 
 #if defined __OFF_T_MATCHES_OFF64_T && defined __INO_T_MATCHES_INO64_T
 /* Inform libc code that these two types are effectively identical.  */
-# define _DIRENT_MATCHES_DIRENT64	1
+# define _DIRENT_MATCHES_DIRENT64   1
 #else
-# define _DIRENT_MATCHES_DIRENT64	0
+# define _DIRENT_MATCHES_DIRENT64   0
 #endif
 #endif
\ No newline at end of file
diff --git a/common/inc/endian.h b/common/inc/endian.h
index fcd74c9..2620c58 100644
--- a/common/inc/endian.h
+++ b/common/inc/endian.h
@@ -1,4 +1,4 @@
-/*	$OpenBSD: endian.h,v 1.18 2006/03/27 07:09:24 otto Exp $	*/
+/*  $OpenBSD: endian.h,v 1.18 2006/03/27 07:09:24 otto Exp $    */
 
 /*-
  * Copyright (c) 1997 Niklas Hallqvist.  All rights reserved.
diff --git a/common/inc/errno.h b/common/inc/errno.h
index 0924d5a..dbe293c 100644
--- a/common/inc/errno.h
+++ b/common/inc/errno.h
@@ -1,4 +1,4 @@
-/*	$OpenBSD: errno.h,v 1.1 2005/12/28 16:33:56 millert Exp $	*/
+/*  $OpenBSD: errno.h,v 1.1 2005/12/28 16:33:56 millert Exp $   */
 
 /*
  * Copyright (c) 1982, 1986, 1989, 1993
@@ -33,7 +33,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- *	@(#)errno.h	8.5 (Berkeley) 1/21/94
+ *  @(#)errno.h 8.5 (Berkeley) 1/21/94
  */
 
 #ifndef	_ERRNO_H_
@@ -180,7 +180,7 @@ __BEGIN_DECLS
 
 #ifndef errno
 int * _TLIBC_CDECL_ __errno(void);
-#define	errno (*__errno())
+#define errno   (*__errno())
 #endif /* errno */
 __END_DECLS
 
diff --git a/common/inc/float.h b/common/inc/float.h
index 5ca839a..e38a7c6 100644
--- a/common/inc/float.h
+++ b/common/inc/float.h
@@ -1,5 +1,5 @@
-/* $OpenBSD: float.h,v 1.3 2008/07/21 20:50:54 martynas Exp $ */
-/* $NetBSD: float.h,v 1.8 1995/06/20 20:45:37 jtc Exp $ */
+/*  $OpenBSD: float.h,v 1.3 2008/07/21 20:50:54 martynas Exp $  */
+/*  $NetBSD: float.h,v 1.8 1995/06/20 20:45:37 jtc Exp $    */
 
 /*
  * Copyright (c) 1989 Regents of the University of California.
diff --git a/common/inc/iso646.h b/common/inc/iso646.h
index 83feb52..a0c341b 100644
--- a/common/inc/iso646.h
+++ b/common/inc/iso646.h
@@ -1,5 +1,5 @@
-/*	$OpenBSD: iso646.h,v 1.3 2001/10/11 00:05:21 espie Exp $	*/
-/*	$NetBSD: iso646.h,v 1.1 1995/02/17 09:08:10 jtc Exp $	*/
+/*  $OpenBSD: iso646.h,v 1.3 2001/10/11 00:05:21 espie Exp $  */
+/*  $NetBSD: iso646.h,v 1.1 1995/02/17 09:08:10 jtc Exp $     */
 
 /*
  * Written by J.T. Conklin <jt...@wimsey.com> 02/16/95.
diff --git a/common/inc/limits.h b/common/inc/limits.h
index fab59c9..9d42cb5 100644
--- a/common/inc/limits.h
+++ b/common/inc/limits.h
@@ -1,5 +1,5 @@
-/*	$OpenBSD: limits.h,v 1.15 2008/02/10 09:59:54 kettenis Exp $	*/
-/*	$NetBSD: limits.h,v 1.7 1994/10/26 00:56:00 cgd Exp $	*/
+/*  $OpenBSD: limits.h,v 1.15 2008/02/10 09:59:54 kettenis Exp $    */
+/*  $NetBSD: limits.h,v 1.7 1994/10/26 00:56:00 cgd Exp $           */
 
 /*
  * Copyright (c) 1988 The Regents of the University of California.
@@ -29,7 +29,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- *	@(#)limits.h	5.9 (Berkeley) 4/3/91
+ *  @(#)limits.h    5.9 (Berkeley) 4/3/91
  */
 
 
diff --git a/common/inc/math.h b/common/inc/math.h
index 749f935..048508f 100644
--- a/common/inc/math.h
+++ b/common/inc/math.h
@@ -1,4 +1,4 @@
-/*	$OpenBSD: math.h,v 1.27 2010/12/14 11:16:15 martynas Exp $	*/
+/*  $OpenBSD: math.h,v 1.27 2010/12/14 11:16:15 martynas Exp $  */
 /*
  * ====================================================
  * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
diff --git a/common/inc/mbusafecrt.h b/common/inc/mbusafecrt.h
index 466c550..1d8c9d8 100644
--- a/common/inc/mbusafecrt.h
+++ b/common/inc/mbusafecrt.h
@@ -80,4 +80,4 @@ extern errno_t memmove_s( void * dst, size_t sizeInBytes, const void * src, size
     }
 #endif
 
-#endif	/* MBUSAFECRT_H */
+#endif  /* MBUSAFECRT_H */
diff --git a/common/inc/netdb.h b/common/inc/netdb.h
new file mode 100644
index 0000000..4d2d14a
--- /dev/null
+++ b/common/inc/netdb.h
@@ -0,0 +1,37 @@
+  /* Copyright (C) 1996-2018 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
+
+/* All data returned by the network data base library are supplied in
+   host order and returned in network order (suitable for use in
+   system calls).  */
+
+#ifndef _NETDB_H
+#define _NETDB_H
+
+struct addrinfo
+{
+    int ai_flags;               /* Input flags.  */
+    int ai_family;              /* Protocol family for socket.  */
+    int ai_socktype;            /* Socket type.  */
+    int ai_protocol;            /* Protocol for socket.  */
+    socklen_t ai_addrlen;       /* Length of socket address.  */
+    struct sockaddr *ai_addr;   /* Socket address for socket.  */
+    char *ai_canonname;         /* Canonical name for service location.  */
+    struct addrinfo *ai_next;   /* Pointer to next in list.  */
+};
+
+#endif
\ No newline at end of file
diff --git a/common/inc/poll.h b/common/inc/poll.h
index 35815a9..1a070e0 100644
--- a/common/inc/poll.h
+++ b/common/inc/poll.h
@@ -7,9 +7,9 @@ typedef unsigned long int nfds_t;
 /* Data structure describing a polling request.  */
 struct pollfd
 {
-    int fd;			/* File descriptor to poll.  */
-    short int events;		/* Types of events poller cares about.  */
-    short int revents;		/* Types of events that actually occurred.  */
+    int fd;             /* File descriptor to poll.  */
+    short int events;   /* Types of events poller cares about.  */
+    short int revents;  /* Types of events that actually occurred.  */
 };
 
 #endif
diff --git a/common/inc/pthread.h b/common/inc/pthread.h
index 2d78a98..4930ca3 100644
--- a/common/inc/pthread.h
+++ b/common/inc/pthread.h
@@ -6,18 +6,18 @@
 typedef unsigned long int pthread_t;
 
 #if defined __x86_64__ && !defined __ILP32__
-# define __WORDSIZE	64
+# define __WORDSIZE 64
 #else
-# define __WORDSIZE	32
-#define __WORDSIZE32_SIZE_ULONG		0
-#define __WORDSIZE32_PTRDIFF_LONG	0
+# define __WORDSIZE 32
+#define __WORDSIZE32_SIZE_ULONG     0
+#define __WORDSIZE32_PTRDIFF_LONG   0
 #endif
 
 #ifdef __x86_64__
 # if __WORDSIZE == 64
-#  define __SIZEOF_PTHREAD_ATTR_T 56
+#  define __SIZEOF_PTHREAD_ATTR_T   56
 # else
-#  define __SIZEOF_PTHREAD_ATTR_T 32
+#  define __SIZEOF_PTHREAD_ATTR_T   32
 #endif
 
 union pthread_attr_t
diff --git a/common/inc/pwd.h b/common/inc/pwd.h
index a240236..e1ee8ca 100644
--- a/common/inc/pwd.h
+++ b/common/inc/pwd.h
@@ -19,18 +19,18 @@
  *	POSIX Standard: 9.2.2 User Database Access	<pwd.h>
  */
 
-#ifndef	_PWD_H
-#define	_PWD_H
+#ifndef _PWD_H
+#define _PWD_H
 
 struct passwd
 {
-    char *pw_name;		/* Username.  */
-    char *pw_passwd;	/* Password.  */
-    __uid_t pw_uid;		/* User ID.  */
-    __gid_t pw_gid;		/* Group ID.  */
-    char *pw_gecos;		/* Real name.  */
-    char *pw_dir;		/* Home directory.  */
-    char *pw_shell;		/* Shell program.  */
+    char *pw_name;      /* Username.  */
+    char *pw_passwd;    /* Password.  */
+    __uid_t pw_uid;     /* User ID.  */
+    __gid_t pw_gid;     /* Group ID.  */
+    char *pw_gecos;     /* Real name.  */
+    char *pw_dir;       /* Home directory.  */
+    char *pw_shell;     /* Shell program.  */
 };
 
 #endif
\ No newline at end of file
diff --git a/common/inc/setjmp.h b/common/inc/setjmp.h
index 6954e2b..752f0cf 100644
--- a/common/inc/setjmp.h
+++ b/common/inc/setjmp.h
@@ -1,4 +1,4 @@
-/*	$NetBSD: setjmp.h,v 1.26 2011/11/05 09:27:06 joerg Exp $	*/
+/*  $NetBSD: setjmp.h,v 1.26 2011/11/05 09:27:06 joerg Exp $    */
 
 /*-
  * Copyright (c) 1990, 1993
@@ -33,7 +33,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- *	@(#)setjmp.h	8.2 (Berkeley) 1/21/94
+ *  @(#)setjmp.h    8.2 (Berkeley) 1/21/94
  */
 
 #ifndef _SETJMP_H_
diff --git a/common/inc/stdarg.h b/common/inc/stdarg.h
index ed73e24..b2a5d36 100644
--- a/common/inc/stdarg.h
+++ b/common/inc/stdarg.h
@@ -1,5 +1,5 @@
-/*	$OpenBSD: stdarg.h,v 1.14 2010/12/30 05:01:36 tedu Exp $	*/
-/*	$NetBSD: stdarg.h,v 1.12 1995/12/25 23:15:31 mycroft Exp $	*/
+/*  $OpenBSD: stdarg.h,v 1.14 2010/12/30 05:01:36 tedu Exp $    */
+/*  $NetBSD: stdarg.h,v 1.12 1995/12/25 23:15:31 mycroft Exp $  */
 
 /*-
  * Copyright (c) 1991, 1993
@@ -29,7 +29,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- *	@(#)stdarg.h	8.1 (Berkeley) 6/10/93
+ *  @(#)stdarg.h    8.1 (Berkeley) 6/10/93
  */
 
 #ifndef _STDARG_H_
diff --git a/common/inc/stdbool.h b/common/inc/stdbool.h
index bd1837e..86b866d 100644
--- a/common/inc/stdbool.h
+++ b/common/inc/stdbool.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: stdbool.h,v 1.5 2010/07/24 22:17:03 guenther Exp $ */
+/*  $OpenBSD: stdbool.h,v 1.5 2010/07/24 22:17:03 guenther Exp $    */
 
 /*
  * Written by Marc Espie, September 25, 1999
diff --git a/common/inc/stddef.h b/common/inc/stddef.h
index 84509c5..c132882 100644
--- a/common/inc/stddef.h
+++ b/common/inc/stddef.h
@@ -1,5 +1,5 @@
-/*	$OpenBSD: stddef.h,v 1.10 2009/09/22 21:40:02 jsg Exp $	*/
-/*	$NetBSD: stddef.h,v 1.4 1994/10/26 00:56:26 cgd Exp $	*/
+/*  $OpenBSD: stddef.h,v 1.10 2009/09/22 21:40:02 jsg Exp $ */
+/*  $NetBSD: stddef.h,v 1.4 1994/10/26 00:56:26 cgd Exp $   */
 
 /*-
  * Copyright (c) 1990 The Regents of the University of California.
@@ -29,7 +29,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- *	@(#)stddef.h	5.5 (Berkeley) 4/3/91
+ *  @(#)stddef.h    5.5 (Berkeley) 4/3/91
  */
 
 #ifndef _STDDEF_H_
diff --git a/common/inc/stdint.h b/common/inc/stdint.h
index d283ae9..e574484 100644
--- a/common/inc/stdint.h
+++ b/common/inc/stdint.h
@@ -1,4 +1,4 @@
-/*	$OpenBSD: stdint.h,v 1.4 2006/12/10 22:17:55 deraadt Exp $	*/
+/*  $OpenBSD: stdint.h,v 1.4 2006/12/10 22:17:55 deraadt Exp $  */
 
 /*
  * Copyright (c) 1997, 2005 Todd C. Miller <To...@courtesan.com>
@@ -16,7 +16,7 @@
  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  */
 
-#ifndef	_STDINT_H_
+#ifndef _STDINT_H_
 #define _STDINT_H_
 
 #include <sys/stdint.h>
diff --git a/common/inc/stdio.h b/common/inc/stdio.h
index 0175a3a..92d01a0 100644
--- a/common/inc/stdio.h
+++ b/common/inc/stdio.h
@@ -1,5 +1,5 @@
-/*	$OpenBSD: stdio.h,v 1.38 2009/11/09 00:18:27 kurt Exp $	*/
-/*	$NetBSD: stdio.h,v 1.18 1996/04/25 18:29:21 jtc Exp $	*/
+/*  $OpenBSD: stdio.h,v 1.38 2009/11/09 00:18:27 kurt Exp $ */
+/*  $NetBSD: stdio.h,v 1.18 1996/04/25 18:29:21 jtc Exp $   */
 
 /*-
  * Copyright (c) 1990 The Regents of the University of California.
@@ -32,7 +32,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- *	@(#)stdio.h	5.17 (Berkeley) 6/3/91
+ *  @(#)stdio.h 5.17 (Berkeley) 6/3/91
  */
 
 #ifndef _STDIO_H_
diff --git a/common/inc/stdlib.h b/common/inc/stdlib.h
index f321738..e5b6365 100644
--- a/common/inc/stdlib.h
+++ b/common/inc/stdlib.h
@@ -1,5 +1,5 @@
-/*	$OpenBSD: stdlib.h,v 1.47 2010/05/18 22:24:55 tedu Exp $	*/
-/*	$NetBSD: stdlib.h,v 1.25 1995/12/27 21:19:08 jtc Exp $	*/
+/*      $OpenBSD: stdlib.h,v 1.47 2010/05/18 22:24:55 tedu Exp $ */
+/*      $NetBSD: stdlib.h,v 1.25 1995/12/27 21:19:08 jtc Exp $   */
 
 /*-
 * Copyright (c) 1990 The Regents of the University of California.
@@ -29,7 +29,7 @@
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 * SUCH DAMAGE.
 *
-*	@(#)stdlib.h	5.13 (Berkeley) 6/4/91
+*       @(#)stdlib.h    5.13 (Berkeley) 6/4/91
 */
 
 #ifndef _STDLIB_H_
diff --git a/common/inc/string.h b/common/inc/string.h
index 86d3cd2..0cc7206 100644
--- a/common/inc/string.h
+++ b/common/inc/string.h
@@ -1,5 +1,5 @@
-/*	$OpenBSD: string.h,v 1.20 2010/09/24 13:33:00 matthew Exp $	*/
-/*	$NetBSD: string.h,v 1.6 1994/10/26 00:56:30 cgd Exp $	*/
+/*  $OpenBSD: string.h,v 1.20 2010/09/24 13:33:00 matthew Exp $ */
+/*  $NetBSD: string.h,v 1.6 1994/10/26 00:56:30 cgd Exp $       */
 
 /*-
  * Copyright (c) 1990 The Regents of the University of California.
@@ -29,7 +29,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- *	@(#)string.h	5.10 (Berkeley) 3/9/91
+ *  @(#)string.h    5.10 (Berkeley) 3/9/91
  */
 
 #ifndef _STRING_H_
diff --git a/common/inc/sys/_types.h b/common/inc/sys/_types.h
index fc9f153..7768f18 100644
--- a/common/inc/sys/_types.h
+++ b/common/inc/sys/_types.h
@@ -1,4 +1,4 @@
-/*	$OpenBSD: _types.h,v 1.2 2008/03/16 19:42:57 otto Exp $	*/
+/*  $OpenBSD: _types.h,v 1.2 2008/03/16 19:42:57 otto Exp $ */
 
 /*-
  * Copyright (c) 1990, 1993
@@ -28,7 +28,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- *	@(#)types.h	8.3 (Berkeley) 1/5/94
+ *  @(#)types.h 8.3 (Berkeley) 1/5/94
  */
 
 #ifndef _SYS__TYPES_H_
@@ -83,9 +83,9 @@ typedef __uint64_t          __uint_fast64_t;
 
 typedef long                __off_t;
 #ifdef __x86_64__
-typedef long int 			__off64_t;
+typedef long int            __off64_t;
 #else
-typedef long long int 		__off64_t;
+typedef long long int       __off64_t;
 #endif
 
 /* 7.18.1.4 Integer types capable of holding object pointers */
@@ -138,25 +138,25 @@ typedef __int64_t           __intmax_t;
 typedef __uint64_t          __uintmax_t;
 
 
-typedef unsigned long int 		__ino_t;
-typedef unsigned int 			__mode_t;
-typedef unsigned int 			__uid_t;
-typedef unsigned int 			__gid_t;
-typedef long int 				__blksize_t;
-typedef long int 				__blkcnt_t;
+typedef unsigned long int       __ino_t;
+typedef unsigned int            __mode_t;
+typedef unsigned int            __uid_t;
+typedef unsigned int            __gid_t;
+typedef long int                __blksize_t;
+typedef long int                __blkcnt_t;
 
 #ifdef __x86_64__
-typedef unsigned long int 		__dev_t;
-typedef long int 				__off64_t;
-typedef unsigned long int		__nlink_t;
-typedef long int 				__blkcnt64_t;
-typedef unsigned long int 		__ino64_t;
+typedef unsigned long int       __dev_t;
+typedef long int                __off64_t;
+typedef unsigned long int       __nlink_t;
+typedef long int                __blkcnt64_t;
+typedef unsigned long int       __ino64_t;
 #else
-typedef unsigned long long int 	__dev_t;
-typedef long long int 			__off64_t;
-typedef unsigned int 			__nlink_t;
-typedef long long int 			__blkcnt64_t;
-typedef unsigned long long int 	__ino64_t;
+typedef unsigned long long int  __dev_t;
+typedef long long int           __off64_t;
+typedef unsigned int            __nlink_t;
+typedef long long int           __blkcnt64_t;
+typedef unsigned long long int  __ino64_t;
 #endif
 
 typedef unsigned int            __socklen_t;
diff --git a/common/inc/sys/cdefs.h b/common/inc/sys/cdefs.h
index a6fdb58..71c3c1c 100644
--- a/common/inc/sys/cdefs.h
+++ b/common/inc/sys/cdefs.h
@@ -1,5 +1,5 @@
-/*	$OpenBSD: cdefs.h,v 1.34 2012/08/14 20:11:37 matthew Exp $	*/
-/*	$NetBSD: cdefs.h,v 1.16 1996/04/03 20:46:39 christos Exp $	*/
+/*  $OpenBSD: cdefs.h,v 1.34 2012/08/14 20:11:37 matthew Exp $  */
+/*  $NetBSD: cdefs.h,v 1.16 1996/04/03 20:46:39 christos Exp $  */
 
 /*
  * Copyright (c) 1991, 1993
@@ -32,7 +32,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- *	@(#)cdefs.h	8.7 (Berkeley) 1/21/94
+ *  @(#)cdefs.h 8.7 (Berkeley) 1/21/94
  */
 
 #ifndef _SYS_CDEFS_H_
@@ -122,11 +122,11 @@
  *	  larger code.
  */
 #if defined(__GNUC__) && __GNUC_PREREQ__(2, 96)
-#define __predict_true(exp)	__builtin_expect(((exp) != 0), 1)
-#define __predict_false(exp)	__builtin_expect(((exp) != 0), 0)
+#define __predict_true(exp)     __builtin_expect(((exp) != 0), 1)
+#define __predict_false(exp)    __builtin_expect(((exp) != 0), 0)
 #else
-#define __predict_true(exp)	((exp) != 0)
-#define __predict_false(exp)	((exp) != 0)
+#define __predict_true(exp)     ((exp) != 0)
+#define __predict_false(exp)    ((exp) != 0)
 #endif
 
 #endif /* !_SYS_CDEFS_H_ */
diff --git a/common/inc/sys/endian.h b/common/inc/sys/endian.h
index 29edd81..1cd7b81 100644
--- a/common/inc/sys/endian.h
+++ b/common/inc/sys/endian.h
@@ -1,4 +1,4 @@
-/*	$OpenBSD: endian.h,v 1.18 2006/03/27 07:09:24 otto Exp $	*/
+/*  $OpenBSD: endian.h,v 1.18 2006/03/27 07:09:24 otto Exp $    */
 
 /*-
  * Copyright (c) 1997 Niklas Hallqvist.  All rights reserved.
diff --git a/common/inc/sys/epoll.h b/common/inc/sys/epoll.h
index f464db4..64e3ddb 100644
--- a/common/inc/sys/epoll.h
+++ b/common/inc/sys/epoll.h
@@ -15,23 +15,23 @@
    License along with the GNU C Library; if not, see
    <http://www.gnu.org/licenses/>.  */
 
-#ifndef	_SYS_EPOLL_H
-#define	_SYS_EPOLL_H
+#ifndef _SYS_EPOLL_H
+#define _SYS_EPOLL_H
 
 #define __EPOLL_PACKED __attribute__ ((__packed__))
 
 typedef union epoll_data
 {
-  void *ptr;
-  int fd;
-  uint32_t u32;
-  uint64_t u64;
+    void *ptr;
+    int fd;
+    uint32_t u32;
+    uint64_t u64;
 } epoll_data_t;
 
 struct epoll_event
 {
-  uint32_t events;	/* Epoll events */
-  epoll_data_t data;	/* User data variable */
+    uint32_t events;    /* Epoll events */
+    epoll_data_t data;  /* User data variable */
 } __EPOLL_PACKED;
 
 #endif
\ No newline at end of file
diff --git a/common/inc/sys/ieee.h b/common/inc/sys/ieee.h
index 8370cd8..eab3b97 100644
--- a/common/inc/sys/ieee.h
+++ b/common/inc/sys/ieee.h
@@ -1,5 +1,5 @@
-/*	$OpenBSD: ieee.h,v 1.2 2008/09/07 20:36:06 martynas Exp $ */
-/*	$NetBSD: ieee.h,v 1.1 1996/09/30 16:34:25 ws Exp $ */
+/*  $OpenBSD: ieee.h,v 1.2 2008/09/07 20:36:06 martynas Exp $   */
+/*  $NetBSD: ieee.h,v 1.1 1996/09/30 16:34:25 ws Exp $  */
 
 /*
  * Copyright (c) 1992, 1993
@@ -38,7 +38,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- *	@(#)ieee.h	8.1 (Berkeley) 6/11/93
+ *  @(#)ieee.h  8.1 (Berkeley) 6/11/93
  */
 
 /*
@@ -50,27 +50,27 @@
 /*
  * Define the number of bits in each fraction and exponent.
  *
- *		     k	         k+1
+ *              k           k+1
  * Note that  1.0 x 2  == 0.1 x 2      and that denorms are represented
  *
- *					  (-exp_bias+1)
+ *                          (-exp_bias+1)
  * as fractions that look like 0.fffff x 2             .  This means that
  *
- *			 -126
+ *              -126
  * the number 0.10000 x 2    , for instance, is the same as the normalized
  *
- *		-127			   -128
+ *              -127        -128
  * float 1.0 x 2    .  Thus, to represent 2    , we need one leading zero
  *
- *				  -129
+ *              -129
  * in the fraction; to represent 2    , we need two, and so on.  This
  *
- *						     (-exp_bias-fracbits+1)
+ *                          (-exp_bias-fracbits+1)
  * implies that the smallest denormalized number is 2
  *
  * for whichever format we are talking about: for single precision, for
  *
- *						-126		-149
+ *              -126        -149
  * instance, we get .00000000000000000000001 x 2    , or 1.0 x 2    , and
  *
  * -149 == -127 - 23 + 1.
diff --git a/common/inc/sys/sockaddr.h b/common/inc/sys/sockaddr.h
index 3a1a958..6be9dd2 100644
--- a/common/inc/sys/sockaddr.h
+++ b/common/inc/sys/sockaddr.h
@@ -25,10 +25,10 @@ typedef unsigned short int sa_family_t;
    of the data types used for socket addresses, `struct sockaddr',
    `struct sockaddr_in', `struct sockaddr_un', etc.  */
 
-#define	__SOCKADDR_COMMON(sa_prefix) \
-  sa_family_t sa_prefix##family
+#define __SOCKADDR_COMMON(sa_prefix) \
+    sa_family_t sa_prefix##family
 
-#define __SOCKADDR_COMMON_SIZE	(sizeof (unsigned short int))
+#define __SOCKADDR_COMMON_SIZE  (sizeof (unsigned short int))
 
 /* Size of struct sockaddr_storage.  */
 #define _SS_SIZE 128
diff --git a/common/inc/sys/socket.h b/common/inc/sys/socket.h
index 2f0bd0e..889e361 100644
--- a/common/inc/sys/socket.h
+++ b/common/inc/sys/socket.h
@@ -31,24 +31,24 @@ typedef __socklen_t socklen_t;
 /* Structure describing a generic socket address.  */
 struct sockaddr
 {
-    __SOCKADDR_COMMON (sa_);	/* Common data: address family and length.  */
-    char sa_data[14];		    /* Address data.  */
+    __SOCKADDR_COMMON (sa_);    /* Common data: address family and length.  */
+    char sa_data[14];           /* Address data.  */
 };
 
 struct msghdr
 {
-    void *msg_name;		    /* Address to send to/receive from.  */
-    socklen_t msg_namelen;	/* Length of address data.  */
+    void *msg_name;         /* Address to send to/receive from.  */
+    socklen_t msg_namelen;  /* Length of address data.  */
 
-    struct iovec *msg_iov;	/* Vector of data to send/receive into.  */
-    size_t msg_iovlen;		/* Number of elements in the vector.  */
+    struct iovec *msg_iov;  /* Vector of data to send/receive into.  */
+    size_t msg_iovlen;      /* Number of elements in the vector.  */
 
-    void *msg_control;		/* Ancillary data (eg BSD filedesc passing). */
-    size_t msg_controllen;	/* Ancillary data buffer length.
-				            !! The type should be socklen_t but the
+    void *msg_control;      /* Ancillary data (eg BSD filedesc passing). */
+    size_t msg_controllen;  /* Ancillary data buffer length.
+                            !! The type should be socklen_t but the
                             definition of the kernel is incompatible
                             with this.  */
-    int msg_flags;		/* Flags on received message.  */
+    int msg_flags;          /* Flags on received message.  */
 };
 
 #endif
\ No newline at end of file
diff --git a/common/inc/sys/stat.h b/common/inc/sys/stat.h
index 7ba561f..43b4776 100644
--- a/common/inc/sys/stat.h
+++ b/common/inc/sys/stat.h
@@ -25,39 +25,39 @@
 
 /* Versions of the `struct stat' data structure.  */
 #ifndef __x86_64__
-# define _STAT_VER_LINUX_OLD	1
-# define _STAT_VER_KERNEL		1
-# define _STAT_VER_SVR4			2
-# define _STAT_VER_LINUX		3
+# define _STAT_VER_LINUX_OLD    1
+# define _STAT_VER_KERNEL       1
+# define _STAT_VER_SVR4         2
+# define _STAT_VER_LINUX        3
 
 /* i386 versions of the `xmknod' interface.  */
-# define _MKNOD_VER_LINUX		1
-# define _MKNOD_VER_SVR4		2
-# define _MKNOD_VER		_MKNOD_VER_LINUX /* The bits defined below.  */
+# define _MKNOD_VER_LINUX       1
+# define _MKNOD_VER_SVR4        2
+# define _MKNOD_VER     _MKNOD_VER_LINUX /* The bits defined below.  */
 #else
-# define _STAT_VER_KERNEL		0
-# define _STAT_VER_LINUX		1
+# define _STAT_VER_KERNEL       0
+# define _STAT_VER_LINUX        1
 
 /* x86-64 versions of the `xmknod' interface.  */
-# define _MKNOD_VER_LINUX	0
+# define _MKNOD_VER_LINUX   0
 #endif
 
-#define _STAT_VER		_STAT_VER_LINUX
+#define _STAT_VER       _STAT_VER_LINUX
 
 #ifndef _DEV_T_DEFINED_
 #define _DEV_T_DEFINED_
-typedef __dev_t   dev_t;
+typedef __dev_t     dev_t;
 #endif
 
 #ifndef _INO_T_DEFINED_
 #define _INO_T_DEFINED_
-typedef __ino_t   	ino_t;
+typedef __ino_t     ino_t;
 typedef __ino64_t   ino64_t;
 #endif
 
 #ifndef _MODE_T_DEFINED_
 #define _MODE_T_DEFINED_
-typedef __mode_t   mode_t;
+typedef __mode_t    mode_t;
 #endif
 
 #ifndef _NLINK_T_DEFINED_
@@ -67,71 +67,71 @@ typedef __nlink_t   nlink_t;
 
 #ifndef _UID_T_DEFINED_
 #define _UID_T_DEFINED_
-typedef __uid_t   uid_t;
+typedef __uid_t     uid_t;
 #endif
 
 #ifndef _GID_T_DEFINED_
 #define _GID_T_DEFINED_
-typedef __gid_t   gid_t;
+typedef __gid_t     gid_t;
 #endif
 
 #ifndef _BLKSIZE_T_DEFINED_
 #define _BLKSIZE_T_DEFINED_
-typedef __blksize_t   blksize_t;
+typedef __blksize_t blksize_t;
 #endif
 
 #ifndef _BLKCNT_T_DEFINED_
 #define _BLKCNT_T_DEFINED_
-typedef __blkcnt_t   	blkcnt_t;
-typedef __blkcnt64_t   	blkcnt64_t;
+typedef __blkcnt_t      blkcnt_t;
+typedef __blkcnt64_t    blkcnt64_t;
 #endif
 
 
 struct stat
 {
-    dev_t st_dev;		/* Device.  */
+    dev_t st_dev;       /* Device.  */
 #ifndef __x86_64__
     unsigned short int __pad1;
 #endif
 #if defined __x86_64__ || !defined __USE_FILE_OFFSET64
-    ino_t st_ino;			/* File serial number.	*/
+    ino_t st_ino;           /* File serial number.	*/
 #else
-    ino_t __st_ino;			/* 32bit file serial number.	*/
+    ino_t __st_ino;         /* 32bit file serial number.	*/
 #endif
 #ifndef __x86_64__
-    mode_t st_mode;			/* File mode.  */
-    nlink_t st_nlink;		/* Link count.  */
+    mode_t st_mode;         /* File mode.  */
+    nlink_t st_nlink;       /* Link count.  */
 #else
-    nlink_t st_nlink;		/* Link count.  */
-    mode_t st_mode;			/* File mode.  */
+    nlink_t st_nlink;       /* Link count.  */
+    mode_t st_mode;         /* File mode.  */
 #endif
-    uid_t st_uid;			/* User ID of the file's owner.	*/
-    gid_t st_gid;			/* Group ID of the file's group.*/
+    uid_t st_uid;           /* User ID of the file's owner.	*/
+    gid_t st_gid;           /* Group ID of the file's group.*/
 #ifdef __x86_64__
     int __pad0;
 #endif
-    dev_t st_rdev;			/* Device number, if device.  */
+    dev_t st_rdev;          /* Device number, if device.  */
 #ifndef __x86_64__
     unsigned short int __pad2;
 #endif
 #if defined __x86_64__ || !defined __USE_FILE_OFFSET64
-    off_t st_size;			/* Size of file, in bytes.  */
+    off_t st_size;          /* Size of file, in bytes.  */
 #else
-    off64_t st_size;		/* Size of file, in bytes.  */
+    off64_t st_size;        /* Size of file, in bytes.  */
 #endif
-    blksize_t st_blksize;	/* Optimal block size for I/O.  */
+    blksize_t st_blksize;   /* Optimal block size for I/O.  */
 #if defined __x86_64__  || !defined __USE_FILE_OFFSET64
-    blkcnt_t st_blocks;		/* Number 512-byte blocks allocated. */
+    blkcnt_t st_blocks;     /* Number 512-byte blocks allocated. */
 #else
-    blkcnt64_t st_blocks;	/* Number 512-byte blocks allocated. */
+    blkcnt64_t st_blocks;   /* Number 512-byte blocks allocated. */
 #endif
 
-    time_t st_atime;			/* Time of last access.  */
-    unsigned long int  st_atimensec;	/* Nscecs of last access.  */
+    time_t st_atime;            /* Time of last access.  */
+    unsigned long int  st_atimensec;    /* Nscecs of last access.  */
     time_t st_mtime;			/* Time of last modification.  */
-    unsigned long int  st_mtimensec;	/* Nsecs of last modification.  */
-    time_t st_ctime;			/* Time of last status change.  */
-    unsigned long int  st_ctimensec;	/* Nsecs of last status change.  */
+    unsigned long int  st_mtimensec;    /* Nsecs of last modification.  */
+    time_t st_ctime;            /* Time of last status change.  */
+    unsigned long int  st_ctimensec;    /* Nsecs of last status change.  */
 #ifdef __x86_64__
     long int  __glibc_reserved[3];
 #else
@@ -139,37 +139,37 @@ struct stat
     unsigned long int __glibc_reserved4;
     unsigned long int __glibc_reserved5;
 # else
-    ino64_t st_ino;			/* File serial number.	*/
+    ino64_t st_ino;         /* File serial number.	*/
 # endif
 #endif
 };
 
 struct stat64
 {
-    dev_t st_dev;			/* Device.  */
+    dev_t st_dev;           /* Device.  */
 # ifdef __x86_64__
-    ino64_t st_ino;			/* File serial number.  */
-    nlink_t st_nlink;		/* Link count.  */
-    mode_t st_mode;			/* File mode.  */
+    ino64_t st_ino;         /* File serial number.  */
+    nlink_t st_nlink;       /* Link count.  */
+    mode_t st_mode;         /* File mode.  */
 # else
     unsigned int __pad1;
-    ino_t __st_ino;			/* 32bit file serial number.	*/
-    mode_t st_mode;			/* File mode.  */
-    nlink_t st_nlink;		/* Link count.  */
+    ino_t __st_ino;         /* 32bit file serial number.	*/
+    mode_t st_mode;         /* File mode.  */
+    nlink_t st_nlink;       /* Link count.  */
 # endif
-    uid_t st_uid;			/* User ID of the file's owner.	*/
-    gid_t st_gid;			/* Group ID of the file's group.*/
+    uid_t st_uid;           /* User ID of the file's owner.	*/
+    gid_t st_gid;           /* Group ID of the file's group.*/
 # ifdef __x86_64__
     int __pad0;
-    dev_t st_rdev;			/* Device number, if device.  */
-    off_t st_size;			/* Size of file, in bytes.  */
+    dev_t st_rdev;          /* Device number, if device.  */
+    off_t st_size;          /* Size of file, in bytes.  */
 # else
-    dev_t st_rdev;			/* Device number, if device.  */
+    dev_t st_rdev;          /* Device number, if device.  */
     unsigned int __pad2;
-    off64_t st_size;		/* Size of file, in bytes.  */
+    off64_t st_size;        /* Size of file, in bytes.  */
 # endif
-    blksize_t st_blksize;	/* Optimal block size for I/O.  */
-    blkcnt64_t st_blocks;	/* Nr. 512-byte blocks allocated.  */
+    blksize_t st_blksize;   /* Optimal block size for I/O.  */
+    blkcnt64_t st_blocks;   /* Nr. 512-byte blocks allocated.  */
 # ifdef __USE_XOPEN2K8
     /* Nanosecond resolution timestamps are stored in a format
        equivalent to 'struct timespec'.  This is the type used
@@ -177,70 +177,70 @@ struct stat64
        identifier 'timespec' to appear in the <sys/stat.h> header.
        Therefore we have to handle the use of this header in strictly
        standard-compliant sources special.  */
-    struct timespec st_atim;		/* Time of last access.  */
-    struct timespec st_mtim;		/* Time of last modification.  */
-    struct timespec st_ctim;		/* Time of last status change.  */
+    struct timespec st_atim;        /* Time of last access.  */
+    struct timespec st_mtim;        /* Time of last modification.  */
+    struct timespec st_ctim;        /* Time of last status change.  */
 # else
-    time_t st_atime;			/* Time of last access.  */
-    unsigned long int st_atimensec;	/* Nscecs of last access.  */
-    time_t st_mtime;			/* Time of last modification.  */
-    unsigned long int st_mtimensec;	/* Nsecs of last modification.  */
-    time_t st_ctime;			/* Time of last status change.  */
+    time_t st_atime;            /* Time of last access.  */
+    unsigned long int st_atimensec; /* Nscecs of last access.  */
+    time_t st_mtime;            /* Time of last modification.  */
+    unsigned long int st_mtimensec; /* Nsecs of last modification.  */
+    time_t st_ctime;            /* Time of last status change.  */
     unsigned long int st_ctimensec;	/* Nsecs of last status change.  */
 # endif
 # ifdef __x86_64__
     long int __glibc_reserved[3];
 # else
-    ino64_t st_ino;			/* File serial number.		*/
+    ino64_t st_ino;             /* File serial number.		*/
 # endif
  };
 
 /* Tell code we have these members.  */
-#define	_STATBUF_ST_BLKSIZE
+#define _STATBUF_ST_BLKSIZE
 #define _STATBUF_ST_RDEV
 /* Nanosecond resolution time values are supported.  */
 #define _STATBUF_ST_NSEC
 
 /* Encoding of the file mode.  */
 
-#define	S_IFMT	0170000	/* These bits determine file type.  */
+#define S_IFMT  0170000	/* These bits determine file type.  */
 
 /* File types.  */
-#define	S_IFDIR	0040000	/* Directory.  */
-#define	S_IFCHR	0020000	/* Character device.  */
-#define	S_IFBLK	0060000	/* Block device.  */
-#define	S_IFREG	0100000	/* Regular file.  */
-#define	S_IFIFO	0010000	/* FIFO.  */
-#define	S_IFLNK	0120000	/* Symbolic link.  */
-#define	S_IFSOCK	0140000	/* Socket.  */
+#define S_IFDIR 0040000 /* Directory.  */
+#define S_IFCHR 0020000 /* Character device.  */
+#define S_IFBLK 0060000 /* Block device.  */
+#define S_IFREG 0100000 /* Regular file.  */
+#define S_IFIFO 0010000 /* FIFO.  */
+#define S_IFLNK 0120000 /* Symbolic link.  */
+#define S_IFSOCK    0140000 /* Socket.  */
 
 /* POSIX.1b objects.  Note that these macros always evaluate to zero.  But
    they do it by enforcing the correct use of the macros.  */
-#define S_TYPEISMQ(buf)  ((buf)->st_mode - (buf)->st_mode)
-#define S_TYPEISSEM(buf) ((buf)->st_mode - (buf)->st_mode)
-#define S_TYPEISSHM(buf) ((buf)->st_mode - (buf)->st_mode)
+#define S_TYPEISMQ(buf)     ((buf)->st_mode - (buf)->st_mode)
+#define S_TYPEISSEM(buf)    ((buf)->st_mode - (buf)->st_mode)
+#define S_TYPEISSHM(buf)    ((buf)->st_mode - (buf)->st_mode)
 
 /* Protection bits.  */
 
-#define	S_ISUID	04000	/* Set user ID on execution.  */
-#define	S_ISGID	02000	/* Set group ID on execution.  */
-#define	S_ISVTX	01000	/* Save swapped text after use (sticky).  */
-#define	S_IREAD	0400	/* Read by owner.  */
-#define	S_IWRITE	0200	/* Write by owner.  */
-#define	S_IEXEC	0100	/* Execute by owner.  */
+#define S_ISUID 04000   /* Set user ID on execution.  */
+#define S_ISGID 02000   /* Set group ID on execution.  */
+#define S_ISVTX 01000   /* Save swapped text after use (sticky).  */
+#define S_IREAD 0400    /* Read by owner.  */
+#define S_IWRITE    0200    /* Write by owner.  */
+#define S_IEXEC 0100    /* Execute by owner.  */
 
 #ifdef __USE_ATFILE
-# define UTIME_NOW	((1l << 30) - 1l)
-# define UTIME_OMIT	((1l << 30) - 2l)
+# define UTIME_NOW  ((1l << 30) - 1l)
+# define UTIME_OMIT ((1l << 30) - 2l)
 #endif
 
-#define	S_ISTYPE(mode, mask)	(((mode) & __S_IFMT) == (mask))
+#define S_ISTYPE(mode, mask)    (((mode) & __S_IFMT) == (mask))
 
-#define	S_ISDIR(mode)	 S_ISTYPE((mode), S_IFDIR)
-#define	S_ISCHR(mode)	 S_ISTYPE((mode), S_IFCHR)
-#define	S_ISBLK(mode)	 S_ISTYPE((mode), S_IFBLK)
-#define	S_ISREG(mode)	 S_ISTYPE((mode), S_IFREG)
-#define S_ISFIFO(mode)	 S_ISTYPE((mode), S_IFIFO)
-#define S_ISLNK(mode)	 S_ISTYPE((mode), S_IFLNK)
+#define S_ISDIR(mode)   S_ISTYPE((mode), S_IFDIR)
+#define S_ISCHR(mode)   S_ISTYPE((mode), S_IFCHR)
+#define S_ISBLK(mode)   S_ISTYPE((mode), S_IFBLK)
+#define S_ISREG(mode)   S_ISTYPE((mode), S_IFREG)
+#define S_ISFIFO(mode)  S_ISTYPE((mode), S_IFIFO)
+#define S_ISLNK(mode)   S_ISTYPE((mode), S_IFLNK)
 
-#endif	/* bits/stat.h */
+#endif  /* bits/stat.h */
diff --git a/common/inc/sys/stdint.h b/common/inc/sys/stdint.h
index 97407ce..5159945 100644
--- a/common/inc/sys/stdint.h
+++ b/common/inc/sys/stdint.h
@@ -1,4 +1,4 @@
-/*	$OpenBSD: stdint.h,v 1.4 2006/12/10 22:17:55 deraadt Exp $	*/
+/*  $OpenBSD: stdint.h,v 1.4 2006/12/10 22:17:55 deraadt Exp $  */
 
 /*
  * Copyright (c) 1997, 2005 Todd C. Miller <To...@courtesan.com>
diff --git a/common/inc/sys/struct_timespec.h b/common/inc/sys/struct_timespec.h
index f2ac6d7..3e3f356 100644
--- a/common/inc/sys/struct_timespec.h
+++ b/common/inc/sys/struct_timespec.h
@@ -24,8 +24,8 @@
    has nanoseconds instead of microseconds.  */
 struct timespec
 {
-	__time_t 	tv_sec;		/* Seconds.  */
-	long 	   	tv_nsec;	/* Nanoseconds.  */
+    __time_t  tv_sec;   /* Seconds.  */
+    long      tv_nsec;  /* Nanoseconds.  */
 };
 
 #endif
diff --git a/common/inc/sys/types.h b/common/inc/sys/types.h
index cc4e753..b64f89d 100644
--- a/common/inc/sys/types.h
+++ b/common/inc/sys/types.h
@@ -1,5 +1,5 @@
-/*	$OpenBSD: types.h,v 1.31 2008/03/16 19:42:57 otto Exp $	*/
-/*	$NetBSD: types.h,v 1.29 1996/11/15 22:48:25 jtc Exp $	*/
+/*  $OpenBSD: types.h,v 1.31 2008/03/16 19:42:57 otto Exp $ */
+/*  $NetBSD: types.h,v 1.29 1996/11/15 22:48:25 jtc Exp $   */
 
 /*-
  * Copyright (c) 1982, 1986, 1991, 1993
@@ -34,7 +34,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- *	@(#)types.h	8.4 (Berkeley) 1/21/94
+ *  @(#)types.h 8.4 (Berkeley) 1/21/94
  */
 
 #ifndef _SYS_TYPES_H_
diff --git a/common/inc/sys/uio.h b/common/inc/sys/uio.h
index e3f33d1..14440b6 100644
--- a/common/inc/sys/uio.h
+++ b/common/inc/sys/uio.h
@@ -21,8 +21,8 @@
 /* Structure for scatter/gather I/O.  */
 struct iovec
 {
-    void *iov_base;	/* Pointer to data.  */
-    size_t iov_len;	/* Length of data.  */
+    void *iov_base; /* Pointer to data.  */
+    size_t iov_len; /* Length of data.  */
 };
 
 #endif
\ No newline at end of file
diff --git a/common/inc/time.h b/common/inc/time.h
index 29852c5..01cfd6e 100644
--- a/common/inc/time.h
+++ b/common/inc/time.h
@@ -1,5 +1,5 @@
-/*	$OpenBSD: time.h,v 1.18 2006/01/06 18:53:04 millert Exp $	*/
-/*	$NetBSD: time.h,v 1.9 1994/10/26 00:56:35 cgd Exp $	*/
+/*  $OpenBSD: time.h,v 1.18 2006/01/06 18:53:04 millert Exp $   */
+/*  $NetBSD: time.h,v 1.9 1994/10/26 00:56:35 cgd Exp $ */
 
 /*
  * Copyright (c) 1989 The Regents of the University of California.
@@ -35,7 +35,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- *	@(#)time.h	5.12 (Berkeley) 3/9/91
+ *  @(#)time.h  5.12 (Berkeley) 3/9/91
  */
 
 #ifndef _TIME_H_
diff --git a/common/inc/unistd.h b/common/inc/unistd.h
index 4da748a..2ab3a9a 100644
--- a/common/inc/unistd.h
+++ b/common/inc/unistd.h
@@ -1,5 +1,5 @@
-/*	$OpenBSD: unistd.h,v 1.62 2008/06/25 14:58:54 millert Exp $ */
-/*	$NetBSD: unistd.h,v 1.26.4.1 1996/05/28 02:31:51 mrg Exp $	*/
+/*  $OpenBSD: unistd.h,v 1.62 2008/06/25 14:58:54 millert Exp $ */
+/*  $NetBSD: unistd.h,v 1.26.4.1 1996/05/28 02:31:51 mrg Exp $  */
 
 /*-
  * Copyright (c) 1991 The Regents of the University of California.
@@ -29,7 +29,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- *	@(#)unistd.h	5.13 (Berkeley) 6/17/91
+ *  @(#)unistd.h    5.13 (Berkeley) 6/17/91
  */
 
 #ifndef _UNISTD_H_
diff --git a/common/inc/wchar.h b/common/inc/wchar.h
index 4ca0b39..5982aef 100644
--- a/common/inc/wchar.h
+++ b/common/inc/wchar.h
@@ -1,5 +1,5 @@
-/*	$OpenBSD: wchar.h,v 1.11 2010/07/24 09:58:39 guenther Exp $	*/
-/*	$NetBSD: wchar.h,v 1.16 2003/03/07 07:11:35 tshiozak Exp $	*/
+/*  $OpenBSD: wchar.h,v 1.11 2010/07/24 09:58:39 guenther Exp $ */
+/*  $NetBSD: wchar.h,v 1.16 2003/03/07 07:11:35 tshiozak Exp $  */
 
 /*-
  * Copyright (c)1999 Citrus Project,
diff --git a/common/inc/wctype.h b/common/inc/wctype.h
index 25466f1..fb421af 100644
--- a/common/inc/wctype.h
+++ b/common/inc/wctype.h
@@ -1,5 +1,5 @@
-/*	$OpenBSD: wctype.h,v 1.5 2006/01/06 18:53:04 millert Exp $	*/
-/*	$NetBSD: wctype.h,v 1.5 2003/03/02 22:18:11 tshiozak Exp $	*/
+/*  $OpenBSD: wctype.h,v 1.5 2006/01/06 18:53:04 millert Exp $  */
+/*  $NetBSD: wctype.h,v 1.5 2003/03/02 22:18:11 tshiozak Exp $  */
 
 /*-
  * Copyright (c)1999 Citrus Project,
@@ -26,7 +26,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- *	citrus Id: wctype.h,v 1.4 2000/12/21 01:50:21 itojun Exp
+ *  citrus Id: wctype.h,v 1.4 2000/12/21 01:50:21 itojun Exp
  */
 
 #ifndef _WCTYPE_H_
diff --git a/dockerfile/Dockerfile.centos7.nightly b/dockerfile/Dockerfile.centos7.nightly
index 63eb386..e5f2c7b 100644
--- a/dockerfile/Dockerfile.centos7.nightly
+++ b/dockerfile/Dockerfile.centos7.nightly
@@ -32,9 +32,9 @@
 FROM centos:7
 MAINTAINER Yu Ding
 
-ENV sdk_bin https://download.01.org/intel-sgx/linux-2.6/centos7.5-server/sgx_linux_x64_sdk_2.6.100.51363.bin
-ENV psw_deb https://download.01.org/intel-sgx/linux-2.6/centos7.5-server/sgx_linux_x64_psw_2.6.100.51363.bin
-ENV rust_toolchain nightly-2019-08-01
+ENV sdk_bin https://download.01.org/intel-sgx/latest/linux-latest/distro/centos7.5-server/sgx_linux_x64_sdk_2.7.100.4.bin
+ENV psw_deb https://download.01.org/intel-sgx/latest/linux-latest/distro/centos7.5-server/sgx_linux_x64_psw_2.7.100.4.bin
+ENV rust_toolchain nightly-2019-10-14
 ENV DEBIAN_FRONTEND=noninteractive
 
 RUN yum groupinstall -y 'Development Tools' && yum install -y ocaml ocaml-ocamlbuild wget python openssl-devel protobuf which
diff --git a/edl/sgx_net.edl b/edl/sgx_net.edl
index 6d6c33e..fd1a90f 100644
--- a/edl/sgx_net.edl
+++ b/edl/sgx_net.edl
@@ -31,6 +31,9 @@
 
 enclave {
 
+    include "sys/socket.h"
+    include "netdb.h"
+
     from "sgx_socket.edl" import *;
     from "sgx_asyncio.edl" import *;
     from "sgx_fd.edl" import *;
@@ -41,6 +44,8 @@ enclave {
     };
 
     untrusted {
-        /* define OCALLs here. */
+        int u_getaddrinfo_ocall([out]int * error,  [in, string] const char * node,  [in, string] const char * service, [in] const struct addrinfo * hints, [out] struct addrinfo ** res);
+        void u_freeaddrinfo_ocall([user_check] struct addrinfo *res);
+        char *u_gai_strerror_ocall(int errcode);
     };
 };
\ No newline at end of file
diff --git a/samplecode/backtrace/enclave/Xargo.toml b/samplecode/backtrace/enclave/Xargo.toml
index e974105..558d1d0 100644
--- a/samplecode/backtrace/enclave/Xargo.toml
+++ b/samplecode/backtrace/enclave/Xargo.toml
@@ -5,6 +5,14 @@ alloc = {}
 path = "../../../sgx_types"
 stage = 1
 
+[dependencies.sgx_alloc]
+path = "../../../sgx_alloc"
+stage = 1
+
+[dependencies.sgx_unwind]
+path = "../../../sgx_unwind"
+stage = 1
+
 [dependencies.sgx_demangle]
 path = "../../../sgx_demangle"
 stage = 1
@@ -41,9 +49,9 @@ stage = 3
 path = "../../../sgx_backtrace_sys"
 stage = 3
 
-[dependencies.sgx_unwind]
-path = "../../../sgx_unwind"
-stage = 4
+[dependencies.panic_unwind]
+path = "../../../sgx_panic_unwind"
+stage = 3
 
 [dependencies.sgx_tdh]
 path = "../../../sgx_tdh"
@@ -57,35 +65,31 @@ stage = 4
 path = "../../../sgx_tprotected_fs"
 stage = 4
 
-[dependencies.sgx_alloc]
-path = "../../../sgx_alloc"
-stage = 4
-
-[dependencies.panic_unwind]
-path = "../../../sgx_panic_unwind"
-stage = 5
-
 [dependencies.std]
 path = "../../../xargo/sgx_tstd"
 features = ["backtrace"]
-stage = 6
+stage = 5
+
+[dependencies.sgx_no_tstd]
+path = "../../../sgx_no_tstd"
+stage = 5
 
 [dependencies.sgx_rand]
 path = "../../../sgx_rand"
-stage = 7
+stage = 6
 
 [dependencies.sgx_serialize]
 path = "../../../sgx_serialize"
-stage = 7
+stage = 6
 
 [dependencies.sgx_tunittest]
 path = "../../../sgx_tunittest"
-stage = 7
+stage = 6
 
 [dependencies.sgx_backtrace]
 path = "../../../sgx_backtrace"
-stage = 8
+stage = 7
 
 [dependencies.sgx_cov]
 path = "../../../sgx_cov"
-stage = 8
\ No newline at end of file
+stage = 7
\ No newline at end of file
diff --git a/samplecode/crypto/enclave/Xargo.toml b/samplecode/crypto/enclave/Xargo.toml
index c088ebb..cb43640 100644
--- a/samplecode/crypto/enclave/Xargo.toml
+++ b/samplecode/crypto/enclave/Xargo.toml
@@ -5,6 +5,14 @@ alloc = {}
 path = "../../../sgx_types"
 stage = 1
 
+[dependencies.sgx_alloc]
+path = "../../../sgx_alloc"
+stage = 1
+
+[dependencies.sgx_unwind]
+path = "../../../sgx_unwind"
+stage = 1
+
 [dependencies.sgx_demangle]
 path = "../../../sgx_demangle"
 stage = 1
@@ -41,9 +49,9 @@ stage = 3
 path = "../../../sgx_backtrace_sys"
 stage = 3
 
-[dependencies.sgx_unwind]
-path = "../../../sgx_unwind"
-stage = 4
+[dependencies.panic_unwind]
+path = "../../../sgx_panic_unwind"
+stage = 3
 
 [dependencies.sgx_tdh]
 path = "../../../sgx_tdh"
@@ -57,34 +65,30 @@ stage = 4
 path = "../../../sgx_tprotected_fs"
 stage = 4
 
-[dependencies.sgx_alloc]
-path = "../../../sgx_alloc"
-stage = 4
-
-[dependencies.panic_unwind]
-path = "../../../sgx_panic_unwind"
-stage = 5
-
 [dependencies.std]
 path = "../../../xargo/sgx_tstd"
-stage = 6
+stage = 5
+
+[dependencies.sgx_no_tstd]
+path = "../../../sgx_no_tstd"
+stage = 5
 
 [dependencies.sgx_rand]
 path = "../../../sgx_rand"
-stage = 7
+stage = 6
 
 [dependencies.sgx_serialize]
 path = "../../../sgx_serialize"
-stage = 7
+stage = 6
 
 [dependencies.sgx_tunittest]
 path = "../../../sgx_tunittest"
-stage = 7
+stage = 6
 
 [dependencies.sgx_backtrace]
 path = "../../../sgx_backtrace"
-stage = 8
+stage = 7
 
 [dependencies.sgx_cov]
 path = "../../../sgx_cov"
-stage = 8
+stage = 7
diff --git a/samplecode/db-proxy/db-proxy/enclave/Xargo.toml b/samplecode/db-proxy/db-proxy/enclave/Xargo.toml
index cc955cd..6d4db74 100644
--- a/samplecode/db-proxy/db-proxy/enclave/Xargo.toml
+++ b/samplecode/db-proxy/db-proxy/enclave/Xargo.toml
@@ -5,6 +5,10 @@ alloc = {}
 path = "../../../../sgx_types"
 stage = 1
 
+[dependencies.sgx_alloc]
+path = "../../../../sgx_alloc"
+stage = 1
+
 [dependencies.sgx_demangle]
 path = "../../../../sgx_demangle"
 stage = 1
@@ -41,9 +45,9 @@ stage = 3
 path = "../../../../sgx_backtrace_sys"
 stage = 3
 
-[dependencies.sgx_unwind]
-path = "../../../../sgx_unwind"
-stage = 4
+[dependencies.panic_unwind]
+path = "../../../../sgx_panic_unwind"
+stage = 3
 
 [dependencies.sgx_tdh]
 path = "../../../../sgx_tdh"
@@ -57,34 +61,30 @@ stage = 4
 path = "../../../../sgx_tprotected_fs"
 stage = 4
 
-[dependencies.sgx_alloc]
-path = "../../../../sgx_alloc"
-stage = 4
-
-[dependencies.panic_unwind]
-path = "../../../../sgx_panic_unwind"
-stage = 5
-
 [dependencies.std]
 path = "../../../../xargo/sgx_tstd"
-stage = 6
+stage = 5
+
+[dependencies.sgx_no_tstd]
+path = "../../../../sgx_no_tstd"
+stage = 5
 
 [dependencies.sgx_rand]
 path = "../../../../sgx_rand"
-stage = 7
+stage = 6
 
 [dependencies.sgx_serialize]
 path = "../../../../sgx_serialize"
-stage = 7
+stage = 6
 
 [dependencies.sgx_tunittest]
 path = "../../../../sgx_tunittest"
-stage = 7
+stage = 6
 
 [dependencies.sgx_backtrace]
 path = "../../../../sgx_backtrace"
-stage = 8
+stage = 7
 
 [dependencies.sgx_cov]
 path = "../../../../sgx_cov"
-stage = 8
+stage = 7
diff --git a/samplecode/file/enclave/Xargo.toml b/samplecode/file/enclave/Xargo.toml
index c088ebb..cb43640 100644
--- a/samplecode/file/enclave/Xargo.toml
+++ b/samplecode/file/enclave/Xargo.toml
@@ -5,6 +5,14 @@ alloc = {}
 path = "../../../sgx_types"
 stage = 1
 
+[dependencies.sgx_alloc]
+path = "../../../sgx_alloc"
+stage = 1
+
+[dependencies.sgx_unwind]
+path = "../../../sgx_unwind"
+stage = 1
+
 [dependencies.sgx_demangle]
 path = "../../../sgx_demangle"
 stage = 1
@@ -41,9 +49,9 @@ stage = 3
 path = "../../../sgx_backtrace_sys"
 stage = 3
 
-[dependencies.sgx_unwind]
-path = "../../../sgx_unwind"
-stage = 4
+[dependencies.panic_unwind]
+path = "../../../sgx_panic_unwind"
+stage = 3
 
 [dependencies.sgx_tdh]
 path = "../../../sgx_tdh"
@@ -57,34 +65,30 @@ stage = 4
 path = "../../../sgx_tprotected_fs"
 stage = 4
 
-[dependencies.sgx_alloc]
-path = "../../../sgx_alloc"
-stage = 4
-
-[dependencies.panic_unwind]
-path = "../../../sgx_panic_unwind"
-stage = 5
-
 [dependencies.std]
 path = "../../../xargo/sgx_tstd"
-stage = 6
+stage = 5
+
+[dependencies.sgx_no_tstd]
+path = "../../../sgx_no_tstd"
+stage = 5
 
 [dependencies.sgx_rand]
 path = "../../../sgx_rand"
-stage = 7
+stage = 6
 
 [dependencies.sgx_serialize]
 path = "../../../sgx_serialize"
-stage = 7
+stage = 6
 
 [dependencies.sgx_tunittest]
 path = "../../../sgx_tunittest"
-stage = 7
+stage = 6
 
 [dependencies.sgx_backtrace]
 path = "../../../sgx_backtrace"
-stage = 8
+stage = 7
 
 [dependencies.sgx_cov]
 path = "../../../sgx_cov"
-stage = 8
+stage = 7
diff --git a/samplecode/hello-regex/enclave/Xargo.toml b/samplecode/hello-regex/enclave/Xargo.toml
index c088ebb..cb43640 100644
--- a/samplecode/hello-regex/enclave/Xargo.toml
+++ b/samplecode/hello-regex/enclave/Xargo.toml
@@ -5,6 +5,14 @@ alloc = {}
 path = "../../../sgx_types"
 stage = 1
 
+[dependencies.sgx_alloc]
+path = "../../../sgx_alloc"
+stage = 1
+
+[dependencies.sgx_unwind]
+path = "../../../sgx_unwind"
+stage = 1
+
 [dependencies.sgx_demangle]
 path = "../../../sgx_demangle"
 stage = 1
@@ -41,9 +49,9 @@ stage = 3
 path = "../../../sgx_backtrace_sys"
 stage = 3
 
-[dependencies.sgx_unwind]
-path = "../../../sgx_unwind"
-stage = 4
+[dependencies.panic_unwind]
+path = "../../../sgx_panic_unwind"
+stage = 3
 
 [dependencies.sgx_tdh]
 path = "../../../sgx_tdh"
@@ -57,34 +65,30 @@ stage = 4
 path = "../../../sgx_tprotected_fs"
 stage = 4
 
-[dependencies.sgx_alloc]
-path = "../../../sgx_alloc"
-stage = 4
-
-[dependencies.panic_unwind]
-path = "../../../sgx_panic_unwind"
-stage = 5
-
 [dependencies.std]
 path = "../../../xargo/sgx_tstd"
-stage = 6
+stage = 5
+
+[dependencies.sgx_no_tstd]
+path = "../../../sgx_no_tstd"
+stage = 5
 
 [dependencies.sgx_rand]
 path = "../../../sgx_rand"
-stage = 7
+stage = 6
 
 [dependencies.sgx_serialize]
 path = "../../../sgx_serialize"
-stage = 7
+stage = 6
 
 [dependencies.sgx_tunittest]
 path = "../../../sgx_tunittest"
-stage = 7
+stage = 6
 
 [dependencies.sgx_backtrace]
 path = "../../../sgx_backtrace"
-stage = 8
+stage = 7
 
 [dependencies.sgx_cov]
 path = "../../../sgx_cov"
-stage = 8
+stage = 7
diff --git a/samplecode/hello-rust-vscode-debug/enclave/Xargo.toml b/samplecode/hello-rust-vscode-debug/enclave/Xargo.toml
index c088ebb..cb43640 100644
--- a/samplecode/hello-rust-vscode-debug/enclave/Xargo.toml
+++ b/samplecode/hello-rust-vscode-debug/enclave/Xargo.toml
@@ -5,6 +5,14 @@ alloc = {}
 path = "../../../sgx_types"
 stage = 1
 
+[dependencies.sgx_alloc]
+path = "../../../sgx_alloc"
+stage = 1
+
+[dependencies.sgx_unwind]
+path = "../../../sgx_unwind"
+stage = 1
+
 [dependencies.sgx_demangle]
 path = "../../../sgx_demangle"
 stage = 1
@@ -41,9 +49,9 @@ stage = 3
 path = "../../../sgx_backtrace_sys"
 stage = 3
 
-[dependencies.sgx_unwind]
-path = "../../../sgx_unwind"
-stage = 4
+[dependencies.panic_unwind]
+path = "../../../sgx_panic_unwind"
+stage = 3
 
 [dependencies.sgx_tdh]
 path = "../../../sgx_tdh"
@@ -57,34 +65,30 @@ stage = 4
 path = "../../../sgx_tprotected_fs"
 stage = 4
 
-[dependencies.sgx_alloc]
-path = "../../../sgx_alloc"
-stage = 4
-
-[dependencies.panic_unwind]
-path = "../../../sgx_panic_unwind"
-stage = 5
-
 [dependencies.std]
 path = "../../../xargo/sgx_tstd"
-stage = 6
+stage = 5
+
+[dependencies.sgx_no_tstd]
+path = "../../../sgx_no_tstd"
+stage = 5
 
 [dependencies.sgx_rand]
 path = "../../../sgx_rand"
-stage = 7
+stage = 6
 
 [dependencies.sgx_serialize]
 path = "../../../sgx_serialize"
-stage = 7
+stage = 6
 
 [dependencies.sgx_tunittest]
 path = "../../../sgx_tunittest"
-stage = 7
+stage = 6
 
 [dependencies.sgx_backtrace]
 path = "../../../sgx_backtrace"
-stage = 8
+stage = 7
 
 [dependencies.sgx_cov]
 path = "../../../sgx_cov"
-stage = 8
+stage = 7
diff --git a/samplecode/hello-rust/enclave/Xargo.toml b/samplecode/hello-rust/enclave/Xargo.toml
index c088ebb..866117d 100644
--- a/samplecode/hello-rust/enclave/Xargo.toml
+++ b/samplecode/hello-rust/enclave/Xargo.toml
@@ -5,6 +5,14 @@ alloc = {}
 path = "../../../sgx_types"
 stage = 1
 
+[dependencies.sgx_alloc]
+path = "../../../sgx_alloc"
+stage = 1
+
+[dependencies.sgx_unwind]
+path = "../../../sgx_unwind"
+stage = 1
+
 [dependencies.sgx_demangle]
 path = "../../../sgx_demangle"
 stage = 1
@@ -41,9 +49,9 @@ stage = 3
 path = "../../../sgx_backtrace_sys"
 stage = 3
 
-[dependencies.sgx_unwind]
-path = "../../../sgx_unwind"
-stage = 4
+[dependencies.panic_unwind]
+path = "../../../sgx_panic_unwind"
+stage = 3
 
 [dependencies.sgx_tdh]
 path = "../../../sgx_tdh"
@@ -57,34 +65,31 @@ stage = 4
 path = "../../../sgx_tprotected_fs"
 stage = 4
 
-[dependencies.sgx_alloc]
-path = "../../../sgx_alloc"
-stage = 4
-
-[dependencies.panic_unwind]
-path = "../../../sgx_panic_unwind"
-stage = 5
-
 [dependencies.std]
 path = "../../../xargo/sgx_tstd"
-stage = 6
+stage = 5
+features = ["backtrace"]
+
+[dependencies.sgx_no_tstd]
+path = "../../../sgx_no_tstd"
+stage = 5
 
 [dependencies.sgx_rand]
 path = "../../../sgx_rand"
-stage = 7
+stage = 6
 
 [dependencies.sgx_serialize]
 path = "../../../sgx_serialize"
-stage = 7
+stage = 6
 
 [dependencies.sgx_tunittest]
 path = "../../../sgx_tunittest"
-stage = 7
+stage = 6
 
 [dependencies.sgx_backtrace]
 path = "../../../sgx_backtrace"
-stage = 8
+stage = 7
 
 [dependencies.sgx_cov]
 path = "../../../sgx_cov"
-stage = 8
+stage = 7
diff --git a/samplecode/helloworld/enclave/Xargo.toml b/samplecode/helloworld/enclave/Xargo.toml
index c088ebb..cb43640 100644
--- a/samplecode/helloworld/enclave/Xargo.toml
+++ b/samplecode/helloworld/enclave/Xargo.toml
@@ -5,6 +5,14 @@ alloc = {}
 path = "../../../sgx_types"
 stage = 1
 
+[dependencies.sgx_alloc]
+path = "../../../sgx_alloc"
+stage = 1
+
+[dependencies.sgx_unwind]
+path = "../../../sgx_unwind"
+stage = 1
+
 [dependencies.sgx_demangle]
 path = "../../../sgx_demangle"
 stage = 1
@@ -41,9 +49,9 @@ stage = 3
 path = "../../../sgx_backtrace_sys"
 stage = 3
 
-[dependencies.sgx_unwind]
-path = "../../../sgx_unwind"
-stage = 4
+[dependencies.panic_unwind]
+path = "../../../sgx_panic_unwind"
+stage = 3
 
 [dependencies.sgx_tdh]
 path = "../../../sgx_tdh"
@@ -57,34 +65,30 @@ stage = 4
 path = "../../../sgx_tprotected_fs"
 stage = 4
 
-[dependencies.sgx_alloc]
-path = "../../../sgx_alloc"
-stage = 4
-
-[dependencies.panic_unwind]
-path = "../../../sgx_panic_unwind"
-stage = 5
-
 [dependencies.std]
 path = "../../../xargo/sgx_tstd"
-stage = 6
+stage = 5
+
+[dependencies.sgx_no_tstd]
+path = "../../../sgx_no_tstd"
+stage = 5
 
 [dependencies.sgx_rand]
 path = "../../../sgx_rand"
-stage = 7
+stage = 6
 
 [dependencies.sgx_serialize]
 path = "../../../sgx_serialize"
-stage = 7
+stage = 6
 
 [dependencies.sgx_tunittest]
 path = "../../../sgx_tunittest"
-stage = 7
+stage = 6
 
 [dependencies.sgx_backtrace]
 path = "../../../sgx_backtrace"
-stage = 8
+stage = 7
 
 [dependencies.sgx_cov]
 path = "../../../sgx_cov"
-stage = 8
+stage = 7
diff --git a/samplecode/http_req/enclave/Xargo.toml b/samplecode/http_req/enclave/Xargo.toml
index 001c383..c3fc4df 100644
--- a/samplecode/http_req/enclave/Xargo.toml
+++ b/samplecode/http_req/enclave/Xargo.toml
@@ -5,6 +5,14 @@ alloc = {}
 path = "../../../sgx_types"
 stage = 1
 
+[dependencies.sgx_alloc]
+path = "../../../sgx_alloc"
+stage = 1
+
+[dependencies.sgx_unwind]
+path = "../../../sgx_unwind"
+stage = 1
+
 [dependencies.sgx_demangle]
 path = "../../../sgx_demangle"
 stage = 1
@@ -41,9 +49,9 @@ stage = 3
 path = "../../../sgx_backtrace_sys"
 stage = 3
 
-[dependencies.sgx_unwind]
-path = "../../../sgx_unwind"
-stage = 4
+[dependencies.panic_unwind]
+path = "../../../sgx_panic_unwind"
+stage = 3
 
 [dependencies.sgx_tdh]
 path = "../../../sgx_tdh"
@@ -57,35 +65,31 @@ stage = 4
 path = "../../../sgx_tprotected_fs"
 stage = 4
 
-[dependencies.sgx_alloc]
-path = "../../../sgx_alloc"
-stage = 4
-
-[dependencies.panic_unwind]
-path = "../../../sgx_panic_unwind"
-stage = 5
-
 [dependencies.std]
 path = "../../../xargo/sgx_tstd"
 features = ["net"]
-stage = 6
+stage = 5
+
+[dependencies.sgx_no_tstd]
+path = "../../../sgx_no_tstd"
+stage = 5
 
 [dependencies.sgx_rand]
 path = "../../../sgx_rand"
-stage = 7
+stage = 6
 
 [dependencies.sgx_serialize]
 path = "../../../sgx_serialize"
-stage = 7
+stage = 6
 
 [dependencies.sgx_tunittest]
 path = "../../../sgx_tunittest"
-stage = 7
+stage = 6
 
 [dependencies.sgx_backtrace]
 path = "../../../sgx_backtrace"
-stage = 8
+stage = 7
 
 [dependencies.sgx_cov]
 path = "../../../sgx_cov"
-stage = 8
+stage = 7
diff --git a/samplecode/hugemem/enclave/Xargo.toml b/samplecode/hugemem/enclave/Xargo.toml
index c088ebb..cb43640 100644
--- a/samplecode/hugemem/enclave/Xargo.toml
+++ b/samplecode/hugemem/enclave/Xargo.toml
@@ -5,6 +5,14 @@ alloc = {}
 path = "../../../sgx_types"
 stage = 1
 
+[dependencies.sgx_alloc]
+path = "../../../sgx_alloc"
+stage = 1
+
+[dependencies.sgx_unwind]
+path = "../../../sgx_unwind"
+stage = 1
+
 [dependencies.sgx_demangle]
 path = "../../../sgx_demangle"
 stage = 1
@@ -41,9 +49,9 @@ stage = 3
 path = "../../../sgx_backtrace_sys"
 stage = 3
 
-[dependencies.sgx_unwind]
-path = "../../../sgx_unwind"
-stage = 4
+[dependencies.panic_unwind]
+path = "../../../sgx_panic_unwind"
+stage = 3
 
 [dependencies.sgx_tdh]
 path = "../../../sgx_tdh"
@@ -57,34 +65,30 @@ stage = 4
 path = "../../../sgx_tprotected_fs"
 stage = 4
 
-[dependencies.sgx_alloc]
-path = "../../../sgx_alloc"
-stage = 4
-
-[dependencies.panic_unwind]
-path = "../../../sgx_panic_unwind"
-stage = 5
-
 [dependencies.std]
 path = "../../../xargo/sgx_tstd"
-stage = 6
+stage = 5
+
+[dependencies.sgx_no_tstd]
+path = "../../../sgx_no_tstd"
+stage = 5
 
 [dependencies.sgx_rand]
 path = "../../../sgx_rand"
-stage = 7
+stage = 6
 
 [dependencies.sgx_serialize]
 path = "../../../sgx_serialize"
-stage = 7
+stage = 6
 
 [dependencies.sgx_tunittest]
 path = "../../../sgx_tunittest"
-stage = 7
+stage = 6
 
 [dependencies.sgx_backtrace]
 path = "../../../sgx_backtrace"
-stage = 8
+stage = 7
 
 [dependencies.sgx_cov]
 path = "../../../sgx_cov"
-stage = 8
+stage = 7
diff --git a/samplecode/kvdb-memdb/enclave/Xargo.toml b/samplecode/kvdb-memdb/enclave/Xargo.toml
index c088ebb..cb43640 100644
--- a/samplecode/kvdb-memdb/enclave/Xargo.toml
+++ b/samplecode/kvdb-memdb/enclave/Xargo.toml
@@ -5,6 +5,14 @@ alloc = {}
 path = "../../../sgx_types"
 stage = 1
 
+[dependencies.sgx_alloc]
+path = "../../../sgx_alloc"
+stage = 1
+
+[dependencies.sgx_unwind]
+path = "../../../sgx_unwind"
+stage = 1
+
 [dependencies.sgx_demangle]
 path = "../../../sgx_demangle"
 stage = 1
@@ -41,9 +49,9 @@ stage = 3
 path = "../../../sgx_backtrace_sys"
 stage = 3
 
-[dependencies.sgx_unwind]
-path = "../../../sgx_unwind"
-stage = 4
+[dependencies.panic_unwind]
+path = "../../../sgx_panic_unwind"
+stage = 3
 
 [dependencies.sgx_tdh]
 path = "../../../sgx_tdh"
@@ -57,34 +65,30 @@ stage = 4
 path = "../../../sgx_tprotected_fs"
 stage = 4
 
-[dependencies.sgx_alloc]
-path = "../../../sgx_alloc"
-stage = 4
-
-[dependencies.panic_unwind]
-path = "../../../sgx_panic_unwind"
-stage = 5
-
 [dependencies.std]
 path = "../../../xargo/sgx_tstd"
-stage = 6
+stage = 5
+
+[dependencies.sgx_no_tstd]
+path = "../../../sgx_no_tstd"
+stage = 5
 
 [dependencies.sgx_rand]
 path = "../../../sgx_rand"
-stage = 7
+stage = 6
 
 [dependencies.sgx_serialize]
 path = "../../../sgx_serialize"
-stage = 7
+stage = 6
 
 [dependencies.sgx_tunittest]
 path = "../../../sgx_tunittest"
-stage = 7
+stage = 6
 
 [dependencies.sgx_backtrace]
 path = "../../../sgx_backtrace"
-stage = 8
+stage = 7
 
 [dependencies.sgx_cov]
 path = "../../../sgx_cov"
-stage = 8
+stage = 7
diff --git a/samplecode/localattestation/attestation/Xargo.toml b/samplecode/localattestation/attestation/Xargo.toml
index c088ebb..cb43640 100644
--- a/samplecode/localattestation/attestation/Xargo.toml
+++ b/samplecode/localattestation/attestation/Xargo.toml
@@ -5,6 +5,14 @@ alloc = {}
 path = "../../../sgx_types"
 stage = 1
 
+[dependencies.sgx_alloc]
+path = "../../../sgx_alloc"
+stage = 1
+
+[dependencies.sgx_unwind]
+path = "../../../sgx_unwind"
+stage = 1
+
 [dependencies.sgx_demangle]
 path = "../../../sgx_demangle"
 stage = 1
@@ -41,9 +49,9 @@ stage = 3
 path = "../../../sgx_backtrace_sys"
 stage = 3
 
-[dependencies.sgx_unwind]
-path = "../../../sgx_unwind"
-stage = 4
+[dependencies.panic_unwind]
+path = "../../../sgx_panic_unwind"
+stage = 3
 
 [dependencies.sgx_tdh]
 path = "../../../sgx_tdh"
@@ -57,34 +65,30 @@ stage = 4
 path = "../../../sgx_tprotected_fs"
 stage = 4
 
-[dependencies.sgx_alloc]
-path = "../../../sgx_alloc"
-stage = 4
-
-[dependencies.panic_unwind]
-path = "../../../sgx_panic_unwind"
-stage = 5
-
 [dependencies.std]
 path = "../../../xargo/sgx_tstd"
-stage = 6
+stage = 5
+
+[dependencies.sgx_no_tstd]
+path = "../../../sgx_no_tstd"
+stage = 5
 
 [dependencies.sgx_rand]
 path = "../../../sgx_rand"
-stage = 7
+stage = 6
 
 [dependencies.sgx_serialize]
 path = "../../../sgx_serialize"
-stage = 7
+stage = 6
 
 [dependencies.sgx_tunittest]
 path = "../../../sgx_tunittest"
-stage = 7
+stage = 6
 
 [dependencies.sgx_backtrace]
 path = "../../../sgx_backtrace"
-stage = 8
+stage = 7
 
 [dependencies.sgx_cov]
 path = "../../../sgx_cov"
-stage = 8
+stage = 7
diff --git a/samplecode/localattestation/enclave1/Xargo.toml b/samplecode/localattestation/enclave1/Xargo.toml
index c088ebb..b157608 100644
--- a/samplecode/localattestation/enclave1/Xargo.toml
+++ b/samplecode/localattestation/enclave1/Xargo.toml
@@ -5,6 +5,14 @@ alloc = {}
 path = "../../../sgx_types"
 stage = 1
 
+[dependencies.sgx_alloc]
+path = "../../../sgx_alloc"
+stage = 1
+
+[dependencies.sgx_unwind]
+path = "../../../sgx_unwind"
+stage = 1
+
 [dependencies.sgx_demangle]
 path = "../../../sgx_demangle"
 stage = 1
@@ -41,9 +49,9 @@ stage = 3
 path = "../../../sgx_backtrace_sys"
 stage = 3
 
-[dependencies.sgx_unwind]
-path = "../../../sgx_unwind"
-stage = 4
+[dependencies.panic_unwind]
+path = "../../../sgx_panic_unwind"
+stage = 3
 
 [dependencies.sgx_tdh]
 path = "../../../sgx_tdh"
@@ -57,34 +65,30 @@ stage = 4
 path = "../../../sgx_tprotected_fs"
 stage = 4
 
-[dependencies.sgx_alloc]
-path = "../../../sgx_alloc"
-stage = 4
-
-[dependencies.panic_unwind]
-path = "../../../sgx_panic_unwind"
-stage = 5
-
 [dependencies.std]
 path = "../../../xargo/sgx_tstd"
-stage = 6
+stage = 5
+
+[dependencies.sgx_no_tstd]
+path = "../../../sgx_no_tstd"
+stage = 5
 
 [dependencies.sgx_rand]
 path = "../../../sgx_rand"
-stage = 7
+stage = 6
 
 [dependencies.sgx_serialize]
 path = "../../../sgx_serialize"
-stage = 7
+stage = 6
 
 [dependencies.sgx_tunittest]
 path = "../../../sgx_tunittest"
-stage = 7
+stage = 6
 
 [dependencies.sgx_backtrace]
 path = "../../../sgx_backtrace"
-stage = 8
+stage = 7
 
 [dependencies.sgx_cov]
 path = "../../../sgx_cov"
-stage = 8
+stage = 7
\ No newline at end of file
diff --git a/samplecode/localattestation/enclave2/Xargo.toml b/samplecode/localattestation/enclave2/Xargo.toml
index c088ebb..b157608 100644
--- a/samplecode/localattestation/enclave2/Xargo.toml
+++ b/samplecode/localattestation/enclave2/Xargo.toml
@@ -5,6 +5,14 @@ alloc = {}
 path = "../../../sgx_types"
 stage = 1
 
+[dependencies.sgx_alloc]
+path = "../../../sgx_alloc"
+stage = 1
+
+[dependencies.sgx_unwind]
+path = "../../../sgx_unwind"
+stage = 1
+
 [dependencies.sgx_demangle]
 path = "../../../sgx_demangle"
 stage = 1
@@ -41,9 +49,9 @@ stage = 3
 path = "../../../sgx_backtrace_sys"
 stage = 3
 
-[dependencies.sgx_unwind]
-path = "../../../sgx_unwind"
-stage = 4
+[dependencies.panic_unwind]
+path = "../../../sgx_panic_unwind"
+stage = 3
 
 [dependencies.sgx_tdh]
 path = "../../../sgx_tdh"
@@ -57,34 +65,30 @@ stage = 4
 path = "../../../sgx_tprotected_fs"
 stage = 4
 
-[dependencies.sgx_alloc]
-path = "../../../sgx_alloc"
-stage = 4
-
-[dependencies.panic_unwind]
-path = "../../../sgx_panic_unwind"
-stage = 5
-
 [dependencies.std]
 path = "../../../xargo/sgx_tstd"
-stage = 6
+stage = 5
+
+[dependencies.sgx_no_tstd]
+path = "../../../sgx_no_tstd"
+stage = 5
 
 [dependencies.sgx_rand]
 path = "../../../sgx_rand"
-stage = 7
+stage = 6
 
 [dependencies.sgx_serialize]
 path = "../../../sgx_serialize"
-stage = 7
+stage = 6
 
 [dependencies.sgx_tunittest]
 path = "../../../sgx_tunittest"
-stage = 7
+stage = 6
 
 [dependencies.sgx_backtrace]
 path = "../../../sgx_backtrace"
-stage = 8
+stage = 7
 
 [dependencies.sgx_cov]
 path = "../../../sgx_cov"
-stage = 8
+stage = 7
\ No newline at end of file
diff --git a/samplecode/localattestation/enclave3/Xargo.toml b/samplecode/localattestation/enclave3/Xargo.toml
index c088ebb..b157608 100644
--- a/samplecode/localattestation/enclave3/Xargo.toml
+++ b/samplecode/localattestation/enclave3/Xargo.toml
@@ -5,6 +5,14 @@ alloc = {}
 path = "../../../sgx_types"
 stage = 1
 
+[dependencies.sgx_alloc]
+path = "../../../sgx_alloc"
+stage = 1
+
+[dependencies.sgx_unwind]
+path = "../../../sgx_unwind"
+stage = 1
+
 [dependencies.sgx_demangle]
 path = "../../../sgx_demangle"
 stage = 1
@@ -41,9 +49,9 @@ stage = 3
 path = "../../../sgx_backtrace_sys"
 stage = 3
 
-[dependencies.sgx_unwind]
-path = "../../../sgx_unwind"
-stage = 4
+[dependencies.panic_unwind]
+path = "../../../sgx_panic_unwind"
+stage = 3
 
 [dependencies.sgx_tdh]
 path = "../../../sgx_tdh"
@@ -57,34 +65,30 @@ stage = 4
 path = "../../../sgx_tprotected_fs"
 stage = 4
 
-[dependencies.sgx_alloc]
-path = "../../../sgx_alloc"
-stage = 4
-
-[dependencies.panic_unwind]
-path = "../../../sgx_panic_unwind"
-stage = 5
-
 [dependencies.std]
 path = "../../../xargo/sgx_tstd"
-stage = 6
+stage = 5
+
+[dependencies.sgx_no_tstd]
+path = "../../../sgx_no_tstd"
+stage = 5
 
 [dependencies.sgx_rand]
 path = "../../../sgx_rand"
-stage = 7
+stage = 6
 
 [dependencies.sgx_serialize]
 path = "../../../sgx_serialize"
-stage = 7
+stage = 6
 
 [dependencies.sgx_tunittest]
 path = "../../../sgx_tunittest"
-stage = 7
+stage = 6
 
 [dependencies.sgx_backtrace]
 path = "../../../sgx_backtrace"
-stage = 8
+stage = 7
 
 [dependencies.sgx_cov]
 path = "../../../sgx_cov"
-stage = 8
+stage = 7
\ No newline at end of file
diff --git a/samplecode/logger/enclave/Xargo.toml b/samplecode/logger/enclave/Xargo.toml
index c088ebb..b157608 100644
--- a/samplecode/logger/enclave/Xargo.toml
+++ b/samplecode/logger/enclave/Xargo.toml
@@ -5,6 +5,14 @@ alloc = {}
 path = "../../../sgx_types"
 stage = 1
 
+[dependencies.sgx_alloc]
+path = "../../../sgx_alloc"
+stage = 1
+
+[dependencies.sgx_unwind]
+path = "../../../sgx_unwind"
+stage = 1
+
 [dependencies.sgx_demangle]
 path = "../../../sgx_demangle"
 stage = 1
@@ -41,9 +49,9 @@ stage = 3
 path = "../../../sgx_backtrace_sys"
 stage = 3
 
-[dependencies.sgx_unwind]
-path = "../../../sgx_unwind"
-stage = 4
+[dependencies.panic_unwind]
+path = "../../../sgx_panic_unwind"
+stage = 3
 
 [dependencies.sgx_tdh]
 path = "../../../sgx_tdh"
@@ -57,34 +65,30 @@ stage = 4
 path = "../../../sgx_tprotected_fs"
 stage = 4
 
-[dependencies.sgx_alloc]
-path = "../../../sgx_alloc"
-stage = 4
-
-[dependencies.panic_unwind]
-path = "../../../sgx_panic_unwind"
-stage = 5
-
 [dependencies.std]
 path = "../../../xargo/sgx_tstd"
-stage = 6
+stage = 5
+
+[dependencies.sgx_no_tstd]
+path = "../../../sgx_no_tstd"
+stage = 5
 
 [dependencies.sgx_rand]
 path = "../../../sgx_rand"
-stage = 7
+stage = 6
 
 [dependencies.sgx_serialize]
 path = "../../../sgx_serialize"
-stage = 7
+stage = 6
 
 [dependencies.sgx_tunittest]
 path = "../../../sgx_tunittest"
-stage = 7
+stage = 6
 
 [dependencies.sgx_backtrace]
 path = "../../../sgx_backtrace"
-stage = 8
+stage = 7
 
 [dependencies.sgx_cov]
 path = "../../../sgx_cov"
-stage = 8
+stage = 7
\ No newline at end of file
diff --git a/samplecode/machine-learning/enclave/Xargo.toml b/samplecode/machine-learning/enclave/Xargo.toml
index c088ebb..b157608 100644
--- a/samplecode/machine-learning/enclave/Xargo.toml
+++ b/samplecode/machine-learning/enclave/Xargo.toml
@@ -5,6 +5,14 @@ alloc = {}
 path = "../../../sgx_types"
 stage = 1
 
+[dependencies.sgx_alloc]
+path = "../../../sgx_alloc"
+stage = 1
+
+[dependencies.sgx_unwind]
+path = "../../../sgx_unwind"
+stage = 1
+
 [dependencies.sgx_demangle]
 path = "../../../sgx_demangle"
 stage = 1
@@ -41,9 +49,9 @@ stage = 3
 path = "../../../sgx_backtrace_sys"
 stage = 3
 
-[dependencies.sgx_unwind]
-path = "../../../sgx_unwind"
-stage = 4
+[dependencies.panic_unwind]
+path = "../../../sgx_panic_unwind"
+stage = 3
 
 [dependencies.sgx_tdh]
 path = "../../../sgx_tdh"
@@ -57,34 +65,30 @@ stage = 4
 path = "../../../sgx_tprotected_fs"
 stage = 4
 
-[dependencies.sgx_alloc]
-path = "../../../sgx_alloc"
-stage = 4
-
-[dependencies.panic_unwind]
-path = "../../../sgx_panic_unwind"
-stage = 5
-
 [dependencies.std]
 path = "../../../xargo/sgx_tstd"
-stage = 6
+stage = 5
+
+[dependencies.sgx_no_tstd]
+path = "../../../sgx_no_tstd"
+stage = 5
 
 [dependencies.sgx_rand]
 path = "../../../sgx_rand"
-stage = 7
+stage = 6
 
 [dependencies.sgx_serialize]
 path = "../../../sgx_serialize"
-stage = 7
+stage = 6
 
 [dependencies.sgx_tunittest]
 path = "../../../sgx_tunittest"
-stage = 7
+stage = 6
 
 [dependencies.sgx_backtrace]
 path = "../../../sgx_backtrace"
-stage = 8
+stage = 7
 
 [dependencies.sgx_cov]
 path = "../../../sgx_cov"
-stage = 8
+stage = 7
\ No newline at end of file
diff --git a/samplecode/mio/client/enclave/Xargo.toml b/samplecode/mio/client/enclave/Xargo.toml
index 8177578..780a570 100644
--- a/samplecode/mio/client/enclave/Xargo.toml
+++ b/samplecode/mio/client/enclave/Xargo.toml
@@ -5,6 +5,14 @@ alloc = {}
 path = "../../../../sgx_types"
 stage = 1
 
+[dependencies.sgx_alloc]
+path = "../../../../sgx_alloc"
+stage = 1
+
+[dependencies.sgx_unwind]
+path = "../../../../sgx_unwind"
+stage = 1
+
 [dependencies.sgx_demangle]
 path = "../../../../sgx_demangle"
 stage = 1
@@ -41,9 +49,9 @@ stage = 3
 path = "../../../../sgx_backtrace_sys"
 stage = 3
 
-[dependencies.sgx_unwind]
-path = "../../../../sgx_unwind"
-stage = 4
+[dependencies.panic_unwind]
+path = "../../../../sgx_panic_unwind"
+stage = 3
 
 [dependencies.sgx_tdh]
 path = "../../../../sgx_tdh"
@@ -57,35 +65,31 @@ stage = 4
 path = "../../../../sgx_tprotected_fs"
 stage = 4
 
-[dependencies.sgx_alloc]
-path = "../../../../sgx_alloc"
-stage = 4
-
-[dependencies.panic_unwind]
-path = "../../../../sgx_panic_unwind"
-stage = 5
-
 [dependencies.std]
 path = "../../../../xargo/sgx_tstd"
 features = ["net"]
-stage = 6
+stage = 5
+
+[dependencies.sgx_no_tstd]
+path = "../../../../sgx_no_tstd"
+stage = 5
 
 [dependencies.sgx_rand]
 path = "../../../../sgx_rand"
-stage = 7
+stage = 6
 
 [dependencies.sgx_serialize]
 path = "../../../../sgx_serialize"
-stage = 7
+stage = 6
 
 [dependencies.sgx_tunittest]
 path = "../../../../sgx_tunittest"
-stage = 7
+stage = 6
 
 [dependencies.sgx_backtrace]
 path = "../../../../sgx_backtrace"
-stage = 8
+stage = 7
 
 [dependencies.sgx_cov]
 path = "../../../../sgx_cov"
-stage = 8
+stage = 7
\ No newline at end of file
diff --git a/samplecode/mio/server/enclave/Xargo.toml b/samplecode/mio/server/enclave/Xargo.toml
index 8177578..780a570 100644
--- a/samplecode/mio/server/enclave/Xargo.toml
+++ b/samplecode/mio/server/enclave/Xargo.toml
@@ -5,6 +5,14 @@ alloc = {}
 path = "../../../../sgx_types"
 stage = 1
 
+[dependencies.sgx_alloc]
+path = "../../../../sgx_alloc"
+stage = 1
+
+[dependencies.sgx_unwind]
+path = "../../../../sgx_unwind"
+stage = 1
+
 [dependencies.sgx_demangle]
 path = "../../../../sgx_demangle"
 stage = 1
@@ -41,9 +49,9 @@ stage = 3
 path = "../../../../sgx_backtrace_sys"
 stage = 3
 
-[dependencies.sgx_unwind]
-path = "../../../../sgx_unwind"
-stage = 4
+[dependencies.panic_unwind]
+path = "../../../../sgx_panic_unwind"
+stage = 3
 
 [dependencies.sgx_tdh]
 path = "../../../../sgx_tdh"
@@ -57,35 +65,31 @@ stage = 4
 path = "../../../../sgx_tprotected_fs"
 stage = 4
 
-[dependencies.sgx_alloc]
-path = "../../../../sgx_alloc"
-stage = 4
-
-[dependencies.panic_unwind]
-path = "../../../../sgx_panic_unwind"
-stage = 5
-
 [dependencies.std]
 path = "../../../../xargo/sgx_tstd"
 features = ["net"]
-stage = 6
+stage = 5
+
+[dependencies.sgx_no_tstd]
+path = "../../../../sgx_no_tstd"
+stage = 5
 
 [dependencies.sgx_rand]
 path = "../../../../sgx_rand"
-stage = 7
+stage = 6
 
 [dependencies.sgx_serialize]
 path = "../../../../sgx_serialize"
-stage = 7
+stage = 6
 
 [dependencies.sgx_tunittest]
 path = "../../../../sgx_tunittest"
-stage = 7
+stage = 6
 
 [dependencies.sgx_backtrace]
 path = "../../../../sgx_backtrace"
-stage = 8
+stage = 7
 
 [dependencies.sgx_cov]
 path = "../../../../sgx_cov"
-stage = 8
+stage = 7
\ No newline at end of file
diff --git a/samplecode/mutual-ra/enclave/Xargo.toml b/samplecode/mutual-ra/enclave/Xargo.toml
index 00c3334..a057ba7 100644
--- a/samplecode/mutual-ra/enclave/Xargo.toml
+++ b/samplecode/mutual-ra/enclave/Xargo.toml
@@ -5,6 +5,14 @@ alloc = {}
 path = "../../../sgx_types"
 stage = 1
 
+[dependencies.sgx_alloc]
+path = "../../../sgx_alloc"
+stage = 1
+
+[dependencies.sgx_unwind]
+path = "../../../sgx_unwind"
+stage = 1
+
 [dependencies.sgx_demangle]
 path = "../../../sgx_demangle"
 stage = 1
@@ -41,9 +49,9 @@ stage = 3
 path = "../../../sgx_backtrace_sys"
 stage = 3
 
-[dependencies.sgx_unwind]
-path = "../../../sgx_unwind"
-stage = 4
+[dependencies.panic_unwind]
+path = "../../../sgx_panic_unwind"
+stage = 3
 
 [dependencies.sgx_tdh]
 path = "../../../sgx_tdh"
@@ -57,35 +65,31 @@ stage = 4
 path = "../../../sgx_tprotected_fs"
 stage = 4
 
-[dependencies.sgx_alloc]
-path = "../../../sgx_alloc"
-stage = 4
-
-[dependencies.panic_unwind]
-path = "../../../sgx_panic_unwind"
-stage = 5
-
 [dependencies.std]
 path = "../../../xargo/sgx_tstd"
 features = ["backtrace", "net"]
-stage = 6
+stage = 5
+
+[dependencies.sgx_no_tstd]
+path = "../../../sgx_no_tstd"
+stage = 5
 
 [dependencies.sgx_rand]
 path = "../../../sgx_rand"
-stage = 7
+stage = 6
 
 [dependencies.sgx_serialize]
 path = "../../../sgx_serialize"
-stage = 7
+stage = 6
 
 [dependencies.sgx_tunittest]
 path = "../../../sgx_tunittest"
-stage = 7
+stage = 6
 
 [dependencies.sgx_backtrace]
 path = "../../../sgx_backtrace"
-stage = 8
+stage = 7
 
 [dependencies.sgx_cov]
 path = "../../../sgx_cov"
-stage = 8
+stage = 7
\ No newline at end of file
diff --git a/samplecode/net2/enclave/Xargo.toml b/samplecode/net2/enclave/Xargo.toml
index 001c383..5400ea8 100644
--- a/samplecode/net2/enclave/Xargo.toml
+++ b/samplecode/net2/enclave/Xargo.toml
@@ -5,6 +5,14 @@ alloc = {}
 path = "../../../sgx_types"
 stage = 1
 
+[dependencies.sgx_alloc]
+path = "../../../sgx_alloc"
+stage = 1
+
+[dependencies.sgx_unwind]
+path = "../../../sgx_unwind"
+stage = 1
+
 [dependencies.sgx_demangle]
 path = "../../../sgx_demangle"
 stage = 1
@@ -41,9 +49,9 @@ stage = 3
 path = "../../../sgx_backtrace_sys"
 stage = 3
 
-[dependencies.sgx_unwind]
-path = "../../../sgx_unwind"
-stage = 4
+[dependencies.panic_unwind]
+path = "../../../sgx_panic_unwind"
+stage = 3
 
 [dependencies.sgx_tdh]
 path = "../../../sgx_tdh"
@@ -57,35 +65,31 @@ stage = 4
 path = "../../../sgx_tprotected_fs"
 stage = 4
 
-[dependencies.sgx_alloc]
-path = "../../../sgx_alloc"
-stage = 4
-
-[dependencies.panic_unwind]
-path = "../../../sgx_panic_unwind"
-stage = 5
-
 [dependencies.std]
 path = "../../../xargo/sgx_tstd"
 features = ["net"]
-stage = 6
+stage = 5
+
+[dependencies.sgx_no_tstd]
+path = "../../../sgx_no_tstd"
+stage = 5
 
 [dependencies.sgx_rand]
 path = "../../../sgx_rand"
-stage = 7
+stage = 6
 
 [dependencies.sgx_serialize]
 path = "../../../sgx_serialize"
-stage = 7
+stage = 6
 
 [dependencies.sgx_tunittest]
 path = "../../../sgx_tunittest"
-stage = 7
+stage = 6
 
 [dependencies.sgx_backtrace]
 path = "../../../sgx_backtrace"
-stage = 8
+stage = 7
 
 [dependencies.sgx_cov]
 path = "../../../sgx_cov"
-stage = 8
+stage = 7
\ No newline at end of file
diff --git a/samplecode/pcl/encrypted-hello/enclave/Xargo.toml b/samplecode/pcl/encrypted-hello/enclave/Xargo.toml
index cc955cd..74ddc1e 100644
--- a/samplecode/pcl/encrypted-hello/enclave/Xargo.toml
+++ b/samplecode/pcl/encrypted-hello/enclave/Xargo.toml
@@ -5,6 +5,14 @@ alloc = {}
 path = "../../../../sgx_types"
 stage = 1
 
+[dependencies.sgx_alloc]
+path = "../../../../sgx_alloc"
+stage = 1
+
+[dependencies.sgx_unwind]
+path = "../../../../sgx_unwind"
+stage = 1
+
 [dependencies.sgx_demangle]
 path = "../../../../sgx_demangle"
 stage = 1
@@ -41,9 +49,9 @@ stage = 3
 path = "../../../../sgx_backtrace_sys"
 stage = 3
 
-[dependencies.sgx_unwind]
-path = "../../../../sgx_unwind"
-stage = 4
+[dependencies.panic_unwind]
+path = "../../../../sgx_panic_unwind"
+stage = 3
 
 [dependencies.sgx_tdh]
 path = "../../../../sgx_tdh"
@@ -57,34 +65,30 @@ stage = 4
 path = "../../../../sgx_tprotected_fs"
 stage = 4
 
-[dependencies.sgx_alloc]
-path = "../../../../sgx_alloc"
-stage = 4
-
-[dependencies.panic_unwind]
-path = "../../../../sgx_panic_unwind"
-stage = 5
-
 [dependencies.std]
 path = "../../../../xargo/sgx_tstd"
-stage = 6
+stage = 5
+
+[dependencies.sgx_no_tstd]
+path = "../../../../sgx_no_tstd"
+stage = 5
 
 [dependencies.sgx_rand]
 path = "../../../../sgx_rand"
-stage = 7
+stage = 6
 
 [dependencies.sgx_serialize]
 path = "../../../../sgx_serialize"
-stage = 7
+stage = 6
 
 [dependencies.sgx_tunittest]
 path = "../../../../sgx_tunittest"
-stage = 7
+stage = 6
 
 [dependencies.sgx_backtrace]
 path = "../../../../sgx_backtrace"
-stage = 8
+stage = 7
 
 [dependencies.sgx_cov]
 path = "../../../../sgx_cov"
-stage = 8
+stage = 7
\ No newline at end of file
diff --git a/samplecode/pcl/pcl-seal/enclave/Xargo.toml b/samplecode/pcl/pcl-seal/enclave/Xargo.toml
index 8177578..780a570 100644
--- a/samplecode/pcl/pcl-seal/enclave/Xargo.toml
+++ b/samplecode/pcl/pcl-seal/enclave/Xargo.toml
@@ -5,6 +5,14 @@ alloc = {}
 path = "../../../../sgx_types"
 stage = 1
 
+[dependencies.sgx_alloc]
+path = "../../../../sgx_alloc"
+stage = 1
+
+[dependencies.sgx_unwind]
+path = "../../../../sgx_unwind"
+stage = 1
+
 [dependencies.sgx_demangle]
 path = "../../../../sgx_demangle"
 stage = 1
@@ -41,9 +49,9 @@ stage = 3
 path = "../../../../sgx_backtrace_sys"
 stage = 3
 
-[dependencies.sgx_unwind]
-path = "../../../../sgx_unwind"
-stage = 4
+[dependencies.panic_unwind]
+path = "../../../../sgx_panic_unwind"
+stage = 3
 
 [dependencies.sgx_tdh]
 path = "../../../../sgx_tdh"
@@ -57,35 +65,31 @@ stage = 4
 path = "../../../../sgx_tprotected_fs"
 stage = 4
 
-[dependencies.sgx_alloc]
-path = "../../../../sgx_alloc"
-stage = 4
-
-[dependencies.panic_unwind]
-path = "../../../../sgx_panic_unwind"
-stage = 5
-
 [dependencies.std]
 path = "../../../../xargo/sgx_tstd"
 features = ["net"]
-stage = 6
+stage = 5
+
+[dependencies.sgx_no_tstd]
+path = "../../../../sgx_no_tstd"
+stage = 5
 
 [dependencies.sgx_rand]
 path = "../../../../sgx_rand"
-stage = 7
+stage = 6
 
 [dependencies.sgx_serialize]
 path = "../../../../sgx_serialize"
-stage = 7
+stage = 6
 
 [dependencies.sgx_tunittest]
 path = "../../../../sgx_tunittest"
-stage = 7
+stage = 6
 
 [dependencies.sgx_backtrace]
 path = "../../../../sgx_backtrace"
-stage = 8
+stage = 7
 
 [dependencies.sgx_cov]
 path = "../../../../sgx_cov"
-stage = 8
+stage = 7
\ No newline at end of file
diff --git a/samplecode/protobuf/enclave/Xargo.toml b/samplecode/protobuf/enclave/Xargo.toml
index c088ebb..b157608 100644
--- a/samplecode/protobuf/enclave/Xargo.toml
+++ b/samplecode/protobuf/enclave/Xargo.toml
@@ -5,6 +5,14 @@ alloc = {}
 path = "../../../sgx_types"
 stage = 1
 
+[dependencies.sgx_alloc]
+path = "../../../sgx_alloc"
+stage = 1
+
+[dependencies.sgx_unwind]
+path = "../../../sgx_unwind"
+stage = 1
+
 [dependencies.sgx_demangle]
 path = "../../../sgx_demangle"
 stage = 1
@@ -41,9 +49,9 @@ stage = 3
 path = "../../../sgx_backtrace_sys"
 stage = 3
 
-[dependencies.sgx_unwind]
-path = "../../../sgx_unwind"
-stage = 4
+[dependencies.panic_unwind]
+path = "../../../sgx_panic_unwind"
+stage = 3
 
 [dependencies.sgx_tdh]
 path = "../../../sgx_tdh"
@@ -57,34 +65,30 @@ stage = 4
 path = "../../../sgx_tprotected_fs"
 stage = 4
 
-[dependencies.sgx_alloc]
-path = "../../../sgx_alloc"
-stage = 4
-
-[dependencies.panic_unwind]
-path = "../../../sgx_panic_unwind"
-stage = 5
-
 [dependencies.std]
 path = "../../../xargo/sgx_tstd"
-stage = 6
+stage = 5
+
+[dependencies.sgx_no_tstd]
+path = "../../../sgx_no_tstd"
+stage = 5
 
 [dependencies.sgx_rand]
 path = "../../../sgx_rand"
-stage = 7
+stage = 6
 
 [dependencies.sgx_serialize]
 path = "../../../sgx_serialize"
-stage = 7
+stage = 6
 
 [dependencies.sgx_tunittest]
 path = "../../../sgx_tunittest"
-stage = 7
+stage = 6
 
 [dependencies.sgx_backtrace]
 path = "../../../sgx_backtrace"
-stage = 8
+stage = 7
 
 [dependencies.sgx_cov]
 path = "../../../sgx_cov"
-stage = 8
+stage = 7
\ No newline at end of file
diff --git a/samplecode/psi/SMCServer/enclave/Xargo.toml b/samplecode/psi/SMCServer/enclave/Xargo.toml
index cc955cd..74ddc1e 100644
--- a/samplecode/psi/SMCServer/enclave/Xargo.toml
+++ b/samplecode/psi/SMCServer/enclave/Xargo.toml
@@ -5,6 +5,14 @@ alloc = {}
 path = "../../../../sgx_types"
 stage = 1
 
+[dependencies.sgx_alloc]
+path = "../../../../sgx_alloc"
+stage = 1
+
+[dependencies.sgx_unwind]
+path = "../../../../sgx_unwind"
+stage = 1
+
 [dependencies.sgx_demangle]
 path = "../../../../sgx_demangle"
 stage = 1
@@ -41,9 +49,9 @@ stage = 3
 path = "../../../../sgx_backtrace_sys"
 stage = 3
 
-[dependencies.sgx_unwind]
-path = "../../../../sgx_unwind"
-stage = 4
+[dependencies.panic_unwind]
+path = "../../../../sgx_panic_unwind"
+stage = 3
 
 [dependencies.sgx_tdh]
 path = "../../../../sgx_tdh"
@@ -57,34 +65,30 @@ stage = 4
 path = "../../../../sgx_tprotected_fs"
 stage = 4
 
-[dependencies.sgx_alloc]
-path = "../../../../sgx_alloc"
-stage = 4
-
-[dependencies.panic_unwind]
-path = "../../../../sgx_panic_unwind"
-stage = 5
-
 [dependencies.std]
 path = "../../../../xargo/sgx_tstd"
-stage = 6
+stage = 5
+
+[dependencies.sgx_no_tstd]
+path = "../../../../sgx_no_tstd"
+stage = 5
 
 [dependencies.sgx_rand]
 path = "../../../../sgx_rand"
-stage = 7
+stage = 6
 
 [dependencies.sgx_serialize]
 path = "../../../../sgx_serialize"
-stage = 7
+stage = 6
 
 [dependencies.sgx_tunittest]
 path = "../../../../sgx_tunittest"
-stage = 7
+stage = 6
 
 [dependencies.sgx_backtrace]
 path = "../../../../sgx_backtrace"
-stage = 8
+stage = 7
 
 [dependencies.sgx_cov]
 path = "../../../../sgx_cov"
-stage = 8
+stage = 7
\ No newline at end of file
diff --git a/samplecode/remoteattestation/Application/enclave/Xargo.toml b/samplecode/remoteattestation/Application/enclave/Xargo.toml
index cc955cd..74ddc1e 100644
--- a/samplecode/remoteattestation/Application/enclave/Xargo.toml
+++ b/samplecode/remoteattestation/Application/enclave/Xargo.toml
@@ -5,6 +5,14 @@ alloc = {}
 path = "../../../../sgx_types"
 stage = 1
 
+[dependencies.sgx_alloc]
+path = "../../../../sgx_alloc"
+stage = 1
+
+[dependencies.sgx_unwind]
+path = "../../../../sgx_unwind"
+stage = 1
+
 [dependencies.sgx_demangle]
 path = "../../../../sgx_demangle"
 stage = 1
@@ -41,9 +49,9 @@ stage = 3
 path = "../../../../sgx_backtrace_sys"
 stage = 3
 
-[dependencies.sgx_unwind]
-path = "../../../../sgx_unwind"
-stage = 4
+[dependencies.panic_unwind]
+path = "../../../../sgx_panic_unwind"
+stage = 3
 
 [dependencies.sgx_tdh]
 path = "../../../../sgx_tdh"
@@ -57,34 +65,30 @@ stage = 4
 path = "../../../../sgx_tprotected_fs"
 stage = 4
 
-[dependencies.sgx_alloc]
-path = "../../../../sgx_alloc"
-stage = 4
-
-[dependencies.panic_unwind]
-path = "../../../../sgx_panic_unwind"
-stage = 5
-
 [dependencies.std]
 path = "../../../../xargo/sgx_tstd"
-stage = 6
+stage = 5
+
+[dependencies.sgx_no_tstd]
+path = "../../../../sgx_no_tstd"
+stage = 5
 
 [dependencies.sgx_rand]
 path = "../../../../sgx_rand"
-stage = 7
+stage = 6
 
 [dependencies.sgx_serialize]
 path = "../../../../sgx_serialize"
-stage = 7
+stage = 6
 
 [dependencies.sgx_tunittest]
 path = "../../../../sgx_tunittest"
-stage = 7
+stage = 6
 
 [dependencies.sgx_backtrace]
 path = "../../../../sgx_backtrace"
-stage = 8
+stage = 7
 
 [dependencies.sgx_cov]
 path = "../../../../sgx_cov"
-stage = 8
+stage = 7
\ No newline at end of file
diff --git a/samplecode/sealeddata/enclave/Xargo.toml b/samplecode/sealeddata/enclave/Xargo.toml
index c088ebb..b157608 100644
--- a/samplecode/sealeddata/enclave/Xargo.toml
+++ b/samplecode/sealeddata/enclave/Xargo.toml
@@ -5,6 +5,14 @@ alloc = {}
 path = "../../../sgx_types"
 stage = 1
 
+[dependencies.sgx_alloc]
+path = "../../../sgx_alloc"
+stage = 1
+
+[dependencies.sgx_unwind]
+path = "../../../sgx_unwind"
+stage = 1
+
 [dependencies.sgx_demangle]
 path = "../../../sgx_demangle"
 stage = 1
@@ -41,9 +49,9 @@ stage = 3
 path = "../../../sgx_backtrace_sys"
 stage = 3
 
-[dependencies.sgx_unwind]
-path = "../../../sgx_unwind"
-stage = 4
+[dependencies.panic_unwind]
+path = "../../../sgx_panic_unwind"
+stage = 3
 
 [dependencies.sgx_tdh]
 path = "../../../sgx_tdh"
@@ -57,34 +65,30 @@ stage = 4
 path = "../../../sgx_tprotected_fs"
 stage = 4
 
-[dependencies.sgx_alloc]
-path = "../../../sgx_alloc"
-stage = 4
-
-[dependencies.panic_unwind]
-path = "../../../sgx_panic_unwind"
-stage = 5
-
 [dependencies.std]
 path = "../../../xargo/sgx_tstd"
-stage = 6
+stage = 5
+
+[dependencies.sgx_no_tstd]
+path = "../../../sgx_no_tstd"
+stage = 5
 
 [dependencies.sgx_rand]
 path = "../../../sgx_rand"
-stage = 7
+stage = 6
 
 [dependencies.sgx_serialize]
 path = "../../../sgx_serialize"
-stage = 7
+stage = 6
 
 [dependencies.sgx_tunittest]
 path = "../../../sgx_tunittest"
-stage = 7
+stage = 6
 
 [dependencies.sgx_backtrace]
 path = "../../../sgx_backtrace"
-stage = 8
+stage = 7
 
 [dependencies.sgx_cov]
 path = "../../../sgx_cov"
-stage = 8
+stage = 7
\ No newline at end of file
diff --git a/samplecode/secretsharing/enclave/Xargo.toml b/samplecode/secretsharing/enclave/Xargo.toml
index c088ebb..b157608 100644
--- a/samplecode/secretsharing/enclave/Xargo.toml
+++ b/samplecode/secretsharing/enclave/Xargo.toml
@@ -5,6 +5,14 @@ alloc = {}
 path = "../../../sgx_types"
 stage = 1
 
+[dependencies.sgx_alloc]
+path = "../../../sgx_alloc"
+stage = 1
+
+[dependencies.sgx_unwind]
+path = "../../../sgx_unwind"
+stage = 1
+
 [dependencies.sgx_demangle]
 path = "../../../sgx_demangle"
 stage = 1
@@ -41,9 +49,9 @@ stage = 3
 path = "../../../sgx_backtrace_sys"
 stage = 3
 
-[dependencies.sgx_unwind]
-path = "../../../sgx_unwind"
-stage = 4
+[dependencies.panic_unwind]
+path = "../../../sgx_panic_unwind"
+stage = 3
 
 [dependencies.sgx_tdh]
 path = "../../../sgx_tdh"
@@ -57,34 +65,30 @@ stage = 4
 path = "../../../sgx_tprotected_fs"
 stage = 4
 
-[dependencies.sgx_alloc]
-path = "../../../sgx_alloc"
-stage = 4
-
-[dependencies.panic_unwind]
-path = "../../../sgx_panic_unwind"
-stage = 5
-
 [dependencies.std]
 path = "../../../xargo/sgx_tstd"
-stage = 6
+stage = 5
+
+[dependencies.sgx_no_tstd]
+path = "../../../sgx_no_tstd"
+stage = 5
 
 [dependencies.sgx_rand]
 path = "../../../sgx_rand"
-stage = 7
+stage = 6
 
 [dependencies.sgx_serialize]
 path = "../../../sgx_serialize"
-stage = 7
+stage = 6
 
 [dependencies.sgx_tunittest]
 path = "../../../sgx_tunittest"
-stage = 7
+stage = 6
 
 [dependencies.sgx_backtrace]
 path = "../../../sgx_backtrace"
-stage = 8
+stage = 7
 
 [dependencies.sgx_cov]
 path = "../../../sgx_cov"
-stage = 8
+stage = 7
\ No newline at end of file
diff --git a/samplecode/serialize/enclave/Xargo.toml b/samplecode/serialize/enclave/Xargo.toml
index c088ebb..b157608 100644
--- a/samplecode/serialize/enclave/Xargo.toml
+++ b/samplecode/serialize/enclave/Xargo.toml
@@ -5,6 +5,14 @@ alloc = {}
 path = "../../../sgx_types"
 stage = 1
 
+[dependencies.sgx_alloc]
+path = "../../../sgx_alloc"
+stage = 1
+
+[dependencies.sgx_unwind]
+path = "../../../sgx_unwind"
+stage = 1
+
 [dependencies.sgx_demangle]
 path = "../../../sgx_demangle"
 stage = 1
@@ -41,9 +49,9 @@ stage = 3
 path = "../../../sgx_backtrace_sys"
 stage = 3
 
-[dependencies.sgx_unwind]
-path = "../../../sgx_unwind"
-stage = 4
+[dependencies.panic_unwind]
+path = "../../../sgx_panic_unwind"
+stage = 3
 
 [dependencies.sgx_tdh]
 path = "../../../sgx_tdh"
@@ -57,34 +65,30 @@ stage = 4
 path = "../../../sgx_tprotected_fs"
 stage = 4
 
-[dependencies.sgx_alloc]
-path = "../../../sgx_alloc"
-stage = 4
-
-[dependencies.panic_unwind]
-path = "../../../sgx_panic_unwind"
-stage = 5
-
 [dependencies.std]
 path = "../../../xargo/sgx_tstd"
-stage = 6
+stage = 5
+
+[dependencies.sgx_no_tstd]
+path = "../../../sgx_no_tstd"
+stage = 5
 
 [dependencies.sgx_rand]
 path = "../../../sgx_rand"
-stage = 7
+stage = 6
 
 [dependencies.sgx_serialize]
 path = "../../../sgx_serialize"
-stage = 7
+stage = 6
 
 [dependencies.sgx_tunittest]
 path = "../../../sgx_tunittest"
-stage = 7
+stage = 6
 
 [dependencies.sgx_backtrace]
 path = "../../../sgx_backtrace"
-stage = 8
+stage = 7
 
 [dependencies.sgx_cov]
 path = "../../../sgx_cov"
-stage = 8
+stage = 7
\ No newline at end of file
diff --git a/samplecode/sgx-cov/enclave/Xargo.toml b/samplecode/sgx-cov/enclave/Xargo.toml
index 5100d1e..56b4df0 100644
--- a/samplecode/sgx-cov/enclave/Xargo.toml
+++ b/samplecode/sgx-cov/enclave/Xargo.toml
@@ -3,12 +3,20 @@ alloc = {}
 
 #[dependencies.profiler_builtins]
 #path = "profiler_builtins"
-#stage = 7
+#stage = 6
 
 [dependencies.sgx_types]
 path = "../../../sgx_types"
 stage = 1
 
+[dependencies.sgx_alloc]
+path = "../../../sgx_alloc"
+stage = 1
+
+[dependencies.sgx_unwind]
+path = "../../../sgx_unwind"
+stage = 1
+
 [dependencies.sgx_demangle]
 path = "../../../sgx_demangle"
 stage = 1
@@ -45,9 +53,9 @@ stage = 3
 path = "../../../sgx_backtrace_sys"
 stage = 3
 
-[dependencies.sgx_unwind]
-path = "../../../sgx_unwind"
-stage = 4
+[dependencies.panic_unwind]
+path = "../../../sgx_panic_unwind"
+stage = 3
 
 [dependencies.sgx_tdh]
 path = "../../../sgx_tdh"
@@ -61,35 +69,31 @@ stage = 4
 path = "../../../sgx_tprotected_fs"
 stage = 4
 
-[dependencies.sgx_alloc]
-path = "../../../sgx_alloc"
-stage = 4
-
-[dependencies.panic_unwind]
-path = "../../../sgx_panic_unwind"
-stage = 5
-
 [dependencies.std]
 path = "../../../xargo/sgx_tstd"
 #features = ["profiler"]
-stage = 6
+stage = 5
+
+[dependencies.sgx_no_tstd]
+path = "../../../sgx_no_tstd"
+stage = 5
 
 [dependencies.sgx_rand]
 path = "../../../sgx_rand"
-stage = 7
+stage = 6
 
 [dependencies.sgx_serialize]
 path = "../../../sgx_serialize"
-stage = 7
+stage = 6
 
 [dependencies.sgx_tunittest]
 path = "../../../sgx_tunittest"
-stage = 7
+stage = 6
 
 [dependencies.sgx_backtrace]
 path = "../../../sgx_backtrace"
-stage = 8
+stage = 7
 
 [dependencies.sgx_cov]
 path = "../../../sgx_cov"
-stage = 8
+stage = 7
diff --git a/samplecode/sgxcounter/enclave/Xargo.toml b/samplecode/sgxcounter/enclave/Xargo.toml
index c088ebb..b157608 100644
--- a/samplecode/sgxcounter/enclave/Xargo.toml
+++ b/samplecode/sgxcounter/enclave/Xargo.toml
@@ -5,6 +5,14 @@ alloc = {}
 path = "../../../sgx_types"
 stage = 1
 
+[dependencies.sgx_alloc]
+path = "../../../sgx_alloc"
+stage = 1
+
+[dependencies.sgx_unwind]
+path = "../../../sgx_unwind"
+stage = 1
+
 [dependencies.sgx_demangle]
 path = "../../../sgx_demangle"
 stage = 1
@@ -41,9 +49,9 @@ stage = 3
 path = "../../../sgx_backtrace_sys"
 stage = 3
 
-[dependencies.sgx_unwind]
-path = "../../../sgx_unwind"
-stage = 4
+[dependencies.panic_unwind]
+path = "../../../sgx_panic_unwind"
+stage = 3
 
 [dependencies.sgx_tdh]
 path = "../../../sgx_tdh"
@@ -57,34 +65,30 @@ stage = 4
 path = "../../../sgx_tprotected_fs"
 stage = 4
 
-[dependencies.sgx_alloc]
-path = "../../../sgx_alloc"
-stage = 4
-
-[dependencies.panic_unwind]
-path = "../../../sgx_panic_unwind"
-stage = 5
-
 [dependencies.std]
 path = "../../../xargo/sgx_tstd"
-stage = 6
+stage = 5
+
+[dependencies.sgx_no_tstd]
+path = "../../../sgx_no_tstd"
+stage = 5
 
 [dependencies.sgx_rand]
 path = "../../../sgx_rand"
-stage = 7
+stage = 6
 
 [dependencies.sgx_serialize]
 path = "../../../sgx_serialize"
-stage = 7
+stage = 6
 
 [dependencies.sgx_tunittest]
 path = "../../../sgx_tunittest"
-stage = 7
+stage = 6
 
 [dependencies.sgx_backtrace]
 path = "../../../sgx_backtrace"
-stage = 8
+stage = 7
 
 [dependencies.sgx_cov]
 path = "../../../sgx_cov"
-stage = 8
+stage = 7
\ No newline at end of file
diff --git a/samplecode/sgxtime/enclave/Xargo.toml b/samplecode/sgxtime/enclave/Xargo.toml
index c088ebb..b157608 100644
--- a/samplecode/sgxtime/enclave/Xargo.toml
+++ b/samplecode/sgxtime/enclave/Xargo.toml
@@ -5,6 +5,14 @@ alloc = {}
 path = "../../../sgx_types"
 stage = 1
 
+[dependencies.sgx_alloc]
+path = "../../../sgx_alloc"
+stage = 1
+
+[dependencies.sgx_unwind]
+path = "../../../sgx_unwind"
+stage = 1
+
 [dependencies.sgx_demangle]
 path = "../../../sgx_demangle"
 stage = 1
@@ -41,9 +49,9 @@ stage = 3
 path = "../../../sgx_backtrace_sys"
 stage = 3
 
-[dependencies.sgx_unwind]
-path = "../../../sgx_unwind"
-stage = 4
+[dependencies.panic_unwind]
+path = "../../../sgx_panic_unwind"
+stage = 3
 
 [dependencies.sgx_tdh]
 path = "../../../sgx_tdh"
@@ -57,34 +65,30 @@ stage = 4
 path = "../../../sgx_tprotected_fs"
 stage = 4
 
-[dependencies.sgx_alloc]
-path = "../../../sgx_alloc"
-stage = 4
-
-[dependencies.panic_unwind]
-path = "../../../sgx_panic_unwind"
-stage = 5
-
 [dependencies.std]
 path = "../../../xargo/sgx_tstd"
-stage = 6
+stage = 5
+
+[dependencies.sgx_no_tstd]
+path = "../../../sgx_no_tstd"
+stage = 5
 
 [dependencies.sgx_rand]
 path = "../../../sgx_rand"
-stage = 7
+stage = 6
 
 [dependencies.sgx_serialize]
 path = "../../../sgx_serialize"
-stage = 7
+stage = 6
 
 [dependencies.sgx_tunittest]
 path = "../../../sgx_tunittest"
-stage = 7
+stage = 6
 
 [dependencies.sgx_backtrace]
 path = "../../../sgx_backtrace"
-stage = 8
+stage = 7
 
 [dependencies.sgx_cov]
 path = "../../../sgx_cov"
-stage = 8
+stage = 7
\ No newline at end of file
diff --git a/samplecode/static-data-distribution/enclave/Xargo.toml b/samplecode/static-data-distribution/enclave/Xargo.toml
index 198e661..b157608 100644
--- a/samplecode/static-data-distribution/enclave/Xargo.toml
+++ b/samplecode/static-data-distribution/enclave/Xargo.toml
@@ -5,6 +5,14 @@ alloc = {}
 path = "../../../sgx_types"
 stage = 1
 
+[dependencies.sgx_alloc]
+path = "../../../sgx_alloc"
+stage = 1
+
+[dependencies.sgx_unwind]
+path = "../../../sgx_unwind"
+stage = 1
+
 [dependencies.sgx_demangle]
 path = "../../../sgx_demangle"
 stage = 1
@@ -41,9 +49,9 @@ stage = 3
 path = "../../../sgx_backtrace_sys"
 stage = 3
 
-[dependencies.sgx_unwind]
-path = "../../../sgx_unwind"
-stage = 4
+[dependencies.panic_unwind]
+path = "../../../sgx_panic_unwind"
+stage = 3
 
 [dependencies.sgx_tdh]
 path = "../../../sgx_tdh"
@@ -57,35 +65,30 @@ stage = 4
 path = "../../../sgx_tprotected_fs"
 stage = 4
 
-[dependencies.sgx_alloc]
-path = "../../../sgx_alloc"
-stage = 4
-
-[dependencies.panic_unwind]
-path = "../../../sgx_panic_unwind"
-stage = 5
-
 [dependencies.std]
 path = "../../../xargo/sgx_tstd"
-stage = 6
+stage = 5
+
+[dependencies.sgx_no_tstd]
+path = "../../../sgx_no_tstd"
+stage = 5
 
 [dependencies.sgx_rand]
 path = "../../../sgx_rand"
-stage = 7
+stage = 6
 
 [dependencies.sgx_serialize]
 path = "../../../sgx_serialize"
-stage = 7
+stage = 6
 
 [dependencies.sgx_tunittest]
 path = "../../../sgx_tunittest"
-stage = 7
+stage = 6
 
 [dependencies.sgx_backtrace]
 path = "../../../sgx_backtrace"
-stage = 8
+stage = 7
 
 [dependencies.sgx_cov]
 path = "../../../sgx_cov"
-stage = 8
-
+stage = 7
\ No newline at end of file
diff --git a/samplecode/switchless/enclave/Xargo.toml b/samplecode/switchless/enclave/Xargo.toml
index c088ebb..b157608 100644
--- a/samplecode/switchless/enclave/Xargo.toml
+++ b/samplecode/switchless/enclave/Xargo.toml
@@ -5,6 +5,14 @@ alloc = {}
 path = "../../../sgx_types"
 stage = 1
 
+[dependencies.sgx_alloc]
+path = "../../../sgx_alloc"
+stage = 1
+
+[dependencies.sgx_unwind]
+path = "../../../sgx_unwind"
+stage = 1
+
 [dependencies.sgx_demangle]
 path = "../../../sgx_demangle"
 stage = 1
@@ -41,9 +49,9 @@ stage = 3
 path = "../../../sgx_backtrace_sys"
 stage = 3
 
-[dependencies.sgx_unwind]
-path = "../../../sgx_unwind"
-stage = 4
+[dependencies.panic_unwind]
+path = "../../../sgx_panic_unwind"
+stage = 3
 
 [dependencies.sgx_tdh]
 path = "../../../sgx_tdh"
@@ -57,34 +65,30 @@ stage = 4
 path = "../../../sgx_tprotected_fs"
 stage = 4
 
-[dependencies.sgx_alloc]
-path = "../../../sgx_alloc"
-stage = 4
-
-[dependencies.panic_unwind]
-path = "../../../sgx_panic_unwind"
-stage = 5
-
 [dependencies.std]
 path = "../../../xargo/sgx_tstd"
-stage = 6
+stage = 5
+
+[dependencies.sgx_no_tstd]
+path = "../../../sgx_no_tstd"
+stage = 5
 
 [dependencies.sgx_rand]
 path = "../../../sgx_rand"
-stage = 7
+stage = 6
 
 [dependencies.sgx_serialize]
 path = "../../../sgx_serialize"
-stage = 7
+stage = 6
 
 [dependencies.sgx_tunittest]
 path = "../../../sgx_tunittest"
-stage = 7
+stage = 6
 
 [dependencies.sgx_backtrace]
 path = "../../../sgx_backtrace"
-stage = 8
+stage = 7
 
 [dependencies.sgx_cov]
 path = "../../../sgx_cov"
-stage = 8
+stage = 7
\ No newline at end of file
diff --git a/samplecode/tcmalloc/enclave/Xargo.toml b/samplecode/tcmalloc/enclave/Xargo.toml
index 4bedfd5..b157608 100644
--- a/samplecode/tcmalloc/enclave/Xargo.toml
+++ b/samplecode/tcmalloc/enclave/Xargo.toml
@@ -5,6 +5,14 @@ alloc = {}
 path = "../../../sgx_types"
 stage = 1
 
+[dependencies.sgx_alloc]
+path = "../../../sgx_alloc"
+stage = 1
+
+[dependencies.sgx_unwind]
+path = "../../../sgx_unwind"
+stage = 1
+
 [dependencies.sgx_demangle]
 path = "../../../sgx_demangle"
 stage = 1
@@ -41,9 +49,9 @@ stage = 3
 path = "../../../sgx_backtrace_sys"
 stage = 3
 
-[dependencies.sgx_unwind]
-path = "../../../sgx_unwind"
-stage = 4
+[dependencies.panic_unwind]
+path = "../../../sgx_panic_unwind"
+stage = 3
 
 [dependencies.sgx_tdh]
 path = "../../../sgx_tdh"
@@ -57,34 +65,30 @@ stage = 4
 path = "../../../sgx_tprotected_fs"
 stage = 4
 
-[dependencies.sgx_alloc]
-path = "../../../sgx_alloc"
-stage = 4
-
-[dependencies.panic_unwind]
-path = "../../../sgx_panic_unwind"
-stage = 5
-
 [dependencies.std]
 path = "../../../xargo/sgx_tstd"
-stage = 6
+stage = 5
+
+[dependencies.sgx_no_tstd]
+path = "../../../sgx_no_tstd"
+stage = 5
 
 [dependencies.sgx_rand]
 path = "../../../sgx_rand"
-stage = 7
+stage = 6
 
 [dependencies.sgx_serialize]
 path = "../../../sgx_serialize"
-stage = 7
+stage = 6
 
 [dependencies.sgx_tunittest]
 path = "../../../sgx_tunittest"
-stage = 7
+stage = 6
 
 [dependencies.sgx_backtrace]
 path = "../../../sgx_backtrace"
-stage = 8
+stage = 7
 
 [dependencies.sgx_cov]
 path = "../../../sgx_cov"
-stage = 8
\ No newline at end of file
+stage = 7
\ No newline at end of file
diff --git a/samplecode/thread/enclave/Xargo.toml b/samplecode/thread/enclave/Xargo.toml
index c088ebb..b157608 100644
--- a/samplecode/thread/enclave/Xargo.toml
+++ b/samplecode/thread/enclave/Xargo.toml
@@ -5,6 +5,14 @@ alloc = {}
 path = "../../../sgx_types"
 stage = 1
 
+[dependencies.sgx_alloc]
+path = "../../../sgx_alloc"
+stage = 1
+
+[dependencies.sgx_unwind]
+path = "../../../sgx_unwind"
+stage = 1
+
 [dependencies.sgx_demangle]
 path = "../../../sgx_demangle"
 stage = 1
@@ -41,9 +49,9 @@ stage = 3
 path = "../../../sgx_backtrace_sys"
 stage = 3
 
-[dependencies.sgx_unwind]
-path = "../../../sgx_unwind"
-stage = 4
+[dependencies.panic_unwind]
+path = "../../../sgx_panic_unwind"
+stage = 3
 
 [dependencies.sgx_tdh]
 path = "../../../sgx_tdh"
@@ -57,34 +65,30 @@ stage = 4
 path = "../../../sgx_tprotected_fs"
 stage = 4
 
-[dependencies.sgx_alloc]
-path = "../../../sgx_alloc"
-stage = 4
-
-[dependencies.panic_unwind]
-path = "../../../sgx_panic_unwind"
-stage = 5
-
 [dependencies.std]
 path = "../../../xargo/sgx_tstd"
-stage = 6
+stage = 5
+
+[dependencies.sgx_no_tstd]
+path = "../../../sgx_no_tstd"
+stage = 5
 
 [dependencies.sgx_rand]
 path = "../../../sgx_rand"
-stage = 7
+stage = 6
 
 [dependencies.sgx_serialize]
 path = "../../../sgx_serialize"
-stage = 7
+stage = 6
 
 [dependencies.sgx_tunittest]
 path = "../../../sgx_tunittest"
-stage = 7
+stage = 6
 
 [dependencies.sgx_backtrace]
 path = "../../../sgx_backtrace"
-stage = 8
+stage = 7
 
 [dependencies.sgx_cov]
 path = "../../../sgx_cov"
-stage = 8
+stage = 7
\ No newline at end of file
diff --git a/samplecode/tls/tlsclient/enclave/Xargo.toml b/samplecode/tls/tlsclient/enclave/Xargo.toml
index 8177578..780a570 100644
--- a/samplecode/tls/tlsclient/enclave/Xargo.toml
+++ b/samplecode/tls/tlsclient/enclave/Xargo.toml
@@ -5,6 +5,14 @@ alloc = {}
 path = "../../../../sgx_types"
 stage = 1
 
+[dependencies.sgx_alloc]
+path = "../../../../sgx_alloc"
+stage = 1
+
+[dependencies.sgx_unwind]
+path = "../../../../sgx_unwind"
+stage = 1
+
 [dependencies.sgx_demangle]
 path = "../../../../sgx_demangle"
 stage = 1
@@ -41,9 +49,9 @@ stage = 3
 path = "../../../../sgx_backtrace_sys"
 stage = 3
 
-[dependencies.sgx_unwind]
-path = "../../../../sgx_unwind"
-stage = 4
+[dependencies.panic_unwind]
+path = "../../../../sgx_panic_unwind"
+stage = 3
 
 [dependencies.sgx_tdh]
 path = "../../../../sgx_tdh"
@@ -57,35 +65,31 @@ stage = 4
 path = "../../../../sgx_tprotected_fs"
 stage = 4
 
-[dependencies.sgx_alloc]
-path = "../../../../sgx_alloc"
-stage = 4
-
-[dependencies.panic_unwind]
-path = "../../../../sgx_panic_unwind"
-stage = 5
-
 [dependencies.std]
 path = "../../../../xargo/sgx_tstd"
 features = ["net"]
-stage = 6
+stage = 5
+
+[dependencies.sgx_no_tstd]
+path = "../../../../sgx_no_tstd"
+stage = 5
 
 [dependencies.sgx_rand]
 path = "../../../../sgx_rand"
-stage = 7
+stage = 6
 
 [dependencies.sgx_serialize]
 path = "../../../../sgx_serialize"
-stage = 7
+stage = 6
 
 [dependencies.sgx_tunittest]
 path = "../../../../sgx_tunittest"
-stage = 7
+stage = 6
 
 [dependencies.sgx_backtrace]
 path = "../../../../sgx_backtrace"
-stage = 8
+stage = 7
 
 [dependencies.sgx_cov]
 path = "../../../../sgx_cov"
-stage = 8
+stage = 7
\ No newline at end of file
diff --git a/samplecode/tls/tlsserver/enclave/Xargo.toml b/samplecode/tls/tlsserver/enclave/Xargo.toml
index 8177578..780a570 100644
--- a/samplecode/tls/tlsserver/enclave/Xargo.toml
+++ b/samplecode/tls/tlsserver/enclave/Xargo.toml
@@ -5,6 +5,14 @@ alloc = {}
 path = "../../../../sgx_types"
 stage = 1
 
+[dependencies.sgx_alloc]
+path = "../../../../sgx_alloc"
+stage = 1
+
+[dependencies.sgx_unwind]
+path = "../../../../sgx_unwind"
+stage = 1
+
 [dependencies.sgx_demangle]
 path = "../../../../sgx_demangle"
 stage = 1
@@ -41,9 +49,9 @@ stage = 3
 path = "../../../../sgx_backtrace_sys"
 stage = 3
 
-[dependencies.sgx_unwind]
-path = "../../../../sgx_unwind"
-stage = 4
+[dependencies.panic_unwind]
+path = "../../../../sgx_panic_unwind"
+stage = 3
 
 [dependencies.sgx_tdh]
 path = "../../../../sgx_tdh"
@@ -57,35 +65,31 @@ stage = 4
 path = "../../../../sgx_tprotected_fs"
 stage = 4
 
-[dependencies.sgx_alloc]
-path = "../../../../sgx_alloc"
-stage = 4
-
-[dependencies.panic_unwind]
-path = "../../../../sgx_panic_unwind"
-stage = 5
-
 [dependencies.std]
 path = "../../../../xargo/sgx_tstd"
 features = ["net"]
-stage = 6
+stage = 5
+
+[dependencies.sgx_no_tstd]
+path = "../../../../sgx_no_tstd"
+stage = 5
 
 [dependencies.sgx_rand]
 path = "../../../../sgx_rand"
-stage = 7
+stage = 6
 
 [dependencies.sgx_serialize]
 path = "../../../../sgx_serialize"
-stage = 7
+stage = 6
 
 [dependencies.sgx_tunittest]
 path = "../../../../sgx_tunittest"
-stage = 7
+stage = 6
 
 [dependencies.sgx_backtrace]
 path = "../../../../sgx_backtrace"
-stage = 8
+stage = 7
 
 [dependencies.sgx_cov]
 path = "../../../../sgx_cov"
-stage = 8
+stage = 7
\ No newline at end of file
diff --git a/samplecode/tr-mpc/tr-mpc-server/enclave/Xargo.toml b/samplecode/tr-mpc/tr-mpc-server/enclave/Xargo.toml
index 83272c3..780a570 100644
--- a/samplecode/tr-mpc/tr-mpc-server/enclave/Xargo.toml
+++ b/samplecode/tr-mpc/tr-mpc-server/enclave/Xargo.toml
@@ -1,12 +1,26 @@
 [dependencies]
 alloc = {}
-panic_unwind = {}
-panic_abort = {}
 
 [dependencies.sgx_types]
 path = "../../../../sgx_types"
 stage = 1
 
+[dependencies.sgx_alloc]
+path = "../../../../sgx_alloc"
+stage = 1
+
+[dependencies.sgx_unwind]
+path = "../../../../sgx_unwind"
+stage = 1
+
+[dependencies.sgx_demangle]
+path = "../../../../sgx_demangle"
+stage = 1
+
+[dependencies.panic_abort]
+path = "../../../../sgx_panic_abort"
+stage = 1
+
 [dependencies.sgx_libc]
 path = "../../../../sgx_libc"
 stage = 2
@@ -31,9 +45,13 @@ stage = 2
 path = "../../../../sgx_trts"
 stage = 3
 
-[dependencies.sgx_unwind]
-path = "../../../../sgx_unwind"
-stage = 4
+[dependencies.sgx_backtrace_sys]
+path = "../../../../sgx_backtrace_sys"
+stage = 3
+
+[dependencies.panic_unwind]
+path = "../../../../sgx_panic_unwind"
+stage = 3
 
 [dependencies.sgx_tdh]
 path = "../../../../sgx_tdh"
@@ -47,15 +65,15 @@ stage = 4
 path = "../../../../sgx_tprotected_fs"
 stage = 4
 
-[dependencies.sgx_alloc]
-path = "../../../../sgx_alloc"
-stage = 4
-
 [dependencies.std]
 path = "../../../../xargo/sgx_tstd"
 features = ["net"]
 stage = 5
 
+[dependencies.sgx_no_tstd]
+path = "../../../../sgx_no_tstd"
+stage = 5
+
 [dependencies.sgx_rand]
 path = "../../../../sgx_rand"
 stage = 6
@@ -68,5 +86,10 @@ stage = 6
 path = "../../../../sgx_tunittest"
 stage = 6
 
-[patch.crates-io]
-libc = { git = "https://github.com/mesalock-linux/libc-sgx" }
+[dependencies.sgx_backtrace]
+path = "../../../../sgx_backtrace"
+stage = 7
+
+[dependencies.sgx_cov]
+path = "../../../../sgx_cov"
+stage = 7
\ No newline at end of file
diff --git a/samplecode/ue-ra/ue-ra-server/enclave/Xargo.toml b/samplecode/ue-ra/ue-ra-server/enclave/Xargo.toml
index 8177578..780a570 100644
--- a/samplecode/ue-ra/ue-ra-server/enclave/Xargo.toml
+++ b/samplecode/ue-ra/ue-ra-server/enclave/Xargo.toml
@@ -5,6 +5,14 @@ alloc = {}
 path = "../../../../sgx_types"
 stage = 1
 
+[dependencies.sgx_alloc]
+path = "../../../../sgx_alloc"
+stage = 1
+
+[dependencies.sgx_unwind]
+path = "../../../../sgx_unwind"
+stage = 1
+
 [dependencies.sgx_demangle]
 path = "../../../../sgx_demangle"
 stage = 1
@@ -41,9 +49,9 @@ stage = 3
 path = "../../../../sgx_backtrace_sys"
 stage = 3
 
-[dependencies.sgx_unwind]
-path = "../../../../sgx_unwind"
-stage = 4
+[dependencies.panic_unwind]
+path = "../../../../sgx_panic_unwind"
+stage = 3
 
 [dependencies.sgx_tdh]
 path = "../../../../sgx_tdh"
@@ -57,35 +65,31 @@ stage = 4
 path = "../../../../sgx_tprotected_fs"
 stage = 4
 
-[dependencies.sgx_alloc]
-path = "../../../../sgx_alloc"
-stage = 4
-
-[dependencies.panic_unwind]
-path = "../../../../sgx_panic_unwind"
-stage = 5
-
 [dependencies.std]
 path = "../../../../xargo/sgx_tstd"
 features = ["net"]
-stage = 6
+stage = 5
+
+[dependencies.sgx_no_tstd]
+path = "../../../../sgx_no_tstd"
+stage = 5
 
 [dependencies.sgx_rand]
 path = "../../../../sgx_rand"
-stage = 7
+stage = 6
 
 [dependencies.sgx_serialize]
 path = "../../../../sgx_serialize"
-stage = 7
+stage = 6
 
 [dependencies.sgx_tunittest]
 path = "../../../../sgx_tunittest"
-stage = 7
+stage = 6
 
 [dependencies.sgx_backtrace]
 path = "../../../../sgx_backtrace"
-stage = 8
+stage = 7
 
 [dependencies.sgx_cov]
 path = "../../../../sgx_cov"
-stage = 8
+stage = 7
\ No newline at end of file
diff --git a/samplecode/unit-test/enclave/Cargo.toml b/samplecode/unit-test/enclave/Cargo.toml
index de9076f..662e3b0 100644
--- a/samplecode/unit-test/enclave/Cargo.toml
+++ b/samplecode/unit-test/enclave/Cargo.toml
@@ -12,7 +12,7 @@ default = []
 
 [target.'cfg(not(target_env = "sgx"))'.dependencies]
 sgx_types = { git = "https://github.com/baidu/rust-sgx-sdk.git" }
-sgx_tstd = { git = "https://github.com/baidu/rust-sgx-sdk.git", features = ["untrusted_fs"] }
+sgx_tstd = { git = "https://github.com/baidu/rust-sgx-sdk.git", features = ["untrusted_fs", "thread"] }
 sgx_tcrypto = { git = "https://github.com/baidu/rust-sgx-sdk.git" }
 sgx_tunittest = { git = "https://github.com/baidu/rust-sgx-sdk.git" }
 sgx_trts = { git = "https://github.com/baidu/rust-sgx-sdk.git" }
diff --git a/samplecode/unit-test/enclave/Xargo.toml b/samplecode/unit-test/enclave/Xargo.toml
index a7b0443..543e88d 100644
--- a/samplecode/unit-test/enclave/Xargo.toml
+++ b/samplecode/unit-test/enclave/Xargo.toml
@@ -5,6 +5,14 @@ alloc = {}
 path = "../../../sgx_types"
 stage = 1
 
+[dependencies.sgx_alloc]
+path = "../../../sgx_alloc"
+stage = 1
+
+[dependencies.sgx_unwind]
+path = "../../../sgx_unwind"
+stage = 1
+
 [dependencies.sgx_demangle]
 path = "../../../sgx_demangle"
 stage = 1
@@ -41,9 +49,9 @@ stage = 3
 path = "../../../sgx_backtrace_sys"
 stage = 3
 
-[dependencies.sgx_unwind]
-path = "../../../sgx_unwind"
-stage = 4
+[dependencies.panic_unwind]
+path = "../../../sgx_panic_unwind"
+stage = 3
 
 [dependencies.sgx_tdh]
 path = "../../../sgx_tdh"
@@ -57,35 +65,31 @@ stage = 4
 path = "../../../sgx_tprotected_fs"
 stage = 4
 
-[dependencies.sgx_alloc]
-path = "../../../sgx_alloc"
-stage = 4
-
-[dependencies.panic_unwind]
-path = "../../../sgx_panic_unwind"
-stage = 5
-
 [dependencies.std]
 path = "../../../xargo/sgx_tstd"
-features = ["untrusted_fs"]
-stage = 6
+features = ["untrusted_fs", "thread"]
+stage = 5
+
+[dependencies.sgx_no_tstd]
+path = "../../../sgx_no_tstd"
+stage = 5
 
 [dependencies.sgx_rand]
 path = "../../../sgx_rand"
-stage = 7
+stage = 6
 
 [dependencies.sgx_serialize]
 path = "../../../sgx_serialize"
-stage = 7
+stage = 6
 
 [dependencies.sgx_tunittest]
 path = "../../../sgx_tunittest"
-stage = 7
+stage = 6
 
 [dependencies.sgx_backtrace]
 path = "../../../sgx_backtrace"
-stage = 8
+stage = 7
 
 [dependencies.sgx_cov]
 path = "../../../sgx_cov"
-stage = 8
+stage = 7
\ No newline at end of file
diff --git a/samplecode/wasmi/enclave/Xargo.toml b/samplecode/wasmi/enclave/Xargo.toml
index c088ebb..b157608 100644
--- a/samplecode/wasmi/enclave/Xargo.toml
+++ b/samplecode/wasmi/enclave/Xargo.toml
@@ -5,6 +5,14 @@ alloc = {}
 path = "../../../sgx_types"
 stage = 1
 
+[dependencies.sgx_alloc]
+path = "../../../sgx_alloc"
+stage = 1
+
+[dependencies.sgx_unwind]
+path = "../../../sgx_unwind"
+stage = 1
+
 [dependencies.sgx_demangle]
 path = "../../../sgx_demangle"
 stage = 1
@@ -41,9 +49,9 @@ stage = 3
 path = "../../../sgx_backtrace_sys"
 stage = 3
 
-[dependencies.sgx_unwind]
-path = "../../../sgx_unwind"
-stage = 4
+[dependencies.panic_unwind]
+path = "../../../sgx_panic_unwind"
+stage = 3
 
 [dependencies.sgx_tdh]
 path = "../../../sgx_tdh"
@@ -57,34 +65,30 @@ stage = 4
 path = "../../../sgx_tprotected_fs"
 stage = 4
 
-[dependencies.sgx_alloc]
-path = "../../../sgx_alloc"
-stage = 4
-
-[dependencies.panic_unwind]
-path = "../../../sgx_panic_unwind"
-stage = 5
-
 [dependencies.std]
 path = "../../../xargo/sgx_tstd"
-stage = 6
+stage = 5
+
+[dependencies.sgx_no_tstd]
+path = "../../../sgx_no_tstd"
+stage = 5
 
 [dependencies.sgx_rand]
 path = "../../../sgx_rand"
-stage = 7
+stage = 6
 
 [dependencies.sgx_serialize]
 path = "../../../sgx_serialize"
-stage = 7
+stage = 6
 
 [dependencies.sgx_tunittest]
 path = "../../../sgx_tunittest"
-stage = 7
+stage = 6
 
 [dependencies.sgx_backtrace]
 path = "../../../sgx_backtrace"
-stage = 8
+stage = 7
 
 [dependencies.sgx_cov]
 path = "../../../sgx_cov"
-stage = 8
+stage = 7
\ No newline at end of file
diff --git a/samplecode/zlib-lazy-static-sample/enclave/Xargo.toml b/samplecode/zlib-lazy-static-sample/enclave/Xargo.toml
index c088ebb..b157608 100644
--- a/samplecode/zlib-lazy-static-sample/enclave/Xargo.toml
+++ b/samplecode/zlib-lazy-static-sample/enclave/Xargo.toml
@@ -5,6 +5,14 @@ alloc = {}
 path = "../../../sgx_types"
 stage = 1
 
+[dependencies.sgx_alloc]
+path = "../../../sgx_alloc"
+stage = 1
+
+[dependencies.sgx_unwind]
+path = "../../../sgx_unwind"
+stage = 1
+
 [dependencies.sgx_demangle]
 path = "../../../sgx_demangle"
 stage = 1
@@ -41,9 +49,9 @@ stage = 3
 path = "../../../sgx_backtrace_sys"
 stage = 3
 
-[dependencies.sgx_unwind]
-path = "../../../sgx_unwind"
-stage = 4
+[dependencies.panic_unwind]
+path = "../../../sgx_panic_unwind"
+stage = 3
 
 [dependencies.sgx_tdh]
 path = "../../../sgx_tdh"
@@ -57,34 +65,30 @@ stage = 4
 path = "../../../sgx_tprotected_fs"
 stage = 4
 
-[dependencies.sgx_alloc]
-path = "../../../sgx_alloc"
-stage = 4
-
-[dependencies.panic_unwind]
-path = "../../../sgx_panic_unwind"
-stage = 5
-
 [dependencies.std]
 path = "../../../xargo/sgx_tstd"
-stage = 6
+stage = 5
+
+[dependencies.sgx_no_tstd]
+path = "../../../sgx_no_tstd"
+stage = 5
 
 [dependencies.sgx_rand]
 path = "../../../sgx_rand"
-stage = 7
+stage = 6
 
 [dependencies.sgx_serialize]
 path = "../../../sgx_serialize"
-stage = 7
+stage = 6
 
 [dependencies.sgx_tunittest]
 path = "../../../sgx_tunittest"
-stage = 7
+stage = 6
 
 [dependencies.sgx_backtrace]
 path = "../../../sgx_backtrace"
-stage = 8
+stage = 7
 
 [dependencies.sgx_cov]
 path = "../../../sgx_cov"
-stage = 8
+stage = 7
\ No newline at end of file
diff --git a/sgx_alloc/Cargo.toml b/sgx_alloc/Cargo.toml
index 38a52e9..b82dbdf 100644
--- a/sgx_alloc/Cargo.toml
+++ b/sgx_alloc/Cargo.toml
@@ -14,6 +14,3 @@ crate-type = ["rlib"]
 
 [features]
 default = []
-
-[target.'cfg(not(target_env = "sgx"))'.dependencies]
-sgx_trts = { path = "../sgx_trts" }
diff --git a/sgx_alloc/src/lib.rs b/sgx_alloc/src/lib.rs
index a26c5e3..090372c 100644
--- a/sgx_alloc/src/lib.rs
+++ b/sgx_alloc/src/lib.rs
@@ -35,13 +35,12 @@
 
 #![no_std]
 
+#![allow(non_camel_case_types)]
+
 #![cfg_attr(target_env = "sgx", feature(rustc_private))]
 
 #![feature(allocator_api)]
 
-#[cfg(target_env = "sgx")]
-extern crate sgx_trts;
-
 use core::alloc::{GlobalAlloc, Alloc, AllocErr, Layout};
 use core::ptr::NonNull;
 
@@ -85,7 +84,6 @@ unsafe impl Alloc for System {
     }
 }
 
-
 mod realloc_fallback {
     use core::alloc::{GlobalAlloc, Layout};
     use core::cmp;
@@ -110,8 +108,8 @@ mod realloc_fallback {
 
 mod platform {
     use super::*;
-
-    use sgx_trts::libc::{self, c_void};
+    use libc;
+    use core::ffi::c_void;
     use core::ptr;
     use core::alloc::{GlobalAlloc, Layout};
 
@@ -151,7 +149,7 @@ mod platform {
                           layout: Layout,
                           new_size: usize) -> *mut u8 {
             if layout.align() <= MIN_ALIGN && layout.align() <= new_size {
-                libc::realloc(ptr as *mut libc::c_void, new_size) as *mut u8
+                libc::realloc(ptr as *mut c_void, new_size) as *mut u8
             } else {
                 self.realloc_fallback(ptr, layout, new_size)
             }
@@ -163,3 +161,15 @@ mod platform {
         libc::memalign(layout.align(), layout.size()) as *mut u8
     }
 }
+
+mod libc {
+    use core::ffi::c_void;
+    type size_t = usize;
+    extern {
+        pub fn calloc(nobj: size_t, size: size_t) -> * mut c_void;
+        pub fn malloc(size: size_t) -> * mut c_void;
+        pub fn realloc(p: * mut c_void, size: size_t) -> * mut c_void;
+        pub fn free(p: * mut c_void);
+        pub fn memalign(align: size_t, size: size_t) -> *mut c_void;
+    }
+}
\ No newline at end of file
diff --git a/sgx_libc/src/lib.rs b/sgx_libc/src/lib.rs
index 0cf92b9..63aa611 100644
--- a/sgx_libc/src/lib.rs
+++ b/sgx_libc/src/lib.rs
@@ -37,6 +37,7 @@
 #![allow(unused_macros)]
 #![allow(unused_assignments)]
 
+#[macro_use]
 extern crate alloc;
 
 #[cfg(all(target_os = "linux", target_arch = "x86_64"))]
diff --git a/sgx_libc/src/linux/x86_64/mod.rs b/sgx_libc/src/linux/x86_64/mod.rs
index e546414..8daa08e 100644
--- a/sgx_libc/src/linux/x86_64/mod.rs
+++ b/sgx_libc/src/linux/x86_64/mod.rs
@@ -36,6 +36,7 @@ pub use sgx_types::{int8_t, int16_t, int32_t, int64_t, uint8_t, uint16_t, uint32
 pub use sgx_types::{c_void, c_schar, c_char, c_uchar, c_short, c_ushort, c_int, c_uint, c_float,
                     c_double, c_longlong, c_ulonglong, intmax_t, uintmax_t, c_ulong, c_long};
 pub use sgx_types::{size_t, ptrdiff_t, intptr_t, uintptr_t, ssize_t};
+pub use sgx_types::time_t;
 
 use core::ptr;
 use core::mem;
@@ -131,7 +132,6 @@ pub type in_port_t = u16;
 pub type sa_family_t = u16;
 pub type socklen_t = u32;
 pub type off64_t = i64;
-pub type time_t = i64;
 pub type clockid_t = i32;
 pub type suseconds_t = i64;
 pub type dev_t = u64;
diff --git a/sgx_libc/src/linux/x86_64/ocall.rs b/sgx_libc/src/linux/x86_64/ocall.rs
index 4c48c46..ea68fa2 100644
--- a/sgx_libc/src/linux/x86_64/ocall.rs
+++ b/sgx_libc/src/linux/x86_64/ocall.rs
@@ -30,6 +30,7 @@ use sgx_types::{self, sgx_status_t};
 use super::*;
 use alloc::slice;
 use alloc::vec::Vec;
+use alloc::boxed::Box;
 use core::ptr;
 use core::mem;
 
@@ -386,6 +387,15 @@ extern "C" {
                             errno: * mut c_int,
                             sockfd: c_int,
                             how: c_int) -> sgx_status_t;
+    // net
+    pub fn u_getaddrinfo_ocall(result: * mut c_int,
+                               errno: * mut c_int,
+                               node: * const c_char,
+                               service: * const c_char,
+                               hints: * const addrinfo,
+                               res: * mut * mut addrinfo) -> sgx_status_t;
+    pub fn u_freeaddrinfo_ocall(res: * mut addrinfo) -> sgx_status_t;
+    pub fn u_gai_strerror_ocall(result: * mut * const c_char, errcode: c_int) -> sgx_status_t;
     // async io
     pub fn u_poll_ocall(result: * mut c_int,
                         errno: * mut c_int,
@@ -2340,6 +2350,120 @@ pub unsafe fn shutdown(sockfd: c_int, how: c_int) -> c_int {
     result
 }
 
+pub unsafe fn getaddrinfo(node: * const c_char, service: * const c_char, hints: * const addrinfo, res: * mut * mut addrinfo) -> c_int {
+    let mut result: c_int = 0;
+    let mut error: c_int = 0;
+    let mut ret_res: * mut addrinfo = ptr::null_mut();
+    let hint: addrinfo = addrinfo {
+        ai_flags: (*hints).ai_flags,
+        ai_family: (*hints).ai_family,
+        ai_socktype: (*hints).ai_socktype,
+        ai_protocol: (*hints).ai_protocol,
+        ai_addrlen: 0,
+        ai_addr: ptr::null_mut(),
+        ai_canonname: ptr::null_mut(),
+        ai_next: ptr::null_mut(),
+    };
+
+    let status = u_getaddrinfo_ocall(&mut result as * mut c_int,
+                                     &mut error as * mut c_int,
+                                     node,
+                                     service,
+                                     &hint as * const addrinfo,
+                                     &mut ret_res as * mut * mut addrinfo);
+    if status == sgx_status_t::SGX_SUCCESS {
+        if result == 0 {
+            *res = ptr::null_mut();
+            let mut cur_ptr: * mut addrinfo = ret_res;
+            let mut addrinfo_vec: Vec<Box<addrinfo>> = Vec::new();
+            while cur_ptr != ptr::null_mut() {
+                let cur: &addrinfo = &*cur_ptr;
+                let mut info = addrinfo {
+                    ai_flags: cur.ai_flags,
+                    ai_family: cur.ai_family,
+                    ai_socktype: cur.ai_socktype,
+                    ai_protocol: cur.ai_protocol,
+                    ai_addrlen: 0,
+                    ai_addr: ptr::null_mut(),
+                    ai_canonname: ptr::null_mut(),
+                    ai_next: ptr::null_mut(),
+                };
+
+                if !cur.ai_addr.is_null() && cur.ai_addrlen > 0 {
+                    let mut addr_vec = vec![0u8; cur.ai_addrlen as usize];
+                    let addr_slice: &[u8] = slice::from_raw_parts(cur.ai_addr as * const u8, cur.ai_addrlen as usize);
+                    addr_vec.copy_from_slice(addr_slice);
+                    addr_vec.shrink_to_fit();
+                    info.ai_addrlen = cur.ai_addrlen;
+                    info.ai_addr = addr_vec.as_mut_ptr() as * mut sockaddr;
+                    mem::forget(addr_vec);
+                }
+
+                if !cur.ai_canonname.is_null() {
+                    let len: usize = strlen(cur.ai_canonname) + 1;
+                    let mut name_vec = vec![0u8; len];
+                    let name_slice: &[u8] = slice::from_raw_parts(cur.ai_canonname as * const u8, len);
+                    name_vec.copy_from_slice(name_slice);
+                    name_vec.shrink_to_fit();
+                    info.ai_canonname = name_vec.as_mut_ptr() as * mut c_char;
+                    mem::forget(name_vec);
+                }
+
+                addrinfo_vec.push(Box::new(info));
+                cur_ptr = cur.ai_next;
+            }
+
+            if addrinfo_vec.len() > 0 {
+                for i in 0..addrinfo_vec.len() - 1 {
+                    addrinfo_vec[i].ai_next = addrinfo_vec[i + 1].as_mut() as * mut addrinfo;
+                }
+                *res = addrinfo_vec[0].as_mut() as * mut addrinfo;
+
+                for info in addrinfo_vec {
+                    let _ = Box::into_raw(info);
+                }
+            }
+            let _ = u_freeaddrinfo_ocall(ret_res);
+
+        } else if result == EAI_SYSTEM {
+            set_errno(error);
+        }
+    } else {
+        set_errno(ESGX);
+        result = EAI_SYSTEM;
+    }
+    result
+}
+
+pub unsafe fn freeaddrinfo(res: * mut addrinfo ) {
+    let mut cur_ptr: * mut addrinfo = res;
+    let mut addrinfo_vec: Vec<Box<addrinfo>> = Vec::new();
+    while cur_ptr != ptr::null_mut() {
+        let cur: &addrinfo = &*cur_ptr;
+        if !cur.ai_addr.is_null() && cur.ai_addrlen > 0 {
+            let addr_vec = Vec::from_raw_parts(cur.ai_addr as * mut u8, cur.ai_addrlen as usize, cur.ai_addrlen as usize);
+            drop(addr_vec);
+        }
+        if !cur.ai_canonname.is_null() {
+            let len: usize = strlen(cur.ai_canonname) + 1;
+            let name_vec = Vec::from_raw_parts(cur.ai_canonname as * mut u8, len, len);
+            drop(name_vec);
+        }
+        addrinfo_vec.push(Box::from_raw(cur_ptr));
+        cur_ptr = cur.ai_next;
+    }
+    drop(addrinfo_vec);
+}
+
+pub unsafe fn gai_strerror(errcode: c_int) -> * const c_char {
+    let mut result: * const c_char = ptr::null();
+    let status = u_gai_strerror_ocall(&mut result as * mut * const c_char, errcode);
+    if status != sgx_status_t::SGX_SUCCESS {
+        set_errno(ESGX);
+    }
+    result
+}
+
 pub unsafe fn poll(fds: * mut pollfd, nfds: nfds_t, timeout: c_int) -> c_int {
     let mut result: c_int = 0;
     let mut error: c_int = 0;
diff --git a/sgx_libc/src/macros.rs b/sgx_libc/src/macros.rs
index f2d1c71..a414e37 100644
--- a/sgx_libc/src/macros.rs
+++ b/sgx_libc/src/macros.rs
@@ -27,39 +27,105 @@
 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
 macro_rules! cfg_if {
+    // match if/else chains with a final `else`
     ($(
         if #[cfg($($meta:meta),*)] { $($it:item)* }
     ) else * else {
         $($it2:item)*
     }) => {
-        __cfg_if_items! {
+        cfg_if! {
+            @__items
             () ;
             $( ( ($($meta),*) ($($it)*) ), )*
             ( () ($($it2)*) ),
         }
-    }
-}
+    };
 
-macro_rules! __cfg_if_items {
-    (($($not:meta,)*) ; ) => {};
-    (($($not:meta,)*) ; ( ($($m:meta),*) ($($it:item)*) ), $($rest:tt)*) => {
-        __cfg_if_apply! { cfg(all(not(any($($not),*)), $($m,)*)), $($it)* }
-        __cfg_if_items! { ($($not,)* $($m,)*) ; $($rest)* }
-    }
-}
+    // match if/else chains lacking a final `else`
+    (
+        if #[cfg($($i_met:meta),*)] { $($i_it:item)* }
+        $(
+            else if #[cfg($($e_met:meta),*)] { $($e_it:item)* }
+        )*
+    ) => {
+        cfg_if! {
+            @__items
+            () ;
+            ( ($($i_met),*) ($($i_it)*) ),
+            $( ( ($($e_met),*) ($($e_it)*) ), )*
+            ( () () ),
+        }
+    };
 
-macro_rules! __cfg_if_apply {
-    ($m:meta, $($it:item)*) => {
+    // Internal and recursive macro to emit all the items
+    //
+    // Collects all the negated cfgs in a list at the beginning and after the
+    // semicolon is all the remaining items
+    (@__items ($($not:meta,)*) ; ) => {};
+    (@__items ($($not:meta,)*) ; ( ($($m:meta),*) ($($it:item)*) ),
+     $($rest:tt)*) => {
+        // Emit all items within one block, applying an approprate #[cfg]. The
+        // #[cfg] will require all `$m` matchers specified and must also negate
+        // all previous matchers.
+        cfg_if! { @__apply cfg(all($($m,)* not(any($($not),*)))), $($it)* }
+
+        // Recurse to emit all other items in `$rest`, and when we do so add all
+        // our `$m` matchers to the list of `$not` matchers as future emissions
+        // will have to negate everything we just matched as well.
+        cfg_if! { @__items ($($not,)* $($m,)*) ; $($rest)* }
+    };
+
+    // Internal macro to Apply a cfg attribute to a list of items
+    (@__apply $m:meta, $($it:item)*) => {
         $(#[$m] $it)*
-    }
+    };
 }
 
-macro_rules! __item {
-    ($i:item) => ($i)
+macro_rules! s {
+    ($($(#[$attr:meta])* pub $t:ident $i:ident { $($field:tt)* })*) => ($(
+        s!(it: $(#[$attr])* pub $t $i { $($field)* });
+    )*);
+    (it: $(#[$attr:meta])* pub union $i:ident { $($field:tt)* }) => (
+        compile_error!("unions cannot derive extra traits, use s_no_extra_traits instead");
+    );
+    (it: $(#[$attr:meta])* pub struct $i:ident { $($field:tt)* }) => (
+        __item! {
+            #[repr(C)]
+            #[cfg_attr(feature = "extra_traits", derive(Debug, Eq, Hash, PartialEq))]
+            #[allow(deprecated)]
+            $(#[$attr])*
+            pub struct $i { $($field)* }
+        }
+        #[allow(deprecated)]
+        impl Copy for $i {}
+        #[allow(deprecated)]
+        impl Clone for $i {
+            fn clone(&self) -> $i { *self }
+        }
+    );
 }
 
-macro_rules! s {
-    ($($(#[$attr:meta])* pub struct $i:ident { $($field:tt)* })*) => ($(
+macro_rules! s_no_extra_traits {
+    ($($(#[$attr:meta])* pub $t:ident $i:ident { $($field:tt)* })*) => ($(
+        s_no_extra_traits!(it: $(#[$attr])* pub $t $i { $($field)* });
+    )*);
+    (it: $(#[$attr:meta])* pub union $i:ident { $($field:tt)* }) => (
+        cfg_if! {
+            if #[cfg(libc_union)] {
+                __item! {
+                    #[repr(C)]
+                    $(#[$attr])*
+                    pub union $i { $($field)* }
+                }
+
+                impl Copy for $i {}
+                impl Clone for $i {
+                    fn clone(&self) -> $i { *self }
+                }
+            }
+        }
+    );
+    (it: $(#[$attr:meta])* pub struct $i:ident { $($field:tt)* }) => (
         __item! {
             #[repr(C)]
             $(#[$attr])*
@@ -69,7 +135,7 @@ macro_rules! s {
         impl Clone for $i {
             fn clone(&self) -> $i { *self }
         }
-    )*)
+    );
 }
 
 macro_rules! f {
@@ -77,15 +143,33 @@ macro_rules! f {
         $($body:stmt);*
     })*) => ($(
         #[inline]
-        #[cfg(not(cross_platform_docs))]
         pub unsafe extern fn $i($($arg: $argty),*) -> $ret {
             $($body);*
         }
+    )*)
+}
 
-        #[cfg(cross_platform_docs)]
-        #[allow(dead_code)]
-        pub unsafe extern fn $i($($arg: $argty),*) -> $ret {
-            loop {}
-        }
+
+macro_rules! __item {
+    ($i:item) => {
+        $i
+    };
+}
+
+macro_rules! align_const {
+    ($($(#[$attr:meta])*
+       pub const $name:ident : $t1:ty
+       = $t2:ident { $($field:tt)* };)*) => ($(
+        #[cfg(libc_align)]
+        $(#[$attr])*
+        pub const $name : $t1 = $t2 {
+            $($field)*
+        };
+        #[cfg(not(libc_align))]
+        $(#[$attr])*
+        pub const $name : $t1 = $t2 {
+            $($field)*
+            __align: [],
+        };
     )*)
 }
\ No newline at end of file
diff --git a/sgx_alloc/Cargo.toml b/sgx_no_tstd/Cargo.toml
similarity index 70%
copy from sgx_alloc/Cargo.toml
copy to sgx_no_tstd/Cargo.toml
index 38a52e9..ec1aa1e 100644
--- a/sgx_alloc/Cargo.toml
+++ b/sgx_no_tstd/Cargo.toml
@@ -1,7 +1,8 @@
 [package]
-name = "sgx_alloc"
+name = "sgx_no_tstd"
 version = "1.0.9"
 authors = ["Baidu"]
+build = "build.rs"
 repository = "https://github.com/baidu/rust-sgx-sdk"
 license-file = "LICENSE"
 documentation = "https://dingelish.github.io/"
@@ -9,11 +10,14 @@ description = "Rust SGX SDK provides the ability to write Intel SGX applications
 edition = "2018"
 
 [lib]
-name = "sgx_alloc"
+name = "sgx_no_tstd"
 crate-type = ["rlib"]
 
 [features]
 default = []
 
+[build-dependencies]
+sgx_build_helper = { path = "../sgx_build_helper" }
+
 [target.'cfg(not(target_env = "sgx"))'.dependencies]
-sgx_trts = { path = "../sgx_trts" }
+sgx_alloc = { path = "../sgx_alloc" }
\ No newline at end of file
diff --git a/sgx_no_tstd/LICENSE b/sgx_no_tstd/LICENSE
new file mode 100644
index 0000000..a329fc5
--- /dev/null
+++ b/sgx_no_tstd/LICENSE
@@ -0,0 +1,613 @@
+BSD License
+
+Copyright (C) 2017-2019 Baidu, Inc. All Rights Reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions
+are met:
+
+  * Redistributions of source code must retain the above copyright
+    notice, this list of conditions and the following disclaimer.
+  * Redistributions in binary form must reproduce the above copyright
+    notice, this list of conditions and the following disclaimer in
+    the documentation and/or other materials provided with the
+    distribution.
+  * Neither the name of Baidu, Inc., nor the names of its
+    contributors may be used to endorse or promote products derived
+    from this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+
+
+===========================================================================================================================================================
+
+Rust SGX SDK software for Linux also uses third-party projects that may be distributed under different licenses. Please see below for details.
+
+
+1. Intel(R) SGX
+
+Copyright (C) 2011-2017 Intel Corporation. All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions
+are met:
+
+  * Redistributions of source code must retain the above copyright
+    notice, this list of conditions and the following disclaimer.
+  * Redistributions in binary form must reproduce the above copyright
+    notice, this list of conditions and the following disclaimer in
+    the documentation and/or other materials provided with the
+    distribution.
+  * Neither the name of Intel Corporation nor the names of its
+    contributors may be used to endorse or promote products derived
+    from this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+
+2. Rust Project
+
+                              Apache License
+                        Version 2.0, January 2004
+                     http://www.apache.org/licenses/
+
+TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+1. Definitions.
+
+   "License" shall mean the terms and conditions for use, reproduction,
+   and distribution as defined by Sections 1 through 9 of this document.
+
+   "Licensor" shall mean the copyright owner or entity authorized by
+   the copyright owner that is granting the License.
+
+   "Legal Entity" shall mean the union of the acting entity and all
+   other entities that control, are controlled by, or are under common
+   control with that entity. For the purposes of this definition,
+   "control" means (i) the power, direct or indirect, to cause the
+   direction or management of such entity, whether by contract or
+   otherwise, or (ii) ownership of fifty percent (50%) or more of the
+   outstanding shares, or (iii) beneficial ownership of such entity.
+
+   "You" (or "Your") shall mean an individual or Legal Entity
+   exercising permissions granted by this License.
+
+   "Source" form shall mean the preferred form for making modifications,
+   including but not limited to software source code, documentation
+   source, and configuration files.
+
+   "Object" form shall mean any form resulting from mechanical
+   transformation or translation of a Source form, including but
+   not limited to compiled object code, generated documentation,
+   and conversions to other media types.
+
+   "Work" shall mean the work of authorship, whether in Source or
+   Object form, made available under the License, as indicated by a
+   copyright notice that is included in or attached to the work
+   (an example is provided in the Appendix below).
+
+   "Derivative Works" shall mean any work, whether in Source or Object
+   form, that is based on (or derived from) the Work and for which the
+   editorial revisions, annotations, elaborations, or other modifications
+   represent, as a whole, an original work of authorship. For the purposes
+   of this License, Derivative Works shall not include works that remain
+   separable from, or merely link (or bind by name) to the interfaces of,
+   the Work and Derivative Works thereof.
+
+   "Contribution" shall mean any work of authorship, including
+   the original version of the Work and any modifications or additions
+   to that Work or Derivative Works thereof, that is intentionally
+   submitted to Licensor for inclusion in the Work by the copyright owner
+   or by an individual or Legal Entity authorized to submit on behalf of
+   the copyright owner. For the purposes of this definition, "submitted"
+   means any form of electronic, verbal, or written communication sent
+   to the Licensor or its representatives, including but not limited to
+   communication on electronic mailing lists, source code control systems,
+   and issue tracking systems that are managed by, or on behalf of, the
+   Licensor for the purpose of discussing and improving the Work, but
+   excluding communication that is conspicuously marked or otherwise
+   designated in writing by the copyright owner as "Not a Contribution."
+
+   "Contributor" shall mean Licensor and any individual or Legal Entity
+   on behalf of whom a Contribution has been received by Licensor and
+   subsequently incorporated within the Work.
+
+2. Grant of Copyright License. Subject to the terms and conditions of
+   this License, each Contributor hereby grants to You a perpetual,
+   worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+   copyright license to reproduce, prepare Derivative Works of,
+   publicly display, publicly perform, sublicense, and distribute the
+   Work and such Derivative Works in Source or Object form.
+
+3. Grant of Patent License. Subject to the terms and conditions of
+   this License, each Contributor hereby grants to You a perpetual,
+   worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+   (except as stated in this section) patent license to make, have made,
+   use, offer to sell, sell, import, and otherwise transfer the Work,
+   where such license applies only to those patent claims licensable
+   by such Contributor that are necessarily infringed by their
+   Contribution(s) alone or by combination of their Contribution(s)
+   with the Work to which such Contribution(s) was submitted. If You
+   institute patent litigation against any entity (including a
+   cross-claim or counterclaim in a lawsuit) alleging that the Work
+   or a Contribution incorporated within the Work constitutes direct
+   or contributory patent infringement, then any patent licenses
+   granted to You under this License for that Work shall terminate
+   as of the date such litigation is filed.
+
+4. Redistribution. You may reproduce and distribute copies of the
+   Work or Derivative Works thereof in any medium, with or without
+   modifications, and in Source or Object form, provided that You
+   meet the following conditions:
+
+   (a) You must give any other recipients of the Work or
+       Derivative Works a copy of this License; and
+
+   (b) You must cause any modified files to carry prominent notices
+       stating that You changed the files; and
+
+   (c) You must retain, in the Source form of any Derivative Works
+       that You distribute, all copyright, patent, trademark, and
+       attribution notices from the Source form of the Work,
+       excluding those notices that do not pertain to any part of
+       the Derivative Works; and
+
+   (d) If the Work includes a "NOTICE" text file as part of its
+       distribution, then any Derivative Works that You distribute must
+       include a readable copy of the attribution notices contained
+       within such NOTICE file, excluding those notices that do not
+       pertain to any part of the Derivative Works, in at least one
+       of the following places: within a NOTICE text file distributed
+       as part of the Derivative Works; within the Source form or
+       documentation, if provided along with the Derivative Works; or,
+       within a display generated by the Derivative Works, if and
+       wherever such third-party notices normally appear. The contents
+       of the NOTICE file are for informational purposes only and
+       do not modify the License. You may add Your own attribution
+       notices within Derivative Works that You distribute, alongside
+       or as an addendum to the NOTICE text from the Work, provided
+       that such additional attribution notices cannot be construed
+       as modifying the License.
+
+   You may add Your own copyright statement to Your modifications and
+   may provide additional or different license terms and conditions
+   for use, reproduction, or distribution of Your modifications, or
+   for any such Derivative Works as a whole, provided Your use,
+   reproduction, and distribution of the Work otherwise complies with
+   the conditions stated in this License.
+
+5. Submission of Contributions. Unless You explicitly state otherwise,
+   any Contribution intentionally submitted for inclusion in the Work
+   by You to the Licensor shall be under the terms and conditions of
+   this License, without any additional terms or conditions.
+   Notwithstanding the above, nothing herein shall supersede or modify
+   the terms of any separate license agreement you may have executed
+   with Licensor regarding such Contributions.
+
+6. Trademarks. This License does not grant permission to use the trade
+   names, trademarks, service marks, or product names of the Licensor,
+   except as required for reasonable and customary use in describing the
+   origin of the Work and reproducing the content of the NOTICE file.
+
+7. Disclaimer of Warranty. Unless required by applicable law or
+   agreed to in writing, Licensor provides the Work (and each
+   Contributor provides its Contributions) on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+   implied, including, without limitation, any warranties or conditions
+   of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+   PARTICULAR PURPOSE. You are solely responsible for determining the
+   appropriateness of using or redistributing the Work and assume any
+   risks associated with Your exercise of permissions under this License.
+
+8. Limitation of Liability. In no event and under no legal theory,
+   whether in tort (including negligence), contract, or otherwise,
+   unless required by applicable law (such as deliberate and grossly
+   negligent acts) or agreed to in writing, shall any Contributor be
+   liable to You for damages, including any direct, indirect, special,
+   incidental, or consequential damages of any character arising as a
+   result of this License or out of the use or inability to use the
+   Work (including but not limited to damages for loss of goodwill,
+   work stoppage, computer failure or malfunction, or any and all
+   other commercial damages or losses), even if such Contributor
+   has been advised of the possibility of such damages.
+
+9. Accepting Warranty or Additional Liability. While redistributing
+   the Work or Derivative Works thereof, You may choose to offer,
+   and charge a fee for, acceptance of support, warranty, indemnity,
+   or other liability obligations and/or rights consistent with this
+   License. However, in accepting such obligations, You may act only
+   on Your own behalf and on Your sole responsibility, not on behalf
+   of any other Contributor, and only if You agree to indemnify,
+   defend, and hold each Contributor harmless for any liability
+   incurred by, or claims asserted against, such Contributor by reason
+   of your accepting any such warranty or additional liability.
+
+END OF TERMS AND CONDITIONS
+
+APPENDIX: How to apply the Apache License to your work.
+
+   To apply the Apache License to your work, attach the following
+   boilerplate notice, with the fields enclosed by brackets "[]"
+   replaced with your own identifying information. (Don't include
+   the brackets!)  The text should be enclosed in the appropriate
+   comment syntax for the file format. We also recommend that a
+   file or class name and description of purpose be included on the
+   same "printed page" as the copyright notice for easier
+   identification within third-party archives.
+
+Copyright [yyyy] [name of copyright owner]
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+	http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+
+
+3. compiler_rt
+
+The compiler_rt library is dual licensed under both the University of Illinois
+"BSD-Like" license and the MIT license.  As a user of this code you may choose
+to use it under either license.  As a contributor, you agree to allow your code
+to be used under both.
+
+Full text of the relevant licenses is included below.
+
+=============================================================================
+
+University of Illinois/NCSA
+Open Source License
+
+Copyright (c) 2009-2013 by the contributors listed in CREDITS.TXT
+
+All rights reserved.
+
+Developed by:
+
+    LLVM Team
+
+    University of Illinois at Urbana-Champaign
+
+    http://llvm.org
+
+Permission is hereby granted, free of charge, to any person obtaining a copy of this
+software and associated documentation files (the "Software"), to deal with the
+Software without restriction, including without limitation the rights to use,
+copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the
+Software, and to permit persons to whom the Software is furnished to do so, subject
+to the following conditions:
+
+-	Redistributions of source code must retain the above copyright notice,
+this list of conditions and the following disclaimers.
+
+-	Redistributions in binary form must reproduce the above copyright notice,
+this list of conditions and the following disclaimers in the documentation and/or
+other materials provided with the distribution.
+
+-	Neither the names of the LLVM Team, University of Illinois at Urbana-Champaign,
+nor the names of its contributors may be used to endorse or romote products derived
+from this Software without specific prior written permission.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
+INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
+PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE CONTRIBUTORS OR COPYRIGHT HOLDERS BE
+LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT
+OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+DEALINGS WITH THE SOFTWARE.
+
+=============================================================================
+
+Copyright (c) 2009-2013 by the contributors listed in CREDITS.TXT
+
+Permission is hereby granted, free of charge, to any person obtaining a copy of this
+software and associated documentation files (the "Software"), to deal in the Software
+without restriction, including without limitation the rights to use, copy, modify, merge,
+publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
+to whom the Software is furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all copies or
+substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
+INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
+PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
+FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+DEALINGS IN THE SOFTWARE.
+
+=============================================================================
+Copyrights and Licenses for Third Party Software Distributed with LLVM:
+=============================================================================
+The LLVM software contains code written by third parties.  Such software will have its
+own individual LICENSE.TXT file in the directory in which it appears.
+This file will describe the copyrights, license, and restrictions which apply to that code.
+
+The disclaimer of warranty in the University of Illinois Open Source License applies to all
+code in the LLVM Distribution, and nothing in any of the other licenses gives permission to
+use the names of the LLVM Team or the University of Illinois to endorse or promote products
+derived from this Software.
+
+The following pieces of software have additional or alternate copyrights, licenses, and/or
+restrictions:
+
+Program             Directory
+-------             ---------
+mach_override       lib/interception/mach_override
+
+
+
+4. NetBSD
+
+===============================================================================================
+
+/*-
+ * Copyright (c) 2008 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+________________________________________
+For complete copyright and licensing terms, see: http://www.netbsd.org/about/redistribution.html
+
+
+
+
+5. OpenBSD
+
+http://openbsd.org/
+
+OpenBSD* Copyright Policy
+________________________________________
+-	Goal
+Copyright law is complex, OpenBSD* policy is simple - OpenBSD strives to maintain the spirit
+of the original Berkeley Unix copyrights.
+OpenBSD can exist as it does today because of the example set by the Computer Systems Research
+Group at Berkeley and the battles which they and others fought to create a relatively
+un-encumbered Unix source distribution.
+The ability of a freely redistributable "Berkeley" Unix to move forward on a competitive
+basis with other operating systems depends on the willingness of the various development
+groups to exchange code amongst themselves and with other projects. Understanding the legal
+issues surrounding copyright is fundamental to the ability to exchange and re-distribute code,
+while honoring the spirit of the copyright and concept of attribution is fundamental to
+promoting the cooperation of the people involved.
+-	The Berkeley* Copyright
+The Berkeley* copyright poses no restrictions on private or commercial use of the software
+and imposes only simple and uniform requirements for maintaining copyright notices in
+redistributed versions and crediting the originator of the material only in advertising.
+For instance:
+ * Copyright (c) 1982, 1986, 1990, 1991, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *	This product includes software developed by the University of
+ *	California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+Berkeley rescinded the 3rd term (the advertising term) on 22 July 1999. Verbatim copies
+of the Berkeley license in the OpenBSD tree have that term removed. In addition, many
+3rd-party BSD-style licenses consist solely of the first two terms.
+Because the OpenBSD copyright imposes no conditions beyond those imposed by the Berkeley
+copyright, OpenBSD can hope to share the same wide distribution and applicability as the
+Berkeley distributions. It follows however, that OpenBSD cannot include material which
+includes copyrights which are more restrictive than the Berkeley copyright, or must
+relegate this material to a secondary status, i.e. OpenBSD as a whole is freely
+redistributable, but some optional components may not be.
+-	Copyright Law
+While the overall subject of copyright law is far beyond the scope of this document, some
+basics are in order. Under the current copyright law, copyrights are implicit in the
+creation of a new work and reside with the creator, unless otherwise assigned. In general
+the copyright applies only to the new work, not the material the work was derived from,
+nor those portions of the derivative material included in the new work.
+Copyright law admits to three general categories of works:
+Original Work
+A new work that is not derived from an existing work.
+Derivative Work
+Work that is derived from, includes or amends existing works.
+Compilations
+A work that is a compilation of existing new and derivative works.
+The fundamental concept is that there is primacy of the copyright, that is a copyright of a
+derivative work does not affect the rights held by the owner of the copyright of the original
+work, rather only the part added. Likewise the copyright of a compilation does not affect the
+rights of the owner of the included works, only the compilation as an entity.
+It is vitally important to understand that copyrights are broad protections as defined by
+national and international copyright law. The "copyright notices" usually included in source
+files are not copyrights, but rather notices that a party asserts that they hold copyright
+to the material or to part of the material. Typically these notices are associated with
+license terms which grant permissions subject to copyright law and with disclaimers that
+state the position of the copyright holder/distributor with respect to liability surrounding
+use of the material.
+-	Permissions - the flip side
+Because copyrights arise from the creation of a work, rather than through a registration process,
+there needs to be a practical way to extend permission to use a work beyond what might be allowed
+by "fair use" provisions of the copyright laws.
+This permission typically takes the form of a "release" or "license" included in the work, which
+grants the additional uses beyond those granted by copyright law, usually subject to a variety of
+conditions. At one extreme sits "public domain" where the originator asserts that he imposes no
+restrictions on use of the material, at the other restrictive clauses that actually grant no
+additional rights or impose restrictive, discriminatory or impractical conditions on use of the
+work.
+Again, an important point to note is that the release and conditions can only apply to the
+portion of the work that was originated by the copyright holder - the holder of a copyright
+on a derivative work can neither grant additional permissions for use of the original work,
+nor impose more restrictive conditions for use of that work.
+Because copyright arises from the creation of a work and not the text or a registration process,
+removing or altering a copyright notice or associated release terms has no bearing on the
+existence of the copyright, rather all that is accomplished is to cast doubt upon whatever rights
+the person making the modifications had to use the material in the first place. Likewise, adding
+terms and conditions in conflict with the original terms and conditions does not supersede them,
+rather it casts doubts on the rights of the person making the amendments to use the material and
+creates confusion as to whether anyone can use the amended version or derivatives thereof.
+Finally, releases are generally binding on the material that they are distributed with. This means
+that if the originator of a work distributes that work with a release granting certain permissions,
+those permissions apply as stated, without discrimination, to all persons legitimately possessing
+a copy of the work. That means that having granted a permission, the copyright holder can not
+retroactively say that an individual or class of individuals are no longer granted those permissions.
+Likewise should the copyright holder decide to "go commercial" he can not revoke permissions already
+granted for the use of the work as distributed, though he may impose more restrictive permissions in
+his future distributions of that work.
+-	Specific Cases
+This section attempts to summarize the position of OpenBSD relative to some commonly encountered
+copyrights.
+Berkeley*
+The Berkeley copyright is the model for the OpenBSD copyright. It retains the rights of the
+copyright holder, while imposing minimal conditions on the use of the copyrighted material.
+Material with Berkeley copyrights, or copyrights closely adhering to the Berkeley model can
+generally be included in OpenBSD.
+AT&amp;T*
+As part of its settlement with AT&amp;T*, Berkeley included an AT&amp;T copyright notice on some of the
+files in 4.4BSD lite and lite2. The terms of this license are identical to the standard Berkeley
+license.
+Additionally, OpenBSD includes some other AT&amp;T code with non-restrictive copyrights, such as the
+reference implementation of awk.
+Caldera*
+Caldera* (now known as the SCO group) is the current owner of the Unix code copyrights. On 23
+January 2002, the original Unix code (versions 1 through seven, including 32V) was freed by Caldera.
+This code is now available under a 4-term BSD-style license. As a result, it is now possible to
+incorporate real Unix code into OpenBSD (though this code is quite old and generally requires significant
+changes to bring it up to date).
+DEC*, Sun*, other manufacturers/software houses.
+In general OpenBSD does not include material copyrighted by manufacturers or software houses.
+Material may be included where the copyright owner has granted general permission for reuse
+without conditions, with terms similar to the Berkeley copyright, or where the material is the
+product of an employee and the employer's copyright notice effectively releases any rights they
+might have to the work.
+Carnegie-Mellon* (CMU, Mach)
+The Carnegie-Mellon copyright is similar to the Berkeley copyright, except that it requests that
+derivative works be made available to Carnegie-Mellon. Because this is only a request and not a
+condition, such material can still be included in OpenBSD. It should be noted that existing
+versions of Mach are still subject to AT&amp;T copyrights, which prevents the general distribution
+of Mach sources.
+Apache*
+The original Apache* copyright is similar to the Berkeley copyright, except that it stipulates
+that products derived from the code may not have "Apache" in their name. The purpose of this
+clause is to avoid a situation in which another party releases a modified version of the code
+named in such a way to make users think that it is the "official" version. This is not an issue
+with OpenBSD because OpenBSD is a Compilation, and not a Derived Work. Source code published under
+version 2 of the Apache license cannot be included into OpenBSD. As a consequence, OpenBSD now
+maintains its own version of Apache based on version 1.3.29. The OpenBSD version includes many
+enhancements and bugfixes.
+ISC*
+The ISC* copyright is functionally equivalent to a two-term BSD copyright with language removed
+that is made unnecessary by the Berne convention. This is the preferred license for new code
+incorporated into OpenBSD. A sample license is included in the source tree as
+/usr/src/share/misc/license.template.
+GNU* General Public License, GPL, LGPL, copyleft, etc.
+The GNU* Public License and licenses modeled on it impose the restriction that source code must
+be distributed or made available for all works that are derivatives of the GNU copyrighted code.
+While this may be a noble strategy in terms of software sharing, it is a condition that is
+typically unacceptable for commercial use of software. As a consequence, software bound by the
+GPL terms can not be included in the kernel or "runtime" of OpenBSD, though software subject to
+ GPL terms may be included as development tools or as part of the system that are "optional" as
+long as such use does not result in OpenBSD as a whole becoming subject to the GPL terms.
+As an example, GCC and other GNU tools are included in the OpenBSD tool chain. However, it is
+quite possible to distribute a system for many applications without a tool chain, or the
+distributor can choose to include a tool chain as an optional bundle which conforms to the
+GPL terms.
+NetBSD*
+Much of OpenBSD is originally based on and evolved from NetBSD*, since some of the OpenBSD
+developers were involved in the NetBSD project. The general NetBSD license terms are compatible
+with the Berkeley license and permit such use. Material subject only to the general NetBSD license
+can generally be included in OpenBSD.
+In the past, NetBSD has included material copyrighted by individuals who have imposed license
+conditions beyond that of the general NetBSD license, but granted the NetBSD Foundation license
+to distribute the material. Such material can not be included in OpenBSD as long as the conditions
+imposed are at odds with the OpenBSD license terms or releases from those terms are offered on a
+discriminatory basis.
+FreeBSD*
+Most of FreeBSD* is also based on Berkeley licensed material or includes copyright notices based
+on the Berkeley model. Such material can be included in OpenBSD, while those parts that are subject
+to GPL or various individual copyright terms that are at odds with the OpenBSD license can not be
+included in OpenBSD.
+Linux*
+Most of Linux* is subject to GPL style licensing terms and therefore can not be included in
+OpenBSD. Individual components may be eligible, subject to the terms of the originator's copyright
+notices. Note that Linux "distributions" may also be subject to additional copyright claims of the
+distributing organization, either as a compilation or on material included that is not part of the
+Linux core.
+X*, XFree86*, X.Org*
+X*, X.Org* or XFree86* are not parts of OpenBSD, rather X.Org and parts of XFree86 3.3.6 are
+distributed with many OpenBSD ports as a convenience to the user, subject to applicable license
+terms.
+Shareware, Charityware, Freeware, etc.
+Most "shareware" copyright notices impose conditions for redistribution, use or visibility that
+are at conflict with the OpenBSD project goals. Review on a case-by-case basis is required as to
+whether the wording of the conditions is acceptable in terms of conditions being requested vs.
+demanded and whether the spirit of the conditions is compatible with goals of the OpenBSD project.
+Public Domain
+While material that is truly entered into the "Public Domain" can be included in OpenBSD, review
+is required on a case by case basis. Frequently the "public domain" assertion is made by someone
+who does not really hold all rights under Copyright law to grant that status or there are a variety
+of conditions imposed on use. For a work to be truly in the "Public Domain" all rights are abandoned
+and the material is offered without restrictions.
diff --git a/sgx_no_tstd/Readme.md b/sgx_no_tstd/Readme.md
new file mode 100644
index 0000000..3d5259f
--- /dev/null
+++ b/sgx_no_tstd/Readme.md
@@ -0,0 +1,3 @@
+# Note
+
+Please visit our [homepage](https://github.com/baidu/rust-sgx-sdk) for usage. Thanks!
diff --git a/sgx_tstd/src/rt.rs b/sgx_no_tstd/build.rs
similarity index 56%
copy from sgx_tstd/src/rt.rs
copy to sgx_no_tstd/build.rs
index fcfd0a4..47af261 100644
--- a/sgx_tstd/src/rt.rs
+++ b/sgx_no_tstd/build.rs
@@ -24,35 +24,35 @@
 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
-//! Runtime services
+extern crate sgx_build_helper as build_helper;
 
-use sgx_types::sgx_enclave_id_t;
-use crate::enclave;
-use alloc_crate::slice;
-use core::str;
-// Reexport some of our utilities which are expected by other crates.
-pub use crate::panicking::{begin_panic, begin_panic_fmt, update_panic_count};
-pub use crate::sys_common::at_exit;
-use crate::sys_common::cleanup;
+use std::env;
+use std::process::Command;
+use build_helper::{run, native_lib_boilerplate};
 
-#[no_mangle]
-pub extern "C" fn t_global_exit_ecall() {
+fn main() {
+    println!("cargo:rerun-if-changed=build.rs");
+    let target = env::var("TARGET").expect("TARGET was not set");
+    let host = env::var("HOST").expect("HOST was not set");
+
+    let _ = build_libunwind(&host, &target);
 }
 
-#[no_mangle]
-pub extern "C" fn t_global_init_ecall(id: u64, path: * const u8, len: usize) {
+fn build_libunwind(host: &str, target: &str) -> Result<(), ()> {
+    let native = native_lib_boilerplate("sgx_unwind/libunwind", "libunwind", "unwind", "src/.libs")?;
+    let cflags = env::var("CFLAGS").unwrap_or_default() + " -fvisibility=hidden -O2";
 
-    enclave::set_enclave_id(id as sgx_enclave_id_t);
-    let s = unsafe {
-        let str_slice = slice::from_raw_parts(path, len);
-        str::from_utf8_unchecked(str_slice)
-    };
-    enclave::set_enclave_path(s);
-}
+    run(Command::new("sh")
+                .current_dir(&native.out_dir)
+                .arg(native.src_dir.join("autogen-linux.sh").to_str().unwrap())
+                .arg(format!("--host={}", build_helper::gnu_target(target)))
+                .arg(format!("--build={}", build_helper::gnu_target(host)))
+                .env("CFLAGS", cflags));
 
-global_dtors_object! {
-    GLOBAL_DTORS, global_exit = { cleanup(); }
+    run(Command::new(build_helper::make(host))
+                .current_dir(&native.out_dir)
+                .arg(format!("INCDIR={}", native.src_dir.display()))
+                .arg("-j5"));
+    Ok(())
 }
-
diff --git a/sgx_no_tstd/src/lib.rs b/sgx_no_tstd/src/lib.rs
new file mode 100644
index 0000000..0b5fc0a
--- /dev/null
+++ b/sgx_no_tstd/src/lib.rs
@@ -0,0 +1,117 @@
+// Copyright (C) 2017-2019 Baidu, Inc. All Rights Reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions
+// are met:
+//
+//  * Redistributions of source code must retain the above copyright
+//    notice, this list of conditions and the following disclaimer.
+//  * Redistributions in binary form must reproduce the above copyright
+//    notice, this list of conditions and the following disclaimer in
+//    the documentation and/or other materials provided with the
+//    distribution.
+//  * Neither the name of Baidu, Inc., nor the names of its
+//    contributors may be used to endorse or promote products derived
+//    from this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+//! # liballoc crate for Rust SGX SDK
+//!
+//! This crate equals to the `liballoc_system` crate in Rust.
+//! It connects Rust memory allocation to Intel SGX's sgx_tstd library.
+//! It is essential, because we depends on Intel SGX's SDK.
+//! 2018-06-22 Add liballoc components here
+
+#![no_std]
+#![cfg_attr(target_env = "sgx", feature(rustc_private))]
+
+#![feature(lang_items)]
+#![feature(alloc_error_handler)]
+
+extern crate alloc as alloc_crate;
+
+#[cfg(target_env = "sgx")]
+extern crate sgx_alloc;
+
+use core::alloc::Layout;
+use core::panic::PanicInfo;
+use core::sync::atomic::{AtomicPtr, Ordering};
+use core::{mem, ptr};
+
+pub use alloc_crate::alloc::*;
+pub use sgx_alloc::System;
+
+#[global_allocator]
+static ALLOC: sgx_alloc::System = sgx_alloc::System;
+
+#[panic_handler]
+fn rust_begin_panic(_info: &PanicInfo<'_>) -> ! {
+    sgx_abort();
+}
+
+#[lang = "eh_personality"]
+#[no_mangle]
+unsafe extern "C" fn rust_eh_personality() {}
+
+static HOOK: AtomicPtr<()> = AtomicPtr::new(ptr::null_mut());
+
+/// Registers a custom allocation error hook, replacing any that was previously registered.
+///
+/// The allocation error hook is invoked when an infallible memory allocation fails, before
+/// the runtime aborts. The default hook prints a message to standard error,
+/// but this behavior can be customized with the [`set_alloc_error_hook`] and
+/// [`take_alloc_error_hook`] functions.
+///
+/// The hook is provided with a `Layout` struct which contains information
+/// about the allocation that failed.
+///
+/// The allocation error hook is a global resource.
+pub fn set_alloc_error_hook(hook: fn(Layout)) {
+    HOOK.store(hook as *mut (), Ordering::SeqCst);
+}
+
+/// Unregisters the current allocation error hook, returning it.
+///
+/// *See also the function [`set_alloc_error_hook`].*
+///
+/// If no custom hook is registered, the default hook will be returned.
+pub fn take_alloc_error_hook() -> fn(Layout) {
+    let hook = HOOK.swap(ptr::null_mut(), Ordering::SeqCst);
+    if hook.is_null() {
+        default_alloc_error_hook
+    } else {
+        unsafe { mem::transmute(hook) }
+    }
+}
+
+fn default_alloc_error_hook(_layout: Layout) {}
+
+#[alloc_error_handler]
+pub fn rust_oom(layout: Layout) -> ! {
+    let hook = HOOK.load(Ordering::SeqCst);
+    let hook: fn(Layout) = if hook.is_null() {
+        default_alloc_error_hook
+    } else {
+        unsafe { mem::transmute(hook) }
+    };
+    hook(layout);
+    sgx_abort();
+}
+
+#[link(name = "sgx_trts")]
+extern { pub fn abort() -> !; }
+
+fn sgx_abort() -> ! {
+    unsafe { abort() }
+}
diff --git a/sgx_tseal/src/internal.rs b/sgx_tseal/src/internal.rs
index 3e83e37..b32a19b 100644
--- a/sgx_tseal/src/internal.rs
+++ b/sgx_tseal/src/internal.rs
@@ -35,22 +35,6 @@ use core::ptr;
 use alloc::boxed::Box;
 use alloc::vec::Vec;
 
-//const SGX_MISCSEL_EXINFO: uint32_t     = 0x00000001;
-//const TSEAL_DEFAULT_MISCMASK: uint32_t = (!SGX_MISCSEL_EXINFO);
-
-/* intel sgx sdk 1.8 */
-/* Set the bits which have no security implications to 0 for sealed data migration */
-/* Bits which have no security implications in attributes.flags:
- *    Reserved bit[55:6]  - 0xFFFFFFFFFFFFC0ULL
- *    SGX_FLAGS_MODE64BIT
- *    SGX_FLAGS_PROVISION_KEY
- *    SGX_FLAGS_EINITTOKEN_KEY */
-const FLAGS_NON_SECURITY_BITS: uint64_t = (0x00FF_FFFF_FFFF_FFC0 | SGX_FLAGS_MODE64BIT | SGX_FLAGS_PROVISION_KEY| SGX_FLAGS_EINITTOKEN_KEY);
-const TSEAL_DEFAULT_FLAGSMASK: uint64_t = (!FLAGS_NON_SECURITY_BITS);
-
-const MISC_NON_SECURITY_BITS: uint32_t =  0x0FFF_FFFF;  /* bit[27:0]: have no security implications */
-const TSEAL_DEFAULT_MISCMASK: uint32_t =  (!MISC_NON_SECURITY_BITS);
-
 /* intel sgx sdk 2.4 */
 const KEY_POLICY_KSS: uint16_t = (SGX_KEYPOLICY_CONFIGID | SGX_KEYPOLICY_ISVFAMILYID | SGX_KEYPOLICY_ISVEXTPRODID);
 
diff --git a/sgx_tstd/Cargo.toml b/sgx_tstd/Cargo.toml
index fc72f4c..50ee373 100644
--- a/sgx_tstd/Cargo.toml
+++ b/sgx_tstd/Cargo.toml
@@ -19,6 +19,7 @@ backtrace = ["stdio"]
 stdio = []
 net = []
 pipe = []
+thread = []
 untrusted_fs = []
 untrusted_time = []
 
diff --git a/sgx_tstd/src/lib.rs b/sgx_tstd/src/lib.rs
index 443dccd..e7b483a 100644
--- a/sgx_tstd/src/lib.rs
+++ b/sgx_tstd/src/lib.rs
@@ -56,19 +56,16 @@
 
 #![feature(alloc_error_handler)]
 #![feature(panic_unwind)]
-//#![feature(__rust_unstable_column)]
 #![feature(allocator_api)]
 #![feature(allow_internal_unsafe)]
 #![feature(allocator_internals)]
 #![feature(allow_internal_unstable)]
 #![feature(array_error_internals)]
-//#![feature(bind_by_move_pattern_guards)]
 #![feature(asm)]
 #![feature(box_syntax)]
 #![feature(c_variadic)]
 #![feature(cfg_target_has_atomic)]
 #![feature(char_error_internals)]
-#![feature(compiler_builtins_lib)]
 #![feature(concat_idents)]
 #![feature(const_fn)]
 #![feature(core_intrinsics)]
@@ -111,14 +108,10 @@
 #![feature(unicode_internals)]
 #![feature(alloc_layout_extra)]
 #![feature(non_exhaustive)]
-//#![feature(const_vec_new)]
 #![feature(vec_remove_item)]
 #![feature(int_error_matching)]
 #![default_lib_allocator]
 
-#[global_allocator]
-static ALLOC: sgx_alloc::System = sgx_alloc::System;
-
 // Explicitly import the prelude. The compiler uses this same unstable attribute
 // to import the prelude implicitly when building crates that depend on std.
 #[prelude_import]
diff --git a/sgx_tstd/src/net/addr.rs b/sgx_tstd/src/net/addr.rs
index 078d747..05d5f09 100644
--- a/sgx_tstd/src/net/addr.rs
+++ b/sgx_tstd/src/net/addr.rs
@@ -32,11 +32,15 @@ use core::hash;
 use core::mem;
 use core::option;
 use core::iter;
+#[cfg(feature = "net")]
+use core::convert::TryInto;
 use alloc_crate::vec;
 use alloc_crate::slice;
 use crate::io;
 use crate::net::{ntoh, hton, IpAddr, Ipv4Addr, Ipv6Addr};
 use crate::sys_common::{FromInner, AsInner, IntoInner};
+#[cfg(feature = "net")]
+use crate::sys_common::net::LookupHost;
 
 /// An internet socket address, either IPv4 or IPv6.
 ///
@@ -497,6 +501,13 @@ impl ToSocketAddrs for (Ipv6Addr, u16) {
     }
 }
 
+#[cfg(feature = "net")]
+fn resolve_socket_addr(lh: LookupHost) -> io::Result<vec::IntoIter<SocketAddr>> {
+    let p = lh.port();
+    let v: Vec<_> = lh.map(|mut a| { a.set_port(p); a }).collect();
+    Ok(v.into_iter())
+}
+
 impl ToSocketAddrs for (&str, u16) {
     type Iter = vec::IntoIter<SocketAddr>;
     fn to_socket_addrs(&self) -> io::Result<vec::IntoIter<SocketAddr>> {
@@ -512,12 +523,15 @@ impl ToSocketAddrs for (&str, u16) {
             return Ok(vec![SocketAddr::V6(addr)].into_iter())
         }
 
-        Err(io::Error::new(io::ErrorKind::InvalidInput, "invalid socket address"))
+        #[cfg(not(feature = "net"))]
+        let r = Err(io::Error::new(io::ErrorKind::InvalidInput, "invalid socket address"));
+        #[cfg(feature = "net")]
+        let r = resolve_socket_addr((host, port).try_into()?);
+        r
     }
 }
 
 // accepts strings like 'localhost:12345'
-#[allow(unused_variables)]
 impl ToSocketAddrs for str {
     type Iter = vec::IntoIter<SocketAddr>;
     fn to_socket_addrs(&self) -> io::Result<vec::IntoIter<SocketAddr>> {
@@ -526,22 +540,11 @@ impl ToSocketAddrs for str {
             return Ok(vec![addr].into_iter());
         }
 
-        macro_rules! try_opt {
-            ($e:expr, $msg:expr) => (
-                match $e {
-                    Some(r) => r,
-                    None => return Err(io::Error::new(io::ErrorKind::InvalidInput,
-                                                      $msg)),
-                }
-            )
-        }
-
-        // split the string by ':' and convert the second part to u16
-        let mut parts_iter = self.rsplitn(2, ':');
-        let port_str = try_opt!(parts_iter.next(), "invalid socket address");
-        let host = try_opt!(parts_iter.next(), "invalid socket address");
-        let port: u16 = try_opt!(port_str.parse().ok(), "invalid port value");
-        Err(io::Error::new(io::ErrorKind::InvalidInput, "invalid socket address"))
+        #[cfg(not(feature = "net"))]
+        let r = Err(io::Error::new(io::ErrorKind::InvalidInput, "invalid socket address"));
+        #[cfg(feature = "net")]
+        let r = resolve_socket_addr(self.try_into()?);
+        r
     }
 }
 
diff --git a/sgx_tstd/src/net/mod.rs b/sgx_tstd/src/net/mod.rs
index ef3e5a1..f07ac38 100644
--- a/sgx_tstd/src/net/mod.rs
+++ b/sgx_tstd/src/net/mod.rs
@@ -32,9 +32,7 @@
 //! Datagram Protocols, as well as types for IP and socket addresses.
 //!
 
-//use core::fmt;
 use crate::io::{self, Error, ErrorKind};
-//use sys_common::net as net_imp;
 
 pub use self::ip::{IpAddr, Ipv4Addr, Ipv6Addr, Ipv6MulticastScope};
 pub use self::addr::{SocketAddr, SocketAddrV4, SocketAddrV6, ToSocketAddrs};
diff --git a/sgx_tstd/src/rt.rs b/sgx_tstd/src/rt.rs
index fcfd0a4..3f738a5 100644
--- a/sgx_tstd/src/rt.rs
+++ b/sgx_tstd/src/rt.rs
@@ -36,6 +36,9 @@ use core::str;
 pub use crate::panicking::{begin_panic, begin_panic_fmt, update_panic_count};
 pub use crate::sys_common::at_exit;
 use crate::sys_common::cleanup;
+use crate::sync::Once;
+
+static INIT: Once = Once::new();
 
 #[no_mangle]
 pub extern "C" fn t_global_exit_ecall() {
@@ -43,13 +46,14 @@ pub extern "C" fn t_global_exit_ecall() {
 
 #[no_mangle]
 pub extern "C" fn t_global_init_ecall(id: u64, path: * const u8, len: usize) {
-
-    enclave::set_enclave_id(id as sgx_enclave_id_t);
-    let s = unsafe {
-        let str_slice = slice::from_raw_parts(path, len);
-        str::from_utf8_unchecked(str_slice)
-    };
-    enclave::set_enclave_path(s);
+    INIT.call_once(|| {
+        enclave::set_enclave_id(id as sgx_enclave_id_t);
+        let s = unsafe {
+            let str_slice = slice::from_raw_parts(path, len);
+            str::from_utf8_unchecked(str_slice)
+        };
+        enclave::set_enclave_path(s);
+    });
 }
 
 global_dtors_object! {
diff --git a/sgx_tstd/src/sync/mod.rs b/sgx_tstd/src/sync/mod.rs
index 5acd4cb..db0e9b0 100644
--- a/sgx_tstd/src/sync/mod.rs
+++ b/sgx_tstd/src/sync/mod.rs
@@ -49,6 +49,7 @@ pub use self::once::{Once, OnceState, ONCE_INIT};
 pub use self::rwlock::{SgxRwLock, SgxRwLockReadGuard, SgxRwLockWriteGuard, SgxThreadRwLock};
 pub use self::spinlock::{SgxSpinlock, SgxSpinlockGuard, SgxThreadSpinlock};
 pub use crate::sys_common::poison::{PoisonError, TryLockError, TryLockResult, LockResult};
+#[cfg(feature = "thread")]
 pub mod mpsc;
 mod barrier;
 mod condvar;
diff --git a/sgx_tstd/src/sys/mod.rs b/sgx_tstd/src/sys/mod.rs
index 4f25943..271074a 100644
--- a/sgx_tstd/src/sys/mod.rs
+++ b/sgx_tstd/src/sys/mod.rs
@@ -35,6 +35,7 @@ pub mod fd;
 pub mod fs;
 pub mod sgxfs;
 pub mod io;
+#[cfg(feature = "thread")]
 pub mod thread;
 #[cfg(feature = "net")]
 pub mod net;
diff --git a/sgx_tstd/src/sys/net.rs b/sgx_tstd/src/sys/net.rs
index a87cf8c..0510b97 100644
--- a/sgx_tstd/src/sys/net.rs
+++ b/sgx_tstd/src/sys/net.rs
@@ -27,10 +27,11 @@
 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
 #![allow(dead_code)]
-
 use sgx_trts::libc::{c_int, size_t, c_void};
 use core::mem;
 use core::cmp;
+use core::str;
+use crate::ffi::CStr;
 use crate::io::{self, IoSlice, IoSliceMut};
 use crate::net::{SocketAddr, Shutdown};
 use crate::sys::fd::FileDesc;
@@ -44,6 +45,34 @@ pub type wrlen_t = size_t;
 
 pub struct Socket(FileDesc);
 
+pub fn init() {}
+
+pub fn cvt_gai(err: c_int) -> io::Result<()> {
+    if err == 0 {
+        return Ok(())
+    }
+
+    // We may need to trigger a glibc workaround. See on_resolver_failure() for details.
+    // on_resolver_failure();
+
+    if err == libc::EAI_SYSTEM {
+        return Err(io::Error::last_os_error())
+    }
+
+    let detail = unsafe {
+        let strerr = libc::gai_strerror(err);
+        if strerr.is_null() {
+            return Err(io::Error::from_raw_os_error(libc::ESGX))
+        }
+
+        str::from_utf8(CStr::from_ptr(strerr).to_bytes()).unwrap()
+            .to_owned()
+    };
+    Err(io::Error::new(io::ErrorKind::Other,
+                       &format!("failed to lookup address information: {}",
+                                detail)[..]))
+}
+
 impl Socket {
 
     pub fn new(sockfd: c_int) -> io::Result<Socket> {
@@ -357,5 +386,5 @@ impl IntoInner<c_int> for Socket {
 mod libc {
     pub use sgx_trts::libc::*;
     pub use sgx_trts::libc::ocall::{socket, socketpair, connect, accept4, recv, recvfrom, shutdown,
-                                    ioctl_arg1, poll};
+                                    ioctl_arg1, poll, gai_strerror};
 }
\ No newline at end of file
diff --git a/sgx_tstd/src/sys/thread.rs b/sgx_tstd/src/sys/thread.rs
index bd3aea8..0ba37aa 100644
--- a/sgx_tstd/src/sys/thread.rs
+++ b/sgx_tstd/src/sys/thread.rs
@@ -36,8 +36,8 @@ use crate::cmp;
 use crate::sys::os;
 use crate::ffi::CStr;
 use crate::enclave::get_enclave_id;
-use crate::sgx_tseal::{SgxSealedData, SgxUnsealedData};
-use crate::sgx_types::{sgx_enclave_id_t, sgx_sealed_data_t, sgx_status_t, c_void, c_int} ;
+use crate::sgx_tseal::SgxSealedData;
+use crate::sgx_types::{self, sgx_attributes_t, sgx_enclave_id_t, sgx_sealed_data_t, sgx_status_t, c_void, c_int};
 
 pub struct Thread {
     id: libc::pthread_t,
@@ -57,9 +57,15 @@ pub struct ThreadParam {
 
 impl ThreadParam {
     pub fn new(eid: sgx_enclave_id_t, p: *mut c_void) -> io::Result<ThreadParam> {
+        let key_policy = sgx_types::SGX_KEYPOLICY_MRENCLAVE;
+        let attr_mask = sgx_attributes_t {
+                        flags: sgx_types::TSEAL_DEFAULT_FLAGSMASK,
+                        xfrm: 0};
+        let misc_mask = sgx_types::TSEAL_DEFAULT_MISCMASK;
+
         let aad: [u8; 8] = unsafe{ mem::transmute(eid) };
         let main = p as usize;
-        let result = SgxSealedData::<usize>::seal_data(&aad, &main);
+        let result = SgxSealedData::<usize>::seal_data_ex(key_policy, attr_mask, misc_mask, &aad, &main);
         let sealed_data = match result {
             Ok(t) => t,
             Err(ret) => { return Err(io::Error::from_sgx_error(ret)); },
@@ -98,10 +104,9 @@ impl ThreadParam {
         let mut addr = [0_u8; 8];
         &mut addr[..].copy_from_slice(unsealed_data.get_additional_txt());
         let eid = u64::from_ne_bytes(addr);
-        if eid != self.eid {
+        if eid != self.eid || eid != get_enclave_id() {
             return Err(io::Error::from_sgx_error(sgx_status_t::SGX_ERROR_INVALID_ENCLAVE_ID));
         }
-
         Ok(*unsealed_data.get_decrypt_txt() as *mut c_void)
     }
 
diff --git a/sgx_tstd/src/sys_common/mod.rs b/sgx_tstd/src/sys_common/mod.rs
index f417ac2..726b86f 100644
--- a/sgx_tstd/src/sys_common/mod.rs
+++ b/sgx_tstd/src/sys_common/mod.rs
@@ -36,6 +36,7 @@ pub mod io;
 pub mod memchr;
 pub mod poison;
 pub mod thread_info;
+#[cfg(feature = "thread")]
 pub mod thread;
 pub mod util;
 pub mod wtf8;
diff --git a/sgx_tstd/src/sys_common/net.rs b/sgx_tstd/src/sys_common/net.rs
index e8667fc..ff3c38b 100644
--- a/sgx_tstd/src/sys_common/net.rs
+++ b/sgx_tstd/src/sys_common/net.rs
@@ -32,9 +32,12 @@ use sgx_trts::libc::{c_int, c_uint, c_void};
 use core::cmp;
 use core::fmt;
 use core::mem;
+use core::ptr;
+use core::convert::{TryFrom, TryInto};
+use crate::ffi::CString;
 use crate::io::{self, Error, ErrorKind, IoSlice, IoSliceMut};
 use crate::net::{SocketAddr, Shutdown, Ipv4Addr, Ipv6Addr};
-use crate::sys::net::{cvt, cvt_r, Socket, wrlen_t};
+use crate::sys::net::{cvt, cvt_r, cvt_gai, Socket, init, wrlen_t};
 use crate::sys_common::{AsInner, FromInner, IntoInner};
 use crate::time::Duration;
 
@@ -104,6 +107,91 @@ fn to_ipv6mr_interface(value: u32) -> c_uint {
 }
 
 ////////////////////////////////////////////////////////////////////////////////
+// get_host_addresses
+////////////////////////////////////////////////////////////////////////////////
+
+pub struct LookupHost {
+    original: *mut libc::addrinfo,
+    cur: *mut libc::addrinfo,
+    port: u16
+}
+
+impl LookupHost {
+    pub fn port(&self) -> u16 {
+        self.port
+    }
+}
+
+impl Iterator for LookupHost {
+    type Item = SocketAddr;
+    fn next(&mut self) -> Option<SocketAddr> {
+        loop {
+            unsafe {
+                let cur = self.cur.as_ref()?;
+                self.cur = cur.ai_next;
+                match sockaddr_to_addr(mem::transmute(cur.ai_addr),
+                                       cur.ai_addrlen as usize)
+                {
+                    Ok(addr) => return Some(addr),
+                    Err(_) => continue,
+                }
+            }
+        }
+    }
+}
+
+unsafe impl Sync for LookupHost {}
+unsafe impl Send for LookupHost {}
+
+impl Drop for LookupHost {
+    fn drop(&mut self) {
+        unsafe { libc::freeaddrinfo(self.original) }
+    }
+}
+
+impl TryFrom<&str> for LookupHost {
+    type Error = io::Error;
+
+    fn try_from(s: &str) -> io::Result<LookupHost> {
+        macro_rules! try_opt {
+            ($e:expr, $msg:expr) => (
+                match $e {
+                    Some(r) => r,
+                    None => return Err(io::Error::new(io::ErrorKind::InvalidInput,
+                                                      $msg)),
+                }
+            )
+        }
+
+        // split the string by ':' and convert the second part to u16
+        let mut parts_iter = s.rsplitn(2, ':');
+        let port_str = try_opt!(parts_iter.next(), "invalid socket address");
+        let host = try_opt!(parts_iter.next(), "invalid socket address");
+        let port: u16 = try_opt!(port_str.parse().ok(), "invalid port value");
+
+        (host, port).try_into()
+    }
+}
+
+impl<'a> TryFrom<(&'a str, u16)> for LookupHost {
+    type Error = io::Error;
+
+    fn try_from((host, port): (&'a str, u16)) -> io::Result<LookupHost> {
+        init();
+
+        let c_host = CString::new(host)?;
+        let mut hints: libc::addrinfo = unsafe { mem::zeroed() };
+        hints.ai_socktype = libc::SOCK_STREAM;
+        let mut res = ptr::null_mut();
+        unsafe {
+            cvt_gai(libc::getaddrinfo(c_host.as_ptr(), ptr::null(), &hints, &mut res)).map(|_| {
+                LookupHost { original: res, cur: res, port }
+            })
+        }
+    }
+}
+
+////////////////////////////////////////////////////////////////////////////////
 // TCP streams
 ////////////////////////////////////////////////////////////////////////////////
 
@@ -640,5 +728,5 @@ impl fmt::Debug for UdpSocket {
 mod libc {
     pub use sgx_trts::libc::*;
     pub use sgx_trts::libc::ocall::{bind, listen, connect, setsockopt, getsockopt, send, sendto,
-                                    getpeername, getsockname};
+                                    getpeername, getsockname, getaddrinfo, freeaddrinfo};
 }
\ No newline at end of file
diff --git a/sgx_tstd/src/thread/mod.rs b/sgx_tstd/src/thread/mod.rs
index 26b9e1f..4cee35c 100644
--- a/sgx_tstd/src/thread/mod.rs
+++ b/sgx_tstd/src/thread/mod.rs
@@ -44,6 +44,7 @@ use crate::panicking;
 use crate::sys_common::thread_info;
 use crate::sync::{SgxMutex, SgxCondvar, Once, ONCE_INIT};
 use crate::time::Duration;
+#[cfg(feature = "thread")]
 use crate::sys::thread as imp;
 use crate::io::{self, Error, ErrorKind};
 use crate::ffi::{CStr, CString};
@@ -51,12 +52,15 @@ use crate::sys_common::{AsInner, IntoInner};
 
 #[macro_use] mod local;
 pub use self::local::{LocalKey, LocalKeyInner, AccessError};
+
+#[cfg(feature = "thread")]
 #[derive(Debug)]
 pub struct Builder {
     // A name for the thread-to-be, for identification in panic messages
     name: Option<String>,
 }
 
+#[cfg(feature = "thread")]
 impl Builder {
     pub fn new() -> Builder {
         if rsgx_get_thread_policy() != SgxThreadPolicy::Bound {
@@ -127,20 +131,24 @@ impl Builder {
     }
 }
 
+#[cfg(feature = "thread")]
 pub fn spawn<F, T>(f: F) -> JoinHandle<T> where
     F: FnOnce() -> T, F: Send + 'static, T: Send + 'static
 {
     Builder::new().spawn(f).expect("failed to spawn thread")
 }
 
+#[cfg(feature = "thread")]
 pub fn yield_now() {
     imp::Thread::yield_now()
 }
 
+#[cfg(feature = "thread")]
 pub fn sleep_ms(ms: u32) {
     sleep(Duration::from_millis(ms as u64))
 }
 
+#[cfg(feature = "thread")]
 pub fn sleep(dur: Duration) {
     imp::Thread::sleep(dur)
 }
@@ -582,18 +590,23 @@ pub type Result<T> = crate::result::Result<T, Box<dyn Any + Send + 'static>>;
 // this type is inherently Sync because no methods take &self. Regardless,
 // however, we add inheriting impls for Send/Sync to this type to ensure it's
 // Send/Sync and that future modifications will still appropriately classify it.
+#[cfg(feature = "thread")]
 struct Packet<T>(Arc<UnsafeCell<Option<Result<T>>>>);
 
+#[cfg(feature = "thread")]
 unsafe impl<T: Send> Send for Packet<T> {}
+#[cfg(feature = "thread")]
 unsafe impl<T: Sync> Sync for Packet<T> {}
 
 /// Inner representation for JoinHandle
+#[cfg(feature = "thread")]
 struct JoinInner<T> {
     native: Option<imp::Thread>,
     thread: SgxThread,
     packet: Packet<T>,
 }
 
+#[cfg(feature = "thread")]
 impl<T> JoinInner<T> {
     fn join(&mut self) -> Result<T> {
         let reval = self.native.take().unwrap().join();
@@ -671,12 +684,13 @@ impl<T> JoinInner<T> {
 /// [`thread::spawn`]: fn.spawn.html
 /// [`thread::Builder::spawn`]: struct.Builder.html#method.spawn
 
+#[cfg(feature = "thread")]
 pub struct JoinHandle<T>(JoinInner<T>);
-
+#[cfg(feature = "thread")]
 unsafe impl<T> Send for JoinHandle<T> {}
-
+#[cfg(feature = "thread")]
 unsafe impl<T> Sync for JoinHandle<T> {}
-
+#[cfg(feature = "thread")]
 impl<T> JoinHandle<T> {
     /// Extracts a handle to the underlying thread.
     ///
@@ -734,20 +748,24 @@ impl<T> JoinHandle<T> {
     }
 }
 
+#[cfg(feature = "thread")]
 impl<T> AsInner<imp::Thread> for JoinHandle<T> {
     fn as_inner(&self) -> &imp::Thread { self.0.native.as_ref().unwrap() }
 }
 
+#[cfg(feature = "thread")]
 impl<T> IntoInner<imp::Thread> for JoinHandle<T> {
     fn into_inner(self) -> imp::Thread { self.0.native.unwrap() }
 }
 
+#[cfg(feature = "thread")]
 impl<T> fmt::Debug for JoinHandle<T> {
     fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
         f.pad("JoinHandle { .. }")
     }
 }
 
+#[cfg(feature = "thread")]
 fn _assert_sync_and_send() {
     fn _assert_both<T: Send + Sync>() {}
     _assert_both::<JoinHandle<()>>();
diff --git a/sgx_types/src/error.rs b/sgx_types/src/error.rs
index d6e5951..6465342 100644
--- a/sgx_types/src/error.rs
+++ b/sgx_types/src/error.rs
@@ -34,7 +34,6 @@ use crate::int32_t;
 // sgx_error.h
 //
 impl_enum! {
-
     #[repr(u32)]
     #[derive(Copy, Clone, PartialEq, Eq, Ord, PartialOrd, Debug)]
     pub enum sgx_status_t {
@@ -323,7 +322,6 @@ impl fmt::Display for sgx_status_t {
 
 
 impl_enum! {
-
     #[repr(u32)]
     #[derive(Copy, Clone, PartialEq, Eq, Ord, PartialOrd, Debug)]
     pub enum sgx_pce_error_t {
@@ -339,7 +337,6 @@ impl_enum! {
     }
 }
 
-
 impl sgx_pce_error_t {
     pub fn __description(&self) -> &str {
         match *self {
@@ -378,40 +375,70 @@ impl fmt::Display for sgx_pce_error_t {
 
 
 impl_enum! {
-
     #[repr(u32)]
     #[derive(Copy, Clone, PartialEq, Eq, Ord, PartialOrd, Debug)]
     pub enum sgx_quote3_error_t {
-        SGX_QL_SUCCESS                          = 0x0000_0000,
-//      SGX_QL_ERROR_MIN                        = 0x0000_E001,
-        SGX_QL_ERROR_UNEXPECTED                 = 0x0000_E001,
-        SGX_QL_ERROR_INVALID_PARAMETER          = 0x0000_E002,
-        SGX_QL_ERROR_OUT_OF_MEMORY              = 0x0000_E003,
-        SGX_QL_ERROR_ECDSA_ID_MISMATCH          = 0x0000_E004,
-        SGX_QL_PATHNAME_BUFFER_OVERFLOW_ERROR   = 0x0000_E005,
-        SGX_QL_FILE_ACCESS_ERROR                = 0x0000_E006,
-        SGX_QL_ERROR_STORED_KEY                 = 0x0000_E007,
-        SGX_QL_ERROR_PUB_KEY_ID_MISMATCH        = 0x0000_E008,
-        SGX_QL_ERROR_INVALID_PCE_SIG_SCHEME     = 0x0000_E009,
-        SGX_QL_ATT_KEY_BLOB_ERROR               = 0x0000_E00A,
-        SGX_QL_UNSUPPORTED_ATT_KEY_ID           = 0x0000_E00B,
-        SGX_QL_UNSUPPORTED_LOADING_POLICY       = 0x0000_E00C,
-        SGX_QL_INTERFACE_UNAVAILABLE            = 0x0000_E00D,
-        SGX_QL_PLATFORM_LIB_UNAVAILABLE         = 0x0000_E00E,
-        SGX_QL_ATT_KEY_NOT_INITIALIZED          = 0x0000_E00F,
-        SGX_QL_ATT_KEY_CERT_DATA_INVALID        = 0x0000_E010,
-        SGX_QL_NO_PLATFORM_CERT_DATA            = 0x0000_E011,
-        SGX_QL_OUT_OF_EPC                       = 0x0000_E012,
-        SGX_QL_ERROR_REPORT                     = 0x0000_E013,
-        SGX_QL_ENCLAVE_LOST                     = 0x0000_E014,
-        SGX_QL_INVALID_REPORT                   = 0x0000_E015,
-        SGX_QL_ENCLAVE_LOAD_ERROR               = 0x0000_E016,
-        SGX_QL_UNABLE_TO_GENERATE_QE_REPORT     = 0x0000_E017,
-        SGX_QL_KEY_CERTIFCATION_ERROR           = 0x0000_E018,
-        SGX_QL_NETWORK_ERROR                    = 0x0000_E019,
-        SGX_QL_MESSAGE_ERROR                    = 0x0000_E01A,
-        SGX_QL_ERROR_INVALID_PRIVILEGE          = 0x0000_E01B,
-        SGX_QL_ERROR_MAX                        = 0x0000_E0FF,
+        SGX_QL_SUCCESS                                  = 0x0000_0000,
+//      SGX_QL_ERROR_MIN                                = 0x0000_E001,
+        SGX_QL_ERROR_UNEXPECTED                         = 0x0000_E001,
+        SGX_QL_ERROR_INVALID_PARAMETER                  = 0x0000_E002,
+        SGX_QL_ERROR_OUT_OF_MEMORY                      = 0x0000_E003,
+        SGX_QL_ERROR_ECDSA_ID_MISMATCH                  = 0x0000_E004,
+        SGX_QL_PATHNAME_BUFFER_OVERFLOW_ERROR           = 0x0000_E005,
+        SGX_QL_FILE_ACCESS_ERROR                        = 0x0000_E006,
+        SGX_QL_ERROR_STORED_KEY                         = 0x0000_E007,
+        SGX_QL_ERROR_PUB_KEY_ID_MISMATCH                = 0x0000_E008,
+        SGX_QL_ERROR_INVALID_PCE_SIG_SCHEME             = 0x0000_E009,
+        SGX_QL_ATT_KEY_BLOB_ERROR                       = 0x0000_E00A,
+        SGX_QL_UNSUPPORTED_ATT_KEY_ID                   = 0x0000_E00B,
+        SGX_QL_UNSUPPORTED_LOADING_POLICY               = 0x0000_E00C,
+        SGX_QL_INTERFACE_UNAVAILABLE                    = 0x0000_E00D,
+        SGX_QL_PLATFORM_LIB_UNAVAILABLE                 = 0x0000_E00E,
+        SGX_QL_ATT_KEY_NOT_INITIALIZED                  = 0x0000_E00F,
+        SGX_QL_ATT_KEY_CERT_DATA_INVALID                = 0x0000_E010,
+        SGX_QL_NO_PLATFORM_CERT_DATA                    = 0x0000_E011,
+        SGX_QL_OUT_OF_EPC                               = 0x0000_E012,
+        SGX_QL_ERROR_REPORT                             = 0x0000_E013,
+        SGX_QL_ENCLAVE_LOST                             = 0x0000_E014,
+        SGX_QL_INVALID_REPORT                           = 0x0000_E015,
+        SGX_QL_ENCLAVE_LOAD_ERROR                       = 0x0000_E016,
+        SGX_QL_UNABLE_TO_GENERATE_QE_REPORT             = 0x0000_E017,
+        SGX_QL_KEY_CERTIFCATION_ERROR                   = 0x0000_E018,
+        SGX_QL_NETWORK_ERROR                            = 0x0000_E019,
+        SGX_QL_MESSAGE_ERROR                            = 0x0000_E01A,
+//      SGX_QL_ERROR_INVALID_PRIVILEGE                  = 0x0000_E01B,   dcap 1.3 define 0xE035
+        SGX_QL_NO_QUOTE_COLLATERAL_DATA                 = 0x0000_E01B,
+        SGX_QL_QUOTE_CERTIFICATION_DATA_UNSUPPORTED     = 0x0000_E01C,
+        SGX_QL_QUOTE_FORMAT_UNSUPPORTED                 = 0x0000_E01D,
+        SGX_QL_UNABLE_TO_GENERATE_REPORT                = 0x0000_E01E,
+        SGX_QL_QE_REPORT_INVALID_SIGNATURE              = 0x0000_E01F,
+        SGX_QL_QE_REPORT_UNSUPPORTED_FORMAT             = 0x0000_E020,
+        SGX_QL_PCK_CERT_UNSUPPORTED_FORMAT              = 0x0000_E021,
+        SGX_QL_PCK_CERT_CHAIN_ERROR                     = 0x0000_E022,
+        SGX_QL_TCBINFO_UNSUPPORTED_FORMAT               = 0x0000_E023,
+        SGX_QL_TCBINFO_MISMATCH                         = 0x0000_E024,
+        SGX_QL_QEIDENTITY_UNSUPPORTED_FORMAT            = 0x0000_E025,
+        SGX_QL_QEIDENTITY_MISMATCH                      = 0x0000_E026,
+        SGX_QL_TCB_OUT_OF_DATE                          = 0x0000_E027,
+        SGX_QL_TCB_OUT_OF_DATE_CONFIGURATION_NEEDED     = 0x0000_E028,
+        SGX_QL_SGX_ENCLAVE_IDENTITY_OUT_OF_DATE         = 0x0000_E029,
+        SGX_QL_SGX_ENCLAVE_REPORT_ISVSVN_OUT_OF_DATE    = 0x0000_E02A,
+        SGX_QL_QE_IDENTITY_OUT_OF_DATE                  = 0x0000_E02B,
+        SGX_QL_SGX_TCB_INFO_EXPIRED                     = 0x0000_E02C,
+        SGX_QL_SGX_PCK_CERT_CHAIN_EXPIRED               = 0x0000_E02D,
+        SGX_QL_SGX_CRL_EXPIRED                          = 0x0000_E02E,
+        SGX_QL_SGX_SIGNING_CERT_CHAIN_EXPIRED           = 0x0000_E02F,
+        SGX_QL_SGX_ENCLAVE_IDENTITY_EXPIRED             = 0x0000_E030,
+        SGX_QL_PCK_REVOKED                              = 0x0000_E031,
+        SGX_QL_TCB_REVOKED                              = 0x0000_E032,
+        SGX_QL_TCB_CONFIGURATION_NEEDED                 = 0x0000_E033,
+        SGX_QL_UNABLE_TO_GET_COLLATERAL                 = 0x0000_E034,
+        SGX_QL_ERROR_INVALID_PRIVILEGE                  = 0x0000_E035,
+        SGX_QL_NO_QVE_IDENTITY_DATA                     = 0x0000_E037,
+        SGX_QL_CRL_UNSUPPORTED_FORMAT                   = 0x0000_E038,
+        SGX_QL_QEIDENTITY_CHAIN_ERROR                   = 0x0000_E039,
+        SGX_QL_TCBINFO_CHAIN_ERROR                      = 0x0000_E03A,
+        SGX_QL_ERROR_MAX                                = 0x0000_E0FF,
     }
 }
 
@@ -446,7 +473,37 @@ impl sgx_quote3_error_t {
             sgx_quote3_error_t::SGX_QL_KEY_CERTIFCATION_ERROR => "Caused when the provider library returns an invalid TCB.",
             sgx_quote3_error_t::SGX_QL_NETWORK_ERROR => "Network error when retrieving PCK certs.",
             sgx_quote3_error_t::SGX_QL_MESSAGE_ERROR => "Message error when retrieving PCK certs.",
+            sgx_quote3_error_t::SGX_QL_NO_QUOTE_COLLATERAL_DATA => "The platform does not have the quote verification collateral data available.",
+            sgx_quote3_error_t::SGX_QL_QUOTE_CERTIFICATION_DATA_UNSUPPORTED => "",
+            sgx_quote3_error_t::SGX_QL_QUOTE_FORMAT_UNSUPPORTED => "",
+            sgx_quote3_error_t::SGX_QL_UNABLE_TO_GENERATE_REPORT => "",
+            sgx_quote3_error_t::SGX_QL_QE_REPORT_INVALID_SIGNATURE => "",
+            sgx_quote3_error_t::SGX_QL_QE_REPORT_UNSUPPORTED_FORMAT => "",
+            sgx_quote3_error_t::SGX_QL_PCK_CERT_UNSUPPORTED_FORMAT => "",
+            sgx_quote3_error_t::SGX_QL_PCK_CERT_CHAIN_ERROR => "",
+            sgx_quote3_error_t::SGX_QL_TCBINFO_UNSUPPORTED_FORMAT => "",
+            sgx_quote3_error_t::SGX_QL_TCBINFO_MISMATCH => "",
+            sgx_quote3_error_t::SGX_QL_QEIDENTITY_UNSUPPORTED_FORMAT => "",
+            sgx_quote3_error_t::SGX_QL_QEIDENTITY_MISMATCH => "",
+            sgx_quote3_error_t::SGX_QL_TCB_OUT_OF_DATE => "",
+            sgx_quote3_error_t::SGX_QL_TCB_OUT_OF_DATE_CONFIGURATION_NEEDED => "",
+            sgx_quote3_error_t::SGX_QL_SGX_ENCLAVE_IDENTITY_OUT_OF_DATE => "",
+            sgx_quote3_error_t::SGX_QL_SGX_ENCLAVE_REPORT_ISVSVN_OUT_OF_DATE => "",
+            sgx_quote3_error_t::SGX_QL_QE_IDENTITY_OUT_OF_DATE => "",
+            sgx_quote3_error_t::SGX_QL_SGX_TCB_INFO_EXPIRED => "",
+            sgx_quote3_error_t::SGX_QL_SGX_PCK_CERT_CHAIN_EXPIRED => "",
+            sgx_quote3_error_t::SGX_QL_SGX_CRL_EXPIRED => "",
+            sgx_quote3_error_t::SGX_QL_SGX_SIGNING_CERT_CHAIN_EXPIRED => "",
+            sgx_quote3_error_t::SGX_QL_SGX_ENCLAVE_IDENTITY_EXPIRED => "",
+            sgx_quote3_error_t::SGX_QL_PCK_REVOKED => "",
+            sgx_quote3_error_t::SGX_QL_TCB_REVOKED => "",
+            sgx_quote3_error_t::SGX_QL_TCB_CONFIGURATION_NEEDED => "",
+            sgx_quote3_error_t::SGX_QL_UNABLE_TO_GET_COLLATERAL => "",
             sgx_quote3_error_t::SGX_QL_ERROR_INVALID_PRIVILEGE => "No enough privilege to perform the operation.",
+            sgx_quote3_error_t::SGX_QL_NO_QVE_IDENTITY_DATA => "The platform does not have the QVE identity data available.",
+            sgx_quote3_error_t::SGX_QL_CRL_UNSUPPORTED_FORMAT => "",
+            sgx_quote3_error_t::SGX_QL_QEIDENTITY_CHAIN_ERROR => "",
+            sgx_quote3_error_t::SGX_QL_TCBINFO_CHAIN_ERROR => "",
             sgx_quote3_error_t::SGX_QL_ERROR_MAX => "Indicate max error to allow better translation.",
         }
     }
@@ -481,7 +538,37 @@ impl sgx_quote3_error_t {
             sgx_quote3_error_t::SGX_QL_KEY_CERTIFCATION_ERROR => "SGX_QL_KEY_CERTIFCATION_ERROR",
             sgx_quote3_error_t::SGX_QL_NETWORK_ERROR => "SGX_QL_NETWORK_ERROR",
             sgx_quote3_error_t::SGX_QL_MESSAGE_ERROR => "SGX_QL_MESSAGE_ERROR",
+            sgx_quote3_error_t::SGX_QL_NO_QUOTE_COLLATERAL_DATA => "SGX_QL_NO_QUOTE_COLLATERAL_DATA",
+            sgx_quote3_error_t::SGX_QL_QUOTE_CERTIFICATION_DATA_UNSUPPORTED => "SGX_QL_QUOTE_CERTIFICATION_DATA_UNSUPPORTED",
+            sgx_quote3_error_t::SGX_QL_QUOTE_FORMAT_UNSUPPORTED => "SGX_QL_QUOTE_FORMAT_UNSUPPORTED",
+            sgx_quote3_error_t::SGX_QL_UNABLE_TO_GENERATE_REPORT => "SGX_QL_UNABLE_TO_GENERATE_REPORT",
+            sgx_quote3_error_t::SGX_QL_QE_REPORT_INVALID_SIGNATURE => "SGX_QL_QE_REPORT_INVALID_SIGNATURE",
+            sgx_quote3_error_t::SGX_QL_QE_REPORT_UNSUPPORTED_FORMAT => "SGX_QL_QE_REPORT_UNSUPPORTED_FORMAT",
+            sgx_quote3_error_t::SGX_QL_PCK_CERT_UNSUPPORTED_FORMAT => "SGX_QL_PCK_CERT_UNSUPPORTED_FORMAT",
+            sgx_quote3_error_t::SGX_QL_PCK_CERT_CHAIN_ERROR => "SGX_QL_PCK_CERT_CHAIN_ERROR",
+            sgx_quote3_error_t::SGX_QL_TCBINFO_UNSUPPORTED_FORMAT => "SGX_QL_TCBINFO_UNSUPPORTED_FORMAT",
+            sgx_quote3_error_t::SGX_QL_TCBINFO_MISMATCH => "SGX_QL_TCBINFO_MISMATCH",
+            sgx_quote3_error_t::SGX_QL_QEIDENTITY_UNSUPPORTED_FORMAT => "SGX_QL_QEIDENTITY_UNSUPPORTED_FORMAT",
+            sgx_quote3_error_t::SGX_QL_QEIDENTITY_MISMATCH => "SGX_QL_QEIDENTITY_MISMATCH",
+            sgx_quote3_error_t::SGX_QL_TCB_OUT_OF_DATE => "SGX_QL_TCB_OUT_OF_DATE",
+            sgx_quote3_error_t::SGX_QL_TCB_OUT_OF_DATE_CONFIGURATION_NEEDED => "SGX_QL_TCB_OUT_OF_DATE_CONFIGURATION_NEEDED",
+            sgx_quote3_error_t::SGX_QL_SGX_ENCLAVE_IDENTITY_OUT_OF_DATE => "SGX_QL_SGX_ENCLAVE_IDENTITY_OUT_OF_DATE",
+            sgx_quote3_error_t::SGX_QL_SGX_ENCLAVE_REPORT_ISVSVN_OUT_OF_DATE => "SGX_QL_SGX_ENCLAVE_REPORT_ISVSVN_OUT_OF_DATE",
+            sgx_quote3_error_t::SGX_QL_QE_IDENTITY_OUT_OF_DATE => "SGX_QL_QE_IDENTITY_OUT_OF_DATE",
+            sgx_quote3_error_t::SGX_QL_SGX_TCB_INFO_EXPIRED => "SGX_QL_SGX_TCB_INFO_EXPIRED",
+            sgx_quote3_error_t::SGX_QL_SGX_PCK_CERT_CHAIN_EXPIRED => "SGX_QL_SGX_PCK_CERT_CHAIN_EXPIRED",
+            sgx_quote3_error_t::SGX_QL_SGX_CRL_EXPIRED => "SGX_QL_SGX_CRL_EXPIRED",
+            sgx_quote3_error_t::SGX_QL_SGX_SIGNING_CERT_CHAIN_EXPIRED => "SGX_QL_SGX_SIGNING_CERT_CHAIN_EXPIRED",
+            sgx_quote3_error_t::SGX_QL_SGX_ENCLAVE_IDENTITY_EXPIRED => "SGX_QL_SGX_ENCLAVE_IDENTITY_EXPIRED",
+            sgx_quote3_error_t::SGX_QL_PCK_REVOKED => "SGX_QL_PCK_REVOKED",
+            sgx_quote3_error_t::SGX_QL_TCB_REVOKED => "SGX_QL_TCB_REVOKED",
+            sgx_quote3_error_t::SGX_QL_TCB_CONFIGURATION_NEEDED => "SGX_QL_TCB_CONFIGURATION_NEEDED",
+            sgx_quote3_error_t::SGX_QL_UNABLE_TO_GET_COLLATERAL => "SGX_QL_UNABLE_TO_GET_COLLATERAL",
             sgx_quote3_error_t::SGX_QL_ERROR_INVALID_PRIVILEGE => "SGX_QL_ERROR_INVALID_PRIVILEGE",
+            sgx_quote3_error_t::SGX_QL_NO_QVE_IDENTITY_DATA => "SGX_QL_NO_QVE_IDENTITY_DATA",
+            sgx_quote3_error_t::SGX_QL_CRL_UNSUPPORTED_FORMAT => "SGX_QL_CRL_UNSUPPORTED_FORMAT",
+            sgx_quote3_error_t::SGX_QL_QEIDENTITY_CHAIN_ERROR => "SGX_QL_QEIDENTITY_CHAIN_ERROR",
+            sgx_quote3_error_t::SGX_QL_TCBINFO_CHAIN_ERROR => "SGX_QL_TCBINFO_CHAIN_ERROR",
             sgx_quote3_error_t::SGX_QL_ERROR_MAX => "SGX_QL_ERROR_MAX",
         }
     }
@@ -494,6 +581,79 @@ impl fmt::Display for sgx_quote3_error_t {
 }
 
 
+impl_enum! {
+    #[repr(u32)]
+    #[derive(Copy, Clone, PartialEq, Eq, Ord, PartialOrd, Debug)]
+    pub enum sgx_qcnl_error_t {
+        SGX_QCNL_SUCCESS                    = 0x0000_0000,
+        SGX_QCNL_UNEXPECTED_ERROR           = 0x0000_F001,
+        SGX_QCNL_INVALID_PARAMETER          = 0x0000_F002,
+        SGX_QCNL_NETWORK_ERROR              = 0x0000_F003,
+        SGX_QCNL_NETWORK_PROXY_FAIL         = 0x0000_F004,
+        SGX_QCNL_NETWORK_HOST_FAIL          = 0x0000_F005,
+        SGX_QCNL_NETWORK_COULDNT_CONNECT    = 0x0000_F006,
+        SGX_QCNL_NETWORK_HTTP2_ERROR        = 0x0000_F007,
+        SGX_QCNL_NETWORK_WRITE_ERROR        = 0x0000_F008,
+        SGX_QCNL_NETWORK_OPERATION_TIMEDOUT = 0x0000_F009,
+        SGX_QCNL_NETWORK_HTTPS_ERROR        = 0x0000_F00A,
+        SGX_QCNL_NETWORK_UNKNOWN_OPTION     = 0x0000_F00B,
+        SGX_QCNL_NETWORK_INIT_ERROR         = 0x0000_F00C,
+        SGX_QCNL_MSG_ERROR                  = 0x0000_F00D,
+        SGX_QCNL_ERROR_STATUS_NOT_FOUND     = 0x0000_F00E,
+        SGX_QCNL_OUT_OF_MEMORY              = 0x0000_F00F,
+    }
+}
+
+impl sgx_qcnl_error_t {
+    pub fn __description(&self) -> &str {
+        match *self {
+            sgx_qcnl_error_t::SGX_QCNL_SUCCESS => "Success.",
+            sgx_qcnl_error_t::SGX_QCNL_UNEXPECTED_ERROR => "Unexpected error.",
+            sgx_qcnl_error_t::SGX_QCNL_INVALID_PARAMETER => "The parameter is incorrect.",
+            sgx_qcnl_error_t::SGX_QCNL_NETWORK_ERROR => "Network error.",
+            sgx_qcnl_error_t::SGX_QCNL_NETWORK_PROXY_FAIL => "Network error : Couldn't resolve proxy.",
+            sgx_qcnl_error_t::SGX_QCNL_NETWORK_HOST_FAIL => "Network error : Couldn't resolve host.",
+            sgx_qcnl_error_t::SGX_QCNL_NETWORK_COULDNT_CONNECT => "Network error : Failed to connect() to host or proxy.",
+            sgx_qcnl_error_t::SGX_QCNL_NETWORK_HTTP2_ERROR => "Network error : A problem was detected in the HTTP2 framing layer.",
+            sgx_qcnl_error_t::SGX_QCNL_NETWORK_WRITE_ERROR => "Network error : an error was returned to libcurl from a write callback.",
+            sgx_qcnl_error_t::SGX_QCNL_NETWORK_OPERATION_TIMEDOUT => "Network error : Operation timeout.",
+            sgx_qcnl_error_t::SGX_QCNL_NETWORK_HTTPS_ERROR => "Network error : A problem occurred somewhere in the SSL/TLS handshake.",
+            sgx_qcnl_error_t::SGX_QCNL_NETWORK_UNKNOWN_OPTION => "Network error : An option passed to libcurl is not recognized/known.",
+            sgx_qcnl_error_t::SGX_QCNL_NETWORK_INIT_ERROR => "Failed to initialize CURL library.",
+            sgx_qcnl_error_t::SGX_QCNL_MSG_ERROR => "HTTP message error.",
+            sgx_qcnl_error_t::SGX_QCNL_ERROR_STATUS_NOT_FOUND => "Data not found.",
+            sgx_qcnl_error_t::SGX_QCNL_OUT_OF_MEMORY => "Out of memory error.",
+        }
+    }
+
+    pub fn as_str(&self) -> &str {
+        match *self {
+            sgx_qcnl_error_t::SGX_QCNL_SUCCESS => "SGX_QCNL_SUCCESS.",
+            sgx_qcnl_error_t::SGX_QCNL_UNEXPECTED_ERROR => "SGX_QCNL_UNEXPECTED_ERROR",
+            sgx_qcnl_error_t::SGX_QCNL_INVALID_PARAMETER => "SGX_QCNL_INVALID_PARAMETER",
+            sgx_qcnl_error_t::SGX_QCNL_NETWORK_ERROR => "SGX_QCNL_NETWORK_ERROR",
+            sgx_qcnl_error_t::SGX_QCNL_NETWORK_PROXY_FAIL => "SGX_QCNL_NETWORK_PROXY_FAIL",
+            sgx_qcnl_error_t::SGX_QCNL_NETWORK_HOST_FAIL => "SGX_QCNL_NETWORK_HOST_FAIL",
+            sgx_qcnl_error_t::SGX_QCNL_NETWORK_COULDNT_CONNECT => "SGX_QCNL_NETWORK_COULDNT_CONNECT",
+            sgx_qcnl_error_t::SGX_QCNL_NETWORK_HTTP2_ERROR => "SGX_QCNL_NETWORK_HTTP2_ERROR",
+            sgx_qcnl_error_t::SGX_QCNL_NETWORK_WRITE_ERROR => "SGX_QCNL_NETWORK_WRITE_ERROR",
+            sgx_qcnl_error_t::SGX_QCNL_NETWORK_OPERATION_TIMEDOUT => "SGX_QCNL_NETWORK_OPERATION_TIMEDOUT",
+            sgx_qcnl_error_t::SGX_QCNL_NETWORK_HTTPS_ERROR => "SGX_QCNL_NETWORK_HTTPS_ERROR",
+            sgx_qcnl_error_t::SGX_QCNL_NETWORK_UNKNOWN_OPTION => "SGX_QCNL_NETWORK_UNKNOWN_OPTION",
+            sgx_qcnl_error_t::SGX_QCNL_NETWORK_INIT_ERROR => "SGX_QCNL_NETWORK_INIT_ERROR",
+            sgx_qcnl_error_t::SGX_QCNL_MSG_ERROR => "SGX_QCNL_MSG_ERROR",
+            sgx_qcnl_error_t::SGX_QCNL_ERROR_STATUS_NOT_FOUND => "SGX_QCNL_ERROR_STATUS_NOT_FOUND",
+            sgx_qcnl_error_t::SGX_QCNL_OUT_OF_MEMORY => "SGX_QCNL_OUT_OF_MEMORY",
+        }
+    }
+}
+
+impl fmt::Display for sgx_qcnl_error_t {
+    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+        write!(f, "{}", self.as_str())
+    }
+}
+
 pub type sys_error_t = int32_t;
 
 pub type SgxResult<T> = result::Result<T, sgx_status_t>;
@@ -505,5 +665,8 @@ pub type SgxPceError = result::Result<(), sgx_pce_error_t>;
 pub type SgxQuote3Result<T> = result::Result<T, sgx_quote3_error_t>;
 pub type SgxQuote3Error = result::Result<(), sgx_quote3_error_t>;
 
+pub type SgxQcnlResult<T> = result::Result<T, sgx_qcnl_error_t>;
+pub type SgxQcnlError = result::Result<(), sgx_qcnl_error_t>;
+
 pub type SysResult<T> = result::Result<T, sys_error_t>;
 pub type SysError = result::Result<(), sys_error_t>;
diff --git a/sgx_types/src/function.rs b/sgx_types/src/function.rs
index 2ef3ba9..c5fac96 100644
--- a/sgx_types/src/function.rs
+++ b/sgx_types/src/function.rs
@@ -64,10 +64,8 @@ extern {
     pub fn sgx_thread_equal(a: sgx_thread_t, b: sgx_thread_t)  -> int32_t;
 }
 
-
 //#[link(name = "sgx_tservice")]
 extern {
-
     //
     // sgx_dh.h
     //
@@ -111,7 +109,6 @@ extern {
     pub fn sgx_increment_monotonic_counter(counter_uuid: * const sgx_mc_uuid_t, counter_value: * mut uint32_t) -> sgx_status_t;
     pub fn sgx_read_monotonic_counter(counter_uuid: * const sgx_mc_uuid_t, counter_value: * mut uint32_t) -> sgx_status_t;
 
-
     //
     // sgx_tseal.h
     //
@@ -174,10 +171,8 @@ extern {
     pub fn sgx_get_key(key_request: * const sgx_key_request_t, key: * mut sgx_key_128bit_t) -> sgx_status_t;
 }
 
-
 //#[link(name = "sgx_tcrypto")]
 extern {
-
     //
     // sgx_tcrypto.h
     //
@@ -387,34 +382,26 @@ extern {
                                      aes_gcm_state: sgx_aes_state_handle_t) -> sgx_status_t;
 }
 
-
 //#[link(name = "sgx_tkey_exchange")]
 extern {
-
     //
     // sgx_tkey_exchange.h
     //
     pub fn sgx_ra_init(p_pub_key: * const sgx_ec256_public_t, b_pse: int32_t, p_context: * mut sgx_ra_context_t) -> sgx_status_t;
-
     pub fn sgx_ra_init_ex(p_pub_key: * const sgx_ec256_public_t,
                           b_pse: int32_t,
                           derive_key_cb: sgx_ra_derive_secret_keys_t,
                           p_context: * mut sgx_ra_context_t) -> sgx_status_t;
-
     pub fn sgx_ra_get_keys(context: sgx_ra_context_t,
                            keytype: sgx_ra_key_type_t,
                            p_key: * mut sgx_ra_key_128_t) -> sgx_status_t;
-
     pub fn sgx_ra_close(context: sgx_ra_context_t) -> sgx_status_t;
-
     pub fn sgx_ra_get_ga(eid: sgx_enclave_id_t, retval: *mut sgx_status_t,
                          context: sgx_ra_context_t, g_a: *mut sgx_ec256_public_t) -> sgx_status_t;
 }
 
-
 //#[link(name = "sgx_trts")]
 extern {
-
     //
     // sgx_trts.h
     //
@@ -424,13 +411,11 @@ extern {
     /* intel sgx sdk 2.1.2 */
     pub fn sgx_is_enclave_crashed() -> int32_t;
 
-
     //
     // sgx_trts_exception.h
     //
     pub fn sgx_register_exception_handler(is_first_handler: uint32_t,
                                           exception_handler: sgx_exception_handler_t) -> * const c_void;
-
     pub fn sgx_unregister_exception_handler(handler: * const c_void) -> uint32_t;
 
     //
@@ -440,12 +425,10 @@ extern {
     pub fn sgx_ocfree();
 }
 
-
-//#[link(name = "sgx_uae_service")]
+//#[link(name = "sgx_epid")]
 extern {
-
     //
-    // sgx_uae_service.h
+    // sgx_uae_epid.h
     //
     pub fn sgx_init_quote(p_target_info: * mut sgx_target_info_t, p_gid: * mut sgx_epid_group_id_t) -> sgx_status_t;
 
@@ -463,11 +446,7 @@ extern {
                          p_quote: * mut sgx_quote_t,
                          quote_size: uint32_t) -> sgx_status_t;
 
-    pub fn sgx_get_ps_cap(p_sgx_ps_cap: * mut sgx_ps_cap_t) -> sgx_status_t;
-    pub fn sgx_get_whitelist_size(p_whitelist_size: * mut uint32_t) -> sgx_status_t;
-    pub fn sgx_get_whitelist(p_whitelist: * mut uint8_t, whitelist_size: uint32_t) -> sgx_status_t;
     pub fn sgx_get_extended_epid_group_id(p_extended_epid_group_id: * mut uint32_t) -> sgx_status_t;
-
     pub fn sgx_report_attestation_status(p_platform_info: * const sgx_platform_info_t,
                                          attestation_status: int32_t,
                                          p_update_info: * mut sgx_update_info_bit_t) -> sgx_status_t;
@@ -477,10 +456,35 @@ extern {
                                    p_update_info: * mut sgx_update_info_bit_t,
                                    config: uint32_t,
                                    p_status: * mut uint32_t) -> sgx_status_t;
+}
+
+//#[link(name = "sgx_launch")]
+extern {
+    //
+    // sgx_uae_launch.h
+    //
+
+    pub fn sgx_get_whitelist_size(p_whitelist_size: * mut uint32_t) -> sgx_status_t;
+    pub fn sgx_get_whitelist(p_whitelist: * mut uint8_t, whitelist_size: uint32_t) -> sgx_status_t;
 
     /* intel sgx sdk 2.1 */
     pub fn sgx_register_wl_cert_chain(p_wl_cert_chain: * const uint8_t,
                                       wl_cert_chain_size: uint32_t) -> sgx_status_t;
+}
+
+//#[link(name = "sgx_platform")]
+extern {
+    //
+    // sgx_uae_platform.h
+    //
+    pub fn sgx_get_ps_cap(p_sgx_ps_cap: * mut sgx_ps_cap_t) -> sgx_status_t;
+}
+
+//#[link(name = "sgx_quote_ex")]
+extern {
+    //
+    // sgx_uae_quote_ex.h
+    //
 
     /* intel sgx sdk 2.5 */
     pub fn sgx_select_att_key_id(p_att_key_id_list: * const uint8_t,
@@ -501,10 +505,19 @@ extern {
                             quote_size: uint32_t) -> sgx_status_t;
 }
 
+//#[link(name = "sgx_uae_service")]
+extern {
+    //
+    // sgx_uae_service.h
+    //
+
+    // intel sgx sdk 2.7
+    // Split libsgx_uae_service.so to libsgx_epid.so, libsgx_launch.so, libsgx_platform.so and libsgx_quote_ex.so.
+    //
+}
 
 //#[link(name = "sgx_ukey_exchange")]
 extern {
-
     //
     // sgx_ukey_exchange.h
     //
@@ -543,7 +556,6 @@ extern {
 
 //#[link(name = "sgx_urts")]
 extern {
-
     //
     // sgx_urts.h
     //
@@ -591,7 +603,6 @@ extern {
 /* intel sgx sdk 1.9 */
 //#[link(name = "sgx_tprotected_fs")]
 extern {
-
     //
     // sgx_tprotected_fs.h
     //
@@ -627,7 +638,9 @@ extern {
 /* intel sgx sdk 2.0 */
 //#[link(name = "sgx_capable")]
 extern {
-
+    //
+    // sgx_capable.h
+    //
     pub fn sgx_is_capable(sgx_capable: * mut int32_t) -> sgx_status_t;
     pub fn sgx_cap_enable_device(sgx_device_status: * mut sgx_device_status_t) -> sgx_status_t;
     pub fn sgx_cap_get_status(sgx_device_status: * mut sgx_device_status_t) -> sgx_status_t;
@@ -635,7 +648,6 @@ extern {
 
 //#[link(name = "sgx_pce_wrapper")]
 extern {
-
     //
     // sgx_pce.h
     //
@@ -662,7 +674,6 @@ extern {
 
 //#[link(name = "sgx_dcap_ql")]
 extern {
-
     //
     // sgx_dcap_ql_wrapper.h
     //
@@ -671,4 +682,63 @@ extern {
     pub fn sgx_qe_get_quote_size(p_quote_size: * mut uint32_t) -> sgx_quote3_error_t;
     pub fn sgx_qe_get_quote(p_app_report: * const sgx_report_t, quote_size: uint32_t, p_quote: * mut uint8_t) -> sgx_quote3_error_t;
     pub fn sgx_qe_cleanup_by_policy() -> sgx_quote3_error_t;
-}
\ No newline at end of file
+}
+
+//#[link(name = "dcap_quoteprov")]
+extern {
+    //
+    // sgx_default_quote_provider.h
+    //
+    pub fn sgx_ql_get_quote_config(p_pck_cert_id: * const sgx_ql_pck_cert_id_t, pp_quote_config: * mut * mut sgx_ql_config_t) -> sgx_quote3_error_t;
+    pub fn sgx_ql_free_quote_config(p_quote_config: * const sgx_ql_config_t) -> sgx_quote3_error_t;
+    pub fn sgx_ql_get_quote_verification_collateral(fmspc: * const uint8_t,
+                                                    fmspc_size: uint16_t,
+                                                    pck_ra: * const char,
+                                                    pp_quote_collateral: * mut * mut sgx_ql_qve_collateral_t) -> sgx_quote3_error_t;
+    pub fn sgx_ql_free_quote_verification_collateral(p_quote_collateral: * const sgx_ql_qve_collateral_t) -> sgx_quote3_error_t;
+    pub fn sgx_ql_get_qve_identity(pp_qve_identity: * mut * mut char,
+                                   p_qve_identity_size: * mut uint32_t,
+                                   pp_qve_identity_issuer_chain: * mut * mut char,
+                                   p_qve_identity_issuer_chain_size: * mut uint32_t) -> sgx_quote3_error_t;
+    pub fn sgx_ql_free_qve_identity(p_qve_identity: * const char, p_qve_identity_issuer_chain: * const char) -> sgx_quote3_error_t;
+}
+
+//#[link(name = "sgx_default_qcnl_wrapper")]
+extern {
+    //
+    // sgx_default_qcnl_wrapper.h
+    //
+    pub fn sgx_qcnl_get_pck_cert_chain(p_pck_cert_id: * const sgx_ql_pck_cert_id_t, pp_quote_config: * mut * mut sgx_ql_config_t) -> sgx_qcnl_error_t;
+    pub fn sgx_qcnl_free_pck_cert_chain(p_quote_config: * const sgx_ql_config_t);
+    pub fn sgx_qcnl_get_pck_crl_chain(ca: * const char, ca_size: uint16_t, p_crl_chain: * mut * mut uint8_t, p_crl_chain_size: * mut uint16_t) -> sgx_qcnl_error_t;
+    pub fn sgx_qcnl_free_pck_crl_chain(p_crl_chain: * const uint8_t);
+    pub fn sgx_qcnl_get_tcbinfo(fmspc: * const char, fmspc_size: uint16_t, p_tcbinfo: * mut * mut uint8_t, p_tcbinfo_size: * mut uint16_t) -> sgx_qcnl_error_t;
+    pub fn sgx_qcnl_free_tcbinfo(p_tcbinfo: * const uint8_t);
+    pub fn sgx_qcnl_get_qe_identity(qe_type: uint8_t, p_qe_identity: * mut * mut uint8_t, p_qe_identity_size: * mut uint16_t) -> sgx_qcnl_error_t;
+    pub fn sgx_qcnl_free_qe_identity(p_qe_identity: * const uint8_t);
+    pub fn sgx_qcnl_get_qve_identity(pp_qve_identity: * mut * mut char,
+                                     p_qve_identity_size: * mut uint32_t,
+                                     pp_qve_identity_issuer_chain: * mut * mut char,
+                                     p_qve_identity_issuer_chain_size: * mut uint32_t) -> sgx_qcnl_error_t;
+    pub fn sgx_qcnl_free_qve_identity(p_qve_identity: * const char, p_qve_identity_issuer_chain: * const char);
+    pub fn sgx_qcnl_get_root_ca_crl(p_root_ca_crl: * mut * mut uint8_t, p_root_ca_cal_size: * mut uint16_t) -> sgx_qcnl_error_t;
+    pub fn sgx_qcnl_free_root_ca_crl(p_root_ca_crl: * const uint8_t);
+}
+
+//#[link(name = "dcap_quoteverify")]
+extern {
+    //
+    // sgx_dcap_quoteverify.h
+    //
+    pub fn sgx_qv_verify_quote(p_quote: * const uint8_t,
+                               quote_size: uint32_t,
+                               p_quote_collateral: * const sgx_ql_qve_collateral_t,
+                               expiration_check_date: time_t,
+                               p_collateral_expiration_status: * mut uint32_t,
+                               p_quote_verification_result: * mut sgx_ql_qv_result_t,
+                               p_qve_report_info: * mut sgx_ql_qe_report_info_t,
+                               supplemental_data_size: uint32_t,
+                               p_supplemental_data: * mut uint8_t) -> sgx_quote3_error_t;
+    pub fn sgx_qv_get_quote_supplemental_data_size(p_data_size: * mut uint32_t) -> sgx_quote3_error_t;
+    pub fn sgx_qv_set_enclave_load_policy(policy: sgx_ql_request_policy_t) -> sgx_quote3_error_t;
+}
diff --git a/sgx_types/src/lib.rs b/sgx_types/src/lib.rs
index d506945..fabf6f6 100644
--- a/sgx_types/src/lib.rs
+++ b/sgx_types/src/lib.rs
@@ -75,6 +75,7 @@ pub type ptrdiff_t = isize;
 pub type intptr_t = isize;
 pub type uintptr_t = usize;
 pub type ssize_t = isize;
+pub type time_t = i64;
 
 mod types;
 pub use self::types::*;
diff --git a/sgx_types/src/types.rs b/sgx_types/src/types.rs
index 3c50deb..9b0066d 100644
--- a/sgx_types/src/types.rs
+++ b/sgx_types/src/types.rs
@@ -72,6 +72,22 @@ impl_struct! {
 }
 
 //
+// tseal_migration_attr.h
+//
+pub const FLAGS_NON_SECURITY_BITS: uint64_t   = (0x00FF_FFFF_FFFF_FFC0
+                                                | SGX_FLAGS_MODE64BIT
+                                                | SGX_FLAGS_PROVISION_KEY
+                                                | SGX_FLAGS_EINITTOKEN_KEY);
+pub const TSEAL_DEFAULT_FLAGSMASK: uint64_t   = (!FLAGS_NON_SECURITY_BITS);
+pub const FLAGS_SECURITY_BITS_RESERVED: uint64_t = (!(FLAGS_NON_SECURITY_BITS
+                                                   | SGX_FLAGS_INITTED
+                                                   | SGX_FLAGS_DEBUG
+                                                   | SGX_FLAGS_KSS));
+pub const MISC_NON_SECURITY_BITS: uint32_t     = 0x0FFFFFFF;
+pub const TSEAL_DEFAULT_MISCMASK: uint32_t     = (!MISC_NON_SECURITY_BITS);
+
+
+//
 // sgx_dh.h
 //
 
@@ -945,10 +961,9 @@ impl_struct! {
 }
 
 //
-// sgx_uae_service.h
+// sgx_uae_platform.h
 //
 
-
 pub const PS_CAP_TRUSTED_TIME: size_t        = 0x1;
 pub const PS_CAP_MONOTONIC_COUNTER: size_t   = 0x2;
 
@@ -963,7 +978,6 @@ impl_struct! {
 // sgx_ukey_exchange.h
 //
 
-
 pub type sgx_ecall_get_ga_trusted_t = unsafe extern "C" fn(eid: sgx_enclave_id_t,
                                                            retval: * mut sgx_status_t,
                                                            context: sgx_ra_context_t,
@@ -1216,6 +1230,24 @@ pub struct sgx_ql_config_t {
     pub p_cert_data: * mut uint8_t,
 }
 
+#[repr(C)]
+pub struct sgx_ql_qve_collateral_t {
+    pub version: uint32_t,                  // version = 1.  PCK Cert chain is in the Quote.
+    pub pck_crl_issuer_chain: * mut char,
+    pub pck_crl_issuer_chain_size: uint32_t,
+    pub root_ca_crl: * mut char,            // Root CA CRL
+    pub root_ca_crl_size: uint32_t,
+    pub pck_crl: * mut char,                // PCK Cert CRL
+    pub pck_crl_size: uint32_t,
+    pub tcb_info_issuer_chain: * mut char,
+    pub tcb_info_issuer_chain_size: uint32_t,
+    pub tcb_info: * mut char,               // TCB Info structure
+    pub tcb_info_size: uint32_t,
+    pub qe_identity_issuer_chain: * mut char,
+    pub qe_identity_issuer_chain_size: uint32_t,
+    pub qe_identity: * mut char,            // QE Identity Structure
+    pub qe_identity_size: uint32_t,
+}
 
 //
 // sgx_quote_3.h
@@ -1244,10 +1276,10 @@ impl_enum! {
         PCK_CLEARTEXT           = 4,
         PCK_CERT_CHAIN          = 5,
         ECDSA_SIG_AUX_DATA      = 6,
+        QL_CERT_KEY_TYPE_MAX    = 16,
     }
 }
 
-
 impl_copy_clone! {
     #[repr(packed)]
     pub struct sgx_ql_att_key_id_t {
@@ -1353,4 +1385,67 @@ impl_struct_default! {
 
 impl_struct_ContiguousMemory! {
     sgx_quote3_t;
+}
+
+//
+// sgx_ql_quote.h
+//
+impl_copy_clone! {
+    #[repr(packed)]
+    pub struct sgx_ql_qe_report_info_t {
+        pub nonce: sgx_quote_nonce_t,
+        pub app_enclave_target_info: sgx_target_info_t,
+        pub qe_report: sgx_report_t,
+    }
+}
+
+impl_struct_default! {
+    sgx_ql_qe_report_info_t, 960;
+}
+
+impl_struct_ContiguousMemory! {
+    sgx_ql_qe_report_info_t;
+}
+
+//
+// qve_header.h
+//
+impl_copy_clone! {
+    pub struct sgx_ql_qv_supplemental_t {
+        pub version: uint32_t,
+        pub earliest_issue_date: time_t,
+        pub tcb_level_date_tag: time_t,
+        pub pck_crl_num: uint32_t,
+        pub root_ca_crl_num: uint32_t,
+        pub tcb_eval_ref_num: uint32_t,
+        pub root_key_id: [uint8_t; 48],
+        pub pck_ppid: sgx_key_128bit_t,
+        pub tcb_cpusvn: sgx_cpu_svn_t,
+        pub tcb_pce_isvsvn: sgx_isv_svn_t,
+        pub pce_id: uint16_t,
+    }
+}
+
+impl_struct_default! {
+    sgx_ql_qv_supplemental_t, 120;
+}
+
+impl_struct_ContiguousMemory! {
+    sgx_ql_qv_supplemental_t;
+}
+
+impl_enum! {
+    #[repr(u32)]
+    #[derive(Copy, Clone, PartialEq, Eq, Ord, PartialOrd, Debug)]
+    pub enum sgx_ql_qv_result_t {
+        SGX_QL_QV_RESULT_OK                         = 0x0000_0000,
+//      SGX_QL_QV_RESULT_MIN                        = 0x0000_A001,
+        SGX_QL_QV_RESULT_CONFIG_NEEDED              = 0x0000_A001,
+        SGX_QL_QV_RESULT_OUT_OF_DATE                = 0x0000_A002,
+        SGX_QL_QV_RESULT_OUT_OF_DATE_CONFIG_NEEDED  = 0x0000_A003,
+        SGX_QL_QV_RESULT_INVALID_SIGNATURE          = 0x0000_A004,
+        SGX_QL_QV_RESULT_REVOKED                    = 0x0000_A005,
+        SGX_QL_QV_RESULT_UNSPECIFIED                = 0x0000_A006,
+        SGX_QL_QV_RESULT_MAX                        = 0x0000_A0FF,
+    }
 }
\ No newline at end of file
diff --git a/sgx_unwind/Cargo.toml b/sgx_unwind/Cargo.toml
index 49737a0..7551584 100644
--- a/sgx_unwind/Cargo.toml
+++ b/sgx_unwind/Cargo.toml
@@ -27,6 +27,3 @@ doc = false
 
 [build-dependencies]
 sgx_build_helper = { path = "../sgx_build_helper" }
-
-[target.'cfg(not(target_env = "sgx"))'.dependencies]
-sgx_trts = { path = "../sgx_trts" }
diff --git a/sgx_unwind/lib.rs b/sgx_unwind/lib.rs
index b4634bf..16b525c 100644
--- a/sgx_unwind/lib.rs
+++ b/sgx_unwind/lib.rs
@@ -30,7 +30,6 @@ cfg_if! {
     } else if #[cfg(all(target_arch = "wasm32", not(target_os = "emscripten")))] {
         // no unwinder on the system!
     } else {
-        extern crate sgx_trts;
         mod libunwind;
         pub use libunwind::*;
     }
diff --git a/sgx_unwind/libunwind.rs b/sgx_unwind/libunwind.rs
index 6b5ab3c..40c86b4 100644
--- a/sgx_unwind/libunwind.rs
+++ b/sgx_unwind/libunwind.rs
@@ -15,7 +15,9 @@ macro_rules! cfg_if {
         ( $( $( #[cfg($meta)] $it1)* $( #[cfg(not($meta))] $it2)* )* )
 }
 
-use sgx_trts::libc::{c_int, c_void, uintptr_t};
+use core::ffi::c_void;
+type c_int = i32;
+type uintptr_t = usize;
 
 #[repr(C)]
 #[derive(Debug, Copy, Clone, PartialEq)]
diff --git a/sgx_urts/src/lib.rs b/sgx_urts/src/lib.rs
index d9b3e75..d43e5c2 100644
--- a/sgx_urts/src/lib.rs
+++ b/sgx_urts/src/lib.rs
@@ -43,5 +43,6 @@ pub mod sys;
 pub mod pipe;
 pub mod event;
 pub mod thread;
+pub mod net;
 pub use enclave::*;
 
diff --git a/sgx_tstd/src/rt.rs b/sgx_urts/src/net.rs
similarity index 68%
copy from sgx_tstd/src/rt.rs
copy to sgx_urts/src/net.rs
index fcfd0a4..6a2e020 100644
--- a/sgx_tstd/src/rt.rs
+++ b/sgx_urts/src/net.rs
@@ -26,33 +26,28 @@
 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
-//! Runtime services
-
-use sgx_types::sgx_enclave_id_t;
-use crate::enclave;
-use alloc_crate::slice;
-use core::str;
-// Reexport some of our utilities which are expected by other crates.
-pub use crate::panicking::{begin_panic, begin_panic_fmt, update_panic_count};
-pub use crate::sys_common::at_exit;
-use crate::sys_common::cleanup;
+use std::io::Error;
+use libc::{self, c_int, c_char, addrinfo};
 
 #[no_mangle]
-pub extern "C" fn t_global_exit_ecall() {
+pub extern "C" fn u_getaddrinfo_ocall(error: * mut c_int, node: * const c_char, service: * const c_char, hints: * const addrinfo, res: * mut * mut addrinfo) -> c_int {
+    let mut errno = 0;
+    let ret = unsafe { libc::getaddrinfo(node, service, hints, res) };
+    if ret == libc::EAI_SYSTEM {
+        errno = Error::last_os_error().raw_os_error().unwrap_or(0);
+    }
+    if !error.is_null() {
+        unsafe { *error = errno; }
+    }
+    ret
 }
 
 #[no_mangle]
-pub extern "C" fn t_global_init_ecall(id: u64, path: * const u8, len: usize) {
-
-    enclave::set_enclave_id(id as sgx_enclave_id_t);
-    let s = unsafe {
-        let str_slice = slice::from_raw_parts(path, len);
-        str::from_utf8_unchecked(str_slice)
-    };
-    enclave::set_enclave_path(s);
-}
-
-global_dtors_object! {
-    GLOBAL_DTORS, global_exit = { cleanup(); }
+pub extern "C" fn u_freeaddrinfo_ocall(res: * mut addrinfo ) {
+    unsafe { libc::freeaddrinfo(res) }
 }
 
+#[no_mangle]
+pub extern "C" fn u_gai_strerror_ocall(errcode: c_int) -> * const c_char {
+    unsafe { libc::gai_strerror(errcode) }
+}
\ No newline at end of file
diff --git a/sgx_ustdc/env.c b/sgx_ustdc/env.c
index 12bb435..54d507a 100644
--- a/sgx_ustdc/env.c
+++ b/sgx_ustdc/env.c
@@ -26,6 +26,7 @@
 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
+#include <unistd.h>
 #include <sys/types.h>
 #include <stdlib.h>
 #include <errno.h>
@@ -91,11 +92,11 @@ int u_getpwuid_r_ocall(uid_t uid,
 {
     int ret = getpwuid_r(uid, pwd, buf, buflen, passwd_result);
     if (ret == 0 && *passwd_result != NULL) {
-        pwd->pw_name = pwd->pw_name ? pwd->pw_name - buf : -1;
-        pwd->pw_passwd = pwd->pw_passwd ? pwd->pw_passwd - buf : -1;
-        pwd->pw_gecos = pwd->pw_gecos ? pwd->pw_gecos - buf : -1;
-        pwd->pw_dir = pwd->pw_dir ? pwd->pw_dir - buf : -1;
-        pwd->pw_shell = pwd->pw_shell ? pwd->pw_shell - buf : -1;
+        pwd->pw_name = pwd->pw_name ? (char *)(pwd->pw_name - buf) : (char *)-1;
+        pwd->pw_passwd = pwd->pw_passwd ? (char *)(pwd->pw_passwd - buf) : (char *)-1;
+        pwd->pw_gecos = pwd->pw_gecos ? (char *)(pwd->pw_gecos - buf) : (char *)-1;
+        pwd->pw_dir = pwd->pw_dir ? (char *)(pwd->pw_dir - buf) : (char *)-1;
+        pwd->pw_shell = pwd->pw_shell ? (char *)(pwd->pw_shell - buf) : (char *)-1;
     }
     return ret;
 }
\ No newline at end of file
diff --git a/sgx_urts/src/lib.rs b/sgx_ustdc/net.c
similarity index 74%
copy from sgx_urts/src/lib.rs
copy to sgx_ustdc/net.c
index d9b3e75..361e8ce 100644
--- a/sgx_urts/src/lib.rs
+++ b/sgx_ustdc/net.c
@@ -26,22 +26,26 @@
 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
-#![allow(clippy::not_unsafe_ptr_arg_deref)]
-#![feature(ptr_offset_from)]
-extern crate libc;
-extern crate sgx_types;
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <netdb.h>
+#include <errno.h>
 
-mod enclave;
-pub mod mem;
-pub mod time;
-pub mod fd;
-pub mod file;
-pub mod socket;
-pub mod asyncio;
-pub mod env;
-pub mod sys;
-pub mod pipe;
-pub mod event;
-pub mod thread;
-pub use enclave::*;
+int u_getaddrinfo_ocall(int * error, const char * node, const char * service, const struct addrinfo * hints, struct addrinfo ** res)
+{
+    int ret = getaddrinfo(node, service, hints, res);
+    if (error) {
+        *error = ret == EAI_SYSTEM ? errno : 0;
+    }
+    return ret;
+}
 
+void u_freeaddrinfo_ocall(struct addrinfo *res)
+{
+    return freeaddrinfo(res);
+}
+
+const char *u_gai_strerror_ocall(int errcode)
+{
+    return gai_strerror(errcode);
+}
\ No newline at end of file
diff --git a/xargo/sgx_tstd/Cargo.toml b/xargo/sgx_tstd/Cargo.toml
index 6b39361..428c665 100644
--- a/xargo/sgx_tstd/Cargo.toml
+++ b/xargo/sgx_tstd/Cargo.toml
@@ -16,6 +16,7 @@ backtrace = ["stdio"]
 stdio = []
 net = []
 pipe = []
+thread = []
 untrusted_fs = []
 untrusted_time = []
 


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@mesatee.apache.org
For additional commands, e-mail: commits-help@mesatee.apache.org