intel / linux-sgx

Intel SGX for Linux*
https://www.intel.com/content/www/us/en/developer/tools/software-guard-extensions/linux-overview.html
Other
1.33k stars 543 forks source link

sgx-gdb does not work with sgx_create_enclave_from_buffer_ex #482

Open sethmoo opened 4 years ago

sethmoo commented 4 years ago

If an enclave is loaded with sgx_create_enclave_from_buffer_ex, then the sgx-gdb doesn't work. We get a Python exception every time the gdb extension script is called: Python Exception <class 'gdb.error'> No symbol table is loaded. Use the "file" command.:

It appears that retrieve_enclave_info assumes the enclave was loaded by file: https://github.com/intel/linux-sgx/blob/5db5a81b82539abb9a2fbd8bcb44dbaaa6f94c74/sdk/debugger_interface/linux/gdb-sgx-plugin/gdb_sgx_plugin.py#L355

If an enclave is loaded from a buffer the debug_enclave_info_t object won't have lpFileName populated. Thus, the debugger extensions cannot load the symbols, and gdb gets quite sad.

andyzyb commented 4 years ago

I think this is expected. The current design of sgx-gdb needs the enclave file to support debugging.

sethmoo commented 4 years ago

If the enclave is loaded via buffer, couldn't the gdb plugin gather the symbol information from the buffer itself? IIRC, the buffer is no different from an external file, in terms of contents. It's just loaded from memory instead of an external file. Thus, all the information needed to load symbols should still be there.