Hi, I have 3 urgent questions...
Q1. I am trying to use libz3.a (https://github.com/Z3Prover/z3) in SGX. However, if I include "-lz3" in the Enclave_Link_Flag variable, I get hundreds of "undefined reference to ..." errors. All of them are calls to functions defined in libz3.a. Is it that I need to define every single function in libz3.a in the Enclave.edl file? This doesn't seem to be a right solution...
Q2. Also, I am trying to call std library functions such as "printf" and "strcat". However, I cannot use these functions within the Enclave code. I thought libsgx_tstdc.a contains LibC functions, but this library does not have "printf" and "strcat". I wonder if it's impossible to use "printf" and "strcat" and any other common LibC functions within the Enclave.
Q3. I wonder if there is any documentation or tutorials for all functions SGX libraries offer.
I would really appreciate your help!
To answer your second question, if you look at some of the sample code for enclaves you'll see that they make simple wrapper functions to execute functions such as printf():
I'm not sure if this is feasible for your use case, but if you are only using a limited number of std library functions you should be able to make wrappers in a similar fashion. I hope this helps.
Also, as for 3rd party libraries, I tried using one a few months ago when I was working on a project and I had a nightmarish time trying to get it to work (fwiw I was developing in Linux which seems to have much less support than Windows). I don't consider myself an expert with SGX by any means though, so someone else may be able to give you a better idea of how difficult it would be. Bottom line was I spent days trying to modify Makefiles to no avail.
I will say though that you may need to not only add the link flag but also make sure your .a file is in the enclave include path in the Makefile.
Thanks a lot for your insights. It's good to clearly know that we do need to modify the original source code if it uses function calls unsupported by SGX. I also experienced the nightmare of modifying my Makefile to make it work, which didn't eventually..
The original source code of the library I'm trying to use (z3) seems quite complex to modify, so I will instead try to develop my own library instead. Thanks!