#ifndef __DYLD_LOADING_H__
#define __DYLD_LOADING_H__
#include <string.h>
#include <stdint.h>
#include <mach/mach.h>
#include <_simple.h>
#include "LaunchCache.h"
#include "LaunchCacheFormat.h"
#include "MachOParser.h"
#include "ClosureBuffer.h"
namespace dyld3 {
ClosureBuffer closured_CreateImageGroup(const ClosureBuffer& input);
namespace loader {
struct ImageInfo
{
const launch_cache::binary_format::Image* imageData;
const mach_header* loadAddress;
uint32_t groupNum;
uint32_t indexInGroup;
bool previouslyFixedUp;
bool justMapped;
bool justUsedFromDyldCache;
bool neverUnload;
};
#if DYLD_IN_PROCESS
typedef bool (*LogFunc)(const char*, ...) __attribute__((format(printf, 1, 2)));
void mapAndFixupImages(Diagnostics& diag, launch_cache::DynArray<ImageInfo>& images, const uint8_t* cacheLoadAddress,
LogFunc log_loads, LogFunc log_segments, LogFunc log_fixups, LogFunc log_dofs) VIS_HIDDEN;
void unmapImage(const launch_cache::binary_format::Image* image, const mach_header* loadAddress) VIS_HIDDEN;
#if BUILDING_DYLD
bool bootArgsContains(const char* arg) VIS_HIDDEN;
bool internalInstall();
void forEachLineInFile(const char* path, void (^lineHandler)(const char* line, bool& stop));
#endif
#endif
} }
#endif // __DYLD_LOADING_H__