]> git.saurik.com Git - apple/dyld.git/blame - src/dyldSyscallInterface.h
dyld-851.27.tar.gz
[apple/dyld.git] / src / dyldSyscallInterface.h
CommitLineData
2fd3f4e8
A
1/* -*- mode: C++; c-basic-offset: 4; tab-width: 4 -*-
2 *
3 * Copyright (c) 2004-2013 Apple Inc. All rights reserved.
4 *
5 * @APPLE_LICENSE_HEADER_START@
6 *
7 * This file contains Original Code and/or Modifications of Original Code
8 * as defined in and that are subject to the Apple Public Source License
9 * Version 2.0 (the 'License'). You may not use this file except in
10 * compliance with the License. Please obtain a copy of the License at
11 * http://www.opensource.apple.com/apsl/ and read it before using this
12 * file.
13 *
14 * The Original Code and all software distributed under the License are
15 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
16 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
17 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
19 * Please see the License for the specific language governing rights and
20 * limitations under the License.
21 *
22 * @APPLE_LICENSE_HEADER_END@
23 */
24
25
26#ifndef __DYLD_SYSCALL_HELPERS__
27#define __DYLD_SYSCALL_HELPERS__
28
16b475fc
A
29#include <sys/cdefs.h>
30
19894a12 31#include <dirent.h>
16b475fc
A
32#if __has_include(<libamfi.h>)
33#include <libamfi.h>
34#else
35__BEGIN_DECLS
36extern int amfi_check_dyld_policy_self(uint64_t input_flags, uint64_t* output_flags);
37__END_DECLS
38#endif
39#include <libkern/OSAtomic.h>
40#include <libproc.h>
41#include <mach/mach.h>
42#include <mach/mach_time.h>
df9d6cf7 43#include <mach-o/loader.h>
16b475fc
A
44#include <pthread.h>
45#include <stdlib.h>
46#include <sys/fcntl.h>
47#include <sys/ioctl.h>
48#include <sys/kdebug_private.h>
49#include <sys/mman.h>
50#include <sys/stat.h>
51#include <unistd.h>
52#include <System/sys/reason.h>
53
54#define DYLD_SYSCALL_VTABLE_ENTRY(x) __typeof__ (x) *x
2fd3f4e8
A
55
56#if __cplusplus
57namespace dyld {
58#endif
2fd3f4e8
A
59 //
60 // This file contains the table of function pointers the host dyld supplies
61 // to the iOS simulator dyld.
62 //
63 struct SyscallHelpers
64 {
65 uintptr_t version;
16b475fc
A
66 DYLD_SYSCALL_VTABLE_ENTRY(open);
67 DYLD_SYSCALL_VTABLE_ENTRY(close);
68 DYLD_SYSCALL_VTABLE_ENTRY(pread);
69 DYLD_SYSCALL_VTABLE_ENTRY(write);
70 DYLD_SYSCALL_VTABLE_ENTRY(mmap);
71 DYLD_SYSCALL_VTABLE_ENTRY(munmap);
72 DYLD_SYSCALL_VTABLE_ENTRY(madvise);
73 DYLD_SYSCALL_VTABLE_ENTRY(stat);
74 DYLD_SYSCALL_VTABLE_ENTRY(fcntl);
75 DYLD_SYSCALL_VTABLE_ENTRY(ioctl);
76 DYLD_SYSCALL_VTABLE_ENTRY(issetugid);
77 DYLD_SYSCALL_VTABLE_ENTRY(getcwd);
78 DYLD_SYSCALL_VTABLE_ENTRY(realpath);
79 DYLD_SYSCALL_VTABLE_ENTRY(vm_allocate);
80 DYLD_SYSCALL_VTABLE_ENTRY(vm_deallocate);
81 DYLD_SYSCALL_VTABLE_ENTRY(vm_protect);
2fd3f4e8
A
82 void (*vlog)(const char* format, va_list list);
83 void (*vwarn)(const char* format, va_list list);
16b475fc
A
84 DYLD_SYSCALL_VTABLE_ENTRY(pthread_mutex_lock);
85 DYLD_SYSCALL_VTABLE_ENTRY(pthread_mutex_unlock);
86 DYLD_SYSCALL_VTABLE_ENTRY(mach_thread_self);
87 DYLD_SYSCALL_VTABLE_ENTRY(mach_port_deallocate);
88 DYLD_SYSCALL_VTABLE_ENTRY(task_self_trap);
89 DYLD_SYSCALL_VTABLE_ENTRY(mach_timebase_info);
90#if OSATOMIC_USE_INLINED
2fd3f4e8
A
91 bool (*OSAtomicCompareAndSwapPtrBarrier)(void* old, void* nw, void * volatile *value);
92 void (*OSMemoryBarrier)(void);
16b475fc
A
93#else
94#pragma clang diagnostic push
95#pragma clang diagnostic ignored "-Wdeprecated"
96 DYLD_SYSCALL_VTABLE_ENTRY(OSAtomicCompareAndSwapPtrBarrier);
97 DYLD_SYSCALL_VTABLE_ENTRY(OSMemoryBarrier);
98#pragma clang diagnostic pop
99#endif
2fd3f4e8 100 void* (*getProcessInfo)(void); // returns dyld_all_image_infos*;
6cae9b63 101 int* (*errnoAddress)(void);
16b475fc 102 DYLD_SYSCALL_VTABLE_ENTRY(mach_absolute_time);
19894a12 103 // Added in version 2
16b475fc 104 DYLD_SYSCALL_VTABLE_ENTRY(thread_switch);
19894a12 105 // Added in version 3
16b475fc
A
106 DYLD_SYSCALL_VTABLE_ENTRY(opendir);
107 DYLD_SYSCALL_VTABLE_ENTRY(readdir_r);
108 DYLD_SYSCALL_VTABLE_ENTRY(closedir);
df9d6cf7
A
109 // Added in version 4
110 void (*coresymbolication_load_notifier)(void *connection, uint64_t load_timestamp, const char *image_path, const struct mach_header *mach_header);
111 void (*coresymbolication_unload_notifier)(void *connection, uint64_t unload_timestamp, const char *image_path, const struct mach_header *mach_header);
9f83892a 112 // Added in version 5
16b475fc
A
113 DYLD_SYSCALL_VTABLE_ENTRY(proc_regionfilename);
114 DYLD_SYSCALL_VTABLE_ENTRY(getpid);
115 DYLD_SYSCALL_VTABLE_ENTRY(mach_port_insert_right);
116 DYLD_SYSCALL_VTABLE_ENTRY(mach_port_allocate);
117 DYLD_SYSCALL_VTABLE_ENTRY(mach_msg);
9f83892a 118 // Added in version 6
16b475fc 119 DYLD_SYSCALL_VTABLE_ENTRY(abort_with_payload);
9f83892a 120 // Add in version 7
16b475fc
A
121 DYLD_SYSCALL_VTABLE_ENTRY(task_register_dyld_image_infos);
122 DYLD_SYSCALL_VTABLE_ENTRY(task_unregister_dyld_image_infos);
123 DYLD_SYSCALL_VTABLE_ENTRY(task_get_dyld_image_infos);
124 DYLD_SYSCALL_VTABLE_ENTRY(task_register_dyld_shared_cache_image_info);
125 DYLD_SYSCALL_VTABLE_ENTRY(task_register_dyld_set_dyld_state);
126 DYLD_SYSCALL_VTABLE_ENTRY(task_register_dyld_get_process_state);
127 DYLD_SYSCALL_VTABLE_ENTRY(task_info);
128 DYLD_SYSCALL_VTABLE_ENTRY(thread_info);
129 // Add in version 8
130 DYLD_SYSCALL_VTABLE_ENTRY(kdebug_is_enabled);
131 DYLD_SYSCALL_VTABLE_ENTRY(kdebug_trace);
132 // Add in version 9
133 DYLD_SYSCALL_VTABLE_ENTRY(kdebug_trace_string);
134 // Add in version 10
135 DYLD_SYSCALL_VTABLE_ENTRY(amfi_check_dyld_policy_self);
136 // Add in version 11
137 void (*notifyMonitoringDyldMain)(void);
138 void (*notifyMonitoringDyld)(bool unloading, unsigned imageCount, const struct mach_header* loadAddresses[], const char* imagePaths[]);
139 // Add in version 12
140 DYLD_SYSCALL_VTABLE_ENTRY(mach_msg_destroy);
141 DYLD_SYSCALL_VTABLE_ENTRY(mach_port_construct);
142 DYLD_SYSCALL_VTABLE_ENTRY(mach_port_destruct);
bc3b7c8c
A
143 // Add in version 13
144 DYLD_SYSCALL_VTABLE_ENTRY(fstat);
145 DYLD_SYSCALL_VTABLE_ENTRY(vm_copy);
797cc951
A
146 // Add in version 14
147 DYLD_SYSCALL_VTABLE_ENTRY(task_dyld_process_info_notify_get);
16b475fc 148 };
2fd3f4e8
A
149 extern const struct SyscallHelpers* gSyscallHelpers;
150
151
152#if __cplusplus
153}
154#endif
155
9f83892a 156#endif