MCPcopy Create free account
hub / github.com/lief-project/LIEF / main

Function main

examples/cpp/dyld_shared_cache_reader.cpp:11–34  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

9static constexpr auto LOG_LVL = LEVEL::INFO;
10
11int main(int argc, const char** argv) {
12 if (!LIEF::is_extended()) {
13 log(LEVEL::ERR, "This example requires the extended version of LIEF");
14 return EXIT_FAILURE;
15 }
16
17 if (argc != 2) {
18 log(LEVEL::ERR, "Usage: {} <shared-cache>", argv[0]);
19 return EXIT_FAILURE;
20 }
21
22 set_level(LEVEL::INFO);
23 std::unique_ptr<LIEF::dsc::DyldSharedCache> dyld_cache = LIEF::dsc::load(argv[1]);
24 if (dyld_cache == nullptr) {
25 log(LEVEL::ERR, "Can't read {} as a shared cache file", argv[0]);
26 return EXIT_FAILURE;
27 }
28
29 for (std::unique_ptr<LIEF::dsc::Dylib> lib : dyld_cache->libraries()) {
30 log(LOG_LVL, "{}: {}", std::to_string(lib->address()), lib->path());
31 }
32
33 return EXIT_SUCCESS;
34}

Callers

nothing calls this directly

Calls 8

is_extendedFunction · 0.50
logFunction · 0.50
set_levelFunction · 0.50
loadFunction · 0.50
to_stringFunction · 0.50
librariesMethod · 0.45
addressMethod · 0.45
pathMethod · 0.45

Tested by

no test coverage detected