#include <stdio.h>
#include <dlfcn.h>
#include <stdlib.h>
#include <pthread.h>
#include <mach-o/dyld_priv.h>
#include "test_support.h"
static void* work(void* mh)
{
_dyld_is_memory_immutable(mh, 16);
return NULL;
}
static void notify(const struct mach_header* mh, intptr_t vmaddr_slide)
{
if ( mh->flags & 0x80000000 )
return;
pthread_t workerThread;
if ( pthread_create(&workerThread, NULL, &work, (void*)mh) != 0 ) {
FAIL("pthread_create");
}
void* dummy;
pthread_join(workerThread, &dummy);
}
int main(int argc, const char* argv[], const char* envp[], const char* apple[]) {
_dyld_register_func_for_add_image(¬ify);
void* h = dlopen(RUN_DIR "/lock.bundle", 0);
if ( h == NULL ) {
FAIL("lock.bundle not loaded, dlopen(lock.bundle) failed with error: %s", dlerror());
}
PASS("Success");
}