diff options
Diffstat (limited to 'source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.cpp')
| -rw-r--r-- | source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.cpp | 116 |
1 files changed, 11 insertions, 105 deletions
diff --git a/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.cpp b/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.cpp index ecf44b9c4f73..f360a182e065 100644 --- a/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.cpp +++ b/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.cpp @@ -260,12 +260,7 @@ ABIMacOSX_i386::PrepareTrivialCall (Thread &thread, addr_t sp, addr_t func_addr, addr_t return_addr, - addr_t *arg1_ptr, - addr_t *arg2_ptr, - addr_t *arg3_ptr, - addr_t *arg4_ptr, - addr_t *arg5_ptr, - addr_t *arg6_ptr) const + llvm::ArrayRef<addr_t> args) const { RegisterContext *reg_ctx = thread.GetRegisterContext().get(); if (!reg_ctx) @@ -287,114 +282,25 @@ ABIMacOSX_i386::PrepareTrivialCall (Thread &thread, RegisterValue reg_value; // Write any arguments onto the stack - if (arg1_ptr) - { - sp -= 4; - if (arg2_ptr) - { - sp -= 4; - if (arg3_ptr) - { - sp -= 4; - if (arg4_ptr) - { - sp -= 4; - if (arg5_ptr) - { - sp -= 4; - if (arg6_ptr) - { - sp -= 4; - } - } - } - } - } - } - + sp -= 4 * args.size(); + // Align the SP sp &= ~(16ull-1ull); // 16-byte alignment - if (arg1_ptr) + addr_t arg_pos = sp; + + for (addr_t arg : args) { - reg_value.SetUInt32(*arg1_ptr); - error = reg_ctx->WriteRegisterValueToMemory (reg_info_32, - sp, - reg_info_32->byte_size, + reg_value.SetUInt32(arg); + error = reg_ctx->WriteRegisterValueToMemory (reg_info_32, + arg_pos, + reg_info_32->byte_size, reg_value); if (error.Fail()) return false; - - if (arg2_ptr) - { - reg_value.SetUInt32(*arg2_ptr); - // The register info used to write memory just needs to have the correct - // size of a 32 bit register, the actual register it pertains to is not - // important, just the size needs to be correct. Here we use "eax"... - error = reg_ctx->WriteRegisterValueToMemory (reg_info_32, - sp + 4, - reg_info_32->byte_size, - reg_value); - if (error.Fail()) - return false; - - if (arg3_ptr) - { - reg_value.SetUInt32(*arg3_ptr); - // The register info used to write memory just needs to have the correct - // size of a 32 bit register, the actual register it pertains to is not - // important, just the size needs to be correct. Here we use "eax"... - error = reg_ctx->WriteRegisterValueToMemory (reg_info_32, - sp + 8, - reg_info_32->byte_size, - reg_value); - if (error.Fail()) - return false; - - if (arg4_ptr) - { - reg_value.SetUInt32(*arg4_ptr); - // The register info used to write memory just needs to have the correct - // size of a 32 bit register, the actual register it pertains to is not - // important, just the size needs to be correct. Here we use "eax"... - error = reg_ctx->WriteRegisterValueToMemory (reg_info_32, - sp + 12, - reg_info_32->byte_size, - reg_value); - if (error.Fail()) - return false; - if (arg5_ptr) - { - reg_value.SetUInt32(*arg5_ptr); - // The register info used to write memory just needs to have the correct - // size of a 32 bit register, the actual register it pertains to is not - // important, just the size needs to be correct. Here we use "eax"... - error = reg_ctx->WriteRegisterValueToMemory (reg_info_32, - sp + 16, - reg_info_32->byte_size, - reg_value); - if (error.Fail()) - return false; - if (arg6_ptr) - { - reg_value.SetUInt32(*arg6_ptr); - // The register info used to write memory just needs to have the correct - // size of a 32 bit register, the actual register it pertains to is not - // important, just the size needs to be correct. Here we use "eax"... - error = reg_ctx->WriteRegisterValueToMemory (reg_info_32, - sp + 20, - reg_info_32->byte_size, - reg_value); - if (error.Fail()) - return false; - } - } - } - } - } + arg_pos += 4; } - // The return address is pushed onto the stack (yes after we just set the // alignment above!). sp -= 4; |
