According to the Enclave Memory Measurement Tool section of the Intel® Software Guard Extensions (Intel® SGX) Developer Reference Guide for Linux*, export the symbols g_peak_heap_used and g_peak_rsrv_mem_committed in the version script of the enclave, and link the enclave image with the version script as described below.
Refer to the SampleEnclave in the Intel SGX SDK to reuse its Makefile and version script, SampleEnclave/Enclave/Enclave.lds.
enclave.so
{
global:
g_global_data_sim;
g_global_data;
enclave_entry;
g_peak_heap_used;
g_peak_rsrv_mem_committed;
local:
*;
};
$ ld -o enclave.so file1.o file2.o \
-pie -eenclave_entry -nostdlib -nodefaultlibs –nostartfiles --no-undefined \
--whole-archive –lsgx_trts --no-whole-archive \
--start-group –lsgx_tstdc ––lsgx_tservice -lsgx_crypto -
-end-group \
-Bstatic -Bsymbolic --defsym=__ImageBase=0 --exportdynamic \
--version-script=enclave.lds
The most recent Intel® Software Guard Extensions Developer Reference Guide for Linux* is in the Documentation section of the latest release in Intel® Software Guard Extensions SDK for Linux*.