LIEF: Library to Instrument Executable Formats Version 0.16.0
|
This class represents a dyld shared cache file. More...
#include <DyldSharedCache.hpp>
Public Types | |
enum class | VERSION : uint32_t { UNKNOWN = 0 , DYLD_95_3 , DYLD_195_5 , DYLD_239_3 , DYLD_360_14 , DYLD_421_1 , DYLD_832_7_1 , DYLD_940 , DYLD_1042_1 , UNRELEASED } |
This enum wraps the dyld's git tags for which the structure of dyld shared cache evolved. More... | |
enum class | DYLD_TARGET_PLATFORM : uint32_t { UNKNOWN = 0 , MACOS = 1 , IOS = 2 , TVOS = 3 , WATCHOS = 4 , BRIDGEOS = 5 , IOSMAC = 6 , IOS_SIMULATOR = 7 , TVOS_SIMULATOR = 8 , WATCHOS_SIMULATOR = 9 , DRIVERKIT = 10 , VISIONOS = 11 , VISIONOS_SIMULATOR = 12 , FIRMWARE = 13 , SEPOS = 14 , ANY = 0xFFFFFFFF } |
Platforms supported by the dyld shared cache. More... | |
enum class | DYLD_TARGET_ARCH { UNKNOWN = 0 , I386 , X86_64 , X86_64H , ARMV5 , ARMV6 , ARMV7 , ARM64 , ARM64E } |
Architecture supported by the dyld shared cache. More... | |
using | dylib_iterator = iterator_range<Dylib::Iterator> |
Iterator over the libraries in the shared cache. | |
using | mapping_info_iterator = iterator_range<MappingInfo::Iterator> |
Iterator over the mapping info in the shared cache. | |
using | subcache_iterator = iterator_range<SubCache::Iterator> |
Iterator over the split/sub-cache in this main shared cache. | |
Public Member Functions | |
DyldSharedCache (std::unique_ptr< details::DyldSharedCache > impl) | |
~DyldSharedCache () | |
std::string | filename () const |
Filename of the dyld shared file associated with this object. | |
VERSION | version () const |
Version of dyld used by this cache. | |
std::string | filepath () const |
Full path to the original dyld shared cache file associated with object (e.g. /home/lief/downloads/visionos/dyld_shared_cache_arm64e.42 ) | |
uint64_t | load_address () const |
Based address of this cache. | |
std::string | arch_name () const |
Name of the architecture targeted by this cache (x86_64h ) | |
DYLD_TARGET_PLATFORM | platform () const |
Platform targeted by this cache (e.g. vision-os) | |
DYLD_TARGET_ARCH | arch () const |
Architecture targeted by this cache. | |
std::unique_ptr< Dylib > | find_lib_from_va (uint64_t va) const |
Find the Dylib that encompasses the given virtual address. It returns a nullptr if a Dylib can't be found. | |
std::unique_ptr< Dylib > | find_lib_from_path (const std::string &path) const |
Find the Dylib whose Dylib::path matches the provided path. | |
std::unique_ptr< Dylib > | find_lib_from_name (const std::string &name) const |
Find the Dylib whose filename of Dylib::path matches the provided name. | |
bool | has_subcaches () const |
True if the subcaches are associated with this cache. | |
dylib_iterator | libraries () const |
Return an interator over the libraries embedded in this dyld shared cache. | |
mapping_info_iterator | mapping_info () const |
Return an interator over the mapping information of this dyld shared cache. | |
subcache_iterator | subcaches () const |
Return an interator over the subcaches associated with this (main) dyld shared cache. | |
void | enable_caching (const std::string &target_cache_dir) const |
When enabled, this function allows to record and to keep in cache, dyld shared cache information that are costly to access. | |
void | flush_cache () const |
Flush internal information into the on-disk cache (see: enable_caching) | |
Static Public Member Functions | |
static std::unique_ptr< DyldSharedCache > | from_path (const std::string &path, const std::string &arch="") |
See the load functions for the details. | |
static std::unique_ptr< DyldSharedCache > | from_files (const std::vector< std::string > &path) |
See the load functions for the details. | |
This class represents a dyld shared cache file.
Iterator over the libraries in the shared cache.
Iterator over the mapping info in the shared cache.
Iterator over the split/sub-cache in this main shared cache.
|
strong |
|
strong |
|
strong |
This enum wraps the dyld's git tags for which the structure of dyld shared cache evolved.
Enumerator | |
---|---|
UNKNOWN | |
DYLD_95_3 | dyld-95.3 (2007-10-30) |
DYLD_195_5 | dyld-195.5 (2011-07-13) |
DYLD_239_3 | dyld-239.3 (2013-10-29) |
DYLD_360_14 | dyld-360.14 (2015-09-04) |
DYLD_421_1 | dyld-421.1 (2016-09-22) |
DYLD_832_7_1 | dyld-832.7.1 (2020-11-19) |
DYLD_940 | dyld-940 (2021-02-09) |
DYLD_1042_1 | dyld-1042.1 (2022-10-19) |
UNRELEASED | This value is used for versions of dyld not publicly released or not yet supported by LIEF. |
LIEF::dsc::DyldSharedCache::DyldSharedCache | ( | std::unique_ptr< details::DyldSharedCache > | impl | ) |
LIEF::dsc::DyldSharedCache::~DyldSharedCache | ( | ) |
DYLD_TARGET_ARCH LIEF::dsc::DyldSharedCache::arch | ( | ) | const |
Architecture targeted by this cache.
std::string LIEF::dsc::DyldSharedCache::arch_name | ( | ) | const |
Name of the architecture targeted by this cache (x86_64h
)
void LIEF::dsc::DyldSharedCache::enable_caching | ( | const std::string & | target_cache_dir | ) | const |
When enabled, this function allows to record and to keep in cache, dyld shared cache information that are costly to access.
For instance, GOT symbols, rebases information, stub symbols, ...
It is highly recommended to enable this function when processing a dyld shared cache several times or when extracting a large number of LIEF::dsc::Dylib with enhanced extraction options (e.g. Dylib::extract_opt_t::fix_branches)
One can enable caching by calling this function:
One can also enable this cache optimization globally using the function: LIEF::dsc::enable_cache or by setting the environment variable DYLDSC_ENABLE_CACHE
to 1.
std::string LIEF::dsc::DyldSharedCache::filename | ( | ) | const |
Filename of the dyld shared file associated with this object.
For instance: dyld_shared_cache_arm64e, dyld_shared_cache_arm64e.62.dyldlinkedit
std::string LIEF::dsc::DyldSharedCache::filepath | ( | ) | const |
Full path to the original dyld shared cache file associated with object (e.g. /home/lief/downloads/visionos/dyld_shared_cache_arm64e.42
)
std::unique_ptr< Dylib > LIEF::dsc::DyldSharedCache::find_lib_from_name | ( | const std::string & | name | ) | const |
Find the Dylib whose filename of Dylib::path matches the provided name.
If multiple libraries have the same name (but with a different path), the first one matching the provided name is returned.
std::unique_ptr< Dylib > LIEF::dsc::DyldSharedCache::find_lib_from_path | ( | const std::string & | path | ) | const |
Find the Dylib whose Dylib::path matches the provided path.
std::unique_ptr< Dylib > LIEF::dsc::DyldSharedCache::find_lib_from_va | ( | uint64_t | va | ) | const |
void LIEF::dsc::DyldSharedCache::flush_cache | ( | ) | const |
Flush internal information into the on-disk cache (see: enable_caching)
|
static |
See the load functions for the details.
Referenced by LIEF::dsc::load().
|
static |
See the load functions for the details.
Referenced by LIEF::dsc::load().
bool LIEF::dsc::DyldSharedCache::has_subcaches | ( | ) | const |
True if the subcaches are associated with this cache.
dylib_iterator LIEF::dsc::DyldSharedCache::libraries | ( | ) | const |
Return an interator over the libraries embedded in this dyld shared cache.
This iterator implements the random access trait. Thus, one can use iterator_range::size, iterator_range::at, iterator_range::operator[] to a access Dylib at an arbitrary index:
uint64_t LIEF::dsc::DyldSharedCache::load_address | ( | ) | const |
Based address of this cache.
mapping_info_iterator LIEF::dsc::DyldSharedCache::mapping_info | ( | ) | const |
Return an interator over the mapping information of this dyld shared cache.
This iterator implements the random access trait. Thus, one can use iterator_range::size, iterator_range::at, iterator_range::operator[] to access a MappingInfo at an arbitrary index:
DYLD_TARGET_PLATFORM LIEF::dsc::DyldSharedCache::platform | ( | ) | const |
Platform targeted by this cache (e.g. vision-os)
subcache_iterator LIEF::dsc::DyldSharedCache::subcaches | ( | ) | const |
Return an interator over the subcaches associated with this (main) dyld shared cache.
This iterator implements the random access trait. Thus, one can use iterator_range::size, iterator_range::at, iterator_range::operator[] to access a SubCache at an arbitrary index:
VERSION LIEF::dsc::DyldSharedCache::version | ( | ) | const |
Version of dyld used by this cache.