| 9 | static constexpr auto LOG_LVL = LEVEL::INFO; |
| 10 | |
| 11 | int 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 | } |