LIEF: Library to Instrument Executable Formats Version 0.16.0
Loading...
Searching...
No Matches
LIEF::dsc Namespace Reference

Namespace related to the dyld shared cache support. More...

Namespaces

namespace  details
 

Classes

class  DyldSharedCache
 This class represents a dyld shared cache file. More...
 
class  Dylib
 This class represents a library embedded in a dyld shared cache. It mirrors the original dyld_cache_image_info structure. More...
 
class  MappingInfo
 This class represents a dyld_cache_mapping_info entry. More...
 
class  SubCache
 This class represents a subcache in the case of large/split dyld shared cache. More...
 

Typedefs

using sc_uuid_t = std::array<uint8_t, 16>
 UUID used in different places of the shared cache.
 

Functions

bool enable_cache ()
 Enable globally cache/memoization. One can also leverage this function by setting the environment variable DYLDSC_ENABLE_CACHE to 1
 
bool enable_cache (const std::string &dir)
 Same behavior as enable_cache() but with a user-provided cache directory.
 
std::unique_ptr< DyldSharedCacheload (const std::string &path, const std::string &arch="")
 Load a shared cache from a single file or from a directory specified by the path parameter.
 
std::unique_ptr< DyldSharedCacheload (const std::vector< std::string > &files)
 Load a shared cache from a list of files.
 

Detailed Description

Namespace related to the dyld shared cache support.

Typedef Documentation

◆ sc_uuid_t

using LIEF::dsc::sc_uuid_t = std::array<uint8_t, 16>

UUID used in different places of the shared cache.

Function Documentation

◆ enable_cache() [1/2]

bool LIEF::dsc::enable_cache ( )

Enable globally cache/memoization. One can also leverage this function by setting the environment variable DYLDSC_ENABLE_CACHE to 1

By default, LIEF will use the directory specified by the environment variable DYLDSC_CACHE_DIR as its cache-root directory:

DYLDSC_ENABLE_CACHE=1 DYLDSC_CACHE_DIR=/tmp/my_dir ./my-program

Otherwise, if DYLDSC_CACHE_DIR is not set, LIEF will use the following directory (in this priority):

  1. System or user cache directory
    • macOS: DARWIN_USER_TEMP_DIR / DARWIN_USER_CACHE_DIR + /dyld_shared_cache
    • Linux: ${XDG_CACHE_HOME}/dyld_shared_cache
    • Windows: LOCALAPPDATA%\dyld_shared_cache
  2. Home directory
    • macOS/Linux: $HOME/.dyld_shared_cache
    • Windows: USERPROFILE%\.dyld_shared_cache
See also
LIEF::dsc::DyldSharedCache::enable_caching for a finer granularity

◆ enable_cache() [2/2]

bool LIEF::dsc::enable_cache ( const std::string & dir)

Same behavior as enable_cache() but with a user-provided cache directory.

◆ load() [1/2]

std::unique_ptr< DyldSharedCache > LIEF::dsc::load ( const std::string & path,
const std::string & arch = "" )
inline

Load a shared cache from a single file or from a directory specified by the path parameter.

In the case where multiple architectures are available in the path directory, the arch parameter can be used to define which architecture should be prefered.

Example:

// From a directory (split caches)
auto cache = LIEF::dsc::load("vision-pro-2.0/");
// From a single cache file
auto cache = LIEF::dsc::load("ios-14.2/dyld_shared_cache_arm64");
// From a directory with multiple architectures
auto cache = LIEF::dsc::load("macos-12.6/", /*arch=*&zwj;/"x86_64h");
std::unique_ptr< DyldSharedCache > load(const std::string &path, const std::string &arch="")
Load a shared cache from a single file or from a directory specified by the path parameter.
Definition DyldSharedCache/DyldSharedCache.hpp:245

References LIEF::dsc::DyldSharedCache::from_path().

◆ load() [2/2]

std::unique_ptr< DyldSharedCache > LIEF::dsc::load ( const std::vector< std::string > & files)
inline

Load a shared cache from a list of files.

std::vector<std::string> files = {
"/tmp/dsc/dyld_shared_cache_arm64e",
"/tmp/dsc/dyld_shared_cache_arm64e.1"
};
auto cache = LIEF::dsc::load(files);

References LIEF::dsc::DyldSharedCache::from_files().