diff --git a/util/mach/exc_server_variants.cc b/util/mach/exc_server_variants.cc index ff918065..e7174ac7 100644 --- a/util/mach/exc_server_variants.cc +++ b/util/mach/exc_server_variants.cc @@ -30,98 +30,6 @@ #include "util/mach/mach_excServer.h" #include "util/mach/mach_message.h" -extern "C" { - -// These six functions are not used, and are in fact obsoleted by the other -// functionality implemented in this file. The standard MIG-generated exc_server -// (in excServer.c) and mach_exc_server (in mach_excServer.c) server dispatch -// routines usable with the standard mach_msg_server() function call out to -// these functions. exc_server() and mach_exc_server() are unused and are -// replaced by the more flexible ExcServer and MachExcServer, but the linker -// still needs to see these six function definitions. - -kern_return_t catch_exception_raise(exception_handler_t exception_port, - thread_t thread, - task_t task, - exception_type_t exception, - exception_data_t code, - mach_msg_type_number_t code_count) { - NOTREACHED(); - return KERN_FAILURE; -} - -kern_return_t catch_exception_raise_state( - exception_handler_t exception_port, - exception_type_t exception, - exception_data_t code, - mach_msg_type_number_t code_count, - thread_state_flavor_t* flavor, - thread_state_t old_state, - mach_msg_type_number_t old_state_count, - thread_state_t new_state, - mach_msg_type_number_t* new_state_count) { - NOTREACHED(); - return KERN_FAILURE; -} - -kern_return_t catch_exception_raise_state_identity( - exception_handler_t exception_port, - thread_t thread, - task_t task, - exception_type_t exception, - exception_data_t code, - mach_msg_type_number_t code_count, - thread_state_flavor_t* flavor, - thread_state_t old_state, - mach_msg_type_number_t old_state_count, - thread_state_t new_state, - mach_msg_type_number_t* new_state_count) { - NOTREACHED(); - return KERN_FAILURE; -} - -kern_return_t catch_mach_exception_raise(exception_handler_t exception_port, - thread_t thread, - task_t task, - exception_type_t exception, - mach_exception_data_t code, - mach_msg_type_number_t code_count) { - NOTREACHED(); - return KERN_FAILURE; -} - -kern_return_t catch_mach_exception_raise_state( - exception_handler_t exception_port, - exception_type_t exception, - mach_exception_data_t code, - mach_msg_type_number_t code_count, - thread_state_flavor_t* flavor, - thread_state_t old_state, - mach_msg_type_number_t old_state_count, - thread_state_t new_state, - mach_msg_type_number_t* new_state_count) { - NOTREACHED(); - return KERN_FAILURE; -} - -kern_return_t catch_mach_exception_raise_state_identity( - exception_handler_t exception_port, - thread_t thread, - task_t task, - exception_type_t exception, - mach_exception_data_t code, - mach_msg_type_number_t code_count, - thread_state_flavor_t* flavor, - thread_state_t old_state, - mach_msg_type_number_t old_state_count, - thread_state_t new_state, - mach_msg_type_number_t* new_state_count) { - NOTREACHED(); - return KERN_FAILURE; -} - -} // extern "C" - namespace crashpad { namespace { diff --git a/util/mach/mig.py b/util/mach/mig.py index 992f3e1a..9833c8c5 100755 --- a/util/mach/mig.py +++ b/util/mach/mig.py @@ -73,6 +73,18 @@ def FixServerImplementation(implementation): # Rewrite the declarations in this file as “mig_external”. contents = declaration_pattern.sub(r'mig_external \1', contents); + # Crashpad never implements the mach_msg_server() MIG callouts. To avoid + # needing to provide stub implementations, set KERN_FAILURE as the RetCode + # and abort(). + routine_callout_pattern = re.compile( + r'OutP->RetCode = (([a-zA-Z0-9_]+)\(.+\));') + routine_callouts = routine_callout_pattern.findall(contents) + for routine in routine_callouts: + contents = contents.replace(routine[0], 'KERN_FAILURE; abort()') + + # Include the header for abort(). + contents = '#include \n' + contents + file.seek(0) file.truncate() file.write(contents)