LIEF: Library to Instrument Executable Formats Version 0.17.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 , DYLD_1231_3 , 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. | |
using | instructions_iterator = iterator_range<assembly::Instruction::Iterator> |
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. | |
instructions_iterator | disassemble (uint64_t va) const |
Disassemble instructions at the provided virtual address. This function returns an iterator over assembly::Instruction. | |
std::vector< uint8_t > | get_content_from_va (uint64_t va, uint64_t size) const |
Return the content at the specified virtual address. | |
std::unique_ptr< DyldSharedCache > | cache_for_address (uint64_t va) const |
Find the sub-DyldSharedCache that wraps the given virtual address. | |
std::unique_ptr< DyldSharedCache > | main_cache () const |
Return the principal dyld shared cache in the case of multiple subcaches. | |
std::unique_ptr< DyldSharedCache > | find_subcache (const std::string &filename) const |
Try to find the DyldSharedCache associated with the filename given in the first parameter. | |
result< uint64_t > | va_to_offset (uint64_t va) const |
Convert the given virtual address into an offset. | |
FileStream & | stream () const |
Return the stream associated with this dyld shared cache. | |
FileStream & | stream () |
Return the stream associated with this 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.
using LIEF::dsc::DyldSharedCache::instructions_iterator = iterator_range<assembly::Instruction::Iterator> |
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) |
DYLD_1231_3 | dyld-1231.3 (2024-09-24) |
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
)
std::unique_ptr< DyldSharedCache > LIEF::dsc::DyldSharedCache::cache_for_address | ( | uint64_t | va | ) | const |
Find the sub-DyldSharedCache that wraps the given virtual address.
instructions_iterator LIEF::dsc::DyldSharedCache::disassemble | ( | uint64_t | va | ) | const |
Disassemble instructions at the provided virtual address. This function returns an iterator over assembly::Instruction.
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 |
std::unique_ptr< DyldSharedCache > LIEF::dsc::DyldSharedCache::find_subcache | ( | const std::string & | filename | ) | const |
Try to find the DyldSharedCache associated with the filename given in the first parameter.
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().
std::vector< uint8_t > LIEF::dsc::DyldSharedCache::get_content_from_va | ( | uint64_t | va, |
uint64_t | size ) const |
Return the content at the specified virtual address.
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.
std::unique_ptr< DyldSharedCache > LIEF::dsc::DyldSharedCache::main_cache | ( | ) | const |
Return the principal dyld shared cache in the case of multiple subcaches.
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)
FileStream & LIEF::dsc::DyldSharedCache::stream | ( | ) |
Return the stream associated with this dyld shared cache.
FileStream & LIEF::dsc::DyldSharedCache::stream | ( | ) | const |
Return the stream associated with this dyld shared cache.
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:
result< uint64_t > LIEF::dsc::DyldSharedCache::va_to_offset | ( | uint64_t | va | ) | const |
Convert the given virtual address into an offset.
VERSION LIEF::dsc::DyldSharedCache::version | ( | ) | const |
Version of dyld used by this cache.