this repo has no description
1
fork

Configure Feed

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

This work got a simple GUI app working

+208 -13
+2
etc/dylib.conf
··· 6 6 /System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation=libCoreFoundation.so 7 7 /System/Library/Frameworks/CoreServices.framework/Versions/A/CoreServices=libgnustep-base.so 8 8 /System/Library/Frameworks/Foundation.framework/Versions/C/Foundation=libgnustep-base.so 9 + /System/Library/Frameworks/AppKit.framework/Versions/C/AppKit=libgnustep-gui.so 10 + 9 11
+2 -1
src/dyld/ld.cpp
··· 128 128 #ifdef MULTILIB 129 129 { 130 130 size_t pos = path.find("/lib/"); 131 - path.replace(pos, 5, "/" LIB_DIR_NAME "/"); 131 + if (pos != std::string::npos) 132 + path.replace(pos, 5, "/" LIB_DIR_NAME "/"); 132 133 } 133 134 #endif 134 135 LOG << "Trying " << path << std::endl;
+1 -1
src/libSystem/CMakeLists.txt
··· 8 8 enable_language(ASM_NASM) 9 9 10 10 if (NOT "${CMAKE_CXX_COMPILER} ${CMAKE_CXX_COMPILER_ARG1}" MATCHES ".*clang") 11 - message(FATAL_ERROR "Clang is the only supported compiler.") 11 + message(FATAL_ERROR "Clang is the only supported compiler (${CMAKE_CXX_COMPILER} used).") 12 12 endif (NOT "${CMAKE_CXX_COMPILER} ${CMAKE_CXX_COMPILER_ARG1}" MATCHES ".*clang") 13 13 14 14 configure_file(config.h.in config.h)
+2
src/libobjcdarwin/CMakeLists.txt
··· 35 35 new/class.cpp 36 36 new/ivar.cpp 37 37 new/protocol.cpp 38 + 39 + NSBundle_dyld.mm 38 40 ) 39 41 40 42 add_library(objc.A.dylib SHARED ${objcdarwin_SRCS})
+1
src/libobjcdarwin/ClassRegister.cpp
··· 57 57 if (modinfo) 58 58 { 59 59 ProcessClassesOld(mh, slide, modinfo); 60 + ProcessCategoriesOld(mh, slide, modinfo); 60 61 } 61 62 } 62 63 else
+18
src/libobjcdarwin/NSBundle_dyld.h
··· 1 + #ifndef NSBUNDLE_DYLD_H 2 + #define NSBUNDLE_DYLD_H 3 + #define __STDC_LIMIT_MACROS 4 + #include <Foundation/NSBundle.h> 5 + 6 + @interface NSBundle (NSBundle_dyld) 7 + 8 + +(NSBundle*) gnu_mainBundle; 9 + +(NSBundle*) x_mainBundle; 10 + 11 + +(NSBundle*) gnu_bundleForClass: (Class) aClass; 12 + +(NSBundle*) x_bundleForClass: (Class) aClass; 13 + 14 + @end 15 + 16 + 17 + #endif 18 +
+81
src/libobjcdarwin/NSBundle_dyld.mm
··· 1 + #import "NSBundle_dyld.h" 2 + #import <limits.h> 3 + #import <Foundation/NSString.h> 4 + #include <string> 5 + #include <cstdio> 6 + #include <algorithm> 7 + #include "../util/log.h" 8 + 9 + extern char g_darwin_executable_path[PATH_MAX]; 10 + static NSBundle* _mainBundle = 0; 11 + 12 + void MethodSwizzle(Class aClass, SEL orig_sel, SEL alt_sel); 13 + 14 + __attribute__((constructor)) static void myinit() 15 + { 16 + LOG << "Swizzling methods in NSBundle\n"; 17 + 18 + MethodSwizzle(objc_getMetaClass("NSBundle"), @selector(mainBundle), @selector(x_mainBundle)); 19 + } 20 + 21 + 22 + @implementation NSBundle (NSBundle_dyld) 23 + /* 24 + +(void) load 25 + { 26 + LOG << "Swizzling methods in NSBundle\n"; 27 + RenameSelector([self class], @selector(mainBundle), @selector(gnu_mainBundle)); 28 + RenameSelector([self class], @selector(x_mainBundle), @selector(mainBundle)); 29 + } 30 + */ 31 + 32 + +(NSBundle*) x_mainBundle 33 + { 34 + LOG << "x_mainBundle() called\n"; 35 + if (!_mainBundle) 36 + { 37 + std::string path = g_darwin_executable_path; 38 + size_t pos = path.find_last_of('/'); 39 + if (pos == std::string::npos) 40 + return nil; 41 + 42 + path.resize(pos+1); 43 + //path += "Resources"; 44 + 45 + LOG << "NSBundle::x_mainBundle(): deduced " << path << " as resource path\n"; 46 + 47 + _mainBundle = [self alloc]; 48 + _mainBundle = [_mainBundle initWithPath:[NSString stringWithUTF8String:path.c_str()]]; 49 + } 50 + 51 + return _mainBundle; 52 + } 53 + 54 + +(NSBundle*) x_bundleForClass: (Class) aClass 55 + { 56 + return [super gnu_bundleForClass:aClass]; 57 + } 58 + 59 + @end 60 + 61 + struct objc_method 62 + { 63 + SEL selector; 64 + const char* types; 65 + IMP imp; 66 + }; 67 + 68 + void MethodSwizzle(Class aClass, SEL orig_sel, SEL alt_sel) 69 + { 70 + Method orig_method, alt_method; 71 + 72 + orig_method = (Method) class_getInstanceMethod(aClass, orig_sel); 73 + alt_method = (Method) class_getInstanceMethod(aClass, alt_sel); 74 + 75 + if (orig_method && alt_method) 76 + { 77 + std::swap(orig_method->types, alt_method->types); 78 + std::swap(orig_method->imp, alt_method->imp); 79 + } 80 + } 81 +
+2 -2
src/libobjcdarwin/NameTranslate.cpp
··· 2 2 #include <memory> 3 3 #include <dlfcn.h> 4 4 5 - extern "C" void* _objc_empty_cache = 0; 6 - extern "C" void* _objc_empty_vtable = 0; 5 + __attribute__((visibility ("default"))) extern "C" void* _objc_empty_cache = 0; 6 + __attribute__((visibility ("default"))) extern "C" void* _objc_empty_vtable = 0; 7 7 8 8 namespace Darling 9 9 {
+3 -1
src/libobjcdarwin/common/method.h
··· 4 4 template<typename ListType> void ConvertMethodListGen(Class c, const ListType* list) 5 5 { 6 6 LOG << list->count << " methods within\n"; 7 + 8 + const bool isMeta = class_isMetaClass(c) == YES; 7 9 8 10 for (size_t i = 0; i < list->count; i++) 9 11 { 10 12 auto* m = &list->method_list[i]; 11 - 13 + 12 14 LOG << "Method: selName: " << m->selName << "; types: " << m->types << "; impl: " << m->impl << std::endl; 13 15 14 16 SEL sel = sel_registerName(m->selName);
+4
src/libobjcdarwin/old/AppleLayout.h
··· 158 158 old_property_list* properties; // since version 7 159 159 }; 160 160 161 + // static const size_t sizeof_old_category_4 = offsetof(old_category, protocols); 162 + // static const size_t sizeof_old_category_5 = offsetof(old_category, size); 161 163 162 164 static const char* SEG_OBJC = "__OBJC"; 163 165 static const char* SEG_OBJC_CLASSLIST_OLD = SEG_OBJC; ··· 174 176 static const char* SECT_OBJC_PROTOEXT_OLD = "__protocol_ext"; 175 177 static const char* SEG_OBJC_MODINFO_OLD = SEG_OBJC; 176 178 static const char* SECT_OBJC_MODINFO_OLD = "__module_info"; 179 + static const char* SEG_OBJC_CATEGORIES_OLD = SEG_OBJC; 180 + static const char* SECT_OBJC_CATEGORIES_OLD = "__category"; 177 181 178 182 #ifndef CLS_CLASS 179 183 #define CLS_CLASS 0x1
+41
src/libobjcdarwin/old/category.cpp
··· 1 + #include "./category.h" 2 + #include "../../util/log.h" 3 + #include "./class.h" 4 + #include "../common/property.h" 5 + #include "../common/method.h" 6 + 7 + void ProcessCategoriesOld(const struct mach_header* mh, intptr_t slide, module_info* modinfo) 8 + { 9 + struct symtab* symtab = modinfo->symtab; 10 + const size_t firstCat = symtab->countClasses; 11 + 12 + if (!symtab->countCategories) 13 + { 14 + LOG << "No categories found\n"; 15 + return; 16 + } 17 + 18 + for (size_t i = 0; i < symtab->countCategories; i++) 19 + { 20 + old_category* cat = reinterpret_cast<old_category*>(symtab->classesAndCategories[i+firstCat]); 21 + Class cls = (Class) objc_getClass(cat->clsName); 22 + 23 + LOG << "Processing category " << cat->name << " @" << cat << " on top of " << cat->clsName << " @" << cls << std::endl; 24 + 25 + assert(cls != nullptr); 26 + 27 + if (cat->methods) 28 + ConvertMethodListGen(cls, cat->methods); 29 + if (cat->staticMethods) 30 + ConvertMethodListGen(object_getClass(id(cls)), cat->staticMethods); 31 + 32 + if (modinfo->version >= 5 && cat->protocols) 33 + AddClassProtocols(cls, cat->protocols); 34 + 35 + if (modinfo->version >= 7 && cat->properties) 36 + { 37 + ConvertProperties(cat->properties, [cls](const char* name, const objc_property_attribute_t* attr, unsigned int count) { class_addProperty(cls, name, attr, count); bug_gnustepFixPropertyCount(cls); }); 38 + } 39 + } 40 + } 41 +
+12
src/libobjcdarwin/old/category.h
··· 1 + #ifndef OLD_CATEGORY_H 2 + #define OLD_CATEGORY_H 3 + 4 + #include "./AppleLayout.h" 5 + #include <objc/runtime.h> 6 + #include <stdint.h> 7 + #include "../../dyld/public.h" 8 + 9 + void ProcessCategoriesOld(const struct mach_header* mh, intptr_t slide, module_info* modinfo); 10 + 11 + #endif 12 +
+10 -8
src/libobjcdarwin/old/class.cpp
··· 35 35 if (cls->ivars) 36 36 ConvertIvarList(conv, cls->ivars); 37 37 if (cls->protocols) 38 - { 39 - for (long i = 0; i < cls->protocols->count; i++) 40 - { 41 - Protocol* p = objc_getProtocol(cls->protocols->list[i]->name); 42 - assert(p != nullptr); 43 - class_addProtocol(conv, p); 44 - } 45 - } 38 + AddClassProtocols(conv, cls->protocols); 46 39 47 40 if (hasExt && cls->ext && cls->ext->propertyLists) 48 41 { ··· 71 64 return conv; 72 65 } 73 66 67 + void AddClassProtocols(Class conv, old_protocol_list* list) 68 + { 69 + for (long i = 0; i < list->count; i++) 70 + { 71 + Protocol* p = objc_getProtocol(list->list[i]->name); 72 + assert(p != nullptr); 73 + class_addProtocol(conv, p); 74 + } 75 + } 74 76 75 77 void ProcessClassesOld(const struct mach_header* mh, intptr_t slide, module_info* info) 76 78 {
+1
src/libobjcdarwin/old/class.h
··· 7 7 8 8 Class RegisterClass(old_class* cls, bool hasExt); 9 9 void ProcessClassesOld(const struct mach_header* mh, intptr_t slide, module_info* info); 10 + void AddClassProtocols(Class conv, old_protocol_list* list); 10 11 11 12 #endif
+7
tests/src/objc_category.m
··· 1 1 #import <Foundation/NSString.h> 2 2 #include <stdio.h> 3 3 4 + // for old runtime testing 5 + @interface RandomClass : NSObject 6 + @end 7 + 8 + @implementation RandomClass 9 + @end 10 + 4 11 @interface NSString (MyCategory) 5 12 +(void) dummy; 6 13 @end
+21
tests/src/objc_load.m
··· 1 + #import <Foundation/NSObject.h> 2 + #import <stdio.h> 3 + 4 + @interface MyClass : NSObject 5 + +(void) load; 6 + @end 7 + 8 + @implementation MyClass 9 + +(void) load 10 + { 11 + puts("MyClass::load called"); 12 + } 13 + @end 14 + 15 + int main() 16 + { 17 + MyClass* c = [MyClass new]; 18 + [c release]; 19 + return 0; 20 + } 21 +