Index: src/platform.h ================================================================== --- src/platform.h +++ src/platform.h @@ -53,10 +53,12 @@ # define OF_MIPS # define OF_MIPS_O32 #elif defined(__mips_eabi) && _MIPS_SZPTR == 32 # define OF_MIPS # define OF_MIPS_EABI +#elif defined(__sparc64__) || (defined(__sparc__) && defined(__arch64__)) +# define OF_SPARC64 #elif defined(__sparc__) && !defined(__arch64__) # define OF_SPARC #endif #if defined(__APPLE__) Index: src/runtime/lookup-asm/lookup-asm-sparc-elf.S ================================================================== --- src/runtime/lookup-asm/lookup-asm-sparc-elf.S +++ src/runtime/lookup-asm/lookup-asm-sparc-elf.S @@ -80,11 +80,11 @@ generate_lookup objc_msg_lookup_stret objc_method_not_found_stret generate_lookup_super objc_msg_lookup_super objc_msg_lookup generate_lookup_super objc_msg_lookup_super_stret objc_msg_lookup_stret ret_nil: -#ifdef PIC +#ifdef OF_PIC mov %o7, %g1 sethi %hi(_GLOBAL_OFFSET_TABLE_ - 4), %o1 call 0f add %o1, %lo(_GLOBAL_OFFSET_TABLE_ + 4), %o1 ADDED src/runtime/lookup-asm/lookup-asm-sparc64-elf.S Index: src/runtime/lookup-asm/lookup-asm-sparc64-elf.S ================================================================== --- src/runtime/lookup-asm/lookup-asm-sparc64-elf.S +++ src/runtime/lookup-asm/lookup-asm-sparc64-elf.S @@ -0,0 +1,111 @@ +/* + * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015 + * 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. + */ + +#include "config.h" + +#include "platform.h" + +.globl objc_msg_lookup +.globl objc_msg_lookup_stret +.globl objc_msg_lookup_super +.globl objc_msg_lookup_super_stret + +.section .text +.macro generate_lookup name not_found +\name: + cmp %o0, 0 + beq,a ret_nil + nop + + ldx [%o0], %o2 + ldx [%o2 + 64], %o2 + +.Lmain_\name: +#ifdef OF_SELUID24 + ldub [%o1 + 5], %o3 +#endif + ldub [%o1 + 6], %o4 + ldub [%o1 + 7], %o5 + +#ifdef OF_SELUID24 + sll %o3, 3, %o3 +#endif + sll %o4, 3, %o4 + sll %o5, 3, %o5 + +#ifdef OF_SELUID24 + ldx [%o2 + %o3], %o2 +#endif + ldx [%o2 + %o4], %o2 + ldx [%o2 + %o5], %o2 + + cmp %o2, 0 + beq,a \not_found + nop + + retl + mov %o2, %o0 +.type \name, %function +.size \name, .-\name +.endm + +.macro generate_lookup_super name lookup +\name: + ldx [%o0], %o2 + cmp %o2, 0 + beq,a ret_nil + nop + + ldx [%o0 + 8], %o2 + ba .Lmain_\lookup + ldx [%o2 + 64], %o2 +.type \name, %function +.size \name, .-\name +.endm + +generate_lookup objc_msg_lookup objc_method_not_found +generate_lookup objc_msg_lookup_stret objc_method_not_found_stret +generate_lookup_super objc_msg_lookup_super objc_msg_lookup +generate_lookup_super objc_msg_lookup_super_stret objc_msg_lookup_stret + +ret_nil: +#ifdef OF_PIC + mov %o7, %g1 + + sethi %hi(_GLOBAL_OFFSET_TABLE_ - 4), %o1 + call 0f + add %o1, %lo(_GLOBAL_OFFSET_TABLE_ + 4), %o1 +0: + add %o7, %o1, %o1 + + sethi %hi(nil_method), %o0 + or %o0, %lo(nil_method), %o0 + + jmpl %g1 + 8, %g0 + ldx [%o1 + %o0], %o0 +#else + sethi %hi(nil_method), %o0 + retl + or %o0, %lo(nil_method), %o0 +#endif + +nil_method: + retl + clr %o0 + +#ifdef OF_LINUX +.section .note.GNU-stack, "", %progbits +#endif Index: src/runtime/lookup-asm/lookup-asm.S ================================================================== --- src/runtime/lookup-asm/lookup-asm.S +++ src/runtime/lookup-asm/lookup-asm.S @@ -27,10 +27,12 @@ # include "lookup-asm-arm-elf.S" # elif defined(OF_POWERPC) # include "lookup-asm-ppc-elf.S" # elif defined(OF_MIPS) # include "lookup-asm-mips-elf.S" +# elif defined(OF_SPARC64) +# include "lookup-asm-sparc64-elf.S" # elif defined(OF_SPARC) # include "lookup-asm-sparc-elf.S" # endif #elif defined(OF_MACH_O) # if defined(OF_X86_64) Index: src/runtime/runtime-private.h ================================================================== --- src/runtime/runtime-private.h +++ src/runtime/runtime-private.h @@ -184,11 +184,12 @@ #endif } #if defined(OF_ELF) # if defined(OF_X86_64) || defined(OF_X86) || defined(OF_POWERPC) || \ - defined(OF_ARM) || defined(OF_MIPS) || defined(OF_SPARC) + defined(OF_ARM) || defined(OF_MIPS) || defined(OF_SPARC64) || \ + defined(OF_SPARC) # define OF_ASM_LOOKUP # endif #elif defined(OF_MACH_O) # if defined(OF_X86_64) || defined(OF_POWERPC) # define OF_ASM_LOOKUP