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

Adding additional sources to the sgx-ra-sample

mzaman
Novice
380 Views

Hi,

In sgx-ra-sample, I want to add additional source. Let's say my ocall is public A(). In the enclave.cpp file I implement the A() function and the function is depend on B() functionB() is implemented in another file called B.c.

According to Makefile.am, I added B.c in the ENCLAVE_SOURCES. But it's showing undefined reference to B. Here is the enclave sources example

Enclave_SOURCES = Enclave_t.c Enclave_t.h s_client.c Enclave.cpp\
$(ENCLAVE_KEY) $(ENCLAVE_CONFIG)

 

Thanks,

Mzaman

 

0 Kudos
1 Solution
JesusG_Intel
Moderator
334 Views

Hello mzaman,


I got it working by editing the Makefile directly.


  1. Create a header file, B.h, that contains the declaration to your B() function.
  2. Add #include <B.h> to Enclave.cpp.
  3. Edit Makefile:
    1. am_Enclave_OBJECTS = s_client.$(OBJEXT) Enclave_t.$(OBJEXT)...
    2. Enclave_SOURCES = Enclave_t.c Enclave_t.h s_client.c Enclave.cpp\
  4. make clean && make


Sincerely,

Jesus G.

Intel Customer Support


View solution in original post

5 Replies
JesusG_Intel
Moderator
347 Views

Hello mzaman,


Please clarify what you are doing. You wrote that public A() is an ocall.


Ocalls are implemented in the untrusted app, not in the enclave, enclave.cpp.


The enclave calls the ocall which is implemented in the untrusted app.


Sincerely,

Jesus G.

Intel Customer Support


mzaman
Novice
343 Views

Hi JesusG,

Thanks for replying. I think I messed up with the terms.

Let's say, I implement a public A() function (written in the trusted part of Enclave.edl) in Enclave.cpp and it's depend on function B(). Function B() is implemented on B.c file. How can I include B.c file in the make file.

Regards,

Mzaman

JesusG_Intel
Moderator
335 Views

Hello mzaman,


I got it working by editing the Makefile directly.


  1. Create a header file, B.h, that contains the declaration to your B() function.
  2. Add #include <B.h> to Enclave.cpp.
  3. Edit Makefile:
    1. am_Enclave_OBJECTS = s_client.$(OBJEXT) Enclave_t.$(OBJEXT)...
    2. Enclave_SOURCES = Enclave_t.c Enclave_t.h s_client.c Enclave.cpp\
  4. make clean && make


Sincerely,

Jesus G.

Intel Customer Support


View solution in original post

JesusG_Intel
Moderator
305 Views

This thread has been marked as answered and Intel will no longer monitor this thread. If you want a response from Intel in a follow-up question, please open a new thread.


JesusG_Intel
Moderator
305 Views

This thread has been marked as answered and Intel will no longer monitor this thread. If you want a response from Intel in a follow-up question, please open a new thread.


Reply