Index: src/OFObject.h ================================================================== --- src/OFObject.h +++ src/OFObject.h @@ -104,10 +104,13 @@ # define OF_HAVE_FORWARDING_TARGET_FOR_SELECTOR # if __has_feature(objc_msg_lookup_stret) # define OF_HAVE_FORWARDING_TARGET_FOR_SELECTOR_STRET # endif # endif +# if defined(__ppc__) || defined(__PPC__) +# define OF_HAVE_FORWARDING_TARGET_FOR_SELECTOR +# endif # if (defined(_MIPS_SIM) && _MIPS_SIM == _ABIO32) || \ (defined(__mips_eabi) && _MIPS_SZPTR == 32) # define OF_HAVE_FORWARDING_TARGET_FOR_SELECTOR # endif # endif ADDED src/forwarding-ppc-elf.S Index: src/forwarding-ppc-elf.S ================================================================== --- /dev/null +++ src/forwarding-ppc-elf.S @@ -0,0 +1,116 @@ +/* + * 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: +of_forward_stret: /* FIXME */ + stwu %r1, -112(%r1) + mflr %r0 + stw %r0, 116(%r1) + + /* Save all arguments */ + stw %r3, 4(%r1) + stw %r4, 8(%r1) + stw %r5, 12(%r1) + stw %r6, 16(%r1) + stw %r7, 20(%r1) + stw %r8, 24(%r1) + stw %r9, 28(%r1) + stw %r10, 32(%r1) + + /* Save all floating point arguments */ + stfd %f1, 40(%r1) + stfd %f2, 48(%r1) + stfd %f3, 56(%r1) + stfd %f4, 64(%r1) + stfd %f5, 72(%r1) + stfd %f6, 80(%r1) + stfd %f7, 88(%r1) + stfd %f8, 96(%r1) + + lis %r4, sel_forwardingTargetForSelector_@ha + la %r4, sel_forwardingTargetForSelector_@l(%r4) + bl objc_msg_lookup@plt + mtctr %r3 + + lwz %r3, 4(%r1) + lis %r4, sel_forwardingTargetForSelector_@ha + la %r4, sel_forwardingTargetForSelector_@l(%r4) + lwz %r5, 8(%r1) + bctrl + stw %r3, 4(%r1) + + lwz %r4, 8(%r1) + bl objc_msg_lookup@plt + mtctr %r3 + + /* Restore all arguments */ + lwz %r3, 4(%r1) + lwz %r4, 8(%r1) + lwz %r5, 12(%r1) + lwz %r6, 16(%r1) + lwz %r7, 20(%r1) + lwz %r8, 24(%r1) + lwz %r9, 28(%r1) + lwz %r10, 32(%r1) + + /* Restore all floating point arguments */ + lfd %f1, 40(%r1) + lfd %f2, 48(%r1) + lfd %f3, 56(%r1) + lfd %f4, 64(%r1) + lfd %f5, 72(%r1) + lfd %f6, 80(%r1) + lfd %f7, 88(%r1) + lfd %f8, 96(%r1) + + lwz %r0, 116(%r1) + mtlr %r0 + addi %r1, %r1, 112 + bctr +.type of_forward, %function +.size of_forward, .-of_forward + +init: + lis %r3, module@ha + la %r3, module@l(%r3) + b __objc_exec_class@plt + +.section .ctors, "a", %progbits + .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 + +#ifdef __linux__ +.section .note.GNU-stack, "", %progbits +#endif Index: src/forwarding.S ================================================================== --- src/forwarding.S +++ src/forwarding.S @@ -32,10 +32,12 @@ # include "forwarding-amd64-elf.S" # elif defined(__i386__) # include "forwarding-x86-elf.S" # elif defined(__arm__) || defined(__ARM__) # include "forwarding-arm-elf.S" +# elif defined(__ppc__) || defined(__PPC__) +# include "forwarding-ppc-elf.S" # elif (defined(_MIPS_SIM) && _MIPS_SIM == _ABIO32) || \ (defined(__mips_eabi) && _MIPS_SZPTR == 32) # include "forwarding-mips-elf.S" # endif # endif Index: src/runtime/lookup-asm-amd64-elf.S ================================================================== --- src/runtime/lookup-asm-amd64-elf.S +++ src/runtime/lookup-asm-amd64-elf.S @@ -72,11 +72,11 @@ ret_nil: leaq nil_method(%rip), %rax ret nil_method: - movq %rdi, %rax + xorq %rax, %rax ret #ifdef __linux__ .section .note.GNU-stack, "", %progbits #endif Index: src/runtime/lookup-asm-x86-elf.S ================================================================== --- src/runtime/lookup-asm-x86-elf.S +++ src/runtime/lookup-asm-x86-elf.S @@ -81,11 +81,11 @@ .L0: addl $nil_method-.L0, %eax ret nil_method: - movl 4(%esp), %eax + xorl %eax, %eax ret get_eip: movl (%esp), %eax ret Index: src/runtime/lookup-asm.S ================================================================== --- src/runtime/lookup-asm.S +++ src/runtime/lookup-asm.S @@ -19,14 +19,14 @@ #if defined(__ELF__) # if defined(__amd64__) || defined(__x86_64__) # include "lookup-asm-amd64-elf.S" # elif defined(__i386__) # include "lookup-asm-x86-elf.S" +# elif defined(__arm__) || defined(__ARM__) +# include "lookup-asm-arm-elf.S" # elif defined(__ppc__) || defined(__PPC__) # include "lookup-asm-ppc-elf.S" -# elif defined(__arm__) || defined(__ARM__) -# include "lookup-asm-arm-elf.S" # elif (defined(_MIPS_SIM) && _MIPS_SIM == _ABIO32) || \ (defined(__mips_eabi) && _MIPS_SZPTR == 32) # include "lookup-asm-mips-elf.S" # endif #elif defined(__MACH__)