Index: src/runtime/lookup-amd64-elf.S ================================================================== --- src/runtime/lookup-amd64-elf.S +++ src/runtime/lookup-amd64-elf.S @@ -43,11 +43,11 @@ jz forward ret forward: - mov objc_forward_handler@GOTPCREL(%rip), %rax + mov objc_not_found_handler@GOTPCREL(%rip), %rax jmp *(%rax) objc_msg_lookup_super: movq (%rdi), %rax testq %rax, %rax Index: src/runtime/lookup-x86-elf.S ================================================================== --- src/runtime/lookup-x86-elf.S +++ src/runtime/lookup-x86-elf.S @@ -46,11 +46,11 @@ ret forward: call get_eip .L1: - addl $objc_forward_handler-.L1, %eax + addl $objc_not_found_handler-.L1, %eax jmp *(%eax) objc_msg_lookup_super: movl 4(%esp), %edx cmpl $0, (%edx) Index: src/runtime/lookup.m ================================================================== --- src/runtime/lookup.m +++ src/runtime/lookup.m @@ -21,16 +21,18 @@ #import "runtime.h" #import "runtime-private.h" #import "macros.h" -static IMP not_found_handler(id, SEL); -IMP (*objc_forward_handler)(id, SEL) = not_found_handler; +IMP (*objc_forward_handler)(id, SEL) = NULL; -static IMP -not_found_handler(id obj, SEL sel) +IMP +objc_not_found_handler(id obj, SEL sel) { + if (objc_forward_handler != NULL) + return objc_forward_handler(obj, sel); + ERROR("Selector %s is not implemented for class %s!", sel_getName(sel), obj->isa->name); } BOOL @@ -59,11 +61,11 @@ return (IMP)nil_method; imp = objc_sparsearray_get(obj->isa->dtable, (uint32_t)sel->uid); if (imp == NULL) - return objc_forward_handler(obj, sel); + return objc_not_found_handler(obj, sel); return imp; } IMP @@ -75,10 +77,10 @@ return (IMP)nil_method; imp = objc_sparsearray_get(super->class->dtable, (uint32_t)sel->uid); if (imp == NULL) - return objc_forward_handler(super->self, sel); + return objc_not_found_handler(super->self, sel); return imp; } #endif