aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcomex2015-10-27 21:14:05 -0400
committercomex2015-10-27 21:14:05 -0400
commitb0a1b9863a7092b1d191d1523798ba78d5df3e4a (patch)
treed89974b2295bd9d35f7393599b5b938a0175e381
parentavoid overflowing Version into debian_revision (diff)
downloadsubstitute-b0a1b9863a7092b1d191d1523798ba78d5df3e4a.tar.gz
lol, mach awk fail
-rwxr-xr-xconfigure7
-rw-r--r--generated/manual-mach.inc.h337
-rwxr-xr-xscript/gen-manual-mach.sh20
-rw-r--r--script/mconfig.py5
4 files changed, 322 insertions, 47 deletions
diff --git a/configure b/configure
index 5522ac4..386e932 100755
--- a/configure
+++ b/configure
@@ -17,9 +17,11 @@ settings.add_setting_option('enable_ios_bootstrap', '--enable-ios-bootstrap', 'd
lambda: settings.host_machine().is_ios(),
bool=True)
settings.add_setting_option('enable_werror', '--enable-werror', '', False, bool=True)
+settings.add_setting_option('install_name', '--install-name', 'LC_ID_DYLIB',
+ lambda: ['/usr/local/lib/libsubstitute.0.dylib', '/usr/lib/libsubstitute.0.dylib'][settings.host_machine().is_ios()])
ldid_tool = mconfig.CLITool('ldid', ['ldid'], 'LDID', settings.host_machine(), settings.host_machine().toolchains())
-ldid_tool.optional()
+ldid_tool.optional_nocheck()
asm_archs = [
('x86_64', []),
@@ -87,7 +89,6 @@ def cb(fn):
if fn.endswith('/objc.c'):
return settings.specialize(obj_ldflag_sets=[('-lobjc',)])
return settings
-
# Note: the order of darwin-inject-asm.o is significant. Per man page, ld is
# guaranteed to link objects in order, which is necessary because
# darwin-inject-asm.S does not itself ensure there is at least 0x4000 bytes of
@@ -100,7 +101,7 @@ def cb(fn):
mconfig.build_and_link_c_objs(
emitter,
settings.host_machine(),
- settings.specialize(override_ldflags=['-install_name', '/usr/lib/libsubstitute.0.dylib'] + settings.host.ldflags),
+ settings.specialize(override_ldflags=['-install_name', settings.install_name] + settings.host.ldflags),
'dylib',
'(out)/libsubstitute.dylib',
[
diff --git a/generated/manual-mach.inc.h b/generated/manual-mach.inc.h
index c48e545..616acde 100644
--- a/generated/manual-mach.inc.h
+++ b/generated/manual-mach.inc.h
@@ -1,10 +1,5 @@
-/*
- * IDENTIFICATION:
- * stub generated Tue Feb 24 20:19:24 2015
- * with a MiG generated by bootstrap_cmds-91
- * OPTIONS:
- */
-#define __MIG_check__Reply__thread_act_subsystem__ 1
+
+/* Module thread_act */
#include <string.h>
#include <mach/ndr.h>
@@ -22,6 +17,7 @@
#if defined(__has_include)
#if __has_include(<mach/mig_voucher_support.h>)
#ifndef USING_VOUCHERS
+#define USING_VOUCHERS
#endif
#ifndef __VOUCHER_FORWARD_TYPE_DECLS__
#define __VOUCHER_FORWARD_TYPE_DECLS__
@@ -40,19 +36,82 @@ extern "C" {
/* END VOUCHER CODE */
+#ifdef AUTOTEST
+#ifndef FUNCTION_PTR_T
+#define FUNCTION_PTR_T
+typedef void (*function_ptr_t)(mach_port_t, char *, mach_msg_type_number_t);
+typedef struct {
+ char *name;
+ function_ptr_t function;
+} function_table_entry;
+typedef function_table_entry *function_table_t;
+#endif /* FUNCTION_PTR_T */
+#endif /* AUTOTEST */
+
+#ifndef thread_act_MSG_COUNT
+#define thread_act_MSG_COUNT 28
+#endif /* thread_act_MSG_COUNT */
+
+#include <mach/std_types.h>
+#include <mach/mig.h>
+#include <mach/mig.h>
+#include <mach/mach_types.h>
+
+#ifdef __BeforeMigUserHeader
+__BeforeMigUserHeader
+#endif /* __BeforeMigUserHeader */
+
+#include <sys/cdefs.h>
+__BEGIN_DECLS
+
+
+/* Routine thread_get_state */
+#ifdef static
+static
+#else
+extern
+#endif /* static */
+kern_return_t manual_thread_get_state
+(
+ thread_act_t target_act,
+ thread_state_flavor_t flavor,
+ thread_state_t old_state,
+ mach_msg_type_number_t *old_stateCnt
+, mach_port_t reply_port);
+
+/* Routine thread_set_state */
+#ifdef static
+static
+#else
+extern
+#endif /* static */
+kern_return_t manual_thread_set_state
+(
+ thread_act_t target_act,
+ thread_state_flavor_t flavor,
+ thread_state_t new_state,
+ mach_msg_type_number_t new_stateCnt
+, mach_port_t reply_port);
+
+
+/*
+ * IDENTIFICATION:
+ * stub generated Tue Oct 27 21:13:20 2015
+ * with a MiG generated by bootstrap_cmds-93
+ * OPTIONS:
+ */
+#define __MIG_check__Reply__thread_act_subsystem__ 1
+
#ifndef mig_internal
#define mig_internal static __inline__
#endif /* mig_internal */
-#ifndef mig_external
-#define mig_external
-#endif /* mig_external */
+#ifndef static
+#define static
+#endif /* static */
-#if !defined(__MigTypeCheck) && defined(TypeCheck)
-#define __MigTypeCheck TypeCheck /* Legacy setting */
-#endif /* !defined(__MigTypeCheck) */
#if !defined(__MigKernelSpecificCode) && defined(_MIG_KERNEL_SPECIFIC_CODE_)
#define __MigKernelSpecificCode _MIG_KERNEL_SPECIFIC_CODE_ /* Legacy setting */
@@ -137,8 +196,43 @@ extern "C" {
+#if !defined(__MIG_check__Reply__thread_get_state_t_manual__defined)
+#define __MIG_check__Reply__thread_get_state_t_manual__defined
+mig_internal kern_return_t __MIG_check__Reply__thread_get_state_t(__Reply__thread_get_state_t *Out0P)
+{
+ typedef __Reply__thread_get_state_t __Reply __attribute__((unused));
+ unsigned int msgh_size;
+
+ if (Out0P->Head.msgh_id != 3703) {
+ if (Out0P->Head.msgh_id == MACH_NOTIFY_SEND_ONCE)
+ { return MIG_SERVER_DIED; }
+ else
+ { return MIG_REPLY_MISMATCH; }
+ }
+
+ msgh_size = Out0P->Head.msgh_size;
+
+ if ((Out0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX) ||
+ ((msgh_size > (mach_msg_size_t)sizeof(__Reply) || msgh_size < (mach_msg_size_t)(sizeof(__Reply) - 896)) &&
+ (msgh_size != (mach_msg_size_t)sizeof(mig_reply_error_t) ||
+ Out0P->RetCode == KERN_SUCCESS)))
+ { return MIG_TYPE_ERROR ; }
+
+ if (Out0P->RetCode != KERN_SUCCESS) {
+ return ((mig_reply_error_t *)Out0P)->RetCode;
+ }
+
+ if ( Out0P->old_stateCnt > 224 )
+ return MIG_TYPE_ERROR;
+ if (((msgh_size - (mach_msg_size_t)(sizeof(__Reply) - 896)) / 4< Out0P->old_stateCnt) ||
+ (msgh_size != (mach_msg_size_t)(sizeof(__Reply) - 896) + Out0P->old_stateCnt * 4))
+ { return MIG_TYPE_ERROR ; }
+
+ return MACH_MSG_SUCCESS;
+}
+#endif /* !defined(__MIG_check__Reply__thread_get_state_t_manual__defined) */
/* Routine thread_get_state */
static kern_return_t manual_thread_get_state
(
@@ -157,7 +251,7 @@ static kern_return_t manual_thread_get_state
NDR_record_t NDR;
thread_state_flavor_t flavor;
mach_msg_type_number_t old_stateCnt;
- } Request;
+ } Request __attribute__((unused));
#ifdef __MigPackStructs
#pragma pack()
#endif
@@ -172,7 +266,7 @@ static kern_return_t manual_thread_get_state
mach_msg_type_number_t old_stateCnt;
natural_t old_state[224];
mach_msg_trailer_t trailer;
- } Reply;
+ } Reply __attribute__((unused));
#ifdef __MigPackStructs
#pragma pack()
#endif
@@ -186,7 +280,7 @@ static kern_return_t manual_thread_get_state
kern_return_t RetCode;
mach_msg_type_number_t old_stateCnt;
natural_t old_state[224];
- } __Reply;
+ } __Reply __attribute__((unused));
#ifdef __MigPackStructs
#pragma pack()
#endif
@@ -208,9 +302,9 @@ static kern_return_t manual_thread_get_state
mach_msg_return_t msg_result;
-#ifdef __MIG_check__Reply__thread_get_state_t__defined
+#ifdef __MIG_check__Reply__thread_get_state_t_manual__defined
kern_return_t check_result;
-#endif /* __MIG_check__Reply__thread_get_state_t__defined */
+#endif /* __MIG_check__Reply__thread_get_state_t_manual__defined */
__DeclareSendRpc(3603, "thread_get_state")
@@ -249,11 +343,11 @@ static kern_return_t manual_thread_get_state
}
-#if defined(__MIG_check__Reply__thread_get_state_t__defined)
+#if defined(__MIG_check__Reply__thread_get_state_t_manual__defined)
check_result = __MIG_check__Reply__thread_get_state_t((__Reply__thread_get_state_t *)Out0P);
if (check_result != MACH_MSG_SUCCESS)
{ return check_result; }
-#endif /* defined(__MIG_check__Reply__thread_get_state_t__defined) */
+#endif /* defined(__MIG_check__Reply__thread_get_state_t_manual__defined) */
if (Out0P->old_stateCnt > *old_stateCnt) {
(void)manual_memcpy((char *) old_state, (const char *) Out0P->old_state, 4 * *old_stateCnt);
@@ -267,8 +361,29 @@ static kern_return_t manual_thread_get_state
return KERN_SUCCESS;
}
+#if !defined(__MIG_check__Reply__thread_set_state_t_manual__defined)
+#define __MIG_check__Reply__thread_set_state_t_manual__defined
+mig_internal kern_return_t __MIG_check__Reply__thread_set_state_t(__Reply__thread_set_state_t *Out0P)
+{
+
+ typedef __Reply__thread_set_state_t __Reply __attribute__((unused));
+ if (Out0P->Head.msgh_id != 3704) {
+ if (Out0P->Head.msgh_id == MACH_NOTIFY_SEND_ONCE)
+ { return MIG_SERVER_DIED; }
+ else
+ { return MIG_REPLY_MISMATCH; }
+ }
+ if ((Out0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX) ||
+ (Out0P->Head.msgh_size != (mach_msg_size_t)sizeof(__Reply)))
+ { return MIG_TYPE_ERROR ; }
+
+ {
+ return Out0P->RetCode;
+ }
+}
+#endif /* !defined(__MIG_check__Reply__thread_set_state_t_manual__defined) */
/* Routine thread_set_state */
static kern_return_t manual_thread_set_state
(
@@ -288,7 +403,7 @@ static kern_return_t manual_thread_set_state
thread_state_flavor_t flavor;
mach_msg_type_number_t new_stateCnt;
natural_t new_state[224];
- } Request;
+ } Request __attribute__((unused));
#ifdef __MigPackStructs
#pragma pack()
#endif
@@ -301,7 +416,7 @@ static kern_return_t manual_thread_set_state
NDR_record_t NDR;
kern_return_t RetCode;
mach_msg_trailer_t trailer;
- } Reply;
+ } Reply __attribute__((unused));
#ifdef __MigPackStructs
#pragma pack()
#endif
@@ -313,7 +428,7 @@ static kern_return_t manual_thread_set_state
mach_msg_header_t Head;
NDR_record_t NDR;
kern_return_t RetCode;
- } __Reply;
+ } __Reply __attribute__((unused));
#ifdef __MigPackStructs
#pragma pack()
#endif
@@ -336,9 +451,9 @@ static kern_return_t manual_thread_set_state
mach_msg_return_t msg_result;
unsigned int msgh_size;
-#ifdef __MIG_check__Reply__thread_set_state_t__defined
+#ifdef __MIG_check__Reply__thread_set_state_t_manual__defined
kern_return_t check_result;
-#endif /* __MIG_check__Reply__thread_set_state_t__defined */
+#endif /* __MIG_check__Reply__thread_set_state_t_manual__defined */
__DeclareSendRpc(3604, "thread_set_state")
@@ -380,17 +495,169 @@ static kern_return_t manual_thread_set_state
}
-#if defined(__MIG_check__Reply__thread_set_state_t__defined)
+#if defined(__MIG_check__Reply__thread_set_state_t_manual__defined)
check_result = __MIG_check__Reply__thread_set_state_t((__Reply__thread_set_state_t *)Out0P);
if (check_result != MACH_MSG_SUCCESS)
{ return check_result; }
-#endif /* defined(__MIG_check__Reply__thread_set_state_t__defined) */
+#endif /* defined(__MIG_check__Reply__thread_set_state_t_manual__defined) */
return KERN_SUCCESS;
}
+/* Routine mach_vm_remap */
+#ifdef static
+static
+#else
+extern
+#endif /* static */
+kern_return_t manual_mach_vm_remap
+(
+ vm_map_t target_task,
+ mach_vm_address_t *target_address,
+ mach_vm_size_t size,
+ mach_vm_offset_t mask,
+ int flags,
+ vm_map_t src_task,
+ mach_vm_address_t src_address,
+ boolean_t copy,
+ vm_prot_t *cur_protection,
+ vm_prot_t *max_protection,
+ vm_inherit_t inheritance
+, mach_port_t reply_port);
+/*
+ * IDENTIFICATION:
+ * stub generated Tue Oct 27 21:13:20 2015
+ * with a MiG generated by bootstrap_cmds-93
+ * OPTIONS:
+ */
+#define __MIG_check__Reply__mach_vm_subsystem__ 1
+
+
+
+#ifndef mig_internal
+#define mig_internal static __inline__
+#endif /* mig_internal */
+
+#ifndef static
+#define static
+#endif /* static */
+
+
+#if !defined(__MigKernelSpecificCode) && defined(_MIG_KERNEL_SPECIFIC_CODE_)
+#define __MigKernelSpecificCode _MIG_KERNEL_SPECIFIC_CODE_ /* Legacy setting */
+#endif /* !defined(__MigKernelSpecificCode) */
+
+#ifndef LimitCheck
+#define LimitCheck 0
+#endif /* LimitCheck */
+
+#ifndef min
+#define min(a,b) ( ((a) < (b))? (a): (b) )
+#endif /* min */
+
+#if !defined(_WALIGN_)
+#define _WALIGN_(x) (((x) + 3) & ~3)
+#endif /* !defined(_WALIGN_) */
+
+#if !defined(_WALIGNSZ_)
+#define _WALIGNSZ_(x) _WALIGN_(sizeof(x))
+#endif /* !defined(_WALIGNSZ_) */
+
+#ifndef UseStaticTemplates
+#define UseStaticTemplates 0
+#endif /* UseStaticTemplates */
+
+#ifndef __MachMsgErrorWithTimeout
+#define __MachMsgErrorWithTimeout(_R_) { \
+ switch (_R_) { \
+ case MACH_SEND_INVALID_DATA: \
+ case MACH_SEND_INVALID_DEST: \
+ case MACH_SEND_INVALID_HEADER: \
+ mig_put_reply_port(InP->Head.msgh_reply_port); \
+ break; \
+ case MACH_SEND_TIMED_OUT: \
+ case MACH_RCV_TIMED_OUT: \
+ default: \
+ mig_dealloc_reply_port(InP->Head.msgh_reply_port); \
+ } \
+}
+#endif /* __MachMsgErrorWithTimeout */
+
+#ifndef __MachMsgErrorWithoutTimeout
+#define __MachMsgErrorWithoutTimeout(_R_) { \
+ switch (_R_) { \
+ case MACH_SEND_INVALID_DATA: \
+ case MACH_SEND_INVALID_DEST: \
+ case MACH_SEND_INVALID_HEADER: \
+ mig_put_reply_port(InP->Head.msgh_reply_port); \
+ break; \
+ default: \
+ mig_dealloc_reply_port(InP->Head.msgh_reply_port); \
+ } \
+}
+#endif /* __MachMsgErrorWithoutTimeout */
+
+#ifndef __DeclareSendRpc
+#define __DeclareSendRpc(_NUM_, _NAME_)
+#endif /* __DeclareSendRpc */
+
+#ifndef __BeforeSendRpc
+#define __BeforeSendRpc(_NUM_, _NAME_)
+#endif /* __BeforeSendRpc */
+
+#ifndef __AfterSendRpc
+#define __AfterSendRpc(_NUM_, _NAME_)
+#endif /* __AfterSendRpc */
+
+#ifndef __DeclareSendSimple
+#define __DeclareSendSimple(_NUM_, _NAME_)
+#endif /* __DeclareSendSimple */
+
+#ifndef __BeforeSendSimple
+#define __BeforeSendSimple(_NUM_, _NAME_)
+#endif /* __BeforeSendSimple */
+
+#ifndef __AfterSendSimple
+#define __AfterSendSimple(_NUM_, _NAME_)
+#endif /* __AfterSendSimple */
+
+#define msgh_request_port msgh_remote_port
+#define msgh_reply_port msgh_local_port
+
+
+
+#if !defined(__MIG_check__Reply__mach_vm_remap_t_manual__defined)
+#define __MIG_check__Reply__mach_vm_remap_t_manual__defined
+
+mig_internal kern_return_t __MIG_check__Reply__mach_vm_remap_t(__Reply___kernelrpc_mach_vm_remap_t *Out0P)
+{
+
+ typedef __Reply__mach_vm_remap_t __Reply __attribute__((unused));
+ unsigned int msgh_size;
+ if (Out0P->Head.msgh_id != 4913) {
+ if (Out0P->Head.msgh_id == MACH_NOTIFY_SEND_ONCE)
+ { return MIG_SERVER_DIED; }
+ else
+ { return MIG_REPLY_MISMATCH; }
+ }
+
+ msgh_size = Out0P->Head.msgh_size;
+
+ if ((Out0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX) ||
+ ((msgh_size != (mach_msg_size_t)sizeof(__Reply)) &&
+ (msgh_size != (mach_msg_size_t)sizeof(mig_reply_error_t) ||
+ Out0P->RetCode == KERN_SUCCESS)))
+ { return MIG_TYPE_ERROR ; }
+
+ if (Out0P->RetCode != KERN_SUCCESS) {
+ return ((mig_reply_error_t *)Out0P)->RetCode;
+ }
+
+ return MACH_MSG_SUCCESS;
+}
+#endif /* !defined(__MIG_check__Reply__mach_vm_remap_t_manual__defined) */
/* Routine mach_vm_remap */
static kern_return_t manual_mach_vm_remap
(
@@ -425,7 +692,7 @@ static kern_return_t manual_mach_vm_remap
mach_vm_address_t src_address;
boolean_t copy;
vm_inherit_t inheritance;
- } Request;
+ } Request __attribute__((unused));
#ifdef __MigPackStructs
#pragma pack()
#endif
@@ -441,7 +708,7 @@ static kern_return_t manual_mach_vm_remap
vm_prot_t cur_protection;
vm_prot_t max_protection;
mach_msg_trailer_t trailer;
- } Reply;
+ } Reply __attribute__((unused));
#ifdef __MigPackStructs
#pragma pack()
#endif
@@ -456,7 +723,7 @@ static kern_return_t manual_mach_vm_remap
mach_vm_address_t target_address;
vm_prot_t cur_protection;
vm_prot_t max_protection;
- } __Reply;
+ } __Reply __attribute__((unused));
#ifdef __MigPackStructs
#pragma pack()
#endif
@@ -478,9 +745,9 @@ static kern_return_t manual_mach_vm_remap
mach_msg_return_t msg_result;
-#ifdef __MIG_check__Reply__mach_vm_remap_t__defined
+#ifdef __MIG_check__Reply__mach_vm_remap_t_manual__defined
kern_return_t check_result;
-#endif /* __MIG_check__Reply__mach_vm_remap_t__defined */
+#endif /* __MIG_check__Reply__mach_vm_remap_t_manual__defined */
__DeclareSendRpc(4813, "mach_vm_remap")
@@ -546,11 +813,11 @@ static kern_return_t manual_mach_vm_remap
}
-#if defined(__MIG_check__Reply__mach_vm_remap_t__defined)
+#if defined(__MIG_check__Reply__mach_vm_remap_t_manual__defined)
check_result = __MIG_check__Reply__mach_vm_remap_t((__Reply___kernelrpc_mach_vm_remap_t *)Out0P);
if (check_result != MACH_MSG_SUCCESS)
{ return check_result; }
-#endif /* defined(__MIG_check__Reply__mach_vm_remap_t__defined) */
+#endif /* defined(__MIG_check__Reply__mach_vm_remap_t_manual__defined) */
*target_address = Out0P->target_address;
@@ -561,5 +828,3 @@ static kern_return_t manual_mach_vm_remap
return KERN_SUCCESS;
}
-
-
diff --git a/script/gen-manual-mach.sh b/script/gen-manual-mach.sh
index b740af9..e973bce 100755
--- a/script/gen-manual-mach.sh
+++ b/script/gen-manual-mach.sh
@@ -1,13 +1,19 @@
#!/bin/bash
out=generated/manual-mach.inc.h
-(mig -user /dev/stdout -server /dev/null -header /dev/null /usr/include/mach/{thread_act,mach_vm}.defs |
- unifdef -U__MigTypeCheck |
- grep -v '#define USING_VOUCHERS' |
+(mig -user /dev/stdout -server /dev/null -header /dev/stdout /usr/include/mach/{thread_act,mach_vm}.defs |
+ egrep -v '^(#ifndef|#define|#endif).*_user_' |
+ egrep -v '#include "stdout"' |
+ unifdef -D__MigTypeCheck |
sed -E 's/(mach_msg|memcpy)\(/manual_\1(/g;
s/^\)/, mach_port_t reply_port)/;
- s/mig_external kern_return_t /static kern_return_t manual_/;
s/_kernelrpc_//;
+ s/^([a-z].*)?kern_return_t[[:blank:]]+([a-z])/\1kern_return_t manual_\2/;
+ s/mig_external/static/;
+ s/__defined/_manual__defined/g;
s/mig_get_reply_port\(\)/reply_port/g' |
- awk 'BEGIN { on = 1 }
- /^\/\* Routine / { on = /thread_[gs]et_state|vm_remap/; }
- on { print }' > $out) || rm -f $out
+ awk 'BEGIN { on = 1; }
+ /^\/\* Routine / ||
+ (/__MIG_check__Reply__/ && /^#[ie]/) { on = /thread_[gs]et_state|vm_remap/; }
+ on { print; }
+ /#endif.*__AfterMigUserHeader/ { on = 1; }
+ ' > $out) || rm -f $out
diff --git a/script/mconfig.py b/script/mconfig.py
index d025545..5b7aa74 100644
--- a/script/mconfig.py
+++ b/script/mconfig.py
@@ -548,8 +548,11 @@ class CLITool(object):
def __repr__(self):
return 'CLITool(name=%r, defaults=%r, env=%r)' % (self.name, self.defaults, self.env)
- def optional(self):
+ def optional_nocheck(self):
self.argv_opt.need()
+
+ def optional(self):
+ self.optional_nocheck()
def f():
try:
self.argv()