lsds / TaLoS

Efficient TLS termination inside Intel SGX enclaves for existing applications

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Undefined reference with static linking

gmatesunny opened this issue · comments

My /home/roshan/talos/src/nginx-1.11.0/objs/makefile (full version: https://gist.github.com/gmatesunny/ae600c1d4183c12a0a99387923828cab)

$(LINK) -o objs/nginx \
objs/src/core/nginx.o \
objs/src/core/ngx_log.o \
     ----------------------
     ---------------------
-ldl -lpthread /home/roshan/sgxsdk/sdk_libs/libsgx_uae_service_sim.so /home/roshan/sgxsdk/sdk_libs/libsgx_urts_sim.so -lcrypt -lpcre /home/roshan/talos/src/libressl-2.4.1/lib/libssl.a /home/roshan/talos/src/libressl-2.4.1/lib/libcrypto.a -ldl -lz \
-Wl,-E

I have also set: /etc/ld.so.conf.d/sgxlibs.conf to (guide: https://stackoverflow.com/questions/9151491/extending-default-lib-search-path-in-ubuntu)
/home/roshan/sgxsdk/lib64/

Also, set the PATH variable to /home/roshan/sgxsdk/lib64/

I am trying to build Nginx and on doing make at /home/roshan/talos/src/nginx-1.11.0

Step of the readme.md where I got stuck:

on step 3. in `objs/nginx`, for the LINK phase, update the following line with the
   correct path to `libssl.a` and `libcrypto.a` and add `-lsgx_urts
   -lsgx_uae_service`. Depending on how you compiled TaLoS, you may want to
   change `-lsgx_urts -lsgx_uae_service` (real hardware) to `-lsgx_urts_sim
   -lsgx_uae_service_sim` (simulator).

The code is ready to be compiled:
$ make

I am keep getting errors like:
/home/roshan/talos/src/libressl-2.4.1/crypto/enclave_u.c:2101: undefined reference to sgx_ecall' /home/roshan/talos/src/libressl-2.4.1/lib/libssl.a(enclave_u.o): In function ecall_SSL_library_init':
/home/roshan/talos/src/libressl-2.4.1/crypto/enclave_u.c:2109: undefined reference to sgx_ecall' /home/roshan/talos/src/libressl-2.4.1/lib/libssl.a(enclave_u.o): In function ecall_SSL_get_ex_new_index':
/home/roshan/talos/src/libressl-2.4.1/crypto/enclave_u.c:2137: undefined reference to sgx_ecall' /home/roshan/talos/src/libressl-2.4.1/lib/libssl.a(enclave_u.o): In function ecall_SSL_CTX_get_ex_new_index':
/home/roshan/talos/src/libressl-2.4.1/crypto/enclave_u.c:2151: undefined reference to sgx_ecall' /home/roshan/talos/src/libressl-2.4.1/lib/libssl.a(enclave_u.o):/home/roshan/talos/src/libressl-2.4.1/crypto/enclave_u.c:2165: more undefined references to sgx_ecall' follow

Also have a look here:
https://stackoverflow.com/questions/49201545/cannot-find-of-a-so-library

Solution:

-ldl -lpthread -lcrypt -lpcre /home/roshan/talos/src/libressl-2.4.1/lib/libssl.a /home/roshan/talos/src/libressl-2.4.1/lib/libcrypto.a -L /opt/intel/sgxsdk/sdk_libs -lsgx_urts_sim -lsgx_uae_service_sim -ldl -lz \