Article ID: 000058606 Content Type: Error Messages Last Reviewed: 08/02/2024

Unable to see an Enclave's Heap Usage when Using the sgx_emmt Tool in Linux*

BUILT IN - ARTICLE INTRO SECOND COMPONENT
Summary

How to generate an enclave image with the symbols that allow sgx_emmt to report memory usage data

Description
  • Debugged an Intel® Software Guard Extensions (Intel® SGX) application with sgx-gdb and used sgx_emmt to view memory usage
  • The stack usage is shown, but the peak heap and committed reserved memory are not shown:
    [Peak stack used]: 7 KB
    [Can't get peak heap used]: You may use version script to control symbol export. Please export 'g_peak_heap_used' in your version script.
    [Can't get peak committed reserved memory]: You may use version script to control symbol export. Please export 'g_peak_rsrv_mem_committed' in your version script.
Resolution

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.

  1. Create a file with the content of the enclave version script:

    enclave.so

    {

      global:

        g_global_data_sim;

        g_global_data;

        enclave_entry;

        g_peak_heap_used;

        g_peak_rsrv_mem_committed;

      local:

        *;

    };

  2. Save the script in the enclave's source directory as Enclave.lds.
  3. Link the enclave with the version script and define the symbol __ImageBase in the Makefile, similarly to:

    $ 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

Additional information

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*.

Related Products

This article applies to 1 products