Intel® Software Guard Extensions (Intel® SGX)
Use hardware-based isolation and memory encryption to provide more code protection in your solutions.
1346 Discussions

link enclave so fail with "-lsgx_tsgxssl -lsgx_tsgxssl_crypto"

pp__monkeyking
Beginner
388 Views

I installed the sgx release (Nov 18, 2021) on 18.04.1-Ubuntu:
1. Driver: sgx_linux_x64_driver_1.41.bin and sgx_linux_x64_driver_2.11.0_2d2b795.bin;
2. sdk: sgx_linux_x64_sdk_2.15.101.1.bin;
3. psw: related pkg;

Then, I wrote the enclave program that references the openssl library, then I compiled libsgx_tsgxssl.a with openssl-1.1.1l.tar.gz and https://github.com/intel/intel-sgx-ssl.git and libsgx_tsgxssl_crypto.a, when I link my enclave so with the following link flag, it always reports the following error:
Enclave_Link_Flags := $(Enclave_Security_Link_Flags) \
-Wl,--no-undefined -nostdlib -nodefaultlibs -nostartfiles \
-L./include/ssl/lib64 -Wl,--whole-archive -lsgx_tsgxssl -lsgx_tsgxssl_crypto -lpthread -Wl,--no-whole-archive \
-L$(SGX_LIBRARY_PATH) -Wl,--whole-archive -l$(Trts_Library_Name) -Wl,--no-whole-archive \
-Wl,--start-group -lsgx_tstdc -lsgx_tcxx -l$(Crypto_Library_Name) -l$(Service_Library_Name) -Wl,--end-group \
-Wl,-Bstatic -Wl,-Bsymbolic -Wl,--no-undefined -Wl,-pie,-eenclave_entry \
-Wl,--export-dynamic -Wl,--defsym,__ImageBase=0 -Wl,--gc-sections

:link error:
/usr/bin/ld: /usr/lib/x86_64-linux-gnu/libpthread_nonshared.a(pthread_atfork.oS): undefined reference to symbol '__register_atfork@@GLIBC_2.3.2'
//lib/x86_64-linux-gnu/libc.so.6: error adding symbols: DSO missing from command line

0 Kudos
1 Solution
Sahira_Intel
Moderator
348 Views

Hi,

Can you try following these steps and try to compile/link again:


  1. Copy sgxsdk/include/sgx_pthread.edl to the Enclave source directory.
  2. In Enclave.edl, addfrom "sgx_pthread.edl" import *;
  3. In Enclave.cpp, add#include "pthread.h"



Sincerely,

Sahira


View solution in original post

4 Replies
pp__monkeyking
Beginner
364 Views

or :

not -lpthread, 

but -Wl,--start-group -lsgx_tstdc -lsgx_pthread -lsgx_tcxx -lsgx_tcrypto ,

 

link error:

 

/usr/local/bin/ld: /home/data/sgx/sgxsdk/lib64/libsgx_pthread.a(pthread.o): in function `_pthread_wakeup(unsigned long) [clone .part.0]':
pthread.cpp:(.text._Z15_pthread_wakeupm.part.0+0x2d): undefined reference to `pthread_wakeup_ocall'
/usr/local/bin/ld: /home/data/sgx/sgxsdk/lib64/libsgx_pthread.a(pthread.o): in function `_pthread_wait_timeout(unsigned long, unsigned long)':
pthread.cpp:(.text._Z21_pthread_wait_timeoutmm+0x30): undefined reference to `pthread_wait_timeout_ocall'
/usr/local/bin/ld: /home/data/sgx/sgxsdk/lib64/libsgx_pthread.a(pthread.o): in function `pthread_create':
pthread.cpp:(.text.pthread_create+0x113): undefined reference to `pthread_create_ocall'
/usr/local/bin/ld: pthread.cpp:(.text.pthread_create+0x16c): undefined reference to `pthread_wait_timeout_ocall'
/usr/local/bin/ld: /home/data/sgx/sgxsdk/lib64/libsgx_pthread.a(pthread.o): in function `pthread_join':
pthread.cpp:(.text.pthread_join+0xe0): undefined reference to `pthread_wait_timeout_ocall'
collect2: error: ld returned 1 exit status
sgx_t.mk:172: recipe for target 'libenclave_factory.so' failed
make[1]: *** [libenclave_factory.so] Error 1
make[1]: Leaving directory '/home/phf/phf_dell/vault/code/exchange-order-service/sgx'
Makefile:9: recipe for target 'all' failed
make: *** [all] Error 2

Sahira_Intel
Moderator
349 Views

Hi,

Can you try following these steps and try to compile/link again:


  1. Copy sgxsdk/include/sgx_pthread.edl to the Enclave source directory.
  2. In Enclave.edl, addfrom "sgx_pthread.edl" import *;
  3. In Enclave.cpp, add#include "pthread.h"



Sincerely,

Sahira


pp__monkeyking
Beginner
314 Views

Thank you very mach,

it's ok in your way.

Sahira_Intel
Moderator
273 Views

Intel is no longer monitoring this thread. If you want a response from Intel in a follow-up question, please open a new thread.

Reply