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

Adding additional sources to the sgx-ra-sample

mzaman
Novice
1,063 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
1,017 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

0 Kudos
5 Replies
JesusG_Intel
Moderator
1,030 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


0 Kudos
mzaman
Novice
1,026 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

0 Kudos
JesusG_Intel
Moderator
1,018 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


0 Kudos
JesusG_Intel
Moderator
988 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.


0 Kudos
JesusG_Intel
Moderator
988 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.


0 Kudos
Reply