Sharing DLLs

DLLs are shared at the enclave level (as defined by Language Environment). A referenced DLL is loaded only once per enclave, and only one copy of the writable static is created or maintained per DLL per enclave. Thus, a single copy of a DLL serves all modules in a given enclave regardless of whether the DLL is loaded implicitly (through a reference to a function or variable) or explicitly (through dllload()). You can simultaneously access a given DLL within a given enclave both implicitly and by explicit execution-time services.

All accesses to a given variable in a given DLL in a given enclave refer to the only copy of that variable. All accesses to a given function in a given DLL in a given enclave refer to the only copy of that function.

Although only one copy of a DLL is maintained per enclave, multiple logical loads are counted and used to determine when the DLL (including its writable static area) is actually deleted. For a given DLL in a given enclave, there is one logical load of it for the first implicit reference to one of its variables or functions from a given load module, and one logical load for each explicit dllload() request.

DLLs are not shared in a nested enclave environment. Only the enclave that loaded the DLL can access functions and variables. For example, if program A loads a DLL and makes a system call to program B, program B cannot access any of the DLL variables or functions loaded by program A. Program B can access the DLL variables and functions by loading its own copy of the DLL.