0

I want to use Luacpp in an SGX application. For example, in the SampleEnclave application, I want to send some Lua codes to be executed securely in SGX.

I have updated the Enclave's MakeFile to make the SampleEnclave app Lua compatible. But getting below error:

/usr/local/bin/ld: Enclave/Enclave.o: warning: relocation against `_ZTVN6LuaCpp6Engine10LuaTStringE' in read-only section `.text._ZN6LuaCpp6Engine10LuaTStringD2Ev[_ZN6LuaCpp6Engine10LuaTStringD5Ev]'
    /usr/local/bin/ld: /usr/local/bin/ld: DWARF error: section .debug_str is larger than its filesize! (0x55ebb vs 0x40078)
    /usr/local/bin/ld: DWARF error: section .debug_str is larger than its filesize! (0x55ebb vs 0x40078)
    /usr/local/bin/ld: DWARF error: section .debug_str is larger than its filesize! (0x55ebb vs 0x40078)
    /usr/local/bin/ld: DWARF error: section .debug_str is larger than its filesize! (0x55ebb vs 0x40078)
    /usr/local/bin/ld: DWARF error: section .debug_str is larger than its filesize! (0x55ebb vs 0x40078)
    /usr/local/bin/ld: DWARF error: section .debug_str is larger than its filesize! (0x55ebb vs 0x40078)
    /usr/local/bin/ld: DWARF error: section .debug_str is larger than its filesize! (0x55ebb vs 0x40078)
Enclave/Enclave.o:/usr/local/include/LuaCpp/Engine/LuaTString.hpp:62: undefined reference to `LuaCpp::Engine::LuaType::LuaType()'
/usr/local/bin/ld: Enclave/Enclave.o:/usr/local/include/LuaCpp/Engine/LuaTString.hpp:62: undefined reference to `vtable for LuaCpp::Engine::LuaTString'
/usr/local/bin/ld: Enclave/Enclave.o:/usr/local/include/LuaCpp/Engine/LuaTString.hpp:67: undefined reference to `vtable for LuaCpp::Engine::LuaTString'
/usr/local/bin/ld: Enclave/Enclave.o:/usr/local/include/LuaCpp/Engine/LuaTString.hpp:67: undefined reference to `LuaCpp::Engine::LuaType::~LuaType()'
/usr/local/bin/ld: Enclave/Enclave.o: in function `ecall_test':
/home/alam/practice/LuaEnclave/Enclave/Enclave.cpp:55: undefined reference to `LuaCpp::LuaContext::AddGlobalVariable(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::shared_ptr<LuaCpp::Engine::LuaType>)'
/usr/local/bin/ld: /home/alam/practice/LuaEnclave/Enclave/Enclave.cpp:56: undefined reference to `LuaCpp::LuaContext::CompileString(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&)'
/usr/local/bin/ld: /home/alam/practice/LuaEnclave/Enclave/Enclave.cpp:62: undefined reference to `LuaCpp::LuaContext::Run(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&)'
/usr/local/bin/ld: /home/alam/practice/LuaEnclave/Enclave/Enclave.cpp:69: undefined reference to `LuaCpp::Engine::LuaTString::getValue() const'
/usr/local/bin/ld: warning: creating DT_TEXTREL in a PIE
collect2: error: ld returned 1 exit status
make[1]: *** [Makefile:256: enclave.so] Error 1
make[1]: Leaving directory '/home/alam/practice/LuaEnclave'
make: *** [Makefile:181: all] Error 2

Can I get rid of the dynamic library dependency from LUA? Because SGX does not support dynamic libraries in Enclave.

taserghar
  • 340
  • 3
  • 15
  • 1
    What a coincidence, I just had to fit an interpreter in an enclave a few days ago. Here some free tips that will help you along the way: - SGX is limited to C++14 (intul next release), keep that in mind - SGX won't allow any I/O (console for example) - SGX's stdlib is a limited version of the actual stdlib, a lots of features are missing. If you still want an interpreter that fits into an enclave, check this one out: https://github.com/gfwilliams/tiny-js If you still want to shove Luacpp into an enclave, you will have to butcher it until it fits. – X99 Nov 11 '22 at 23:06
  • Hi @X99, thanks for the tips :) Yes, I removed the IO operations (say FILE IO) from the library. but it looks like Lua depends on liblua.so, and enclave does not support DL. Have you ported tiny-js to enclave? If it's not private can you share the code? I will check if I can reuse it. Thanks – taserghar Nov 14 '22 at 00:51

0 Answers0