this repo has no description
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Fixing objc_msgSendSuper2 for x86_64, x86 still broken

+81 -24
+6 -2
src/libobjcdarwin/NSBundle_dyld.mm
··· 70 70 path.resize(pos+1); 71 71 //path += "Resources"; 72 72 73 - if ((pos = path.find(".app/")) != std::string::npos) 73 + if ((pos = path.rfind("Contents/")) != std::string::npos) 74 + { 75 + path.resize(pos+8); 76 + } 77 + else if ((pos = path.rfind(".app/")) != std::string::npos) 74 78 { 75 79 // "path.endsWith()" 76 80 // if (path.compare(path.size()-7, 7, "/MacOS/") == 0) 77 81 // path.resize(path.size() - 7); 78 - path.resize(pos+6); 82 + path.resize(pos+4); 79 83 } 80 84 81 85 LOG << "NSBundle::x_mainBundle(): deduced " << path << " as resource path\n";
+4 -1
src/libobjcdarwin/TrampolineHelper.mm
··· 14 14 id obj; 15 15 Class type; 16 16 std::stringstream ret; 17 + bool superCall = false; 17 18 18 19 if (string_startsWith(invoker, "objc_msgSendSuper2")) 19 20 { 20 21 const objc_super* s = static_cast<objc_super*>(arg1); 21 22 obj = (id) class_getSuperclass(Class(s->super_class)); 23 + superCall = true; 22 24 } 23 25 else if (string_startsWith(invoker, "objc_msgSendSuper")) 24 26 { 25 27 const objc_super* s = static_cast<objc_super*>(arg1); 26 28 obj = (id) s->super_class; 29 + superCall = true; 27 30 } 28 31 else 29 32 obj = id(arg1); ··· 49 52 clsname = class_getName(type); 50 53 51 54 isMeta = class_isMetaClass(type) == YES; 52 - if (isMeta) 55 + if (isMeta && !superCall) 53 56 ret << "+["; 54 57 else 55 58 ret << "-[";
+60 -20
src/libobjcdarwin/objc_msgSendSuper.nasm
··· 8 8 BITS 64 9 9 section text 10 10 11 - __darwin_objc_msgSendSuper2: 12 - mov rdi, [rdi+8] 13 - 14 - __darwin_objc_msgSendSuper: 11 + %macro SaveRegisters 0 15 12 push rdi 16 13 push rsi 17 14 push rdx 18 15 push rcx 19 16 push r8 20 17 push r9 21 - 22 - call objc_msg_lookup_super WRT ..plt 23 - 18 + %endmacro 19 + 20 + %macro RestoreRegisters 0 24 21 pop r9 25 22 pop r8 26 23 pop rcx 27 24 pop rdx 28 25 pop rsi 29 26 pop rdi 27 + %endmacro 28 + 29 + __darwin_objc_msgSendSuper2: 30 + SaveRegisters 30 31 32 + ; Make a copy of the struct on stack 33 + mov rax, [rdi] 34 + mov [rsp-16], rax 35 + mov rax, [rdi+8] 36 + mov rax, [rax+8] ; load superclass 37 + mov [rsp-8], rax 38 + 39 + sub rsp, 16 40 + mov rdi, rsp 41 + 42 + call objc_msg_lookup_super WRT ..plt 43 + 44 + add rsp, 16 45 + 46 + RestoreRegisters 47 + 48 + mov rdi, [rdi] 49 + jmp rax 50 + 51 + __darwin_objc_msgSendSuper: 52 + SaveRegisters 53 + 54 + call objc_msg_lookup_super WRT ..plt 55 + 56 + RestoreRegisters 57 + 58 + mov rdi, [rdi] 31 59 jmp rax 32 60 33 61 __darwin_objc_msgSendSuper2_stret: 34 - mov rdi, [rdi+8] 62 + SaveRegisters 63 + 64 + ; Make a copy of the struct on stack 65 + mov rax, [rsi] 66 + mov [rsp-16], rax 67 + mov rax, [rsi+8] 68 + mov rax, [rax+8] ; load superclass 69 + mov [rsp-8], rax 70 + 71 + sub rsp, 16 72 + mov rdi, rsp 73 + mov rsi, rdx 74 + 75 + call objc_msg_lookup_super WRT ..plt 76 + 77 + add rsp, 16 78 + 79 + RestoreRegisters 80 + 81 + mov rsi, [rsi] 82 + jmp rax 35 83 __darwin_objc_msgSendSuper_stret: 36 - push rdi 37 - push rsi 38 - push rdx 39 - push rcx 40 - push r8 41 - push r9 84 + SaveRegisters 42 85 43 86 mov rdi, rsi 44 87 mov rsi, rdx 45 88 46 89 call objc_msg_lookup_super WRT ..plt 47 90 48 - pop r9 49 - pop r8 50 - pop rcx 51 - pop rdx 52 - pop rsi 53 - pop rdi 91 + RestoreRegisters 54 92 93 + mov rsi, [rsi] 55 94 jmp rax 56 95 57 96 %elifidn __OUTPUT_FORMAT__, elf ··· 59 98 BITS 32 60 99 section text 61 100 101 + ; TODO: needs fixing like above 62 102 __darwin_objc_msgSendSuper2: 63 103 mov eax, [esp+4] 64 104 mov eax, [eax+4]
+2
src/libobjcdarwin/objc_msgSend_fixup.nasm
··· 6 6 BITS 64 7 7 section text 8 8 9 + ; TODO: msgSendSuper2_fixup... 10 + 9 11 __darwin_objc_msgSend_fixup: 10 12 mov rsi, [rsi+8] 11 13 jmp objc_msgSend WRT ..plt
+9 -1
tests/src/objc_super.m
··· 1 1 #include <stdio.h> 2 + #include <assert.h> 2 3 #import <Foundation/NSObject.h> 4 + 5 + @class subclass; 6 + subclass* c; 3 7 4 8 @interface helloclass : NSObject { 5 9 } ··· 11 15 - (void)doHello 12 16 { 13 17 puts("Hello world from helloclass"); 18 + //printf("self at %p\n", self); 19 + assert(self == c); 14 20 } 15 21 @end 16 22 ··· 24 30 - (void)doHello 25 31 { 26 32 puts("Calling superclass"); 33 + //printf("self at %p\n", self); 27 34 [super doHello]; 28 35 } 29 36 @end 30 37 31 38 int main() 32 39 { 33 - subclass* c = [subclass new]; 40 + c = [subclass new]; 41 + //printf("Obj at %p\n", c); 34 42 [c doHello]; 35 43 [c release]; 36 44 return 0;