Index: src/OFObject.h ================================================================== --- src/OFObject.h +++ src/OFObject.h @@ -109,11 +109,11 @@ defined(__ppc__) # define OF_HAVE_FORWARDING_TARGET_FOR_SELECTOR # define OF_HAVE_FORWARDING_TARGET_FOR_SELECTOR_STRET # endif #else -# ifdef __ELF__ +# if defined(__ELF__) # if defined(__amd64__) || defined(__x86_64__) || defined(__i386__) || \ defined(__arm__) || defined(__ARM__) || defined(__ppc__) || defined(__PPC__) # define OF_HAVE_FORWARDING_TARGET_FOR_SELECTOR # if __OBJFW_RUNTIME_ABI__ >= 800 # define OF_HAVE_FORWARDING_TARGET_FOR_SELECTOR_STRET @@ -124,10 +124,15 @@ # define OF_HAVE_FORWARDING_TARGET_FOR_SELECTOR # if __OBJFW_RUNTIME_ABI__ >= 800 # define OF_HAVE_FORWARDING_TARGET_FOR_SELECTOR_STRET # endif # endif +# elif defined(_WIN32) && defined(__i386__) +# define OF_HAVE_FORWARDING_TARGET_FOR_SELECTOR +# if __OBJFW_RUNTIME_ABI__ >= 800 +# define OF_HAVE_FORWARDING_TARGET_FOR_SELECTOR_STRET +# endif # endif #endif #if __has_feature(objc_arc) # define OF_RETURNS_RETAINED __attribute__((ns_returns_retained)) ADDED src/forwarding/forwarding-x86-win32.S Index: src/forwarding/forwarding-x86-win32.S ================================================================== --- src/forwarding/forwarding-x86-win32.S +++ src/forwarding/forwarding-x86-win32.S @@ -0,0 +1,135 @@ +/* + * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013 + * Jonathan Schleifer + * + * All rights reserved. + * + * This file is part of ObjFW. It may be distributed under the terms of the + * Q Public License 1.0, which can be found in the file LICENSE.QPL included in + * the packaging of this file. + * + * Alternatively, it may be distributed under the terms of the GNU General + * Public License, either version 2 or 3, which can be found in the file + * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this + * file. + */ + +.globl _of_forward +.globl _of_forward_stret + +.section .text +_of_forward: + pushl %ebp + movl %esp, %ebp + + pushl %ebx + subl $20, %esp + + call get_eip +.L0: + movl 8(%ebp), %eax + movl %eax, (%esp) + leal sel_forwardingTargetForSelector_-.L0(%ebx), %eax + movl %eax, 4(%esp) + leal _objc_msg_lookup-.L0(%ebx), %eax + call *%eax + + movl 8(%ebp), %edx + movl %edx, (%esp) + leal sel_forwardingTargetForSelector_-.L0(%ebx), %edx + movl %edx, 4(%esp) + movl 12(%ebp), %edx + movl %edx, 8(%esp) + call *%eax + + movl %eax, 8(%ebp) + movl %eax, (%esp) + movl 12(%ebp), %eax + movl %eax, 4(%esp) + leal _objc_msg_lookup-.L0(%ebx), %eax + call *%eax + + addl $20, %esp + popl %ebx + popl %ebp + + jmp *%eax + +_of_forward_stret: + pushl %ebp + movl %esp, %ebp + + pushl %ebx + subl $20, %esp + + call get_eip +.L1: + movl 12(%ebp), %eax + movl %eax, (%esp) + leal sel_forwardingTargetForSelector_-.L1(%ebx), %eax + movl %eax, 4(%esp) + leal _objc_msg_lookup-.L1(%ebx), %eax + call *%eax + + movl 12(%ebp), %edx + movl %edx, (%esp) + leal sel_forwardingTargetForSelector_-.L1(%ebx), %edx + movl %edx, 4(%esp) + movl 16(%ebp), %edx + movl %edx, 8(%esp) + call *%eax + + movl %eax, 12(%ebp) + movl %eax, (%esp) + movl 16(%ebp), %eax + movl %eax, 4(%esp) + leal _objc_msg_lookup_stret-.L1(%ebx), %eax + call *%eax + + addl $20, %esp + popl %ebx + popl %ebp + + jmp *%eax + +init: + pushl %ebp + movl %esp, %ebp + + pushl %ebx + subl $4, %esp + + call get_eip +.L2: + leal module-.L2(%ebx), %eax + movl %eax, (%esp) + leal ___objc_exec_class-.L2(%ebx), %eax + call *%eax + + addl $4, %esp + popl %ebx + popl %ebp + ret + +get_eip: + movl (%esp), %ebx + ret + +.section .ctors, "a" + .long init + +.section .rodata +str_forwardingTargetForSelector_: + .asciz "forwardingTargetForSelector:" + +.section .data +sel_forwardingTargetForSelector_: + .long str_forwardingTargetForSelector_, 0 + .long 0, 0 +symtab: + .long 0, sel_forwardingTargetForSelector_ + .short 0, 0 + .long 0 + .long 0 +module: + .long 8, 16, 0, symtab Index: src/forwarding/forwarding.S ================================================================== --- src/forwarding/forwarding.S +++ src/forwarding/forwarding.S @@ -25,11 +25,11 @@ # include "apple-forwarding-arm.S" # elif defined(__ppc__) # include "apple-forwarding-ppc.S" # endif #else -# ifdef __ELF__ +# if defined(__ELF__) # if defined(__amd64__) || defined(__x86_64__) # include "forwarding-amd64-elf.S" # elif defined(__i386__) # include "forwarding-x86-elf.S" # elif defined(__arm__) || defined(__ARM__) @@ -38,7 +38,9 @@ # include "forwarding-ppc-elf.S" # elif (defined(_MIPS_SIM) && _MIPS_SIM == _ABIO32) || \ (defined(__mips_eabi) && _MIPS_SZPTR == 32) # include "forwarding-mips-elf.S" # endif +# elif defined(_WIN32) && defined(__i386__) +# include "forwarding-x86-win32.S" # endif #endif