Intel® Software Guard Extensions (Intel® SGX)
Discussion board focused on hardware-based isolation and memory encryption to provide extended code protection in solutions.

Dynamic linkage of an Enclave



I need to build a dynamic library that will act as a wrapper for an enclave dynamic library. Reasoning behind that is to provide an interface that could be integrated with a NodeJS application (using node-ffi) as well as to implement error handling. I have already done this on Windows and it worked like a charm - my application dynamically loaded both Enclave DLL and my wrapper DLL and did what I expected it to. However it turned out that this will have to run under Linux, so I'm trying to do the same under Linux which turned out to be problematic.

What have I done so far:

  1. Installed SGX as per and tested it using SampleEnclave app
  2. Copied Makefile from to my project and adapted it for my needs (kept changes to minimum)
  3. Built app using make and got
  4. Built my with 
    g++ -shared -fPIC -Wl,-soname, -o App/*.o
  5.  Built a simple test app that calls a method from with
    g++ -c test.cpp
  6.  Attempted to link both dynamic libs to a test app with
    g++ -o prog test.o -L. -lm

    ... but it failed with following messages:

 ./ undefined reference to `sgx_thread_set_untrusted_event_ocall'
./ undefined reference to `sgx_thread_setwait_untrusted_events_ocall'
./ undefined reference to `sgx_destroy_enclave'
./ undefined reference to `sgx_ecall'
./ undefined reference to `sgx_create_enclave'
./ undefined reference to `sgx_oc_cpuidex'
./ undefined reference to `sgx_thread_set_multiple_untrusted_events_ocall'
./ undefined reference to `sgx_thread_wait_untrusted_event_ocall'
collect2: error: ld returned 1 exit status

Which looks like the linkage to has failed.

Now, I do not have so much experience with developing under Linux, so it was tempting to assume this issue is not related to SGX. However I created a simple project in which I'm doing exactly the same linkage but with no SGX involved. It worked like a charm, so it seems I'm doing something not-too-SGXy ;)

Any help appreciated! I intentionally haven't included my code/makefile because I wanted to keep it as simple as possible and also I don't think those are relevant, since code worked on Windows. If needed, I can of course provide source, via GitHub or just by pasting here.

Thanks for your replies!


0 Kudos
0 Replies