      if (ret != SGX_SUCCESS)
      {
          return ret;
-@@ -263,7 +265,7 @@
+@@ -257,13 +259,13 @@
+     {
+         loader.destroy_enclave();
+         delete enclave;
+-        return SGX_ERROR_UNEXPECTED;
++        return SGX_ERROR_INVALID_ENCLAVE;
+     }
+ 
      std::vector<std::pair<tcs_t *, bool>> tcs_list = loader.get_tcs_list();
      for (unsigned idx = 0; idx < tcs_list.size(); ++idx)
      {

    {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, {0, 0, 0, 0, 0, 0}, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, 0, 0, {{{0, 0, 0, 0, 0, 0, 0}}}};
 uint32_t g_enclave_state __attribute__((section(".nipd"))) = ENCLAVE_INIT_NOT_STARTED;
 
@@ -197,7 +198,7 @@
     else
 #endif
     {

 {
     uint64_t page_frame = rva >> SE_PAGE_SHIFT;
     //NOTE:
@@ -146,7 +148,7 @@
                 {
                     SE_TRACE(SE_TRACE_WARNING, "mprotect(rva=0x%llx, len=%d, flags=%d) failed\n",
                              rva, SE_PAGE_SIZE, int(sinfo.flags & SI_MASK_MEM_ATTRIBUTE));
-                    return SGX_ERROR_UNEXPECTED;
+                    return SGX_ERROR_MEMORY_MAP_CONFLICT;
                 }
             }
         }
@@ -181,7 +183,7 @@
     return SGX_SUCCESS;
 }
