├── README.md ├── objc4-779.1 ├── APPLE_LICENSE ├── KCCommon │ ├── Block_private.h │ ├── CrashReporterClient.h │ ├── System │ │ ├── machine │ │ │ └── cpu_capabilities.h │ │ └── pthread_machdep.h │ ├── _simple.h │ ├── kern │ │ └── restartable.h │ ├── mach-o │ │ └── dyld_priv.h │ ├── objc-shared-cache.h │ ├── os │ │ ├── base_private.h │ │ ├── lock_private.h │ │ └── tsd.h │ ├── pthread │ │ ├── spinlock_private.h │ │ └── tsd_private.h │ └── sys │ │ └── reason.h ├── KCObjcTest │ ├── TestObject.h │ ├── TestObject.m │ └── main.m ├── ReleaseNotes.rtf ├── interposable.txt ├── libobjc.order ├── markgc.cpp ├── objc.sln ├── objc.vcproj ├── objc.xcodeproj │ ├── project.pbxproj │ ├── project.xcworkspace │ │ └── contents.xcworkspacedata │ └── xcshareddata │ │ └── xcschemes │ │ └── KCObjcTest.xcscheme ├── objcrt │ └── objcrt.vcproj ├── prebuild.bat ├── runtime │ ├── DenseMapExtras.h │ ├── Messengers.subproj │ │ ├── objc-msg-arm.s │ │ ├── objc-msg-arm64.s │ │ ├── objc-msg-i386.s │ │ ├── objc-msg-simulator-i386.s │ │ ├── objc-msg-simulator-x86_64.s │ │ ├── objc-msg-win32.m │ │ └── objc-msg-x86_64.s │ ├── Module │ │ ├── ObjectiveC.apinotes │ │ └── module.modulemap │ ├── NSObjCRuntime.h │ ├── NSObject-internal.h │ ├── NSObject.h │ ├── NSObject.mm │ ├── Object.h │ ├── Object.mm │ ├── OldClasses.subproj │ │ ├── List.h │ │ └── List.m │ ├── Protocol.h │ ├── Protocol.mm │ ├── arm64-asm.h │ ├── hashtable.h │ ├── hashtable2.h │ ├── hashtable2.mm │ ├── isa.h │ ├── llvm-AlignOf.h │ ├── llvm-DenseMap.h │ ├── llvm-DenseMapInfo.h │ ├── llvm-DenseSet.h │ ├── llvm-MathExtras.h │ ├── llvm-type_traits.h │ ├── maptable.h │ ├── maptable.mm │ ├── message.h │ ├── objc-abi.h │ ├── objc-accessors.mm │ ├── objc-api.h │ ├── objc-auto.h │ ├── objc-auto.mm │ ├── objc-block-trampolines.h │ ├── objc-block-trampolines.mm │ ├── objc-blocktramps-arm.s │ ├── objc-blocktramps-arm64.s │ ├── objc-blocktramps-i386.s │ ├── objc-blocktramps-x86_64.s │ ├── objc-cache-old.h │ ├── objc-cache-old.mm │ ├── objc-cache.h │ ├── objc-cache.mm │ ├── objc-class-old.mm │ ├── objc-class.h │ ├── objc-class.mm │ ├── objc-config.h │ ├── objc-env.h │ ├── objc-errors.mm │ ├── objc-exception.h │ ├── objc-exception.mm │ ├── objc-file-old.h │ ├── objc-file-old.mm │ ├── objc-file.h │ ├── objc-file.mm │ ├── objc-gdb.h │ ├── objc-initialize.h │ ├── objc-initialize.mm │ ├── objc-internal.h │ ├── objc-layout.mm │ ├── objc-load.h │ ├── objc-load.mm │ ├── objc-loadmethod.h │ ├── objc-loadmethod.mm │ ├── objc-lockdebug.h │ ├── objc-lockdebug.mm │ ├── objc-locks-new.h │ ├── objc-locks-old.h │ ├── objc-locks.h │ ├── objc-object.h │ ├── objc-opt.mm │ ├── objc-os.h │ ├── objc-os.mm │ ├── objc-private.h │ ├── objc-probes.d │ ├── objc-ptrauth.h │ ├── objc-references.h │ ├── objc-references.mm │ ├── objc-runtime-new.h │ ├── objc-runtime-new.mm │ ├── objc-runtime-old.h │ ├── objc-runtime-old.mm │ ├── objc-runtime.h │ ├── objc-runtime.mm │ ├── objc-sel-old.mm │ ├── objc-sel-set.h │ ├── objc-sel-set.mm │ ├── objc-sel-table.s │ ├── objc-sel.mm │ ├── objc-sync.h │ ├── objc-sync.mm │ ├── objc-typeencoding.mm │ ├── objc-weak.h │ ├── objc-weak.mm │ ├── objc.h │ ├── objcrt.c │ ├── objcrt.h │ └── runtime.h ├── test │ ├── ARCBase.h │ ├── ARCBase.m │ ├── ARCLayouts.m │ ├── ARCLayoutsWithoutWeak.m │ ├── ARCMRC.h │ ├── ARCMRC.m │ ├── MRCARC.h │ ├── MRCARC.m │ ├── MRCBase.h │ ├── MRCBase.m │ ├── accessors.m │ ├── accessors2.m │ ├── addMethod.m │ ├── addMethods.m │ ├── addProtocol.m │ ├── applescriptobjc.m │ ├── arr-cast.m │ ├── arr-weak.m │ ├── asm-placeholder.s │ ├── association-cf.m │ ├── association.m │ ├── associationForbidden.h │ ├── associationForbidden.m │ ├── associationForbidden2.m │ ├── associationForbidden3.m │ ├── associationForbidden4.m │ ├── atomicProperty.mm │ ├── badAltHandler.m │ ├── badCache.m │ ├── badPool.m │ ├── badPoolCompat-ios-tvos.m │ ├── badPoolCompat-macos.m │ ├── badPoolCompat-watchos.m │ ├── badSuperclass.m │ ├── badSuperclass2.m │ ├── badTagClass.m │ ├── badTagIndex.m │ ├── bigrc.m │ ├── blocksAsImps.m │ ├── bool.c │ ├── cacheflush.h │ ├── cacheflush.m │ ├── cacheflush0.m │ ├── cacheflush2.m │ ├── cacheflush3.m │ ├── category.m │ ├── cdtors.mm │ ├── classgetclass.m │ ├── classname.m │ ├── classpair.mm │ ├── classversion.m │ ├── concurrentcat.m │ ├── concurrentcat_category.m │ ├── copyFixupHandler.mm │ ├── copyIvarList.m │ ├── copyMethodList.m │ ├── copyPropertyList.m │ ├── copyProtocolList.m │ ├── createInstance.m │ ├── customrr-cat1.m │ ├── customrr-cat2.m │ ├── customrr-nsobject-awz.m │ ├── customrr-nsobject-core.m │ ├── customrr-nsobject-none.m │ ├── customrr-nsobject-rr.m │ ├── customrr-nsobject-rrawz.m │ ├── customrr-nsobject.m │ ├── customrr.m │ ├── customrr2.m │ ├── definitions.c │ ├── designatedinit.m │ ├── duplicateClass.m │ ├── duplicateProtocols.m │ ├── duplicatedClasses.m │ ├── evil-class-def.m │ ├── exc.m │ ├── exchangeImp.m │ ├── foreach.m │ ├── fork.m │ ├── forkInitialize.m │ ├── forkInitializeDisabled.m │ ├── forkInitializeSingleThreaded.m │ ├── forward.m │ ├── forwardDefault.m │ ├── forwardDefaultStret.m │ ├── future.h │ ├── future.m │ ├── future0.m │ ├── future2.m │ ├── gc-main.m │ ├── gc.c │ ├── gc.m │ ├── gcenforcer-app-aso.m │ ├── gcenforcer-app-gc.m │ ├── gcenforcer-app-gcaso.m │ ├── gcenforcer-app-gcaso2.m │ ├── gcenforcer-app-gconly.m │ ├── gcenforcer-app-nogc.m │ ├── gcenforcer-app-noobjc.m │ ├── gcenforcer-dylib-nogc.m │ ├── gcenforcer-dylib-noobjc.m │ ├── gcenforcer-dylib-requiresgc.m │ ├── gcenforcer-dylib-supportsgc.m │ ├── gcenforcer-preflight.m │ ├── gcfiles │ │ ├── evil1 │ │ ├── i386-aso │ │ ├── i386-aso--x86_64-aso │ │ ├── i386-broken │ │ ├── i386-broken--x86_64-gc │ │ ├── i386-broken--x86_64-nogc │ │ ├── i386-gc │ │ ├── i386-gc--x86_64-broken │ │ ├── i386-gc--x86_64-gc │ │ ├── i386-gc--x86_64-nogc │ │ ├── i386-gcaso │ │ ├── i386-gcaso2 │ │ ├── i386-gconly │ │ ├── i386-nogc │ │ ├── i386-nogc--x86_64-broken │ │ ├── i386-nogc--x86_64-gc │ │ ├── i386-nogc--x86_64-nogc │ │ ├── i386-noobjc │ │ ├── libnogc.dylib │ │ ├── libnoobjc.dylib │ │ ├── librequiresgc.dylib │ │ ├── librequiresgc.fake.dylib │ │ ├── libsupportsgc.dylib │ │ ├── x86_64-aso │ │ ├── x86_64-broken │ │ ├── x86_64-gc │ │ ├── x86_64-gcaso │ │ ├── x86_64-gcaso2 │ │ ├── x86_64-gconly │ │ ├── x86_64-nogc │ │ └── x86_64-noobjc │ ├── gdb.m │ ├── getClassHook.m │ ├── getImageNameHook.m │ ├── getMethod.m │ ├── get_task_allow_entitlement.plist │ ├── headers.c │ ├── headers.sh │ ├── imageorder.h │ ├── imageorder.m │ ├── imageorder1.m │ ├── imageorder2.m │ ├── imageorder3.m │ ├── imports.c │ ├── include-warnings.c │ ├── includes-objc2.c │ ├── includes.c │ ├── initialize.m │ ├── initializeVersusWeak.m │ ├── instanceSize.m │ ├── isaValidation.m │ ├── ismeta.m │ ├── ivar.m │ ├── ivarSlide.h │ ├── ivarSlide.m │ ├── ivarSlide1.m │ ├── literals.m │ ├── load-image-notification-dylib.m │ ├── load-image-notification.m │ ├── load-noobjc.m │ ├── load-noobjc2.m │ ├── load-noobjc3.m │ ├── load-order.m │ ├── load-order1.m │ ├── load-order2.m │ ├── load-order3.m │ ├── load-parallel.m │ ├── load-parallel0.m │ ├── load-parallel00.m │ ├── load-reentrant.m │ ├── load-reentrant2.m │ ├── load.m │ ├── methodArgs.m │ ├── methodCacheLeaks.m │ ├── methodListSize.m │ ├── msgSend-performance.m │ ├── msgSend.m │ ├── nilAPIArgs.m │ ├── nonpointerisa.m │ ├── nopool.m │ ├── nscdtors.mm │ ├── nsexc.m │ ├── nsobject.m │ ├── nsprotocol.m │ ├── objectCopy.m │ ├── property.m │ ├── propertyDesc.m │ ├── protocol.m │ ├── protocol_copyMethodList.m │ ├── protocol_copyPropertyList.m │ ├── rawisa.m │ ├── readClassPair.m │ ├── realizedClassGenerationCount.m │ ├── release-workaround.m │ ├── resolve.m │ ├── restartableRangesSynchronizeStress.m │ ├── rr-autorelease-fast.m │ ├── rr-autorelease-fastarc.m │ ├── rr-autorelease-stacklogging.m │ ├── rr-autorelease.m │ ├── rr-autorelease2.m │ ├── rr-nsautorelease.m │ ├── rr-sidetable.m │ ├── runtime.m │ ├── sel.m │ ├── setAssociatedObjectHook.m │ ├── setSuper.m │ ├── subscripting.m │ ├── super.m │ ├── swift-class-def.m │ ├── swiftMetadataInitializer.m │ ├── swiftMetadataInitializerRealloc-dylib1.m │ ├── swiftMetadataInitializerRealloc-dylib2.m │ ├── swiftMetadataInitializerRealloc.m │ ├── synchronized-counter.m │ ├── synchronized-grid.m │ ├── synchronized.m │ ├── taggedNSPointers.m │ ├── taggedPointers.m │ ├── taggedPointersAllClasses.m │ ├── taggedPointersDisabled.m │ ├── taggedPointersTagObfuscationDisabled.m │ ├── tbi.c │ ├── test.h │ ├── test.pl │ ├── testroot.i │ ├── timeout.pl │ ├── unload.h │ ├── unload.m │ ├── unload2.m │ ├── unload3.c │ ├── unload4.m │ ├── unwind.m │ ├── weak.h │ ├── weak.m │ ├── weak2.m │ ├── weakcopy.m │ ├── weakframework-missing.m │ ├── weakframework-not-missing.m │ ├── weakimport-missing.m │ ├── weakimport-not-missing.m │ ├── weakrace.m │ ├── willInitializeClassFunc.m │ └── zone.m ├── unexported_symbols ├── version.bat └── version.rc └── objc4-runtime-750 ├── APPLE_LICENSE ├── README.md ├── ReleaseNotes.rtf ├── debug-objc └── main.m ├── include ├── Block_private.h ├── CrashReporterClient.h ├── System │ ├── machine │ │ └── cpu_capabilities.h │ └── pthread_machdep.h ├── _simple.h ├── mach-o │ └── dyld_priv.h ├── objc-shared-cache.h ├── os │ ├── base_private.h │ ├── lock_private.h │ └── tsd.h ├── pthread │ ├── qos_private.h │ ├── spinlock_private.h │ ├── tsd_private.h │ └── workqueue_private.h └── sys │ ├── qos_private.h │ └── reason.h ├── interposable.txt ├── libobjc.order ├── markgc.cpp ├── objc-debug ├── NSObject+Test.h ├── NSObject+Test.m ├── TestObject.h ├── TestObject.m └── main.m ├── objc.sln ├── objc.suo ├── objc.vcproj ├── objc.xcodeproj ├── project.pbxproj └── project.xcworkspace │ └── contents.xcworkspacedata ├── objcrt └── objcrt.vcproj ├── prebuild.bat ├── runtime ├── Messengers.subproj │ ├── objc-msg-arm.s │ ├── objc-msg-arm64.s │ ├── objc-msg-i386.s │ ├── objc-msg-simulator-i386.s │ ├── objc-msg-simulator-x86_64.s │ ├── objc-msg-win32.m │ └── objc-msg-x86_64.s ├── Module │ ├── ObjectiveC.apinotes │ └── module.modulemap ├── NSObjCRuntime.h ├── NSObject.h ├── NSObject.mm ├── Object.h ├── Object.mm ├── OldClasses.subproj │ ├── List.h │ └── List.m ├── Protocol.h ├── Protocol.mm ├── a1a2-blocktramps-arm.s ├── a1a2-blocktramps-arm64.s ├── a1a2-blocktramps-i386.s ├── a1a2-blocktramps-x86_64.s ├── a2a3-blocktramps-arm.s ├── a2a3-blocktramps-i386.s ├── a2a3-blocktramps-x86_64.s ├── arm64-asm.h ├── hashtable.h ├── hashtable2.h ├── hashtable2.mm ├── isa.h ├── llvm-AlignOf.h ├── llvm-DenseMap.h ├── llvm-DenseMapInfo.h ├── llvm-MathExtras.h ├── llvm-type_traits.h ├── maptable.h ├── maptable.mm ├── message.h ├── objc-abi.h ├── objc-accessors.mm ├── objc-api.h ├── objc-auto.h ├── objc-auto.mm ├── objc-block-trampolines.h ├── objc-block-trampolines.mm ├── objc-blocktramps-arm.s ├── objc-blocktramps-arm64.s ├── objc-blocktramps-i386.s ├── objc-blocktramps-x86_64.s ├── objc-cache-old.h ├── objc-cache-old.mm ├── objc-cache.h ├── objc-cache.mm ├── objc-class-old.mm ├── objc-class.h ├── objc-class.mm ├── objc-config.h ├── objc-env.h ├── objc-errors.mm ├── objc-exception.h ├── objc-exception.mm ├── objc-file-old.h ├── objc-file-old.mm ├── objc-file.h ├── objc-file.mm ├── objc-gdb.h ├── objc-initialize.h ├── objc-initialize.mm ├── objc-internal.h ├── objc-layout.mm ├── objc-load.h ├── objc-load.mm ├── objc-loadmethod.h ├── objc-loadmethod.mm ├── objc-lockdebug.h ├── objc-lockdebug.mm ├── objc-locks-new.h ├── objc-locks-old.h ├── objc-locks.h ├── objc-object.h ├── objc-opt.mm ├── objc-os.h ├── objc-os.mm ├── objc-private.h ├── objc-probes.d ├── objc-ptrauth.h ├── objc-references.h ├── objc-references.mm ├── objc-runtime-new.h ├── objc-runtime-new.mm ├── objc-runtime-old.h ├── objc-runtime-old.mm ├── objc-runtime.h ├── objc-runtime.mm ├── objc-sel-old.mm ├── objc-sel-set.h ├── objc-sel-set.mm ├── objc-sel-table.s ├── objc-sel.mm ├── objc-sync.h ├── objc-sync.mm ├── objc-typeencoding.mm ├── objc-weak.h ├── objc-weak.mm ├── objc.h ├── objcrt.c ├── objcrt.h └── runtime.h ├── unexported_symbols ├── version.bat └── version.rc /README.md: -------------------------------------------------------------------------------- 1 | 我在简书上写了Runtime系列文章,为了让大家更好的理解Runtime,我将苹果开源的Runtime源码放到我Github上。源码中加入了大量的注释,以帮助大家理解源码的实现,大家可以跑一下源码,打上断点跟一下执行流程,更有助于Runtime的理解。 2 | 3 | 内部源码基于objc-runtime-723。 4 | 5 | #### 简书原文链接 6 | 7 | [Runtime介绍](https://www.jianshu.com/p/4a22a39b69c5) 8 | 9 | [剖析Runtime结构体](https://www.jianshu.com/p/f313e8e32946) 10 | 11 | [Runtime源码分析](https://www.jianshu.com/p/0dc2513e117b) 12 | 13 | [Runtime加载过程](https://www.jianshu.com/p/014af0de67cd) 14 | 15 | [Runtime消息发送机制](https://www.jianshu.com/p/4fb2d7014e9e) 16 | 17 | [深入剖析Category](https://www.jianshu.com/p/3019605a4fc9) 18 | 19 | [Runtime Message Forward](https://www.jianshu.com/p/5b7e7c8075ef) 20 | 21 | [Runtime Method Swizzling](https://www.jianshu.com/p/ff19c04b34d0) 22 | 23 | [Runtime的应用](https://www.jianshu.com/p/ce97c66027cd) -------------------------------------------------------------------------------- /objc4-779.1/KCCommon/CrashReporterClient.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2010 Apple Inc. All rights reserved. 3 | * 4 | * @APPLE_LICENSE_HEADER_START@ 5 | * 6 | * This file contains Original Code and/or Modifications of Original Code 7 | * as defined in and that are subject to the Apple Public Source License 8 | * Version 2.0 (the 'License'). You may not use this file except in 9 | * compliance with the License. Please obtain a copy of the License at 10 | * http://www.opensource.apple.com/apsl/ and read it before using this 11 | * file. 12 | * 13 | * The Original Code and all software distributed under the License are 14 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER 15 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, 16 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. 18 | * Please see the License for the specific language governing rights and 19 | * limitations under the License. 20 | * 21 | * @APPLE_LICENSE_HEADER_END@ 22 | */ 23 | 24 | /*********************************************************************** 25 | * Not to be installed in /usr/local/include 26 | ***********************************************************************/ 27 | 28 | #ifndef _LIBC_CRASHREPORTERCLIENT_H 29 | #define _LIBC_CRASHREPORTERCLIENT_H 30 | 31 | #ifdef LIBC_NO_LIBCRASHREPORTERCLIENT 32 | 33 | /* Fake the CrashReporterClient API */ 34 | #define CRGetCrashLogMessage() 0 35 | #define CRSetCrashLogMessage(x) /* nothing */ 36 | 37 | #else /* !LIBC_NO_LIBCRASHREPORTERCLIENT */ 38 | 39 | /* Include the real CrashReporterClient.h */ 40 | #include_next 41 | 42 | #endif /* !LIBC_NO_LIBCRASHREPORTERCLIENT */ 43 | 44 | #endif /* _LIBC_CRASHREPORTERCLIENT_H */ 45 | -------------------------------------------------------------------------------- /objc4-779.1/KCCommon/System/machine/cpu_capabilities.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2000-2007 Apple Inc. All rights reserved. 3 | * 4 | * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ 5 | * 6 | * This file contains Original Code and/or Modifications of Original Code 7 | * as defined in and that are subject to the Apple Public Source License 8 | * Version 2.0 (the 'License'). You may not use this file except in 9 | * compliance with the License. The rights granted to you under the License 10 | * may not be used to create, or enable the creation or redistribution of, 11 | * unlawful or unlicensed copies of an Apple operating system, or to 12 | * circumvent, violate, or enable the circumvention or violation of, any 13 | * terms of an Apple operating system software license agreement. 14 | * 15 | * Please obtain a copy of the License at 16 | * http://www.opensource.apple.com/apsl/ and read it before using this file. 17 | * 18 | * The Original Code and all software distributed under the License are 19 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER 20 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, 21 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, 22 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. 23 | * Please see the License for the specific language governing rights and 24 | * limitations under the License. 25 | * 26 | * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ 27 | */ 28 | #ifdef PRIVATE 29 | 30 | #ifndef _MACHINE_CPU_CAPABILITIES_H 31 | #define _MACHINE_CPU_CAPABILITIES_H 32 | 33 | #ifdef KERNEL_PRIVATE 34 | #if defined (__i386__) || defined (__x86_64__) 35 | #include "i386/cpu_capabilities.h" 36 | #elif defined (__arm__) || defined (__arm64__) 37 | #include "arm/cpu_capabilities.h" 38 | #else 39 | #error architecture not supported 40 | #endif 41 | 42 | #else /* !KERNEL_PRIVATE -- System Framework header */ 43 | #if defined (__i386__) || defined(__x86_64__) 44 | #include 45 | #elif defined (__arm__) || defined(__arm64__) 46 | #include 47 | #else 48 | #error architecture not supported 49 | #endif 50 | #endif /* KERNEL_PRIVATE */ 51 | 52 | #endif /* _MACHINE_CPU_CAPABILITIES_H */ 53 | #endif /* PRIVATE */ 54 | -------------------------------------------------------------------------------- /objc4-779.1/KCCommon/os/base_private.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2008-2013 Apple Inc. All rights reserved. 3 | * 4 | * @APPLE_APACHE_LICENSE_HEADER_START@ 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | * 18 | * @APPLE_APACHE_LICENSE_HEADER_END@ 19 | */ 20 | 21 | #ifndef __OS_BASE_PRIVATE__ 22 | #define __OS_BASE_PRIVATE__ 23 | 24 | #include 25 | 26 | #ifndef os_fastpath 27 | #define os_fastpath(x) ((__typeof__(x))OS_EXPECT((long)(x), ~0l)) 28 | #endif 29 | #ifndef os_slowpath 30 | #define os_slowpath(x) ((__typeof__(x))OS_EXPECT((long)(x), 0l)) 31 | #endif 32 | #ifndef os_likely 33 | #define os_likely(x) OS_EXPECT(!!(x), 1) 34 | #endif 35 | #ifndef os_unlikely 36 | #define os_unlikely(x) OS_EXPECT(!!(x), 0) 37 | #endif 38 | 39 | #endif // __OS_BASE_PRIVATE__ 40 | -------------------------------------------------------------------------------- /objc4-779.1/KCObjcTest/TestObject.h: -------------------------------------------------------------------------------- 1 | // 2 | // TestObject.h 3 | // KCObjcTest 4 | // 5 | // Created by 刘小壮 on 2020/4/6. 6 | // 7 | 8 | #import 9 | 10 | @interface TestObject : NSObject 11 | @property (nonatomic, strong) NSNumber *number; 12 | @property (nonatomic, strong) NSString *name; 13 | @property (nonatomic, strong) NSDictionary *data; 14 | 15 | - (void)testMethod; 16 | 17 | @end 18 | -------------------------------------------------------------------------------- /objc4-779.1/KCObjcTest/TestObject.m: -------------------------------------------------------------------------------- 1 | // 2 | // TestObject.m 3 | // KCObjcTest 4 | // 5 | // Created by 刘小壮 on 2020/4/6. 6 | // 7 | 8 | #import "TestObject.h" 9 | 10 | @implementation TestObject 11 | 12 | - (void)dealloc { 13 | [super dealloc]; 14 | } 15 | 16 | - (void)testMethod { 17 | 18 | } 19 | 20 | @end 21 | -------------------------------------------------------------------------------- /objc4-779.1/KCObjcTest/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // KCObjcTest 4 | // 5 | // Created by Cooci on 2020/3/5. 6 | // 7 | 8 | #import "TestObject.h" 9 | 10 | int main(int argc, const char * argv[]) { 11 | @autoreleasepool { 12 | TestObject *object = [[TestObject alloc] init]; 13 | [object release]; 14 | 15 | [[NSObject alloc] init]; 16 | [[NSNumber alloc] init]; 17 | [[NSDictionary alloc] init]; 18 | [[NSArray alloc] init]; 19 | 20 | [object testMethod]; 21 | 22 | NSLog(@"hello world"); 23 | } 24 | return 0; 25 | } 26 | -------------------------------------------------------------------------------- /objc4-779.1/interposable.txt: -------------------------------------------------------------------------------- 1 | _objc_release 2 | -------------------------------------------------------------------------------- /objc4-779.1/objc.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 9.00 3 | # Visual C++ Express 2005 4 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "objc", "objc.vcproj", "{B3408263-0CF1-47BE-83CC-56070EFC9BC1}" 5 | EndProject 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "objcrt", "objcrt\objcrt.vcproj", "{E38C1996-8B3D-4050-A4B2-DC85957B047D}" 7 | ProjectSection(ProjectDependencies) = postProject 8 | {B3408263-0CF1-47BE-83CC-56070EFC9BC1} = {B3408263-0CF1-47BE-83CC-56070EFC9BC1} 9 | EndProjectSection 10 | EndProject 11 | Global 12 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 13 | Debug|Win32 = Debug|Win32 14 | DebugDLL|Win32 = DebugDLL|Win32 15 | Release|Win32 = Release|Win32 16 | EndGlobalSection 17 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 18 | {B3408263-0CF1-47BE-83CC-56070EFC9BC1}.Debug|Win32.ActiveCfg = Debug|Win32 19 | {B3408263-0CF1-47BE-83CC-56070EFC9BC1}.Debug|Win32.Build.0 = Debug|Win32 20 | {B3408263-0CF1-47BE-83CC-56070EFC9BC1}.DebugDLL|Win32.ActiveCfg = DebugDLL|Win32 21 | {B3408263-0CF1-47BE-83CC-56070EFC9BC1}.DebugDLL|Win32.Build.0 = DebugDLL|Win32 22 | {B3408263-0CF1-47BE-83CC-56070EFC9BC1}.Release|Win32.ActiveCfg = Release|Win32 23 | {B3408263-0CF1-47BE-83CC-56070EFC9BC1}.Release|Win32.Build.0 = Release|Win32 24 | {E38C1996-8B3D-4050-A4B2-DC85957B047D}.Debug|Win32.ActiveCfg = Debug|Win32 25 | {E38C1996-8B3D-4050-A4B2-DC85957B047D}.Debug|Win32.Build.0 = Debug|Win32 26 | {E38C1996-8B3D-4050-A4B2-DC85957B047D}.DebugDLL|Win32.ActiveCfg = Debug|Win32 27 | {E38C1996-8B3D-4050-A4B2-DC85957B047D}.DebugDLL|Win32.Build.0 = Debug|Win32 28 | {E38C1996-8B3D-4050-A4B2-DC85957B047D}.Release|Win32.ActiveCfg = Release|Win32 29 | {E38C1996-8B3D-4050-A4B2-DC85957B047D}.Release|Win32.Build.0 = Release|Win32 30 | EndGlobalSection 31 | GlobalSection(SolutionProperties) = preSolution 32 | HideSolutionNode = FALSE 33 | EndGlobalSection 34 | EndGlobal 35 | -------------------------------------------------------------------------------- /objc4-779.1/objc.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /objc4-779.1/prebuild.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | 3 | echo prebuild: installing headers 4 | xcopy /Y "%ProjectDir%runtime\objc.h" "%DSTROOT%\AppleInternal\include\objc\" 5 | xcopy /Y "%ProjectDir%runtime\objc-api.h" "%DSTROOT%\AppleInternal\include\objc\" 6 | xcopy /Y "%ProjectDir%runtime\objc-auto.h" "%DSTROOT%\AppleInternal\include\objc\" 7 | xcopy /Y "%ProjectDir%runtime\objc-exception.h" "%DSTROOT%\AppleInternal\include\objc\" 8 | xcopy /Y "%ProjectDir%runtime\message.h" "%DSTROOT%\AppleInternal\include\objc\" 9 | xcopy /Y "%ProjectDir%runtime\runtime.h" "%DSTROOT%\AppleInternal\include\objc\" 10 | xcopy /Y "%ProjectDir%runtime\hashtable.h" "%DSTROOT%\AppleInternal\include\objc\" 11 | xcopy /Y "%ProjectDir%runtime\hashtable2.h" "%DSTROOT%\AppleInternal\include\objc\" 12 | xcopy /Y "%ProjectDir%runtime\maptable.h" "%DSTROOT%\AppleInternal\include\objc\" 13 | 14 | echo prebuild: setting version 15 | version 16 | -------------------------------------------------------------------------------- /objc4-779.1/runtime/Module/module.modulemap: -------------------------------------------------------------------------------- 1 | module ObjectiveC [system] [extern_c] { 2 | umbrella "." 3 | export * 4 | module * { 5 | export * 6 | } 7 | 8 | module NSObject { 9 | requires objc 10 | header "NSObject.h" 11 | export * 12 | } 13 | 14 | #if defined(BUILD_FOR_OSX) 15 | module List { 16 | // Uses @defs, which does not work in ObjC++ or non-ARC. 17 | requires objc, !objc_arc, !cplusplus 18 | header "List.h" 19 | export * 20 | } 21 | 22 | module Object { 23 | requires objc 24 | header "Object.h" 25 | export * 26 | } 27 | 28 | module Protocol { 29 | requires objc 30 | header "Protocol.h" 31 | export * 32 | } 33 | #endif 34 | 35 | #if !defined(BUILD_FOR_OSX) 36 | // These file are not available outside macOS. 37 | exclude header "hashtable.h" 38 | exclude header "hashtable2.h" 39 | #endif 40 | } 41 | -------------------------------------------------------------------------------- /objc4-779.1/runtime/NSObjCRuntime.h: -------------------------------------------------------------------------------- 1 | /* NSObjCRuntime.h 2 | Copyright (c) 1994-2012, Apple Inc. All rights reserved. 3 | */ 4 | 5 | #ifndef _OBJC_NSOBJCRUNTIME_H_ 6 | #define _OBJC_NSOBJCRUNTIME_H_ 7 | 8 | #include 9 | #include 10 | 11 | #if __LP64__ || TARGET_OS_WIN32 || NS_BUILD_32_LIKE_64 12 | typedef long NSInteger; 13 | typedef unsigned long NSUInteger; 14 | #else 15 | typedef int NSInteger; 16 | typedef unsigned int NSUInteger; 17 | #endif 18 | 19 | #define NSIntegerMax LONG_MAX 20 | #define NSIntegerMin LONG_MIN 21 | #define NSUIntegerMax ULONG_MAX 22 | 23 | #define NSINTEGER_DEFINED 1 24 | 25 | #ifndef NS_DESIGNATED_INITIALIZER 26 | #if __has_attribute(objc_designated_initializer) 27 | #define NS_DESIGNATED_INITIALIZER __attribute__((objc_designated_initializer)) 28 | #else 29 | #define NS_DESIGNATED_INITIALIZER 30 | #endif 31 | #endif 32 | 33 | #endif 34 | -------------------------------------------------------------------------------- /objc4-779.1/runtime/hashtable.h: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | -------------------------------------------------------------------------------- /objc4-779.1/runtime/objc-cache-old.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012 Apple Inc. All Rights Reserved. 3 | * 4 | * @APPLE_LICENSE_HEADER_START@ 5 | * 6 | * This file contains Original Code and/or Modifications of Original Code 7 | * as defined in and that are subject to the Apple Public Source License 8 | * Version 2.0 (the 'License'). You may not use this file except in 9 | * compliance with the License. Please obtain a copy of the License at 10 | * http://www.opensource.apple.com/apsl/ and read it before using this 11 | * file. 12 | * 13 | * The Original Code and all software distributed under the License are 14 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER 15 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, 16 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. 18 | * Please see the License for the specific language governing rights and 19 | * limitations under the License. 20 | * 21 | * @APPLE_LICENSE_HEADER_END@ 22 | */ 23 | 24 | #ifndef _OBJC_CACHE_OLD_H 25 | #define _OBJC_CACHE_OLD_H 26 | 27 | #include "objc-private.h" 28 | 29 | __BEGIN_DECLS 30 | 31 | extern IMP _cache_getImp(Class cls, SEL sel); 32 | extern Method _cache_getMethod(Class cls, SEL sel, IMP objc_msgForward_internal_imp); 33 | 34 | extern void cache_init(void); 35 | extern void flush_cache(Class cls); 36 | extern bool _cache_fill(Class cls, Method meth, SEL sel); 37 | extern void _cache_addForwardEntry(Class cls, SEL sel); 38 | extern IMP _cache_addIgnoredEntry(Class cls, SEL sel); 39 | extern void _cache_free(Cache cache); 40 | extern void _cache_collect(bool collectALot); 41 | 42 | __END_DECLS 43 | 44 | #endif 45 | -------------------------------------------------------------------------------- /objc4-779.1/runtime/objc-cache.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef _OBJC_CACHE_H 3 | #define _OBJC_CACHE_H 4 | 5 | #include "objc-private.h" 6 | 7 | __BEGIN_DECLS 8 | 9 | extern void cache_init(void); 10 | 11 | extern IMP cache_getImp(Class cls, SEL sel); 12 | 13 | extern void cache_fill(Class cls, SEL sel, IMP imp, id receiver); 14 | 15 | extern void cache_erase_nolock(Class cls); 16 | 17 | extern void cache_delete(Class cls); 18 | 19 | extern void cache_collect(bool collectALot); 20 | 21 | __END_DECLS 22 | 23 | #endif 24 | -------------------------------------------------------------------------------- /objc4-779.1/runtime/objc-class.h: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | -------------------------------------------------------------------------------- /objc4-779.1/runtime/objc-file-old.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2009 Apple Inc. All Rights Reserved. 3 | * 4 | * @APPLE_LICENSE_HEADER_START@ 5 | * 6 | * This file contains Original Code and/or Modifications of Original Code 7 | * as defined in and that are subject to the Apple Public Source License 8 | * Version 2.0 (the 'License'). You may not use this file except in 9 | * compliance with the License. Please obtain a copy of the License at 10 | * http://www.opensource.apple.com/apsl/ and read it before using this 11 | * file. 12 | * 13 | * The Original Code and all software distributed under the License are 14 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER 15 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, 16 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. 18 | * Please see the License for the specific language governing rights and 19 | * limitations under the License. 20 | * 21 | * @APPLE_LICENSE_HEADER_END@ 22 | */ 23 | 24 | #ifndef _OBJC_FILE_OLD_H 25 | #define _OBJC_FILE_OLD_H 26 | 27 | #if !__OBJC2__ 28 | 29 | #include "objc-os.h" 30 | 31 | struct objc_module; 32 | struct old_protocol; 33 | struct old_class; 34 | 35 | __BEGIN_DECLS 36 | 37 | extern struct objc_module *_getObjcModules(const header_info *hi, size_t *nmodules); 38 | extern SEL *_getObjcSelectorRefs(const header_info *hi, size_t *nmess); 39 | extern struct old_protocol **_getObjcProtocols(const header_info *hi, size_t *nprotos); 40 | extern Class *_getObjcClassRefs(const header_info *hi, size_t *nclasses); 41 | extern const char *_getObjcClassNames(const header_info *hi, size_t *size); 42 | 43 | using UnsignedInitializer = void(*)(void); 44 | extern UnsignedInitializer* getLibobjcInitializers(const headerType *mhdr, size_t *count); 45 | 46 | __END_DECLS 47 | 48 | #endif 49 | 50 | #endif 51 | -------------------------------------------------------------------------------- /objc4-779.1/runtime/objc-initialize.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2005-2006 Apple Inc. All Rights Reserved. 3 | * 4 | * @APPLE_LICENSE_HEADER_START@ 5 | * 6 | * This file contains Original Code and/or Modifications of Original Code 7 | * as defined in and that are subject to the Apple Public Source License 8 | * Version 2.0 (the 'License'). You may not use this file except in 9 | * compliance with the License. Please obtain a copy of the License at 10 | * http://www.opensource.apple.com/apsl/ and read it before using this 11 | * file. 12 | * 13 | * The Original Code and all software distributed under the License are 14 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER 15 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, 16 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. 18 | * Please see the License for the specific language governing rights and 19 | * limitations under the License. 20 | * 21 | * @APPLE_LICENSE_HEADER_END@ 22 | */ 23 | 24 | #ifndef _OBJC_INITIALIZE_H 25 | #define _OBJC_INITIALIZE_H 26 | 27 | #include "objc-private.h" 28 | 29 | __BEGIN_DECLS 30 | 31 | struct _objc_initializing_classes; 32 | 33 | extern void initializeNonMetaClass(Class cls); 34 | 35 | extern void _destroyInitializingClassList(struct _objc_initializing_classes *list); 36 | 37 | extern bool _thisThreadIsInitializingClass(Class cls); 38 | 39 | __END_DECLS 40 | 41 | #endif 42 | -------------------------------------------------------------------------------- /objc4-779.1/runtime/objc-load.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1999-2001, 2005-2006 Apple Inc. All Rights Reserved. 3 | * 4 | * @APPLE_LICENSE_HEADER_START@ 5 | * 6 | * This file contains Original Code and/or Modifications of Original Code 7 | * as defined in and that are subject to the Apple Public Source License 8 | * Version 2.0 (the 'License'). You may not use this file except in 9 | * compliance with the License. Please obtain a copy of the License at 10 | * http://www.opensource.apple.com/apsl/ and read it before using this 11 | * file. 12 | * 13 | * The Original Code and all software distributed under the License are 14 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER 15 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, 16 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. 18 | * Please see the License for the specific language governing rights and 19 | * limitations under the License. 20 | * 21 | * @APPLE_LICENSE_HEADER_END@ 22 | */ 23 | /* 24 | * objc-load.h 25 | * Copyright 1988-1996, NeXT Software, Inc. 26 | */ 27 | 28 | #ifndef _OBJC_LOAD_H_ 29 | #define _OBJC_LOAD_H_ 30 | 31 | #include 32 | 33 | #include 34 | 35 | /* dynamically loading Mach-O object files that contain Objective-C code */ 36 | 37 | OBJC_EXPORT long objc_loadModules ( 38 | char * _Nullable modlist[_Nullable], 39 | void * _Nullable errStream, 40 | void (* _Nullable class_callback) (Class _Nullable, Category _Nullable), 41 | /*headerType*/ struct mach_header * _Nullable * _Nullable hdr_addr, 42 | char * _Nullable debug_file 43 | ) OBJC2_UNAVAILABLE; 44 | 45 | OBJC_EXPORT int objc_loadModule ( 46 | char * _Nullable moduleName, 47 | void (* _Nullable class_callback) (Class _Nullable, Category _Nullable), 48 | int * _Nullable errorCode 49 | ) OBJC2_UNAVAILABLE; 50 | OBJC_EXPORT long objc_unloadModules( 51 | void * _Nullable errorStream, /* input (optional) */ 52 | void (* _Nullable unloadCallback)(Class _Nullable, Category _Nullable) /* input (optional) */ 53 | ) OBJC2_UNAVAILABLE; 54 | 55 | #endif /* _OBJC_LOAD_H_ */ 56 | -------------------------------------------------------------------------------- /objc4-779.1/runtime/objc-loadmethod.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2004-2006 Apple Inc. All Rights Reserved. 3 | * 4 | * @APPLE_LICENSE_HEADER_START@ 5 | * 6 | * This file contains Original Code and/or Modifications of Original Code 7 | * as defined in and that are subject to the Apple Public Source License 8 | * Version 2.0 (the 'License'). You may not use this file except in 9 | * compliance with the License. Please obtain a copy of the License at 10 | * http://www.opensource.apple.com/apsl/ and read it before using this 11 | * file. 12 | * 13 | * The Original Code and all software distributed under the License are 14 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER 15 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, 16 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. 18 | * Please see the License for the specific language governing rights and 19 | * limitations under the License. 20 | * 21 | * @APPLE_LICENSE_HEADER_END@ 22 | */ 23 | 24 | /*********************************************************************** 25 | * objc-loadmethod.h 26 | * Support for +load methods. 27 | **********************************************************************/ 28 | 29 | #ifndef _OBJC_LOADMETHOD_H 30 | #define _OBJC_LOADMETHOD_H 31 | 32 | #include "objc-private.h" 33 | 34 | __BEGIN_DECLS 35 | 36 | extern void add_class_to_loadable_list(Class cls); 37 | extern void add_category_to_loadable_list(Category cat); 38 | extern void remove_class_from_loadable_list(Class cls); 39 | extern void remove_category_from_loadable_list(Category cat); 40 | 41 | extern void call_load_methods(void); 42 | 43 | __END_DECLS 44 | 45 | #endif 46 | -------------------------------------------------------------------------------- /objc4-779.1/runtime/objc-locks-new.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2017 Apple Inc. All Rights Reserved. 3 | * 4 | * @APPLE_LICENSE_HEADER_START@ 5 | * 6 | * This file contains Original Code and/or Modifications of Original Code 7 | * as defined in and that are subject to the Apple Public Source License 8 | * Version 2.0 (the 'License'). You may not use this file except in 9 | * compliance with the License. Please obtain a copy of the License at 10 | * http://www.opensource.apple.com/apsl/ and read it before using this 11 | * file. 12 | * 13 | * The Original Code and all software distributed under the License are 14 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER 15 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, 16 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. 18 | * Please see the License for the specific language governing rights and 19 | * limitations under the License. 20 | * 21 | * @APPLE_LICENSE_HEADER_END@ 22 | */ 23 | 24 | /*********************************************************************** 25 | * objc-locks-new.h 26 | * Declarations of all locks used in the runtime. 27 | **********************************************************************/ 28 | 29 | #ifndef _OBJC_LOCKS_NEW_H 30 | #define _OBJC_LOCKS_NEW_H 31 | 32 | // fork() safety requires careful tracking of all locks used in the runtime. 33 | // Thou shalt not declare any locks outside this file. 34 | 35 | extern mutex_t runtimeLock; 36 | extern mutex_t DemangleCacheLock; 37 | 38 | #endif 39 | -------------------------------------------------------------------------------- /objc4-779.1/runtime/objc-locks-old.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2017 Apple Inc. All Rights Reserved. 3 | * 4 | * @APPLE_LICENSE_HEADER_START@ 5 | * 6 | * This file contains Original Code and/or Modifications of Original Code 7 | * as defined in and that are subject to the Apple Public Source License 8 | * Version 2.0 (the 'License'). You may not use this file except in 9 | * compliance with the License. Please obtain a copy of the License at 10 | * http://www.opensource.apple.com/apsl/ and read it before using this 11 | * file. 12 | * 13 | * The Original Code and all software distributed under the License are 14 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER 15 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, 16 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. 18 | * Please see the License for the specific language governing rights and 19 | * limitations under the License. 20 | * 21 | * @APPLE_LICENSE_HEADER_END@ 22 | */ 23 | 24 | /*********************************************************************** 25 | * objc-locks-old.h 26 | * Declarations of all locks used in the runtime. 27 | **********************************************************************/ 28 | 29 | #ifndef _OBJC_LOCKS_OLD_H 30 | #define _OBJC_LOCKS_OLD_H 31 | 32 | // fork() safety requires careful tracking of all locks used in the runtime. 33 | // Thou shalt not declare any locks outside this file. 34 | 35 | extern mutex_t classLock; 36 | extern mutex_t methodListLock; 37 | extern mutex_t NXUniqueStringLock; 38 | extern spinlock_t impLock; 39 | 40 | #endif 41 | -------------------------------------------------------------------------------- /objc4-779.1/runtime/objc-probes.d: -------------------------------------------------------------------------------- 1 | provider objc_runtime 2 | { 3 | probe objc_exception_throw(void *id); 4 | probe objc_exception_rethrow(); 5 | }; 6 | -------------------------------------------------------------------------------- /objc4-779.1/runtime/objc-references.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2008 Apple Inc. All Rights Reserved. 3 | * 4 | * @APPLE_LICENSE_HEADER_START@ 5 | * 6 | * This file contains Original Code and/or Modifications of Original Code 7 | * as defined in and that are subject to the Apple Public Source License 8 | * Version 2.0 (the 'License'). You may not use this file except in 9 | * compliance with the License. Please obtain a copy of the License at 10 | * http://www.opensource.apple.com/apsl/ and read it before using this 11 | * file. 12 | * 13 | * The Original Code and all software distributed under the License are 14 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER 15 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, 16 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. 18 | * Please see the License for the specific language governing rights and 19 | * limitations under the License. 20 | * 21 | * @APPLE_LICENSE_HEADER_END@ 22 | */ 23 | /* 24 | * objc-references.h 25 | */ 26 | 27 | #ifndef _OBJC_REFERENCES_H_ 28 | #define _OBJC_REFERENCES_H_ 29 | 30 | #include "objc-api.h" 31 | #include "objc-config.h" 32 | 33 | __BEGIN_DECLS 34 | 35 | extern void _objc_associations_init(); 36 | extern void _object_set_associative_reference(id object, const void *key, id value, uintptr_t policy); 37 | extern id _object_get_associative_reference(id object, const void *key); 38 | extern void _object_remove_assocations(id object); 39 | 40 | __END_DECLS 41 | 42 | #endif 43 | -------------------------------------------------------------------------------- /objc4-779.1/runtime/objc-runtime.h: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | -------------------------------------------------------------------------------- /objc4-779.1/runtime/objc-sel-set.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2004 Apple Inc. All rights reserved. 3 | * 4 | * @APPLE_LICENSE_HEADER_START@ 5 | * 6 | * This file contains Original Code and/or Modifications of Original Code 7 | * as defined in and that are subject to the Apple Public Source License 8 | * Version 2.0 (the 'License'). You may not use this file except in 9 | * compliance with the License. Please obtain a copy of the License at 10 | * http://www.opensource.apple.com/apsl/ and read it before using this 11 | * file. 12 | * 13 | * The Original Code and all software distributed under the License are 14 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER 15 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, 16 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. 18 | * Please see the License for the specific language governing rights and 19 | * limitations under the License. 20 | * 21 | * @APPLE_LICENSE_HEADER_END@ 22 | */ 23 | 24 | /* 25 | * objc-sel-set.h 26 | * A set of SELs used for SEL uniquing. 27 | */ 28 | 29 | #ifndef _OBJC_SEL_SET_H_ 30 | #define _OBJC_SEL_SET_H_ 31 | 32 | #if !__OBJC2__ 33 | 34 | #include 35 | #include "objc-os.h" 36 | 37 | __BEGIN_DECLS 38 | 39 | struct __objc_sel_set; 40 | 41 | extern struct __objc_sel_set *__objc_sel_set_create(size_t selrefCount); 42 | extern SEL __objc_sel_set_get(struct __objc_sel_set *sset, SEL candidate); 43 | extern void __objc_sel_set_add(struct __objc_sel_set *sset, SEL value); 44 | 45 | __END_DECLS 46 | 47 | #endif 48 | 49 | #endif 50 | -------------------------------------------------------------------------------- /objc4-779.1/runtime/objc-sel-table.s: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #if __LP64__ 5 | # define PTR(x) .quad x 6 | #else 7 | # define PTR(x) .long x 8 | #endif 9 | 10 | // These offsets are populated by the dyld shared cache builder. 11 | // They point to memory allocatd elsewhere in the shared cache. 12 | 13 | .section __TEXT,__objc_opt_ro 14 | .align 3 15 | .private_extern __objc_opt_data 16 | __objc_opt_data: 17 | .long 15 /* table.version */ 18 | .long 0 /* table.flags */ 19 | .long 0 /* table.selopt_offset */ 20 | .long 0 /* table.headeropt_ro_offset */ 21 | .long 0 /* table.clsopt_offset */ 22 | .long 0 /* table.protocolopt_offset */ 23 | .long 0 /* table.headeropt_rw_offset */ 24 | .space PAGE_MAX_SIZE-28 25 | 26 | 27 | /* section of pointers that the shared cache optimizer wants to know about */ 28 | .section __DATA,__objc_opt_ptrs 29 | .align 3 30 | 31 | #if TARGET_OS_OSX && __i386__ 32 | // old ABI 33 | .globl .objc_class_name_Protocol 34 | PTR(.objc_class_name_Protocol) 35 | #else 36 | // new ABI 37 | .globl _OBJC_CLASS_$_Protocol 38 | PTR(_OBJC_CLASS_$_Protocol) 39 | #endif 40 | -------------------------------------------------------------------------------- /objc4-779.1/runtime/objc-sync.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2002, 2006 Apple Inc. All Rights Reserved. 3 | * 4 | * @APPLE_LICENSE_HEADER_START@ 5 | * 6 | * This file contains Original Code and/or Modifications of Original Code 7 | * as defined in and that are subject to the Apple Public Source License 8 | * Version 2.0 (the 'License'). You may not use this file except in 9 | * compliance with the License. Please obtain a copy of the License at 10 | * http://www.opensource.apple.com/apsl/ and read it before using this 11 | * file. 12 | * 13 | * The Original Code and all software distributed under the License are 14 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER 15 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, 16 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. 18 | * Please see the License for the specific language governing rights and 19 | * limitations under the License. 20 | * 21 | * @APPLE_LICENSE_HEADER_END@ 22 | */ 23 | 24 | #ifndef __OBJC_SNYC_H_ 25 | #define __OBJC_SNYC_H_ 26 | 27 | #include 28 | 29 | 30 | /** 31 | * Begin synchronizing on 'obj'. 32 | * Allocates recursive pthread_mutex associated with 'obj' if needed. 33 | * 34 | * @param obj The object to begin synchronizing on. 35 | * 36 | * @return OBJC_SYNC_SUCCESS once lock is acquired. 37 | */ 38 | OBJC_EXPORT int 39 | objc_sync_enter(id _Nonnull obj) 40 | OBJC_AVAILABLE(10.3, 2.0, 9.0, 1.0, 2.0); 41 | 42 | /** 43 | * End synchronizing on 'obj'. 44 | * 45 | * @param obj The object to end synchronizing on. 46 | * 47 | * @return OBJC_SYNC_SUCCESS or OBJC_SYNC_NOT_OWNING_THREAD_ERROR 48 | */ 49 | OBJC_EXPORT int 50 | objc_sync_exit(id _Nonnull obj) 51 | OBJC_AVAILABLE(10.3, 2.0, 9.0, 1.0, 2.0); 52 | 53 | enum { 54 | OBJC_SYNC_SUCCESS = 0, 55 | OBJC_SYNC_NOT_OWNING_THREAD_ERROR = -1 56 | }; 57 | 58 | 59 | #endif // __OBJC_SYNC_H_ 60 | -------------------------------------------------------------------------------- /objc4-779.1/runtime/objcrt.h: -------------------------------------------------------------------------------- 1 | #ifndef _OBJC_RT_H_ 2 | #define _OBJC_RT_H_ 3 | 4 | #include 5 | 6 | 7 | typedef struct { 8 | int count; // number of pointer pairs that follow 9 | void *modStart; 10 | void *modEnd; 11 | void *protoStart; 12 | void *protoEnd; 13 | void *iiStart; 14 | void *iiEnd; 15 | void *selrefsStart; 16 | void *selrefsEnd; 17 | void *clsrefsStart; 18 | void *clsrefsEnd; 19 | } objc_sections; 20 | 21 | OBJC_EXPORT void *_objc_init_image(HMODULE image, const objc_sections *sects); 22 | OBJC_EXPORT void _objc_load_image(HMODULE image, void *hinfo); 23 | OBJC_EXPORT void _objc_unload_image(HMODULE image, void *hinfo); 24 | 25 | #endif 26 | -------------------------------------------------------------------------------- /objc4-779.1/test/ARCBase.h: -------------------------------------------------------------------------------- 1 | // 2 | // ARCBase.h 3 | // TestARCLayouts 4 | // 5 | // Created by Patrick Beard on 3/8/11. 6 | // Copyright 2011 __MyCompanyName__. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface ARCMisalign : NSObject { 12 | char misalign1; 13 | } 14 | @end 15 | 16 | @interface ARCBase : ARCMisalign 17 | @property long number; 18 | @property(retain) id object; 19 | @property void *pointer; 20 | @property(weak) __weak id delegate; 21 | @end 22 | -------------------------------------------------------------------------------- /objc4-779.1/test/ARCBase.m: -------------------------------------------------------------------------------- 1 | // 2 | // ARCBase.m 3 | // TestARCLayouts 4 | // 5 | // Created by Patrick Beard on 3/8/11. 6 | // Copyright 2011 __MyCompanyName__. All rights reserved. 7 | // 8 | 9 | #import "ARCBase.h" 10 | 11 | // ARCMisalign->misalign1 and ARCBase->misalign2 together cause 12 | // ARCBase's instanceStart to be misaligned, which exercises handling 13 | // of storage that is not represented in the class's ivar layout bitmaps. 14 | 15 | @implementation ARCMisalign 16 | @end 17 | 18 | @interface ARCBase () { 19 | @private 20 | char misalign2; 21 | long number; 22 | id object; 23 | void *pointer; 24 | __weak id delegate; 25 | } 26 | @end 27 | 28 | @implementation ARCBase 29 | @synthesize number, object, pointer, delegate; 30 | @end 31 | -------------------------------------------------------------------------------- /objc4-779.1/test/ARCLayoutsWithoutWeak.m: -------------------------------------------------------------------------------- 1 | // Same as test ARCLayouts but with MRC __weak support disabled. 2 | /* 3 | TEST_CONFIG MEM=arc 4 | TEST_BUILD 5 | mkdir -p $T{OBJDIR} 6 | $C{COMPILE_NOLINK_NOMEM} -c $DIR/MRCBase.m -o $T{OBJDIR}/MRCBase.o -fno-objc-weak 7 | $C{COMPILE_NOLINK_NOMEM} -c $DIR/MRCARC.m -o $T{OBJDIR}/MRCARC.o -fno-objc-weak 8 | $C{COMPILE_NOLINK} -c $DIR/ARCBase.m -o $T{OBJDIR}/ARCBase.o 9 | $C{COMPILE_NOLINK} -c $DIR/ARCMRC.m -o $T{OBJDIR}/ARCMRC.o 10 | $C{COMPILE} '-DNAME=\"ARCLayoutsWithoutWeak.m\"' -fobjc-arc $DIR/ARCLayouts.m -x none $T{OBJDIR}/MRCBase.o $T{OBJDIR}/MRCARC.o $T{OBJDIR}/ARCBase.o $T{OBJDIR}/ARCMRC.o -framework Foundation -o ARCLayoutsWithoutWeak.exe 11 | END 12 | */ 13 | -------------------------------------------------------------------------------- /objc4-779.1/test/ARCMRC.h: -------------------------------------------------------------------------------- 1 | // 2 | // ARCMRC.h 3 | // TestARCLayouts 4 | // 5 | // Created by Patrick Beard on 3/8/11. 6 | // Copyright 2011 __MyCompanyName__. All rights reserved. 7 | // 8 | 9 | #import "MRCBase.h" 10 | 11 | @interface ARCMRC : MRCBase 12 | @property(retain) id dataSource; 13 | @end 14 | -------------------------------------------------------------------------------- /objc4-779.1/test/ARCMRC.m: -------------------------------------------------------------------------------- 1 | // 2 | // ARCMRC.m 3 | // 4 | 5 | #import "ARCMRC.h" 6 | 7 | @implementation ARCMRC 8 | 9 | @synthesize dataSource; 10 | 11 | @end 12 | -------------------------------------------------------------------------------- /objc4-779.1/test/MRCARC.h: -------------------------------------------------------------------------------- 1 | // 2 | // MRCARC.h 3 | // TestARCLayouts 4 | // 5 | // Created by Patrick Beard on 3/8/11. 6 | // Copyright 2011 __MyCompanyName__. All rights reserved. 7 | // 8 | 9 | #import "ARCBase.h" 10 | 11 | @interface MRCARC : ARCBase 12 | @property(retain) id dataSource; 13 | @end 14 | -------------------------------------------------------------------------------- /objc4-779.1/test/MRCARC.m: -------------------------------------------------------------------------------- 1 | // 2 | // MRCARC.m 3 | // 4 | 5 | #import "MRCARC.h" 6 | 7 | @implementation MRCARC 8 | 9 | @synthesize dataSource; 10 | 11 | @end 12 | -------------------------------------------------------------------------------- /objc4-779.1/test/MRCBase.h: -------------------------------------------------------------------------------- 1 | // 2 | // MRCBase.h 3 | // TestARCLayouts 4 | // 5 | // Created by Patrick Beard on 3/8/11. 6 | // Copyright 2011 __MyCompanyName__. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | // YES if MRC compiler supports ARC-style weak 12 | extern bool supportsMRCWeak; 13 | 14 | #if __LP64__ 15 | #define DOUBLEWORD_ALIGNED __attribute__((aligned(16))) 16 | #else 17 | #define DOUBLEWORD_ALIGNED __attribute__((aligned(8))) 18 | #endif 19 | 20 | @interface MRCBase : NSObject 21 | @property double number; 22 | @property(retain) id object; 23 | @property void *pointer; 24 | @property(weak) __weak id delegate; 25 | @end 26 | 27 | // Call object_copy from MRC. 28 | extern id __attribute__((ns_returns_retained)) docopy(id obj); 29 | -------------------------------------------------------------------------------- /objc4-779.1/test/MRCBase.m: -------------------------------------------------------------------------------- 1 | // 2 | // MRCBase.m 3 | // TestARCLayouts 4 | // 5 | // Created by Patrick Beard on 3/8/11. 6 | // Copyright 2011 __MyCompanyName__. All rights reserved. 7 | // 8 | 9 | #include "MRCBase.h" 10 | #include "test.h" 11 | 12 | // MRCBase->alignment ensures that there is a gap between the end of 13 | // NSObject's ivars and the start of MRCBase's ivars, which exercises 14 | // handling of storage that is not represented in any class's ivar 15 | // layout bitmaps. 16 | 17 | #if __has_feature(objc_arc_weak) 18 | bool supportsMRCWeak = true; 19 | #else 20 | bool supportsMRCWeak = false; 21 | #endif 22 | 23 | @interface MRCBase () { 24 | @private 25 | double DOUBLEWORD_ALIGNED alignment; 26 | uintptr_t pad[3]; // historically this made OBJC2 layout bitmaps match OBJC1 27 | double number; 28 | id object; 29 | void *pointer; 30 | #if __has_feature(objc_arc_weak) 31 | __weak 32 | #endif 33 | id delegate; 34 | } 35 | @end 36 | 37 | @implementation MRCBase 38 | @synthesize number, object, pointer, delegate; 39 | @end 40 | 41 | // Call object_copy from MRC. 42 | extern id __attribute__((ns_returns_retained)) 43 | docopy(id obj) 44 | { 45 | return object_copy(obj, 0); 46 | } 47 | -------------------------------------------------------------------------------- /objc4-779.1/test/applescriptobjc.m: -------------------------------------------------------------------------------- 1 | // TEST_CONFIG OS=macosx 2 | // TEST_CFLAGS -framework AppleScriptObjC -framework Foundation 3 | 4 | // Verify that trivial AppleScriptObjC apps run with GC off. 5 | 6 | #include 7 | #include "test.h" 8 | 9 | int main() 10 | { 11 | [NSBundle class]; 12 | succeed(__FILE__); 13 | } 14 | -------------------------------------------------------------------------------- /objc4-779.1/test/arr-cast.m: -------------------------------------------------------------------------------- 1 | // TEST_CONFIG 2 | 3 | #include "test.h" 4 | 5 | // objc.h redefines these calls into bridge casts. 6 | // This test verifies that the function implementations are exported. 7 | __BEGIN_DECLS 8 | extern void *retainedObject(void *arg) __asm__("_objc_retainedObject"); 9 | extern void *unretainedObject(void *arg) __asm__("_objc_unretainedObject"); 10 | extern void *unretainedPointer(void *arg) __asm__("_objc_unretainedPointer"); 11 | __END_DECLS 12 | 13 | int main() 14 | { 15 | void *p = (void*)&main; 16 | testassert(p == retainedObject(p)); 17 | testassert(p == unretainedObject(p)); 18 | testassert(p == unretainedPointer(p)); 19 | succeed(__FILE__); 20 | } 21 | -------------------------------------------------------------------------------- /objc4-779.1/test/asm-placeholder.s: -------------------------------------------------------------------------------- 1 | .macro NOP16 2 | nop 3 | nop 4 | nop 5 | nop 6 | nop 7 | nop 8 | nop 9 | nop 10 | nop 11 | nop 12 | nop 13 | nop 14 | nop 15 | nop 16 | nop 17 | nop 18 | .endmacro 19 | 20 | .macro NOP256 21 | NOP16 22 | NOP16 23 | NOP16 24 | NOP16 25 | NOP16 26 | NOP16 27 | NOP16 28 | NOP16 29 | NOP16 30 | NOP16 31 | NOP16 32 | NOP16 33 | NOP16 34 | NOP16 35 | NOP16 36 | NOP16 37 | .endmacro 38 | 39 | .text 40 | .globl _main 41 | .align 14 42 | _main: 43 | // at least 1024 instruction bytes on all architectures 44 | NOP256 45 | NOP256 46 | NOP256 47 | NOP256 48 | -------------------------------------------------------------------------------- /objc4-779.1/test/association-cf.m: -------------------------------------------------------------------------------- 1 | // TEST_CFLAGS -framework CoreFoundation 2 | // TEST_CONFIG MEM=mrc 3 | // not for ARC because ARC memory management doesn't 4 | // work on CF types whose ObjC side is not yet loaded 5 | 6 | #include 7 | #include 8 | 9 | #include "test.h" 10 | 11 | #if __has_feature(objc_arc) 12 | 13 | int main() 14 | { 15 | testwarn("rdar://11368528 confused by Foundation"); 16 | succeed(__FILE__); 17 | } 18 | 19 | #else 20 | 21 | int main() 22 | { 23 | // rdar://6164781 setAssociatedObject on unresolved future class crashes 24 | 25 | id mp = (id)CFMachPortCreate(0, 0, 0, 0); 26 | testassert(mp); 27 | 28 | testassert(! objc_getClass("NSMachPort")); 29 | 30 | objc_setAssociatedObject(mp, (void*)1, mp, OBJC_ASSOCIATION_ASSIGN); 31 | 32 | id obj = objc_getAssociatedObject(mp, (void*)1); 33 | testassert(obj == mp); 34 | 35 | CFRelease((CFTypeRef)mp); 36 | 37 | succeed(__FILE__); 38 | } 39 | 40 | #endif 41 | -------------------------------------------------------------------------------- /objc4-779.1/test/associationForbidden.h: -------------------------------------------------------------------------------- 1 | #include "testroot.i" 2 | 3 | @interface Normal : TestRoot 4 | @end 5 | @implementation Normal 6 | @end 7 | 8 | @interface Forbidden : TestRoot 9 | @end 10 | @implementation Forbidden 11 | @end 12 | 13 | struct minimal_unrealized_class { 14 | void *isa; 15 | void *superclass; 16 | void *cachePtr; 17 | uintptr_t maskAndOccupied; 18 | struct minimal_class_ro *ro; 19 | }; 20 | 21 | struct minimal_class_ro { 22 | uint32_t flags; 23 | }; 24 | 25 | extern struct minimal_unrealized_class OBJC_CLASS_$_Forbidden; 26 | 27 | #define RO_FORBIDS_ASSOCIATED_OBJECTS (1<<10) 28 | 29 | static void *key = &key; 30 | 31 | static void test(void); 32 | 33 | int main() 34 | { 35 | struct minimal_unrealized_class *localForbidden = &OBJC_CLASS_$_Forbidden; 36 | localForbidden->ro->flags |= RO_FORBIDS_ASSOCIATED_OBJECTS; 37 | test(); 38 | } 39 | 40 | static inline void ShouldSucceed(id obj) { 41 | objc_setAssociatedObject(obj, key, obj, OBJC_ASSOCIATION_ASSIGN); 42 | id assoc = objc_getAssociatedObject(obj, key); 43 | fprintf(stderr, "Associated object is %p\n", assoc); 44 | testassert(obj == assoc); 45 | } 46 | 47 | static inline void ShouldFail(id obj) { 48 | objc_setAssociatedObject(obj, key, obj, OBJC_ASSOCIATION_ASSIGN); 49 | fail("should have crashed trying to set the associated object"); 50 | } 51 | -------------------------------------------------------------------------------- /objc4-779.1/test/associationForbidden.m: -------------------------------------------------------------------------------- 1 | // TEST_CRASHES 2 | /* 3 | TEST_RUN_OUTPUT 4 | Associated object is 0x[0-9a-fA-F]+ 5 | objc\[\d+\]: objc_setAssociatedObject called on instance \(0x[0-9a-fA-F]+\) of class Forbidden which does not allow associated objects 6 | objc\[\d+\]: HALTED 7 | END 8 | */ 9 | 10 | #include "associationForbidden.h" 11 | 12 | void test(void) 13 | { 14 | ShouldSucceed([Normal alloc]); 15 | ShouldFail([Forbidden alloc]); 16 | } 17 | -------------------------------------------------------------------------------- /objc4-779.1/test/associationForbidden2.m: -------------------------------------------------------------------------------- 1 | // TEST_CRASHES 2 | /* 3 | TEST_RUN_OUTPUT 4 | Associated object is 0x[0-9a-fA-F]+ 5 | objc\[\d+\]: objc_setAssociatedObject called on instance \(0x[0-9a-fA-F]+\) of class ForbiddenSubclass which does not allow associated objects 6 | objc\[\d+\]: HALTED 7 | END 8 | */ 9 | 10 | #include "associationForbidden.h" 11 | 12 | void test(void) 13 | { 14 | ShouldSucceed([Normal alloc]); 15 | Class ForbiddenSubclass = objc_allocateClassPair([Forbidden class], 16 | "ForbiddenSubclass", 0); 17 | objc_registerClassPair(ForbiddenSubclass); 18 | ShouldFail([ForbiddenSubclass alloc]); 19 | } 20 | -------------------------------------------------------------------------------- /objc4-779.1/test/associationForbidden3.m: -------------------------------------------------------------------------------- 1 | // TEST_CRASHES 2 | /* 3 | TEST_RUN_OUTPUT 4 | Associated object is 0x[0-9a-fA-F]+ 5 | objc\[\d+\]: objc_setAssociatedObject called on instance \(0x[0-9a-fA-F]+\) of class ForbiddenSubclass which does not allow associated objects 6 | objc\[\d+\]: HALTED 7 | END 8 | */ 9 | 10 | #include "associationForbidden.h" 11 | 12 | @interface ForbiddenSubclass : Forbidden 13 | @end 14 | @implementation ForbiddenSubclass 15 | @end 16 | 17 | void test(void) 18 | { 19 | ShouldSucceed([Normal alloc]); 20 | ShouldSucceed([ForbiddenSubclass alloc]); 21 | } 22 | -------------------------------------------------------------------------------- /objc4-779.1/test/associationForbidden4.m: -------------------------------------------------------------------------------- 1 | // TEST_CRASHES 2 | /* 3 | TEST_RUN_OUTPUT 4 | Associated object is 0x[0-9a-fA-F]+ 5 | objc\[\d+\]: objc_setAssociatedObject called on instance \(0x[0-9a-fA-F]+\) of class ForbiddenDuplicate which does not allow associated objects 6 | objc\[\d+\]: HALTED 7 | END 8 | */ 9 | 10 | #include "associationForbidden.h" 11 | 12 | void test(void) 13 | { 14 | ShouldSucceed([Normal alloc]); 15 | Class ForbiddenDuplicate = objc_duplicateClass([Forbidden class], 16 | "ForbiddenDuplicate", 0); 17 | ShouldFail([ForbiddenDuplicate alloc]); 18 | } 19 | -------------------------------------------------------------------------------- /objc4-779.1/test/atomicProperty.mm: -------------------------------------------------------------------------------- 1 | // TEST_CONFIG 2 | 3 | #include "test.h" 4 | #include 5 | #include 6 | #import 7 | 8 | class SerialNumber { 9 | size_t _number; 10 | public: 11 | SerialNumber() : _number(42) {} 12 | SerialNumber(const SerialNumber &number) : _number(number._number + 1) {} 13 | SerialNumber &operator=(const SerialNumber &number) { _number = number._number + 1; return *this; } 14 | 15 | int operator==(const SerialNumber &number) { return _number == number._number; } 16 | int operator!=(const SerialNumber &number) { return _number != number._number; } 17 | }; 18 | 19 | @interface TestAtomicProperty : NSObject { 20 | SerialNumber number; 21 | } 22 | @property(atomic) SerialNumber number; 23 | @end 24 | 25 | @implementation TestAtomicProperty 26 | 27 | @synthesize number; 28 | 29 | @end 30 | 31 | int main() 32 | { 33 | PUSH_POOL { 34 | SerialNumber number; 35 | TestAtomicProperty *test = [TestAtomicProperty new]; 36 | test.number = number; 37 | testassert(test.number != number); 38 | } POP_POOL; 39 | 40 | succeed(__FILE__); 41 | } 42 | -------------------------------------------------------------------------------- /objc4-779.1/test/badPool.m: -------------------------------------------------------------------------------- 1 | // TEST_CONFIG MEM=mrc 2 | // TEST_CRASHES 3 | 4 | // Test badPoolCompat also uses this file. 5 | 6 | /* 7 | TEST_RUN_OUTPUT 8 | objc\[\d+\]: [Ii]nvalid or prematurely-freed autorelease pool 0x[0-9a-fA-F]+\.? 9 | objc\[\d+\]: HALTED 10 | END 11 | */ 12 | 13 | #include "test.h" 14 | 15 | int main() 16 | { 17 | void *outer = objc_autoreleasePoolPush(); 18 | void *inner = objc_autoreleasePoolPush(); 19 | objc_autoreleasePoolPop(outer); 20 | objc_autoreleasePoolPop(inner); 21 | 22 | #if !OLD 23 | fail("should have crashed already with new SDK"); 24 | #else 25 | // should only warn once 26 | outer = objc_autoreleasePoolPush(); 27 | inner = objc_autoreleasePoolPush(); 28 | objc_autoreleasePoolPop(outer); 29 | objc_autoreleasePoolPop(inner); 30 | 31 | succeed(__FILE__); 32 | #endif 33 | } 34 | 35 | -------------------------------------------------------------------------------- /objc4-779.1/test/badPoolCompat-ios-tvos.m: -------------------------------------------------------------------------------- 1 | // Run test badPool as if it were built with an old SDK. 2 | 3 | // TEST_CONFIG MEM=mrc OS=iphoneos,iphonesimulator,appletvos,appletvsimulator 4 | // TEST_CRASHES 5 | // TEST_CFLAGS -DOLD=1 -Xlinker -sdk_version -Xlinker 9.0 6 | 7 | /* 8 | TEST_RUN_OUTPUT 9 | objc\[\d+\]: Invalid or prematurely-freed autorelease pool 0x[0-9a-fA-f]+\. Set a breakpoint .* Proceeding anyway .* 10 | OK: badPool.m 11 | END 12 | */ 13 | 14 | #include "badPool.m" 15 | -------------------------------------------------------------------------------- /objc4-779.1/test/badPoolCompat-macos.m: -------------------------------------------------------------------------------- 1 | // Run test badPool as if it were built with an old SDK. 2 | 3 | // TEST_CONFIG MEM=mrc OS=macosx 4 | // TEST_CRASHES 5 | // TEST_CFLAGS -DOLD=1 -Xlinker -sdk_version -Xlinker 10.11 6 | 7 | /* 8 | TEST_RUN_OUTPUT 9 | objc\[\d+\]: Invalid or prematurely-freed autorelease pool 0x[0-9a-fA-f]+\. Set a breakpoint .* Proceeding anyway .* 10 | OK: badPool.m 11 | END 12 | */ 13 | 14 | #include "badPool.m" 15 | -------------------------------------------------------------------------------- /objc4-779.1/test/badPoolCompat-watchos.m: -------------------------------------------------------------------------------- 1 | // Run test badPool as if it were built with an old SDK. 2 | 3 | // TEST_CONFIG MEM=mrc OS=watchos,watchsimulator 4 | // TEST_CRASHES 5 | // TEST_CFLAGS -DOLD=1 -Xlinker -sdk_version -Xlinker 2.0 6 | 7 | /* 8 | TEST_RUN_OUTPUT 9 | objc\[\d+\]: Invalid or prematurely-freed autorelease pool 0x[0-9a-fA-f]+\. Set a breakpoint .* Proceeding anyway .* 10 | OK: badPool.m 11 | END 12 | */ 13 | 14 | #include "badPool.m" 15 | -------------------------------------------------------------------------------- /objc4-779.1/test/badSuperclass.m: -------------------------------------------------------------------------------- 1 | // TEST_CRASHES 2 | /* 3 | TEST_RUN_OUTPUT 4 | objc\[\d+\]: Memory corruption in class list\. 5 | objc\[\d+\]: HALTED 6 | END 7 | */ 8 | 9 | #include "test.h" 10 | #include "testroot.i" 11 | 12 | @interface Super : TestRoot @end 13 | @implementation Super @end 14 | 15 | @interface Sub : Super @end 16 | @implementation Sub @end 17 | 18 | int main() 19 | { 20 | alarm(10); 21 | 22 | Class supercls = [Super class]; 23 | Class subcls = [Sub class]; 24 | id subobj __unused = [Sub alloc]; 25 | 26 | // Create a cycle in a superclass chain (Sub->supercls == Sub) 27 | // then attempt to walk that chain. Runtime should halt eventually. 28 | _objc_flush_caches(supercls); 29 | ((Class *)(__bridge void *)subcls)[1] = subcls; 30 | #ifdef CACHE_FLUSH 31 | _objc_flush_caches(supercls); 32 | #else 33 | [subobj class]; 34 | #endif 35 | 36 | fail("should have crashed"); 37 | } 38 | -------------------------------------------------------------------------------- /objc4-779.1/test/badSuperclass2.m: -------------------------------------------------------------------------------- 1 | // TEST_CRASHES 2 | /* 3 | TEST_RUN_OUTPUT 4 | objc\[\d+\]: Memory corruption in class list\. 5 | objc\[\d+\]: HALTED 6 | OR 7 | old abi 8 | OK: badSuperclass\.m 9 | END 10 | */ 11 | 12 | #define CACHE_FLUSH 13 | #include "badSuperclass.m" 14 | -------------------------------------------------------------------------------- /objc4-779.1/test/badTagClass.m: -------------------------------------------------------------------------------- 1 | /* 2 | TEST_CRASHES 3 | TEST_BUILD_OUTPUT 4 | .*badTagClass.m:\d+:\d+: warning: null passed to a callee that requires a non-null argument \[-Wnonnull\] 5 | END 6 | TEST_RUN_OUTPUT 7 | objc\[\d+\]: tag index 1 used for two different classes \(was 0x[0-9a-fA-F]+ NSObject, now 0x[0-9a-fA-F]+ TestRoot\) 8 | objc\[\d+\]: HALTED 9 | OR 10 | no tagged pointers 11 | OK: badTagClass.m 12 | END 13 | */ 14 | 15 | #include "test.h" 16 | #include "testroot.i" 17 | 18 | #include 19 | #include 20 | 21 | #if OBJC_HAVE_TAGGED_POINTERS 22 | 23 | int main() 24 | { 25 | // re-registration and nil registration allowed 26 | _objc_registerTaggedPointerClass(OBJC_TAG_1, [NSObject class]); 27 | _objc_registerTaggedPointerClass(OBJC_TAG_1, [NSObject class]); 28 | _objc_registerTaggedPointerClass(OBJC_TAG_1, nil); 29 | _objc_registerTaggedPointerClass(OBJC_TAG_1, [NSObject class]); 30 | 31 | // colliding registration disallowed 32 | _objc_registerTaggedPointerClass(OBJC_TAG_1, [TestRoot class]); 33 | 34 | fail(__FILE__); 35 | } 36 | 37 | #else 38 | 39 | int main() 40 | { 41 | // provoke the same nullability warning as the real test 42 | objc_getClass(nil); 43 | 44 | fprintf(stderr, "no tagged pointers\n"); 45 | succeed(__FILE__); 46 | } 47 | 48 | #endif 49 | -------------------------------------------------------------------------------- /objc4-779.1/test/badTagIndex.m: -------------------------------------------------------------------------------- 1 | /* 2 | TEST_CRASHES 3 | TEST_RUN_OUTPUT 4 | objc\[\d+\]: tag index 264 is invalid 5 | objc\[\d+\]: HALTED 6 | OR 7 | no tagged pointers 8 | OK: badTagIndex.m 9 | END 10 | */ 11 | 12 | #include "test.h" 13 | 14 | #include 15 | #include 16 | 17 | #if OBJC_HAVE_TAGGED_POINTERS 18 | 19 | int main() 20 | { 21 | _objc_registerTaggedPointerClass((objc_tag_index_t)(OBJC_TAG_Last52BitPayload+1), [NSObject class]); 22 | fail(__FILE__); 23 | } 24 | 25 | #else 26 | 27 | int main() 28 | { 29 | fprintf(stderr, "no tagged pointers\n"); 30 | succeed(__FILE__); 31 | } 32 | 33 | #endif 34 | -------------------------------------------------------------------------------- /objc4-779.1/test/bool.c: -------------------------------------------------------------------------------- 1 | // TEST_CFLAGS -funsigned-char 2 | // (verify -funsigned-char doesn't change the definition of BOOL) 3 | 4 | #include "test.h" 5 | #include 6 | 7 | #if TARGET_OS_OSX 8 | # define RealBool 0 9 | #elif TARGET_OS_IOS || TARGET_OS_BRIDGE 10 | # if (__arm__ && !__armv7k__) || __i386__ 11 | # define RealBool 0 12 | # else 13 | # define RealBool 1 14 | # endif 15 | #else 16 | # define RealBool 1 17 | #endif 18 | 19 | #if __OBJC__ && !defined(__OBJC_BOOL_IS_BOOL) 20 | # error no __OBJC_BOOL_IS_BOOL 21 | #endif 22 | 23 | #if RealBool != OBJC_BOOL_IS_BOOL 24 | # error wrong OBJC_BOOL_IS_BOOL 25 | #endif 26 | 27 | #if RealBool == OBJC_BOOL_IS_CHAR 28 | # error wrong OBJC_BOOL_IS_CHAR 29 | #endif 30 | 31 | int main() 32 | { 33 | const char *expected __unused = 34 | #if RealBool 35 | "B" 36 | #else 37 | "c" 38 | #endif 39 | ; 40 | #if __OBJC__ 41 | const char *enc = @encode(BOOL); 42 | testassert(0 == strcmp(enc, expected)); 43 | #endif 44 | succeed(__FILE__); 45 | } 46 | -------------------------------------------------------------------------------- /objc4-779.1/test/cacheflush.h: -------------------------------------------------------------------------------- 1 | #include 2 | #include "test.h" 3 | 4 | @interface TestRoot(cat) 5 | +(int)classMethod; 6 | -(int)instanceMethod; 7 | @end 8 | -------------------------------------------------------------------------------- /objc4-779.1/test/cacheflush.m: -------------------------------------------------------------------------------- 1 | /* 2 | TEST_BUILD 3 | $C{COMPILE} $DIR/cacheflush0.m -o cacheflush0.dylib -dynamiclib 4 | $C{COMPILE} $DIR/cacheflush2.m -x none cacheflush0.dylib -o cacheflush2.dylib -dynamiclib 5 | $C{COMPILE} $DIR/cacheflush3.m -x none cacheflush0.dylib -o cacheflush3.dylib -dynamiclib 6 | $C{COMPILE} $DIR/cacheflush.m -x none cacheflush0.dylib -o cacheflush.exe 7 | END 8 | */ 9 | 10 | #include "test.h" 11 | #include 12 | #include 13 | 14 | #include "cacheflush.h" 15 | 16 | @interface Sub : TestRoot @end 17 | @implementation Sub @end 18 | 19 | 20 | int main() 21 | { 22 | TestRoot *sup = [TestRoot new]; 23 | Sub *sub = [Sub new]; 24 | 25 | // Fill method cache 26 | testassert(1 == [TestRoot classMethod]); 27 | testassert(1 == [sup instanceMethod]); 28 | testassert(1 == [TestRoot classMethod]); 29 | testassert(1 == [sup instanceMethod]); 30 | 31 | testassert(1 == [Sub classMethod]); 32 | testassert(1 == [sub instanceMethod]); 33 | testassert(1 == [Sub classMethod]); 34 | testassert(1 == [sub instanceMethod]); 35 | 36 | // Dynamically load a category 37 | dlopen("cacheflush2.dylib", 0); 38 | 39 | // Make sure old cache results are gone 40 | testassert(2 == [TestRoot classMethod]); 41 | testassert(2 == [sup instanceMethod]); 42 | 43 | testassert(2 == [Sub classMethod]); 44 | testassert(2 == [sub instanceMethod]); 45 | 46 | // Dynamically load another category 47 | dlopen("cacheflush3.dylib", 0); 48 | 49 | // Make sure old cache results are gone 50 | testassert(3 == [TestRoot classMethod]); 51 | testassert(3 == [sup instanceMethod]); 52 | 53 | testassert(3 == [Sub classMethod]); 54 | testassert(3 == [sub instanceMethod]); 55 | 56 | // fixme test subclasses 57 | 58 | // fixme test objc_flush_caches(), class_addMethod(), class_addMethods() 59 | 60 | succeed(__FILE__); 61 | } 62 | -------------------------------------------------------------------------------- /objc4-779.1/test/cacheflush0.m: -------------------------------------------------------------------------------- 1 | #include "cacheflush.h" 2 | #include "testroot.i" 3 | 4 | @implementation TestRoot(cat) 5 | +(int)classMethod { return 1; } 6 | -(int)instanceMethod { return 1; } 7 | @end 8 | -------------------------------------------------------------------------------- /objc4-779.1/test/cacheflush2.m: -------------------------------------------------------------------------------- 1 | #include "cacheflush.h" 2 | 3 | @implementation TestRoot (Category2) 4 | +(int)classMethod { return 2; } 5 | -(int)instanceMethod { return 2; } 6 | @end 7 | -------------------------------------------------------------------------------- /objc4-779.1/test/cacheflush3.m: -------------------------------------------------------------------------------- 1 | #include "cacheflush.h" 2 | 3 | @implementation TestRoot (Category3) 4 | +(int)classMethod { return 3; } 5 | -(int)instanceMethod { return 3; } 6 | @end 7 | -------------------------------------------------------------------------------- /objc4-779.1/test/classgetclass.m: -------------------------------------------------------------------------------- 1 | // TEST_CONFIG 2 | 3 | #include "test.h" 4 | #include 5 | #include 6 | #import 7 | 8 | @interface Foo:NSObject 9 | @end 10 | @implementation Foo 11 | @end 12 | 13 | int main() 14 | { 15 | testassert(gdb_class_getClass([Foo class]) == [Foo class]); 16 | succeed(__FILE__); 17 | } 18 | -------------------------------------------------------------------------------- /objc4-779.1/test/classname.m: -------------------------------------------------------------------------------- 1 | // TEST_CONFIG 2 | 3 | #include "test.h" 4 | #include "testroot.i" 5 | #include 6 | #include 7 | 8 | @interface Fake : TestRoot @end 9 | @implementation Fake @end 10 | 11 | int main() 12 | { 13 | TestRoot *obj = [TestRoot new]; 14 | Class __unsafe_unretained * buf = (Class *)(__bridge void *)(obj); 15 | *buf = [Fake class]; 16 | 17 | testassert(object_getClass(obj) == [Fake class]); 18 | testassert(object_setClass(obj, [TestRoot class]) == [Fake class]); 19 | testassert(object_getClass(obj) == [TestRoot class]); 20 | testassert(object_setClass(nil, [TestRoot class]) == nil); 21 | 22 | testassert(malloc_size(buf) >= sizeof(id)); 23 | bzero(buf, malloc_size(buf)); 24 | testassert(object_setClass(obj, [TestRoot class]) == nil); 25 | 26 | testassert(object_getClass(obj) == [TestRoot class]); 27 | testassert(object_getClass([TestRoot class]) == object_getClass([TestRoot class])); 28 | testassert(object_getClass(nil) == Nil); 29 | 30 | testassert(0 == strcmp(object_getClassName(obj), "TestRoot")); 31 | testassert(0 == strcmp(object_getClassName([TestRoot class]), "TestRoot")); 32 | testassert(0 == strcmp(object_getClassName(nil), "nil")); 33 | 34 | testassert(0 == strcmp(class_getName([TestRoot class]), "TestRoot")); 35 | testassert(0 == strcmp(class_getName(object_getClass([TestRoot class])), "TestRoot")); 36 | testassert(0 == strcmp(class_getName(nil), "nil")); 37 | 38 | succeed(__FILE__); 39 | } 40 | -------------------------------------------------------------------------------- /objc4-779.1/test/classversion.m: -------------------------------------------------------------------------------- 1 | // TEST_CONFIG 2 | 3 | #include "test.h" 4 | #include "testroot.i" 5 | #include 6 | 7 | int main() 8 | { 9 | Class cls = [TestRoot class]; 10 | testassert(class_getVersion(cls) == 0); 11 | testassert(class_getVersion(object_getClass(cls)) > 5); 12 | class_setVersion(cls, 100); 13 | testassert(class_getVersion(cls) == 100); 14 | 15 | testassert(class_getVersion(Nil) == 0); 16 | class_setVersion(Nil, 100); 17 | 18 | succeed(__FILE__); 19 | } 20 | -------------------------------------------------------------------------------- /objc4-779.1/test/concurrentcat_category.m: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #import 4 | 5 | @interface TargetClass : NSObject 6 | @end 7 | 8 | @interface TargetClass(LoadedMethods) 9 | - (void) m0; 10 | - (void) m1; 11 | - (void) m2; 12 | - (void) m3; 13 | - (void) m4; 14 | - (void) m5; 15 | - (void) m6; 16 | - (void) m7; 17 | - (void) m8; 18 | - (void) m9; 19 | - (void) m10; 20 | - (void) m11; 21 | - (void) m12; 22 | - (void) m13; 23 | - (void) m14; 24 | - (void) m15; 25 | @end 26 | 27 | @interface TN:TargetClass 28 | @end 29 | 30 | @implementation TN 31 | - (void) m1 { [super m1]; } 32 | - (void) m3 { [self m1]; } 33 | 34 | - (void) m2 35 | { 36 | [self willChangeValueForKey: @"m4"]; 37 | [self didChangeValueForKey: @"m4"]; 38 | } 39 | 40 | - (void)observeValueForKeyPath:(NSString *) keyPath 41 | ofObject:(id)object 42 | change:(NSDictionary *)change 43 | context:(void *)context 44 | { 45 | // suppress warning 46 | keyPath = nil; 47 | object = nil; 48 | change = nil; 49 | context = NULL; 50 | } 51 | @end 52 | 53 | @implementation TargetClass(LoadedMethods) 54 | - (void) m0 { ; } 55 | - (void) m1 { ; } 56 | - (void) m2 { ; } 57 | - (void) m3 { ; } 58 | - (void) m4 { ; } 59 | - (void) m5 { ; } 60 | - (void) m6 { ; } 61 | - (void) m7 { ; } 62 | - (void) m8 { ; } 63 | - (void) m9 { ; } 64 | - (void) m10 { ; } 65 | - (void) m11 { ; } 66 | - (void) m12 { ; } 67 | - (void) m13 { ; } 68 | - (void) m14 { ; } 69 | - (void) m15 { ; } 70 | @end 71 | -------------------------------------------------------------------------------- /objc4-779.1/test/copyProtocolList.m: -------------------------------------------------------------------------------- 1 | // TEST_CONFIG 2 | 3 | #include "test.h" 4 | #include 5 | #include 6 | #include 7 | 8 | @protocol Proto1 9 | +(id)proto1ClassMethod; 10 | -(id)proto1InstanceMethod; 11 | @end 12 | 13 | void noNullEntries(Protocol * _Nonnull __unsafe_unretained * _Nullable protolist, 14 | unsigned int count) 15 | { 16 | for (unsigned int i = 0; i != count; ++i) { 17 | testassert(protolist[i]); 18 | testassert(protocol_getName(protolist[i])); 19 | testprintf("Protocol[%d/%d]: %p %s\n", i, count, protolist[i], protocol_getName(protolist[i])); 20 | } 21 | } 22 | 23 | Protocol* getProtocol(Protocol * _Nonnull __unsafe_unretained * _Nullable protolist, 24 | unsigned int count, const char* name) { 25 | for (unsigned int i = 0; i != count; ++i) { 26 | if (!strcmp(protocol_getName(protolist[i]), name)) 27 | return protolist[i]; 28 | } 29 | return nil; 30 | } 31 | 32 | int main() 33 | { 34 | Protocol * _Nonnull __unsafe_unretained * _Nullable protolist; 35 | unsigned int count; 36 | 37 | count = 100; 38 | protolist = objc_copyProtocolList(&count); 39 | testassert(protolist); 40 | testassert(count != 0); 41 | testassert(malloc_size(protolist) >= (count * sizeof(Protocol*))); 42 | noNullEntries(protolist, count); 43 | testassert(protolist[count] == nil); 44 | // Check for a shared cache protocol, ie, the one we know comes from libobjc 45 | testassert(getProtocol(protolist, count, "NSObject")); 46 | // Test for a protocol we know isn't in the cache 47 | testassert(getProtocol(protolist, count, "Proto1") == @protocol(Proto1)); 48 | // Test for a protocol we know isn't there 49 | testassert(!getProtocol(protolist, count, "Proto2")); 50 | free(protolist); 51 | 52 | // Now add it 53 | Protocol* newproto = objc_allocateProtocol("Proto2"); 54 | objc_registerProtocol(newproto); 55 | 56 | Protocol * _Nonnull __unsafe_unretained * _Nullable newProtolist; 57 | unsigned int newCount; 58 | 59 | newCount = 100; 60 | newProtolist = objc_copyProtocolList(&newCount); 61 | testassert(newProtolist); 62 | testassert(newCount == (count + 1)); 63 | testassert(getProtocol(newProtolist, newCount, "Proto2")); 64 | free(newProtolist); 65 | 66 | 67 | succeed(__FILE__); 68 | return 0; 69 | } 70 | -------------------------------------------------------------------------------- /objc4-779.1/test/createInstance.m: -------------------------------------------------------------------------------- 1 | // TEST_CONFIG 2 | 3 | #import 4 | #import 5 | #include "test.h" 6 | #include "testroot.i" 7 | 8 | @interface Super : TestRoot @end 9 | @implementation Super @end 10 | 11 | @interface Sub : Super { int array[128]; } @end 12 | @implementation Sub @end 13 | 14 | #if __has_feature(objc_arc) 15 | #define object_dispose(x) do {} while (0) 16 | #endif 17 | 18 | int main() 19 | { 20 | Super *s; 21 | 22 | s = class_createInstance([Super class], 0); 23 | testassert(s); 24 | testassert(object_getClass(s) == [Super class]); 25 | testassert(malloc_size((__bridge const void *)s) >= class_getInstanceSize([Super class])); 26 | 27 | object_dispose(s); 28 | 29 | s = class_createInstance([Sub class], 0); 30 | testassert(s); 31 | testassert(object_getClass(s) == [Sub class]); 32 | testassert(malloc_size((__bridge const void *)s) >= class_getInstanceSize([Sub class])); 33 | 34 | object_dispose(s); 35 | 36 | s = class_createInstance([Super class], 100); 37 | testassert(s); 38 | testassert(object_getClass(s) == [Super class]); 39 | testassert(malloc_size((__bridge const void *)s) >= class_getInstanceSize([Super class]) + 100); 40 | 41 | object_dispose(s); 42 | 43 | s = class_createInstance([Sub class], 100); 44 | testassert(s); 45 | testassert(object_getClass(s) == [Sub class]); 46 | testassert(malloc_size((__bridge const void *)s) >= class_getInstanceSize([Sub class]) + 100); 47 | 48 | object_dispose(s); 49 | 50 | s = class_createInstance(Nil, 0); 51 | testassert(!s); 52 | 53 | testassert(TestRootAlloc == 0); 54 | 55 | #if __has_feature(objc_arc) 56 | // ARC version didn't use object_dispose() 57 | // and should have called -dealloc on 4 objects 58 | testassert(TestRootDealloc == 4); 59 | #else 60 | // MRC version used object_dispose() 61 | // which doesn't call -dealloc 62 | testassert(TestRootDealloc == 0); 63 | #endif 64 | 65 | succeed(__FILE__); 66 | } 67 | -------------------------------------------------------------------------------- /objc4-779.1/test/customrr-cat1.m: -------------------------------------------------------------------------------- 1 | @interface InheritingSubCat @end 2 | 3 | @interface InheritingSubCat (NonClobberingCategory) @end 4 | 5 | @implementation InheritingSubCat (NonClobberingCategory) 6 | -(id) unrelatedMethod { return self; } 7 | @end 8 | -------------------------------------------------------------------------------- /objc4-779.1/test/customrr-cat2.m: -------------------------------------------------------------------------------- 1 | @interface InheritingSubCat @end 2 | 3 | @interface InheritingSubCat (ClobberingCategory) @end 4 | 5 | @implementation InheritingSubCat (ClobberingCategory) 6 | -(int) retainCount { return 1; } 7 | @end 8 | -------------------------------------------------------------------------------- /objc4-779.1/test/customrr-nsobject-awz.m: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | TEST_CONFIG MEM=mrc 4 | TEST_ENV OBJC_PRINT_CUSTOM_RR=YES OBJC_PRINT_CUSTOM_AWZ=YES OBJC_PRINT_CUSTOM_CORE=YES 5 | 6 | TEST_BUILD 7 | $C{COMPILE} $DIR/customrr-nsobject.m -o customrr-nsobject-awz.exe -DSWIZZLE_AWZ=1 -fno-objc-convert-messages-to-runtime-calls 8 | END 9 | 10 | TEST_RUN_OUTPUT 11 | objc\[\d+\]: CUSTOM AWZ: NSObject \(meta\) 12 | OK: customrr-nsobject-awz.exe 13 | END 14 | 15 | */ 16 | 17 | -------------------------------------------------------------------------------- /objc4-779.1/test/customrr-nsobject-core.m: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | TEST_CONFIG MEM=mrc 4 | TEST_ENV OBJC_PRINT_CUSTOM_RR=YES OBJC_PRINT_CUSTOM_AWZ=YES OBJC_PRINT_CUSTOM_CORE=YES 5 | 6 | TEST_BUILD 7 | $C{COMPILE} $DIR/customrr-nsobject.m -o customrr-nsobject-core.exe -DSWIZZLE_CORE=1 -fno-objc-convert-messages-to-runtime-calls 8 | END 9 | 10 | TEST_RUN_OUTPUT 11 | objc\[\d+\]: CUSTOM Core: NSObject 12 | objc\[\d+\]: CUSTOM Core: NSObject \(meta\) 13 | OK: customrr-nsobject-core.exe 14 | END 15 | 16 | */ 17 | 18 | -------------------------------------------------------------------------------- /objc4-779.1/test/customrr-nsobject-none.m: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | TEST_CONFIG MEM=mrc 4 | TEST_ENV OBJC_PRINT_CUSTOM_RR=YES OBJC_PRINT_CUSTOM_AWZ=YES OBJC_PRINT_CUSTOM_CORE=YES 5 | 6 | TEST_BUILD 7 | $C{COMPILE} $DIR/customrr-nsobject.m -o customrr-nsobject-none.exe -fno-objc-convert-messages-to-runtime-calls 8 | END 9 | 10 | TEST_RUN_OUTPUT 11 | OK: customrr-nsobject-none.exe 12 | END 13 | 14 | */ 15 | 16 | -------------------------------------------------------------------------------- /objc4-779.1/test/customrr-nsobject-rr.m: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | TEST_CONFIG MEM=mrc 4 | TEST_ENV OBJC_PRINT_CUSTOM_RR=YES OBJC_PRINT_CUSTOM_AWZ=YES OBJC_PRINT_CUSTOM_CORE=YES 5 | 6 | TEST_BUILD 7 | $C{COMPILE} $DIR/customrr-nsobject.m -o customrr-nsobject-rr.exe -DSWIZZLE_RELEASE=1 -fno-objc-convert-messages-to-runtime-calls 8 | END 9 | 10 | TEST_RUN_OUTPUT 11 | objc\[\d+\]: CUSTOM RR: NSObject 12 | OK: customrr-nsobject-rr.exe 13 | END 14 | 15 | */ 16 | 17 | -------------------------------------------------------------------------------- /objc4-779.1/test/customrr-nsobject-rrawz.m: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | TEST_CONFIG MEM=mrc 4 | TEST_ENV OBJC_PRINT_CUSTOM_RR=YES OBJC_PRINT_CUSTOM_AWZ=YES OBJC_PRINT_CUSTOM_CORE=YES 5 | 6 | TEST_BUILD 7 | $C{COMPILE} $DIR/customrr-nsobject.m -o customrr-nsobject-rrawz.exe -DSWIZZLE_RELEASE=1 -DSWIZZLE_AWZ=1 -fno-objc-convert-messages-to-runtime-calls 8 | END 9 | 10 | TEST_RUN_OUTPUT 11 | objc\[\d+\]: CUSTOM AWZ: NSObject \(meta\) 12 | objc\[\d+\]: CUSTOM RR: NSObject 13 | OK: customrr-nsobject-rrawz.exe 14 | END 15 | 16 | */ 17 | 18 | -------------------------------------------------------------------------------- /objc4-779.1/test/customrr2.m: -------------------------------------------------------------------------------- 1 | // These options must match customrr.m 2 | // TEST_CONFIG MEM=mrc 3 | /* 4 | TEST_BUILD 5 | $C{COMPILE} $DIR/customrr.m -fvisibility=default -o customrr2.exe -DTEST_EXCHANGEIMPLEMENTATIONS=1 -fno-objc-convert-messages-to-runtime-calls 6 | $C{COMPILE} -bundle -bundle_loader customrr2.exe $DIR/customrr-cat1.m -o customrr-cat1.bundle 7 | $C{COMPILE} -bundle -bundle_loader customrr2.exe $DIR/customrr-cat2.m -o customrr-cat2.bundle 8 | END 9 | */ 10 | -------------------------------------------------------------------------------- /objc4-779.1/test/definitions.c: -------------------------------------------------------------------------------- 1 | // TEST_CONFIG 2 | 3 | // DO NOT include anything else here 4 | #include 5 | // DO NOT include anything else here 6 | Class c = Nil; 7 | SEL s; 8 | IMP i; 9 | id o = nil; 10 | BOOL b = YES; 11 | BOOL b2 = NO; 12 | #if !__has_feature(objc_arc) 13 | __strong void *p; 14 | #endif 15 | id __unsafe_unretained u; 16 | #if __has_feature(objc_arc_weak) 17 | id __weak w; 18 | #endif 19 | 20 | void fn(void) __unused; 21 | void fn(void) { 22 | id __autoreleasing a __unused; 23 | } 24 | 25 | // check type inference for blocks returning YES and NO (rdar://10118972) 26 | BOOL (^block1)(void) = ^{ return YES; }; 27 | BOOL (^block2)(void) = ^{ return NO; }; 28 | 29 | #include "test.h" 30 | 31 | int main() 32 | { 33 | testassert(YES); 34 | testassert(!NO); 35 | #if __cplusplus 36 | testwarn("rdar://12371870 -Wnull-conversion"); 37 | testassert(!(bool)nil); 38 | testassert(!(bool)Nil); 39 | #else 40 | testassert(!nil); 41 | testassert(!Nil); 42 | #endif 43 | 44 | #if __has_feature(objc_bool) 45 | // YES[array] is disallowed for objc just as true[array] is for C++ 46 | #else 47 | // this will fail if YES and NO do not have enough parentheses 48 | int array[2] = { 888, 999 }; 49 | testassert(NO[array] == 888); 50 | testassert(YES[array] == 999); 51 | #endif 52 | 53 | succeed(__FILE__); 54 | } 55 | -------------------------------------------------------------------------------- /objc4-779.1/test/designatedinit.m: -------------------------------------------------------------------------------- 1 | // TEST_CONFIG 2 | /* TEST_BUILD_OUTPUT 3 | .*designatedinit.m:\d+:\d+: warning: designated initializer should only invoke a designated initializer on 'super'.* 4 | .*designatedinit.m:\d+:\d+: note: .* 5 | .*designatedinit.m:\d+:\d+: warning: method override for the designated initializer of the superclass '-init' not found.* 6 | .*NSObject.h:\d+:\d+: note: .* 7 | END */ 8 | 9 | #define NS_ENFORCE_NSOBJECT_DESIGNATED_INITIALIZER 1 10 | #include "test.h" 11 | #include 12 | 13 | @interface C : NSObject 14 | -(id) initWithInt:(int)i NS_DESIGNATED_INITIALIZER; 15 | @end 16 | 17 | @implementation C 18 | -(id) initWithInt:(int)__unused i { 19 | return [self init]; 20 | } 21 | @end 22 | 23 | int main() 24 | { 25 | succeed(__FILE__); 26 | } 27 | -------------------------------------------------------------------------------- /objc4-779.1/test/duplicatedClasses.m: -------------------------------------------------------------------------------- 1 | // fixme rdar://24624435 duplicate class warning fails with the shared cache 2 | // OBJC_DISABLE_PREOPTIMIZATION=YES works around that problem. 3 | 4 | // TEST_ENV OBJC_DEBUG_DUPLICATE_CLASSES=YES OBJC_DISABLE_PREOPTIMIZATION=YES 5 | // TEST_CRASHES 6 | /* 7 | TEST_RUN_OUTPUT 8 | objc\[\d+\]: Class [^\s]+ is implemented in both .+ \(0x[0-9a-f]+\) and .+ \(0x[0-9a-f]+\)\. One of the two will be used\. Which one is undefined\. 9 | objc\[\d+\]: HALTED 10 | OR 11 | OK: duplicatedClasses.m 12 | END 13 | */ 14 | 15 | #include "test.h" 16 | #include "testroot.i" 17 | 18 | @interface WKWebView : TestRoot @end 19 | @implementation WKWebView @end 20 | 21 | int main() 22 | { 23 | void *dl = dlopen("/System/Library/Frameworks/WebKit.framework/WebKit", RTLD_LAZY); 24 | if (!dl) fail("couldn't open WebKit"); 25 | fail("should have crashed already"); 26 | } 27 | -------------------------------------------------------------------------------- /objc4-779.1/test/fork.m: -------------------------------------------------------------------------------- 1 | // TEST_CONFIG 2 | 3 | #include "test.h" 4 | 5 | void *flushthread(void *arg __unused) 6 | { 7 | while (1) { 8 | _objc_flush_caches(nil); 9 | } 10 | } 11 | 12 | int main() 13 | { 14 | pthread_t th; 15 | pthread_create(&th, nil, &flushthread, nil); 16 | 17 | alarm(120); 18 | 19 | [NSObject self]; 20 | [NSObject self]; 21 | 22 | int max = is_guardmalloc() ? 10: 100; 23 | 24 | for (int i = 0; i < max; i++) { 25 | pid_t child; 26 | switch ((child = fork())) { 27 | case -1: 28 | abort(); 29 | case 0: 30 | // child 31 | alarm(10); 32 | [NSObject self]; 33 | _exit(0); 34 | default: { 35 | // parent 36 | int result = 0; 37 | while (waitpid(child, &result, 0) < 0) { 38 | if (errno != EINTR) { 39 | fail("waitpid failed (errno %d %s)", 40 | errno, strerror(errno)); 41 | } 42 | } 43 | if (!WIFEXITED(result)) { 44 | fail("child crashed (waitpid result %d)", result); 45 | } 46 | 47 | [NSObject self]; 48 | break; 49 | } 50 | } 51 | } 52 | 53 | succeed(__FILE__ " parent"); 54 | } 55 | -------------------------------------------------------------------------------- /objc4-779.1/test/forkInitializeDisabled.m: -------------------------------------------------------------------------------- 1 | /* 2 | TEST_CONFIG OS=macosx MEM=mrc ARCH=x86_64 3 | (confused by ARC which loads Foundation which provokes more +initialize logs) 4 | (also confused by i386 OS_object +load workaround) 5 | 6 | TEST_ENV OBJC_PRINT_INITIALIZE_METHODS=YES 7 | 8 | TEST_RUN_OUTPUT 9 | objc\[\d+\]: INITIALIZE: disabling \+initialize fork safety enforcement because the app has a __DATA,__objc_fork_ok section 10 | OK: forkInitializeDisabled\.m 11 | END 12 | */ 13 | 14 | #include "test.h" 15 | 16 | asm(".section __DATA, __objc_fork_ok\n.long 0\n"); 17 | 18 | int main() 19 | { 20 | succeed(__FILE__); 21 | } 22 | -------------------------------------------------------------------------------- /objc4-779.1/test/forkInitializeSingleThreaded.m: -------------------------------------------------------------------------------- 1 | /* 2 | TEST_RUN_OUTPUT 3 | OK: forkInitialize\.m 4 | OK: forkInitialize\.m 5 | END 6 | */ 7 | #define SINGLETHREADED 1 8 | #include "forkInitialize.m" 9 | -------------------------------------------------------------------------------- /objc4-779.1/test/forwardDefault.m: -------------------------------------------------------------------------------- 1 | /* 2 | no arc, rdar://11368528 confused by Foundation 3 | TEST_CONFIG MEM=mrc 4 | TEST_CRASHES 5 | TEST_RUN_OUTPUT 6 | objc\[\d+\]: \+\[NSObject fakeorama\]: unrecognized selector sent to instance 0x[0-9a-fA-F]+ \(no message forward handler is installed\) 7 | objc\[\d+\]: HALTED 8 | END 9 | */ 10 | 11 | #include "test.h" 12 | 13 | #include 14 | 15 | @interface NSObject (Fake) 16 | -(void)fakeorama; 17 | @end 18 | 19 | int main() 20 | { 21 | [NSObject fakeorama]; 22 | fail("should have crashed"); 23 | } 24 | 25 | -------------------------------------------------------------------------------- /objc4-779.1/test/forwardDefaultStret.m: -------------------------------------------------------------------------------- 1 | /* 2 | no arc, rdar://11368528 confused by Foundation 3 | TEST_CONFIG MEM=mrc 4 | TEST_CRASHES 5 | TEST_RUN_OUTPUT 6 | objc\[\d+\]: \+\[NSObject fakeorama\]: unrecognized selector sent to instance 0x[0-9a-fA-F]+ \(no message forward handler is installed\) 7 | objc\[\d+\]: HALTED 8 | END 9 | */ 10 | 11 | #include "test.h" 12 | 13 | #include 14 | 15 | @interface NSObject (Fake) 16 | -(struct stret)fakeorama; 17 | @end 18 | 19 | int main() 20 | { 21 | [NSObject fakeorama]; 22 | fail("should have crashed"); 23 | } 24 | 25 | -------------------------------------------------------------------------------- /objc4-779.1/test/future.h: -------------------------------------------------------------------------------- 1 | #include "test.h" 2 | 3 | @interface Sub1 : TestRoot 4 | +(int)method; 5 | +(Class)classref; 6 | @end 7 | 8 | @interface Sub2 : TestRoot 9 | +(int)method; 10 | +(Class)classref; 11 | @end 12 | 13 | @interface SubSub1 : Sub1 @end 14 | 15 | @interface SubSub2 : Sub2 @end 16 | -------------------------------------------------------------------------------- /objc4-779.1/test/future.m: -------------------------------------------------------------------------------- 1 | /* 2 | TEST_BUILD 3 | $C{COMPILE} $DIR/future0.m -o future0.dylib -dynamiclib 4 | $C{COMPILE} $DIR/future2.m -x none future0.dylib -o future2.dylib -dynamiclib 5 | $C{COMPILE} $DIR/future.m -x none future0.dylib -o future.exe 6 | END 7 | */ 8 | 9 | #include "test.h" 10 | 11 | #if __has_feature(objc_arc) 12 | 13 | int main() 14 | { 15 | testwarn("rdar://10041403 future class API is not ARC-compatible"); 16 | succeed(__FILE__); 17 | } 18 | 19 | 20 | #else 21 | 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include "future.h" 27 | 28 | @implementation Sub2 29 | +(int)method { 30 | return 2; 31 | } 32 | +(Class)classref { 33 | return [Sub2 class]; 34 | } 35 | @end 36 | 37 | @implementation SubSub2 38 | +(int)method { 39 | return 1 + [super method]; 40 | } 41 | @end 42 | 43 | int main() 44 | { 45 | Class oldTestRoot; 46 | Class oldSub1; 47 | Class newSub1; 48 | 49 | // objc_getFutureClass with existing class 50 | oldTestRoot = objc_getFutureClass("TestRoot"); 51 | testassert(oldTestRoot == [TestRoot class]); 52 | testassert(! _class_isFutureClass(oldTestRoot)); 53 | 54 | // objc_getFutureClass with missing class 55 | oldSub1 = objc_getFutureClass("Sub1"); 56 | testassert(oldSub1); 57 | testassert(malloc_size((__bridge void*)oldSub1) > 0); 58 | testassert(objc_getClass("Sub1") == Nil); 59 | testassert(_class_isFutureClass(oldSub1)); 60 | testassert(0 == strcmp(class_getName(oldSub1), "Sub1")); 61 | testassert(object_getClass(oldSub1) == Nil); // CF expects this 62 | 63 | // objc_getFutureClass a second time 64 | testassert(oldSub1 == objc_getFutureClass("Sub1")); 65 | 66 | // Load class Sub1 67 | dlopen("future2.dylib", 0); 68 | 69 | // Verify use of future class 70 | newSub1 = objc_getClass("Sub1"); 71 | testassert(oldSub1 == newSub1); 72 | testassert(newSub1 == [newSub1 classref]); 73 | testassert(newSub1 == class_getSuperclass(objc_getClass("SubSub1"))); 74 | testassert(! _class_isFutureClass(newSub1)); 75 | 76 | testassert(1 == [oldSub1 method]); 77 | testassert(1 == [newSub1 method]); 78 | 79 | succeed(__FILE__); 80 | } 81 | 82 | #endif 83 | -------------------------------------------------------------------------------- /objc4-779.1/test/future0.m: -------------------------------------------------------------------------------- 1 | #include "future.h" 2 | #include "testroot.i" 3 | -------------------------------------------------------------------------------- /objc4-779.1/test/future2.m: -------------------------------------------------------------------------------- 1 | #include "future.h" 2 | 3 | 4 | @implementation Sub1 5 | +(Class)classref { 6 | return [Sub1 class]; 7 | } 8 | +(int)method { 9 | return 1; 10 | } 11 | @end 12 | 13 | @implementation SubSub1 14 | +(int)method { 15 | return 1 + [super method]; 16 | } 17 | @end 18 | -------------------------------------------------------------------------------- /objc4-779.1/test/gc-main.m: -------------------------------------------------------------------------------- 1 | #include "test.h" 2 | 3 | OBJC_ROOT_CLASS 4 | @interface Main @end 5 | @implementation Main @end 6 | 7 | int main(int argc __attribute__((unused)), char **argv) 8 | { 9 | succeed(basename(argv[0])); 10 | } 11 | -------------------------------------------------------------------------------- /objc4-779.1/test/gc.c: -------------------------------------------------------------------------------- 1 | int GC(void) { return 42; } 2 | -------------------------------------------------------------------------------- /objc4-779.1/test/gc.m: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | OBJC_ROOT_CLASS 4 | @interface GC @end 5 | @implementation GC @end 6 | 7 | // silence "no debug symbols in executable" warning 8 | void foo(void) { } 9 | -------------------------------------------------------------------------------- /objc4-779.1/test/gcenforcer-app-aso.m: -------------------------------------------------------------------------------- 1 | /* 2 | fixme disabled in BATS because of gcfiles 3 | TEST_CONFIG OS=macosx BATS=0 4 | 5 | TEST_BUILD 6 | cp $DIR/gcfiles/$C{ARCH}-aso gcenforcer-app-aso.exe 7 | END 8 | 9 | TEST_RUN_OUTPUT 10 | .*No Info\.plist file in application bundle or no NSPrincipalClass in the Info\.plist file, exiting 11 | END 12 | */ 13 | -------------------------------------------------------------------------------- /objc4-779.1/test/gcenforcer-app-gc.m: -------------------------------------------------------------------------------- 1 | /* 2 | fixme disabled in BATS because of gcfiles 3 | TEST_CONFIG OS=macosx BATS=0 4 | 5 | TEST_BUILD 6 | cp $DIR/gcfiles/$C{ARCH}-gc gcenforcer-app-gc.exe 7 | END 8 | 9 | TEST_CRASHES 10 | TEST_RUN_OUTPUT 11 | objc\[\d+\]: Objective-C garbage collection is no longer supported\. 12 | objc\[\d+\]: HALTED 13 | END 14 | */ 15 | -------------------------------------------------------------------------------- /objc4-779.1/test/gcenforcer-app-gcaso.m: -------------------------------------------------------------------------------- 1 | /* 2 | fixme disabled in BATS because of gcfiles 3 | TEST_CONFIG OS=macosx BATS=0 4 | 5 | TEST_BUILD 6 | cp $DIR/gcfiles/$C{ARCH}-gcaso gcenforcer-app-gcaso.exe 7 | END 8 | 9 | TEST_CRASHES 10 | TEST_RUN_OUTPUT 11 | objc\[\d+\]: Objective-C garbage collection is no longer supported\. 12 | objc\[\d+\]: HALTED 13 | END 14 | */ 15 | -------------------------------------------------------------------------------- /objc4-779.1/test/gcenforcer-app-gcaso2.m: -------------------------------------------------------------------------------- 1 | /* 2 | fixme disabled in BATS because of gcfiles 3 | TEST_CONFIG OS=macosx BATS=0 4 | 5 | TEST_BUILD 6 | cp $DIR/gcfiles/$C{ARCH}-gcaso2 gcenforcer-app-gcaso2.exe 7 | END 8 | 9 | TEST_CRASHES 10 | TEST_RUN_OUTPUT 11 | objc\[\d+\]: Objective-C garbage collection is no longer supported\. 12 | objc\[\d+\]: HALTED 13 | END 14 | */ 15 | -------------------------------------------------------------------------------- /objc4-779.1/test/gcenforcer-app-gconly.m: -------------------------------------------------------------------------------- 1 | /* 2 | fixme disabled in BATS because of gcfiles 3 | TEST_CONFIG OS=macosx BATS=0 4 | 5 | TEST_BUILD 6 | cp $DIR/gcfiles/$C{ARCH}-gconly gcenforcer-app-gconly.exe 7 | END 8 | 9 | TEST_CRASHES 10 | TEST_RUN_OUTPUT 11 | objc\[\d+\]: Objective-C garbage collection is no longer supported\. 12 | objc\[\d+\]: HALTED 13 | END 14 | */ 15 | -------------------------------------------------------------------------------- /objc4-779.1/test/gcenforcer-app-nogc.m: -------------------------------------------------------------------------------- 1 | /* 2 | fixme disabled in BATS because of gcfiles 3 | TEST_CONFIG OS=macosx BATS=0 4 | 5 | TEST_BUILD 6 | cp $DIR/gcfiles/$C{ARCH}-nogc gcenforcer-app-nogc.exe 7 | END 8 | 9 | TEST_RUN_OUTPUT 10 | running 11 | END 12 | */ 13 | -------------------------------------------------------------------------------- /objc4-779.1/test/gcenforcer-app-noobjc.m: -------------------------------------------------------------------------------- 1 | /* 2 | fixme disabled in BATS because of gcfiles 3 | TEST_CONFIG OS=macosx BATS=0 4 | 5 | TEST_BUILD 6 | cp $DIR/gcfiles/$C{ARCH}-noobjc gcenforcer-app-noobjc.exe 7 | END 8 | 9 | TEST_RUN_OUTPUT 10 | 11 | END 12 | */ 13 | -------------------------------------------------------------------------------- /objc4-779.1/test/gcenforcer-dylib-nogc.m: -------------------------------------------------------------------------------- 1 | // gc-off app loading gc-off dylib: should work 2 | 3 | /* 4 | fixme disabled in BATS because of gcfiles 5 | TEST_CONFIG OS=macosx BATS=0 6 | 7 | TEST_BUILD 8 | cp $DIR/gcfiles/libnogc.dylib . 9 | $C{COMPILE} $DIR/gc-main.m -x none libnogc.dylib -o gcenforcer-dylib-nogc.exe 10 | END 11 | */ 12 | -------------------------------------------------------------------------------- /objc4-779.1/test/gcenforcer-dylib-noobjc.m: -------------------------------------------------------------------------------- 1 | /* 2 | fixme disabled in BATS because of gcfiles 3 | TEST_CONFIG OS=macosx BATS=0 4 | 5 | TEST_BUILD 6 | cp $DIR/gcfiles/libnoobjc.dylib . 7 | $C{COMPILE} $DIR/gc-main.m -x none libnoobjc.dylib -o gcenforcer-dylib-noobjc.exe 8 | END 9 | */ 10 | -------------------------------------------------------------------------------- /objc4-779.1/test/gcenforcer-dylib-requiresgc.m: -------------------------------------------------------------------------------- 1 | // gc-off app loading gc-required dylib: should crash 2 | // linker sees librequiresgc.fake.dylib, runtime uses librequiresgc.dylib 3 | 4 | /* 5 | fixme disabled in BATS because of gcfiles 6 | TEST_CONFIG OS=macosx BATS=0 7 | TEST_CRASHES 8 | 9 | TEST_RUN_OUTPUT 10 | dyld: Library not loaded: librequiresgc\.dylib 11 | Referenced from: .*gcenforcer-dylib-requiresgc.exe 12 | Reason: no suitable image found\. Did find: 13 | (.*librequiresgc\.dylib: cannot load '.*librequiresgc\.dylib' because Objective-C garbage collection is not supported(\n)?)+ 14 | librequiresgc.dylib: cannot load 'librequiresgc\.dylib' because Objective-C garbage collection is not supported( 15 | .*librequiresgc\.dylib: cannot load '.*librequiresgc\.dylib' because Objective-C garbage collection is not supported(\n)?)* 16 | END 17 | 18 | TEST_BUILD 19 | cp $DIR/gcfiles/librequiresgc.dylib . 20 | $C{COMPILE} $DIR/gc-main.m -x none $DIR/gcfiles/librequiresgc.fake.dylib -o gcenforcer-dylib-requiresgc.exe 21 | END 22 | */ 23 | -------------------------------------------------------------------------------- /objc4-779.1/test/gcenforcer-dylib-supportsgc.m: -------------------------------------------------------------------------------- 1 | /* 2 | fixme disabled in BATS because of gcfiles 3 | TEST_CONFIG OS=macosx BATS=0 4 | 5 | TEST_BUILD 6 | cp $DIR/gcfiles/libsupportsgc.dylib . 7 | $C{COMPILE} $DIR/gc-main.m -x none libsupportsgc.dylib -o gcenforcer-dylib-supportsgc.exe 8 | END 9 | */ 10 | -------------------------------------------------------------------------------- /objc4-779.1/test/gcfiles/evil1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DeveloperErenLiu/RuntimeAnalyze/acb7f2ce0dab8b88c759f1019a60dc3e69917b14/objc4-779.1/test/gcfiles/evil1 -------------------------------------------------------------------------------- /objc4-779.1/test/gcfiles/i386-aso: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DeveloperErenLiu/RuntimeAnalyze/acb7f2ce0dab8b88c759f1019a60dc3e69917b14/objc4-779.1/test/gcfiles/i386-aso -------------------------------------------------------------------------------- /objc4-779.1/test/gcfiles/i386-aso--x86_64-aso: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DeveloperErenLiu/RuntimeAnalyze/acb7f2ce0dab8b88c759f1019a60dc3e69917b14/objc4-779.1/test/gcfiles/i386-aso--x86_64-aso -------------------------------------------------------------------------------- /objc4-779.1/test/gcfiles/i386-broken: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DeveloperErenLiu/RuntimeAnalyze/acb7f2ce0dab8b88c759f1019a60dc3e69917b14/objc4-779.1/test/gcfiles/i386-broken -------------------------------------------------------------------------------- /objc4-779.1/test/gcfiles/i386-broken--x86_64-gc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DeveloperErenLiu/RuntimeAnalyze/acb7f2ce0dab8b88c759f1019a60dc3e69917b14/objc4-779.1/test/gcfiles/i386-broken--x86_64-gc -------------------------------------------------------------------------------- /objc4-779.1/test/gcfiles/i386-broken--x86_64-nogc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DeveloperErenLiu/RuntimeAnalyze/acb7f2ce0dab8b88c759f1019a60dc3e69917b14/objc4-779.1/test/gcfiles/i386-broken--x86_64-nogc -------------------------------------------------------------------------------- /objc4-779.1/test/gcfiles/i386-gc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DeveloperErenLiu/RuntimeAnalyze/acb7f2ce0dab8b88c759f1019a60dc3e69917b14/objc4-779.1/test/gcfiles/i386-gc -------------------------------------------------------------------------------- /objc4-779.1/test/gcfiles/i386-gc--x86_64-broken: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DeveloperErenLiu/RuntimeAnalyze/acb7f2ce0dab8b88c759f1019a60dc3e69917b14/objc4-779.1/test/gcfiles/i386-gc--x86_64-broken -------------------------------------------------------------------------------- /objc4-779.1/test/gcfiles/i386-gc--x86_64-gc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DeveloperErenLiu/RuntimeAnalyze/acb7f2ce0dab8b88c759f1019a60dc3e69917b14/objc4-779.1/test/gcfiles/i386-gc--x86_64-gc -------------------------------------------------------------------------------- /objc4-779.1/test/gcfiles/i386-gc--x86_64-nogc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DeveloperErenLiu/RuntimeAnalyze/acb7f2ce0dab8b88c759f1019a60dc3e69917b14/objc4-779.1/test/gcfiles/i386-gc--x86_64-nogc -------------------------------------------------------------------------------- /objc4-779.1/test/gcfiles/i386-gcaso: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DeveloperErenLiu/RuntimeAnalyze/acb7f2ce0dab8b88c759f1019a60dc3e69917b14/objc4-779.1/test/gcfiles/i386-gcaso -------------------------------------------------------------------------------- /objc4-779.1/test/gcfiles/i386-gcaso2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DeveloperErenLiu/RuntimeAnalyze/acb7f2ce0dab8b88c759f1019a60dc3e69917b14/objc4-779.1/test/gcfiles/i386-gcaso2 -------------------------------------------------------------------------------- /objc4-779.1/test/gcfiles/i386-gconly: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DeveloperErenLiu/RuntimeAnalyze/acb7f2ce0dab8b88c759f1019a60dc3e69917b14/objc4-779.1/test/gcfiles/i386-gconly -------------------------------------------------------------------------------- /objc4-779.1/test/gcfiles/i386-nogc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DeveloperErenLiu/RuntimeAnalyze/acb7f2ce0dab8b88c759f1019a60dc3e69917b14/objc4-779.1/test/gcfiles/i386-nogc -------------------------------------------------------------------------------- /objc4-779.1/test/gcfiles/i386-nogc--x86_64-broken: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DeveloperErenLiu/RuntimeAnalyze/acb7f2ce0dab8b88c759f1019a60dc3e69917b14/objc4-779.1/test/gcfiles/i386-nogc--x86_64-broken -------------------------------------------------------------------------------- /objc4-779.1/test/gcfiles/i386-nogc--x86_64-gc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DeveloperErenLiu/RuntimeAnalyze/acb7f2ce0dab8b88c759f1019a60dc3e69917b14/objc4-779.1/test/gcfiles/i386-nogc--x86_64-gc -------------------------------------------------------------------------------- /objc4-779.1/test/gcfiles/i386-nogc--x86_64-nogc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DeveloperErenLiu/RuntimeAnalyze/acb7f2ce0dab8b88c759f1019a60dc3e69917b14/objc4-779.1/test/gcfiles/i386-nogc--x86_64-nogc -------------------------------------------------------------------------------- /objc4-779.1/test/gcfiles/i386-noobjc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DeveloperErenLiu/RuntimeAnalyze/acb7f2ce0dab8b88c759f1019a60dc3e69917b14/objc4-779.1/test/gcfiles/i386-noobjc -------------------------------------------------------------------------------- /objc4-779.1/test/gcfiles/libnogc.dylib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DeveloperErenLiu/RuntimeAnalyze/acb7f2ce0dab8b88c759f1019a60dc3e69917b14/objc4-779.1/test/gcfiles/libnogc.dylib -------------------------------------------------------------------------------- /objc4-779.1/test/gcfiles/libnoobjc.dylib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DeveloperErenLiu/RuntimeAnalyze/acb7f2ce0dab8b88c759f1019a60dc3e69917b14/objc4-779.1/test/gcfiles/libnoobjc.dylib -------------------------------------------------------------------------------- /objc4-779.1/test/gcfiles/librequiresgc.dylib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DeveloperErenLiu/RuntimeAnalyze/acb7f2ce0dab8b88c759f1019a60dc3e69917b14/objc4-779.1/test/gcfiles/librequiresgc.dylib -------------------------------------------------------------------------------- /objc4-779.1/test/gcfiles/librequiresgc.fake.dylib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DeveloperErenLiu/RuntimeAnalyze/acb7f2ce0dab8b88c759f1019a60dc3e69917b14/objc4-779.1/test/gcfiles/librequiresgc.fake.dylib -------------------------------------------------------------------------------- /objc4-779.1/test/gcfiles/libsupportsgc.dylib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DeveloperErenLiu/RuntimeAnalyze/acb7f2ce0dab8b88c759f1019a60dc3e69917b14/objc4-779.1/test/gcfiles/libsupportsgc.dylib -------------------------------------------------------------------------------- /objc4-779.1/test/gcfiles/x86_64-aso: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DeveloperErenLiu/RuntimeAnalyze/acb7f2ce0dab8b88c759f1019a60dc3e69917b14/objc4-779.1/test/gcfiles/x86_64-aso -------------------------------------------------------------------------------- /objc4-779.1/test/gcfiles/x86_64-broken: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DeveloperErenLiu/RuntimeAnalyze/acb7f2ce0dab8b88c759f1019a60dc3e69917b14/objc4-779.1/test/gcfiles/x86_64-broken -------------------------------------------------------------------------------- /objc4-779.1/test/gcfiles/x86_64-gc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DeveloperErenLiu/RuntimeAnalyze/acb7f2ce0dab8b88c759f1019a60dc3e69917b14/objc4-779.1/test/gcfiles/x86_64-gc -------------------------------------------------------------------------------- /objc4-779.1/test/gcfiles/x86_64-gcaso: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DeveloperErenLiu/RuntimeAnalyze/acb7f2ce0dab8b88c759f1019a60dc3e69917b14/objc4-779.1/test/gcfiles/x86_64-gcaso -------------------------------------------------------------------------------- /objc4-779.1/test/gcfiles/x86_64-gcaso2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DeveloperErenLiu/RuntimeAnalyze/acb7f2ce0dab8b88c759f1019a60dc3e69917b14/objc4-779.1/test/gcfiles/x86_64-gcaso2 -------------------------------------------------------------------------------- /objc4-779.1/test/gcfiles/x86_64-gconly: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DeveloperErenLiu/RuntimeAnalyze/acb7f2ce0dab8b88c759f1019a60dc3e69917b14/objc4-779.1/test/gcfiles/x86_64-gconly -------------------------------------------------------------------------------- /objc4-779.1/test/gcfiles/x86_64-nogc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DeveloperErenLiu/RuntimeAnalyze/acb7f2ce0dab8b88c759f1019a60dc3e69917b14/objc4-779.1/test/gcfiles/x86_64-nogc -------------------------------------------------------------------------------- /objc4-779.1/test/gcfiles/x86_64-noobjc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DeveloperErenLiu/RuntimeAnalyze/acb7f2ce0dab8b88c759f1019a60dc3e69917b14/objc4-779.1/test/gcfiles/x86_64-noobjc -------------------------------------------------------------------------------- /objc4-779.1/test/gdb.m: -------------------------------------------------------------------------------- 1 | // TEST_CFLAGS -Wno-deprecated-declarations 2 | 3 | #include "test.h" 4 | #include "testroot.i" 5 | #include 6 | #include 7 | 8 | #define SwiftV1MangledName4 "_TtC6Swiftt13SwiftV1Class4" 9 | __attribute__((objc_runtime_name(SwiftV1MangledName4))) 10 | @interface SwiftV1Class4 : TestRoot @end 11 | @implementation SwiftV1Class4 @end 12 | 13 | int main() 14 | { 15 | // Class hashes 16 | Class result; 17 | 18 | // Class should not be realized yet 19 | // fixme not true during class hash rearrangement 20 | // result = NXMapGet(gdb_objc_realized_classes, "TestRoot"); 21 | // testassert(!result); 22 | 23 | [TestRoot class]; 24 | // Now class should be realized 25 | 26 | result = (__bridge Class)(NXMapGet(gdb_objc_realized_classes, "TestRoot")); 27 | testassert(result); 28 | testassert(result == [TestRoot class]); 29 | 30 | result = (__bridge Class)(NXMapGet(gdb_objc_realized_classes, "DoesNotExist")); 31 | testassert(!result); 32 | 33 | // Class structure decoding 34 | 35 | uintptr_t *maskp = (uintptr_t *)dlsym(RTLD_DEFAULT, "objc_debug_class_rw_data_mask"); 36 | testassert(maskp); 37 | 38 | // Raw class names 39 | testassert(strcmp(objc_debug_class_getNameRaw([SwiftV1Class4 class]), SwiftV1MangledName4) == 0); 40 | testassert(strcmp(objc_debug_class_getNameRaw([TestRoot class]), "TestRoot") == 0); 41 | 42 | 43 | succeed(__FILE__); 44 | } 45 | -------------------------------------------------------------------------------- /objc4-779.1/test/get_task_allow_entitlement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | get-task-allow 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /objc4-779.1/test/headers.c: -------------------------------------------------------------------------------- 1 | /* 2 | TEST_BUILD 3 | $DIR/headers.sh '$C{TESTINCLUDEDIR}' '$C{TESTLOCALINCLUDEDIR}' '$C{COMPILE_C}' '$C{COMPILE_CXX}' '$C{COMPILE_M}' '$C{COMPILE_MM}' '$VERBOSE' 4 | $C{COMPILE_C} $DIR/headers.c -o headers.exe 5 | END 6 | 7 | allow `sh -x` output from headers.sh 8 | TEST_BUILD_OUTPUT 9 | (\+ .*\n)*(\+ .*)?done 10 | END 11 | */ 12 | 13 | 14 | #include "test.h" 15 | 16 | int main() 17 | { 18 | succeed(__FILE__); 19 | } 20 | -------------------------------------------------------------------------------- /objc4-779.1/test/headers.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # Compile every exported ObjC header as if it were a file in every language. 4 | # This script is executed by test headers.c's TEST_BUILD command. 5 | 6 | TESTINCLUDEDIR=$1; shift 7 | TESTLOCALINCLUDEDIR=$1; shift 8 | COMPILE_C=$1; shift 9 | COMPILE_CXX=$1; shift 10 | COMPILE_M=$1; shift 11 | COMPILE_MM=$1; shift 12 | VERBOSE=$1; shift 13 | 14 | # stop after any command error 15 | set -e 16 | 17 | # echo commands when verbose 18 | if [ "$VERBOSE" != "0" ]; then 19 | set -x 20 | fi 21 | 22 | FILES="$TESTINCLUDEDIR/objc/*.h $TESTLOCALINCLUDEDIR/objc/*.h" 23 | CFLAGS='-fsyntax-only -Wno-unused-function -D_OBJC_PRIVATE_H_' 24 | 25 | $COMPILE_C $CFLAGS $FILES 26 | $COMPILE_CXX $CFLAGS $FILES 27 | $COMPILE_M $CFLAGS $FILES 28 | $COMPILE_MM $CFLAGS $FILES 29 | for STDC in '99' '11' ; do 30 | $COMPILE_C $CFLAGS $FILES -std=c$STDC 31 | $COMPILE_M $CFLAGS $FILES -std=c$STDC 32 | done 33 | for STDCXX in '98' '03' '11' '14' '17' ; do 34 | $COMPILE_CXX $CFLAGS $FILES -std=c++$STDCXX 35 | $COMPILE_MM $CFLAGS $FILES -std=c++$STDCXX 36 | done 37 | 38 | echo done 39 | -------------------------------------------------------------------------------- /objc4-779.1/test/imageorder.h: -------------------------------------------------------------------------------- 1 | extern int state; 2 | extern int cstate; 3 | 4 | OBJC_ROOT_CLASS 5 | @interface Super { id isa; } 6 | +(void) method; 7 | +(void) method0; 8 | @end 9 | 10 | @interface Super (cat1) 11 | +(void) method1; 12 | @end 13 | 14 | @interface Super (cat2) 15 | +(void) method2; 16 | @end 17 | 18 | @interface Super (cat3) 19 | +(void) method3; 20 | @end 21 | -------------------------------------------------------------------------------- /objc4-779.1/test/imageorder.m: -------------------------------------------------------------------------------- 1 | /* 2 | TEST_BUILD 3 | $C{COMPILE} $DIR/imageorder1.m -o imageorder1.dylib -dynamiclib 4 | $C{COMPILE} $DIR/imageorder2.m -x none imageorder1.dylib -o imageorder2.dylib -dynamiclib 5 | $C{COMPILE} $DIR/imageorder3.m -x none imageorder2.dylib imageorder1.dylib -o imageorder3.dylib -dynamiclib 6 | $C{COMPILE} $DIR/imageorder.m -x none imageorder3.dylib imageorder2.dylib imageorder1.dylib -o imageorder.exe 7 | END 8 | */ 9 | 10 | #include "test.h" 11 | #include "imageorder.h" 12 | #include 13 | #include 14 | 15 | int main() 16 | { 17 | // +load methods and C static initializers 18 | testassert(state == 3); 19 | testassert(cstate == 3); 20 | 21 | Class cls = objc_getClass("Super"); 22 | testassert(cls); 23 | 24 | // make sure all categories arrived 25 | state = -1; 26 | [Super method0]; 27 | testassert(state == 0); 28 | [Super method1]; 29 | testassert(state == 1); 30 | [Super method2]; 31 | testassert(state == 2); 32 | [Super method3]; 33 | testassert(state == 3); 34 | 35 | // make sure imageorder3.dylib is the last category to attach 36 | state = 0; 37 | [Super method]; 38 | testassert(state == 3); 39 | 40 | succeed(__FILE__); 41 | } 42 | -------------------------------------------------------------------------------- /objc4-779.1/test/imageorder1.m: -------------------------------------------------------------------------------- 1 | #include "test.h" 2 | #include "imageorder.h" 3 | 4 | int state = -1; 5 | int cstate = 0; 6 | 7 | static void c1(void) __attribute__((constructor)); 8 | static void c1(void) 9 | { 10 | testassert(state == 1); // +load before C/C++ 11 | testassert(cstate == 0); 12 | cstate = 1; 13 | } 14 | 15 | 16 | #if __clang__ 17 | #pragma clang diagnostic push 18 | #pragma clang diagnostic ignored "-Wobjc-protocol-method-implementation" 19 | #endif 20 | 21 | @implementation Super (cat1) 22 | +(void) method { 23 | fail("+[Super(cat1) method] not replaced!"); 24 | } 25 | +(void) method1 { 26 | state = 1; 27 | } 28 | +(void) load { 29 | testassert(state == 0); 30 | state = 1; 31 | } 32 | @end 33 | 34 | #if __clang__ 35 | #pragma clang diagnostic pop 36 | #endif 37 | 38 | 39 | @implementation Super 40 | +(void) initialize { } 41 | +(void) method { 42 | fail("+[Super method] not replaced!"); 43 | } 44 | +(void) method0 { 45 | state = 0; 46 | } 47 | +(void) load { 48 | testassert(state == -1); 49 | state = 0; 50 | } 51 | @end 52 | 53 | -------------------------------------------------------------------------------- /objc4-779.1/test/imageorder2.m: -------------------------------------------------------------------------------- 1 | #include "test.h" 2 | #include "imageorder.h" 3 | 4 | static void c2(void) __attribute__((constructor)); 5 | static void c2(void) 6 | { 7 | testassert(state == 2); // +load before C/C++ 8 | testassert(cstate == 1); 9 | cstate = 2; 10 | } 11 | 12 | 13 | #if __clang__ 14 | #pragma clang diagnostic push 15 | #pragma clang diagnostic ignored "-Wobjc-protocol-method-implementation" 16 | #endif 17 | 18 | @implementation Super (cat2) 19 | +(void) method { 20 | fail("+[Super(cat2) method] not replaced!"); 21 | } 22 | +(void) method2 { 23 | state = 2; 24 | } 25 | +(void) load { 26 | testassert(state == 1); 27 | state = 2; 28 | } 29 | @end 30 | 31 | #if __clang__ 32 | #pragma clang diagnostic pop 33 | #endif 34 | -------------------------------------------------------------------------------- /objc4-779.1/test/imageorder3.m: -------------------------------------------------------------------------------- 1 | #include "test.h" 2 | #include "imageorder.h" 3 | 4 | static void c3(void) __attribute__((constructor)); 5 | static void c3(void) 6 | { 7 | testassert(state == 3); // +load before C/C++ 8 | testassert(cstate == 2); 9 | cstate = 3; 10 | } 11 | 12 | 13 | #if __clang__ 14 | #pragma clang diagnostic push 15 | #pragma clang diagnostic ignored "-Wobjc-protocol-method-implementation" 16 | #endif 17 | 18 | @implementation Super (cat3) 19 | +(void) method { 20 | state = 3; 21 | } 22 | +(void) method3 { 23 | state = 3; 24 | } 25 | +(void) load { 26 | testassert(state == 2); 27 | state = 3; 28 | } 29 | @end 30 | 31 | #if __clang__ 32 | #pragma clang diagnostic pop 33 | #endif 34 | -------------------------------------------------------------------------------- /objc4-779.1/test/imports.c: -------------------------------------------------------------------------------- 1 | /* 2 | Disallow some imports into and exports from libobjc.A.dylib. 3 | 4 | To debug, re-run libobjc's link command with 5 | -Xlinker -dead_strip -Xlinker -why_live -Xlinker SYMBOL_NAME_HERE 6 | 7 | Disallowed imports (nm -u): 8 | ___cxa_guard_acquire (C++ function-scope static initializer) 9 | ___cxa_guard_release (C++ function-scope static initializer) 10 | ___cxa_atexit (C++ static destructor) 11 | weak external (any weak externals, including operators new and delete) 12 | 13 | Whitelisted imports: 14 | weak external ____chkstk_darwin (from libSystem) 15 | 16 | Disallowed exports (nm -U): 17 | __Z* (any C++-mangled export) 18 | weak external (any weak externals, including operators new and delete) 19 | 20 | fixme rdar://13354718 should disallow anything from libc++ (i.e. not libc++abi) 21 | */ 22 | 23 | /* 24 | TEST_BUILD 25 | echo $C{XCRUN} nm -m -arch $C{ARCH} $C{TESTLIB} 26 | $C{XCRUN} nm -u -m -arch $C{ARCH} $C{TESTLIB} | grep -v 'weak external ____chkstk_darwin \(from libSystem\)' | egrep '(weak external| external (___cxa_atexit|___cxa_guard_acquire|___cxa_guard_release))' || true 27 | $C{XCRUN} nm -U -m -arch $C{ARCH} $C{TESTLIB} | egrep '(weak external| external __Z)' || true 28 | $C{COMPILE_C} $DIR/imports.c -o imports.exe 29 | END 30 | 31 | TEST_BUILD_OUTPUT 32 | .*libobjc.A.dylib 33 | END 34 | */ 35 | 36 | #include "test.h" 37 | int main() 38 | { 39 | succeed(__FILE__); 40 | } 41 | -------------------------------------------------------------------------------- /objc4-779.1/test/include-warnings.c: -------------------------------------------------------------------------------- 1 | /* 2 | TEST_BUILD 3 | $C{COMPILE} $DIR/include-warnings.c -o include-warnings.exe -Wsystem-headers -Weverything -Wno-undef -Wno-old-style-cast -Wno-nullability-extension -Wno-c++98-compat 2>&1 | grep -v 'In file' | grep objc || true 4 | END 5 | 6 | TEST_RUN_OUTPUT 7 | OK: includes.c 8 | END 9 | */ 10 | 11 | // Detect warnings inside any header. 12 | // The build command above filters out warnings inside non-objc headers 13 | // (which are noisy with -Weverything). 14 | // -Wno-undef suppresses warnings about `#if __cplusplus` and the like. 15 | // -Wno-old-style-cast is tough to avoid in mixed C/C++ code. 16 | // -Wno-nullability-extension disables a warning about non-portable 17 | // _Nullable etc which we already handle correctly in objc-abi.h. 18 | // -Wno-c++98-compat disables warnings about things that already 19 | // have guards against C++98. 20 | 21 | #include "includes.c" 22 | -------------------------------------------------------------------------------- /objc4-779.1/test/includes-objc2.c: -------------------------------------------------------------------------------- 1 | // TEST_CFLAGS -D__OBJC2__ 2 | 3 | // Verify that all headers can be included in any language, even if 4 | // the client is C code that defined __OBJC2__. 5 | 6 | // This is the definition that Instruments uses in its build. 7 | #if defined(__OBJC2__) 8 | #undef __OBJC2__ 9 | #endif 10 | #define __OBJC2__ 1 11 | 12 | #define NAME "includes-objc2.c" 13 | #include "includes.c" 14 | -------------------------------------------------------------------------------- /objc4-779.1/test/includes.c: -------------------------------------------------------------------------------- 1 | // TEST_CONFIG 2 | 3 | // Verify that all headers can be included in any language. 4 | // See also test/include-warnings.c which checks for warnings in these headers. 5 | // See also test/includes-objc2.c which checks for safety even if 6 | // the client is C code that defined __OBJC2__. 7 | 8 | #ifndef NAME 9 | #define NAME "includes.c" 10 | #endif 11 | 12 | #include 13 | 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | 29 | #include 30 | #include 31 | #include 32 | 33 | #if TARGET_OS_OSX 34 | #include 35 | #include 36 | #include 37 | #endif 38 | 39 | #pragma clang diagnostic push 40 | #pragma clang diagnostic ignored "-Weverything" 41 | #include "test.h" 42 | #pragma clang diagnostic pop 43 | 44 | int main() 45 | { 46 | succeed(NAME); 47 | } 48 | -------------------------------------------------------------------------------- /objc4-779.1/test/instanceSize.m: -------------------------------------------------------------------------------- 1 | // TEST_CONFIG 2 | 3 | #include "test.h" 4 | #include "testroot.i" 5 | #include 6 | 7 | 8 | @interface Sub1 : TestRoot { 9 | // id isa; // 0..4 10 | BOOL b; // 4..5 11 | } 12 | @end 13 | 14 | @implementation Sub1 @end 15 | 16 | @interface Sub2 : Sub1 { 17 | // id isa // 0..4 0..8 18 | // BOOL b // 4..5 8..9 19 | BOOL b2; // 5..6 9..10 20 | id o; // 8..12 16..24 21 | } 22 | @end 23 | @implementation Sub2 @end 24 | 25 | @interface Sub3 : Sub1 { 26 | // id isa; // 0..4 0..8 27 | // BOOL b; // 4..5 8..9 28 | id o; // 8..12 16..24 29 | BOOL b2; // 12..13 24..25 30 | } 31 | @end 32 | @implementation Sub3 @end 33 | 34 | int main() 35 | { 36 | testassert(sizeof(id) == class_getInstanceSize([TestRoot class])); 37 | testassert(2*sizeof(id) == class_getInstanceSize([Sub1 class])); 38 | testassert(3*sizeof(id) == class_getInstanceSize([Sub2 class])); 39 | testassert(4*sizeof(id) == class_getInstanceSize([Sub3 class])); 40 | 41 | #if !__has_feature(objc_arc) 42 | id o; 43 | 44 | o = [TestRoot new]; 45 | testassert(object_getIndexedIvars(o) == (char *)o + class_getInstanceSize(object_getClass(o))); 46 | RELEASE_VAR(o); 47 | o = [Sub1 new]; 48 | testassert(object_getIndexedIvars(o) == (char *)o + class_getInstanceSize(object_getClass(o))); 49 | RELEASE_VAR(o); 50 | o = [Sub2 new]; 51 | testassert(object_getIndexedIvars(o) == (char *)o + class_getInstanceSize(object_getClass(o))); 52 | RELEASE_VAR(o); 53 | o = [Sub3 new]; 54 | testassert(object_getIndexedIvars(o) == (char *)o + class_getInstanceSize(object_getClass(o))); 55 | RELEASE_VAR(o); 56 | #endif 57 | 58 | succeed(__FILE__); 59 | } 60 | -------------------------------------------------------------------------------- /objc4-779.1/test/ismeta.m: -------------------------------------------------------------------------------- 1 | // TEST_CONFIG 2 | 3 | #include "test.h" 4 | #include "testroot.i" 5 | #include 6 | 7 | int main() 8 | { 9 | testassert(!class_isMetaClass([TestRoot class])); 10 | testassert(class_isMetaClass(object_getClass([TestRoot class]))); 11 | testassert(!class_isMetaClass(nil)); 12 | succeed(__FILE__); 13 | } 14 | -------------------------------------------------------------------------------- /objc4-779.1/test/ivarSlide.h: -------------------------------------------------------------------------------- 1 | @interface Super : TestRoot { 2 | @public 3 | #if OLD 4 | // nothing 5 | #else 6 | char superIvar; 7 | #endif 8 | } 9 | @end 10 | 11 | 12 | @interface ShrinkingSuper : TestRoot { 13 | @public 14 | #if OLD 15 | id superIvar[5]; 16 | __weak id superIvar2[5]; 17 | #else 18 | // nothing 19 | #endif 20 | } 21 | @end; 22 | 23 | 24 | @interface MoreStrongSuper : TestRoot { 25 | @public 26 | #if OLD 27 | void *superIvar; 28 | #else 29 | id superIvar; 30 | #endif 31 | } 32 | @end; 33 | 34 | 35 | @interface MoreWeakSuper : TestRoot { 36 | @public 37 | #if OLD 38 | id superIvar; 39 | #else 40 | __weak id superIvar; 41 | #endif 42 | } 43 | @end; 44 | 45 | @interface MoreWeak2Super : TestRoot { 46 | @public 47 | #if OLD 48 | void *superIvar; 49 | #else 50 | __weak id superIvar; 51 | #endif 52 | } 53 | @end; 54 | 55 | @interface LessStrongSuper : TestRoot { 56 | @public 57 | #if OLD 58 | id superIvar; 59 | #else 60 | void *superIvar; 61 | #endif 62 | } 63 | @end; 64 | 65 | @interface LessWeakSuper : TestRoot { 66 | @public 67 | #if OLD 68 | __weak id superIvar; 69 | #else 70 | id superIvar; 71 | #endif 72 | } 73 | @end; 74 | 75 | @interface LessWeak2Super : TestRoot { 76 | @public 77 | #if OLD 78 | __weak id superIvar; 79 | #else 80 | void *superIvar; 81 | #endif 82 | } 83 | @end; 84 | 85 | @interface NoGCChangeSuper : TestRoot { 86 | @public 87 | intptr_t d; 88 | char superc1; 89 | #if OLD 90 | // nothing 91 | #else 92 | char superc2; 93 | #endif 94 | } 95 | @end 96 | 97 | @interface RunsOf15 : TestRoot { 98 | @public 99 | id scan1; 100 | intptr_t skip15[15]; 101 | id scan15[15]; 102 | intptr_t skip15_2[15]; 103 | id scan15_2[15]; 104 | #if OLD 105 | // nothing 106 | #else 107 | intptr_t skip1; 108 | #endif 109 | } 110 | @end 111 | -------------------------------------------------------------------------------- /objc4-779.1/test/ivarSlide1.m: -------------------------------------------------------------------------------- 1 | #include "test.h" 2 | #include 3 | #include 4 | 5 | #define OLD 0 6 | #include "ivarSlide.h" 7 | 8 | #include "testroot.i" 9 | 10 | @implementation Super @end 11 | 12 | @implementation ShrinkingSuper @end 13 | 14 | @implementation MoreStrongSuper @end 15 | @implementation LessStrongSuper @end 16 | @implementation MoreWeakSuper @end 17 | @implementation MoreWeak2Super @end 18 | @implementation LessWeakSuper @end 19 | @implementation LessWeak2Super @end 20 | @implementation NoGCChangeSuper @end 21 | @implementation RunsOf15 @end 22 | -------------------------------------------------------------------------------- /objc4-779.1/test/literals.m: -------------------------------------------------------------------------------- 1 | // TEST_CFLAGS -framework Foundation 2 | 3 | #import 4 | #import 5 | #import 6 | #import 7 | #import 8 | #include "test.h" 9 | 10 | int main() { 11 | PUSH_POOL { 12 | 13 | #if __has_feature(objc_bool) // placeholder until we get a more precise macro. 14 | NSArray *array = @[ @1, @2, @YES, @NO, @"Hello", @"World" ]; 15 | testassert([array count] == 6); 16 | NSDictionary *dict = @{ @"Name" : @"John Q. Public", @"Age" : @42 }; 17 | testassert([dict count] == 2); 18 | NSDictionary *numbers = @{ @"π" : @M_PI, @"e" : @M_E }; 19 | testassert([[numbers objectForKey:@"π"] doubleValue] == M_PI); 20 | testassert([[numbers objectForKey:@"e"] doubleValue] == M_E); 21 | 22 | BOOL yesBool = YES; 23 | BOOL noBool = NO; 24 | array = @[ 25 | @(true), 26 | @(YES), 27 | [NSNumber numberWithBool:YES], 28 | @YES, 29 | @(yesBool), 30 | @((BOOL)YES), 31 | 32 | @(false), 33 | @(NO), 34 | [NSNumber numberWithBool:NO], 35 | @NO, 36 | @(noBool), 37 | @((BOOL)NO), 38 | ]; 39 | NSData * jsonData = [NSJSONSerialization dataWithJSONObject:array options:0 error:nil]; 40 | NSString * string = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding]; 41 | #if __cplusplus 42 | testassert([string isEqualToString:@"[true,true,true,true,true,true,false,false,false,false,false,false]"]); 43 | #else 44 | // C99 @(true) and @(false) evaluate to @(1) and @(0). 45 | testassert([string isEqualToString:@"[1,true,true,true,true,true,0,false,false,false,false,false]"]); 46 | #endif 47 | 48 | #endif 49 | 50 | } POP_POOL; 51 | 52 | succeed(__FILE__); 53 | 54 | return 0; 55 | } 56 | -------------------------------------------------------------------------------- /objc4-779.1/test/load-image-notification-dylib.m: -------------------------------------------------------------------------------- 1 | #import "test.h" 2 | 3 | #import 4 | 5 | @interface CLASSNAME: NSObject @end 6 | @implementation CLASSNAME @end 7 | 8 | -------------------------------------------------------------------------------- /objc4-779.1/test/load-noobjc.m: -------------------------------------------------------------------------------- 1 | /* 2 | TEST_BUILD 3 | $C{COMPILE} $DIR/load-noobjc.m -o load-noobjc.exe 4 | $C{COMPILE} $DIR/load-noobjc2.m -o libload-noobjc2.dylib -bundle -bundle_loader load-noobjc.exe 5 | $C{COMPILE} $DIR/load-noobjc3.m -o libload-noobjc3.dylib -bundle -bundle_loader load-noobjc.exe 6 | END 7 | */ 8 | 9 | #include "test.h" 10 | #include 11 | 12 | int state = 0; 13 | semaphore_t go; 14 | 15 | void *thread(void *arg __unused) 16 | { 17 | dlopen("libload-noobjc2.dylib", RTLD_LAZY); 18 | fail("dlopen should not have returned"); 19 | } 20 | 21 | int main() 22 | { 23 | semaphore_create(mach_task_self(), &go, SYNC_POLICY_FIFO, 0); 24 | 25 | pthread_t th; 26 | pthread_create(&th, nil, &thread, nil); 27 | 28 | // Wait for thread to stop in libload-noobjc2's +load method. 29 | semaphore_wait(go); 30 | 31 | // run nooobjc3's constructor function. 32 | // There's no objc code here so it shouldn't require the +load lock. 33 | void *dlh = dlopen("libload-noobjc3.dylib", RTLD_LAZY); 34 | testassert(dlh); 35 | testassert(state == 1); 36 | 37 | succeed(__FILE__); 38 | } 39 | -------------------------------------------------------------------------------- /objc4-779.1/test/load-noobjc2.m: -------------------------------------------------------------------------------- 1 | #include "test.h" 2 | 3 | extern semaphore_t go; 4 | 5 | OBJC_ROOT_CLASS 6 | @interface noobjc @end 7 | @implementation noobjc 8 | +(void)load 9 | { 10 | semaphore_signal(go); 11 | while (1) sleep(1); 12 | } 13 | @end 14 | -------------------------------------------------------------------------------- /objc4-779.1/test/load-noobjc3.m: -------------------------------------------------------------------------------- 1 | #include "test.h" 2 | 3 | extern int state; 4 | 5 | __attribute__((constructor)) 6 | static void ctor(void) 7 | { 8 | state = 1; 9 | } 10 | -------------------------------------------------------------------------------- /objc4-779.1/test/load-order.m: -------------------------------------------------------------------------------- 1 | /* 2 | TEST_BUILD 3 | $C{COMPILE} $DIR/load-order3.m -o load-order3.dylib -dynamiclib 4 | $C{COMPILE} $DIR/load-order2.m -o load-order2.dylib -x none load-order3.dylib -dynamiclib 5 | $C{COMPILE} $DIR/load-order1.m -o load-order1.dylib -x none load-order3.dylib load-order2.dylib -dynamiclib 6 | $C{COMPILE} $DIR/load-order.m -o load-order.exe -x none load-order3.dylib load-order2.dylib load-order1.dylib 7 | END 8 | */ 9 | 10 | #include "test.h" 11 | 12 | extern int state1, state2, state3; 13 | 14 | int main() 15 | { 16 | testassert(state1 == 1 && state2 == 2 && state3 == 3); 17 | succeed(__FILE__); 18 | } 19 | -------------------------------------------------------------------------------- /objc4-779.1/test/load-order1.m: -------------------------------------------------------------------------------- 1 | #include "test.h" 2 | 3 | extern int state2, state3; 4 | 5 | int state1 = 0; 6 | 7 | OBJC_ROOT_CLASS 8 | @interface One @end 9 | @implementation One 10 | +(void)load 11 | { 12 | testassert(state2 == 2 && state3 == 3); 13 | state1 = 1; 14 | } 15 | @end 16 | -------------------------------------------------------------------------------- /objc4-779.1/test/load-order2.m: -------------------------------------------------------------------------------- 1 | #include "test.h" 2 | 3 | extern int state3; 4 | 5 | int state2 = 0; 6 | 7 | OBJC_ROOT_CLASS 8 | @interface Two @end 9 | @implementation Two 10 | +(void)load 11 | { 12 | testassert(state3 == 3); 13 | state2 = 2; 14 | } 15 | @end 16 | -------------------------------------------------------------------------------- /objc4-779.1/test/load-order3.m: -------------------------------------------------------------------------------- 1 | #include "test.h" 2 | 3 | int state3 = 0; 4 | 5 | OBJC_ROOT_CLASS 6 | @interface Three @end 7 | @implementation Three 8 | +(void)load 9 | { 10 | state3 = 3; 11 | } 12 | @end 13 | -------------------------------------------------------------------------------- /objc4-779.1/test/load-parallel.m: -------------------------------------------------------------------------------- 1 | /* 2 | TEST_BUILD 3 | $C{COMPILE} $DIR/load-parallel00.m -o load-parallel00.dylib -dynamiclib 4 | $C{COMPILE} $DIR/load-parallel.m -x none load-parallel00.dylib -o load-parallel.exe -DCOUNT=10 5 | 6 | $C{COMPILE} $DIR/load-parallel0.m -x none load-parallel00.dylib -o load-parallel0.dylib -dynamiclib -DN=0 7 | $C{COMPILE} $DIR/load-parallel0.m -x none load-parallel00.dylib -o load-parallel1.dylib -dynamiclib -DN=1 8 | $C{COMPILE} $DIR/load-parallel0.m -x none load-parallel00.dylib -o load-parallel2.dylib -dynamiclib -DN=2 9 | $C{COMPILE} $DIR/load-parallel0.m -x none load-parallel00.dylib -o load-parallel3.dylib -dynamiclib -DN=3 10 | $C{COMPILE} $DIR/load-parallel0.m -x none load-parallel00.dylib -o load-parallel4.dylib -dynamiclib -DN=4 11 | $C{COMPILE} $DIR/load-parallel0.m -x none load-parallel00.dylib -o load-parallel5.dylib -dynamiclib -DN=5 12 | $C{COMPILE} $DIR/load-parallel0.m -x none load-parallel00.dylib -o load-parallel6.dylib -dynamiclib -DN=6 13 | $C{COMPILE} $DIR/load-parallel0.m -x none load-parallel00.dylib -o load-parallel7.dylib -dynamiclib -DN=7 14 | $C{COMPILE} $DIR/load-parallel0.m -x none load-parallel00.dylib -o load-parallel8.dylib -dynamiclib -DN=8 15 | $C{COMPILE} $DIR/load-parallel0.m -x none load-parallel00.dylib -o load-parallel9.dylib -dynamiclib -DN=9 16 | END 17 | */ 18 | 19 | #include "test.h" 20 | 21 | #include 22 | #include 23 | 24 | #ifndef COUNT 25 | #error -DCOUNT=c missing 26 | #endif 27 | 28 | extern atomic_int state; 29 | 30 | void *thread(void *arg) 31 | { 32 | uintptr_t num = (uintptr_t)arg; 33 | char *buf; 34 | 35 | asprintf(&buf, "load-parallel%lu.dylib", (unsigned long)num); 36 | testprintf("%s\n", buf); 37 | void *dlh = dlopen(buf, RTLD_LAZY); 38 | if (!dlh) { 39 | fail("dlopen failed: %s", dlerror()); 40 | } 41 | free(buf); 42 | 43 | return NULL; 44 | } 45 | 46 | int main() 47 | { 48 | pthread_t t[COUNT]; 49 | uintptr_t i; 50 | 51 | for (i = 0; i < COUNT; i++) { 52 | pthread_create(&t[i], NULL, thread, (void *)i); 53 | } 54 | 55 | for (i = 0; i < COUNT; i++) { 56 | pthread_join(t[i], NULL); 57 | } 58 | 59 | testprintf("loaded %d/%d\n", (int)state, COUNT*26); 60 | testassert(state == COUNT*26); 61 | 62 | succeed(__FILE__); 63 | } 64 | -------------------------------------------------------------------------------- /objc4-779.1/test/load-parallel0.m: -------------------------------------------------------------------------------- 1 | #ifndef N 2 | #error -DN=n missing 3 | #endif 4 | 5 | #import 6 | #include 7 | #include 8 | #include 9 | #include "test.h" 10 | extern atomic_int state; 11 | 12 | #define CLASS0(n,nn) \ 13 | OBJC_ROOT_CLASS \ 14 | @interface C_##n##_##nn @end \ 15 | @implementation C_##n##_##nn \ 16 | +(void)load { \ 17 | atomic_fetch_add_explicit(&state, 1, memory_order_relaxed); \ 18 | usleep(10); } \ 19 | @end 20 | 21 | #define CLASS(n,nn) CLASS0(n,nn) 22 | 23 | CLASS(a,N) 24 | CLASS(b,N) 25 | CLASS(c,N) 26 | CLASS(d,N) 27 | CLASS(e,N) 28 | CLASS(f,N) 29 | CLASS(g,N) 30 | CLASS(h,N) 31 | CLASS(i,N) 32 | CLASS(j,N) 33 | CLASS(k,N) 34 | CLASS(l,N) 35 | CLASS(m,N) 36 | CLASS(n,N) 37 | CLASS(o,N) 38 | CLASS(p,N) 39 | CLASS(q,N) 40 | CLASS(r,N) 41 | CLASS(s,N) 42 | CLASS(t,N) 43 | CLASS(u,N) 44 | CLASS(v,N) 45 | CLASS(w,N) 46 | CLASS(x,N) 47 | CLASS(y,N) 48 | CLASS(z,N) 49 | -------------------------------------------------------------------------------- /objc4-779.1/test/load-parallel00.m: -------------------------------------------------------------------------------- 1 | #include "test.h" 2 | atomic_int state; 3 | -------------------------------------------------------------------------------- /objc4-779.1/test/load-reentrant.m: -------------------------------------------------------------------------------- 1 | /* 2 | TEST_BUILD 3 | $C{COMPILE} $DIR/load-reentrant.m -o load-reentrant.exe 4 | $C{COMPILE} $DIR/load-reentrant2.m -o libload-reentrant2.dylib -bundle -bundle_loader load-reentrant.exe 5 | END 6 | */ 7 | 8 | #include "test.h" 9 | #include 10 | 11 | int state1 = 0; 12 | int *state2_p; 13 | 14 | OBJC_ROOT_CLASS 15 | @interface One @end 16 | @implementation One 17 | +(void)load 18 | { 19 | state1 = 111; 20 | 21 | // Re-entrant +load doesn't get to complete until we do 22 | void *dlh = dlopen("libload-reentrant2.dylib", RTLD_LAZY); 23 | testassert(dlh); 24 | state2_p = (int *)dlsym(dlh, "state2"); 25 | testassert(state2_p); 26 | testassert(*state2_p == 0); 27 | 28 | state1 = 1; 29 | } 30 | @end 31 | 32 | int main() 33 | { 34 | testassert(state1 == 1 && state2_p && *state2_p == 2); 35 | succeed(__FILE__); 36 | } 37 | -------------------------------------------------------------------------------- /objc4-779.1/test/load-reentrant2.m: -------------------------------------------------------------------------------- 1 | #include "test.h" 2 | 3 | int state2 = 0; 4 | extern int state1; 5 | 6 | static void ctor(void) __attribute__((constructor)); 7 | static void ctor(void) 8 | { 9 | // should be called during One's dlopen(), before Two's +load 10 | testassert(state1 == 111); 11 | testassert(state2 == 0); 12 | } 13 | 14 | OBJC_ROOT_CLASS 15 | @interface Two @end 16 | @implementation Two 17 | +(void) load 18 | { 19 | // Does not run until One's +load completes 20 | testassert(state1 == 1); 21 | state2 = 2; 22 | } 23 | @end 24 | -------------------------------------------------------------------------------- /objc4-779.1/test/methodCacheLeaks.m: -------------------------------------------------------------------------------- 1 | // TEST_CONFIG MEM=mrc LANGUAGE=objective-c 2 | /* 3 | TEST_RUN_OUTPUT 4 | [\S\s]*0 leaks for 0 total leaked bytes[\S\s]* 5 | END 6 | */ 7 | 8 | #include "test.h" 9 | #include "testroot.i" 10 | 11 | #include 12 | #include 13 | 14 | void noopIMP(id self __unused, SEL _cmd __unused) {} 15 | 16 | id test(int n, int methodCount) { 17 | char *name; 18 | asprintf(&name, "TestClass%d", n); 19 | Class c = objc_allocateClassPair([TestRoot class], name, 0); 20 | free(name); 21 | 22 | SEL *sels = malloc(methodCount * sizeof(*sels)); 23 | for(int i = 0; i < methodCount; i++) { 24 | asprintf(&name, "selector%d", i); 25 | sels[i] = sel_getUid(name); 26 | free(name); 27 | } 28 | 29 | for(int i = 0; i < methodCount; i++) { 30 | class_addMethod(c, sels[i], (IMP)noopIMP, "v@:"); 31 | } 32 | 33 | objc_registerClassPair(c); 34 | 35 | id obj = [[c alloc] init]; 36 | for (int i = 0; i < methodCount; i++) { 37 | ((void (*)(id, SEL))objc_msgSend)(obj, sels[i]); 38 | } 39 | free(sels); 40 | return obj; 41 | } 42 | 43 | int main() 44 | { 45 | int classCount = 16; 46 | id *objs = malloc(classCount * sizeof(*objs)); 47 | for (int i = 0; i < classCount; i++) { 48 | objs[i] = test(i, 1 << i); 49 | } 50 | 51 | char *pidstr; 52 | int result = asprintf(&pidstr, "%u", getpid()); 53 | testassert(result); 54 | 55 | extern char **environ; 56 | char *argv[] = { "/usr/bin/leaks", pidstr, NULL }; 57 | pid_t pid; 58 | result = posix_spawn(&pid, "/usr/bin/leaks", NULL, NULL, argv, environ); 59 | if (result) { 60 | perror("posix_spawn"); 61 | exit(1); 62 | } 63 | wait4(pid, NULL, 0, NULL); 64 | printf("objs=%p\n", objs); 65 | } 66 | -------------------------------------------------------------------------------- /objc4-779.1/test/methodListSize.m: -------------------------------------------------------------------------------- 1 | // TEST_CONFIG 2 | // rdar://8052003 rdar://8077031 3 | 4 | #include "test.h" 5 | 6 | #include 7 | #include 8 | 9 | // add SELCOUNT methods to each of CLASSCOUNT classes 10 | #define CLASSCOUNT 100 11 | #define SELCOUNT 200 12 | 13 | int main() 14 | { 15 | int i, j; 16 | malloc_statistics_t start, end; 17 | 18 | Class root; 19 | root = objc_allocateClassPair(NULL, "Root", 0); 20 | objc_registerClassPair(root); 21 | 22 | Class classes[CLASSCOUNT]; 23 | for (i = 0; i < CLASSCOUNT; i++) { 24 | char *classname; 25 | asprintf(&classname, "GrP_class_%d", i); 26 | classes[i] = objc_allocateClassPair(root, classname, 0); 27 | objc_registerClassPair(classes[i]); 28 | free(classname); 29 | } 30 | 31 | SEL selectors[SELCOUNT]; 32 | for (i = 0; i < SELCOUNT; i++) { 33 | char *selname; 34 | asprintf(&selname, "GrP_sel_%d", i); 35 | selectors[i] = sel_registerName(selname); 36 | free(selname); 37 | } 38 | 39 | malloc_zone_statistics(NULL, &start); 40 | 41 | for (i = 0; i < CLASSCOUNT; i++) { 42 | for (j = 0; j < SELCOUNT; j++) { 43 | class_addMethod(classes[i], selectors[j], (IMP)main, ""); 44 | } 45 | } 46 | 47 | malloc_zone_statistics(NULL, &end); 48 | 49 | // expected: 3-word method struct plus two other words 50 | ssize_t expected = (sizeof(void*) * (3+2)) * SELCOUNT * CLASSCOUNT; 51 | ssize_t actual = end.size_in_use - start.size_in_use; 52 | testassert(actual < expected * 3); // allow generous fudge factor 53 | 54 | succeed(__FILE__); 55 | } 56 | 57 | -------------------------------------------------------------------------------- /objc4-779.1/test/nilAPIArgs.m: -------------------------------------------------------------------------------- 1 | /* 2 | TEST_BUILD_OUTPUT 3 | .*nilAPIArgs.m:\d+:\d+: warning: null passed to a callee that requires a non-null argument \[-Wnonnull\] 4 | .*nilAPIArgs.m:\d+:\d+: warning: null passed to a callee that requires a non-null argument \[-Wnonnull\] 5 | END 6 | */ 7 | 8 | #include "test.h" 9 | 10 | #import 11 | 12 | int main() { 13 | // ensure various bits of API don't crash when tossed nil parameters 14 | class_conformsToProtocol(nil, nil); 15 | method_setImplementation(nil, NULL); 16 | 17 | succeed(__FILE__); 18 | } 19 | -------------------------------------------------------------------------------- /objc4-779.1/test/nopool.m: -------------------------------------------------------------------------------- 1 | // TEST_CONFIG MEM=mrc 2 | 3 | #include "test.h" 4 | #include "testroot.i" 5 | 6 | @implementation TestRoot (Loader) 7 | +(void)load 8 | { 9 | [[TestRoot new] autorelease]; 10 | testassert(TestRootAutorelease == 1); 11 | testassert(TestRootDealloc == 0); 12 | } 13 | @end 14 | 15 | int main() 16 | { 17 | // +load's autoreleased object should have deallocated 18 | testassert(TestRootDealloc == 1); 19 | 20 | [[TestRoot new] autorelease]; 21 | testassert(TestRootAutorelease == 2); 22 | 23 | 24 | objc_autoreleasePoolPop(objc_autoreleasePoolPush()); 25 | [[TestRoot new] autorelease]; 26 | testassert(TestRootAutorelease == 3); 27 | 28 | 29 | testonthread(^{ 30 | [[TestRoot new] autorelease]; 31 | testassert(TestRootAutorelease == 4); 32 | testassert(TestRootDealloc == 1); 33 | }); 34 | // thread's autoreleased object should have deallocated 35 | testassert(TestRootDealloc == 2); 36 | 37 | 38 | // Test no-pool autorelease after a pool was pushed and popped. 39 | // The simplest POOL_SENTINEL check during pop gets this wrong. 40 | testonthread(^{ 41 | objc_autoreleasePoolPop(objc_autoreleasePoolPush()); 42 | [[TestRoot new] autorelease]; 43 | testassert(TestRootAutorelease == 5); 44 | testassert(TestRootDealloc == 2); 45 | }); 46 | testassert(TestRootDealloc == 3 47 | ); 48 | succeed(__FILE__); 49 | } 50 | -------------------------------------------------------------------------------- /objc4-779.1/test/nscdtors.mm: -------------------------------------------------------------------------------- 1 | // TEST_CONFIG 2 | // test cdtors, with NSObject instead of TestRoot as the root class 3 | 4 | #define USE_FOUNDATION 1 5 | #include "cdtors.mm" 6 | 7 | -------------------------------------------------------------------------------- /objc4-779.1/test/nsexc.m: -------------------------------------------------------------------------------- 1 | /* 2 | need exception-safe ARC for exception deallocation tests 3 | TEST_CFLAGS -fobjc-arc-exceptions -framework Foundation 4 | */ 5 | 6 | #define USE_FOUNDATION 1 7 | #include "exc.m" 8 | -------------------------------------------------------------------------------- /objc4-779.1/test/nsprotocol.m: -------------------------------------------------------------------------------- 1 | // TEST_CONFIG 2 | 3 | #include "test.h" 4 | #include 5 | 6 | int main() 7 | { 8 | // Class Protocol is always a subclass of NSObject 9 | 10 | testassert(objc_getClass("NSObject")); 11 | 12 | Class cls = objc_getClass("Protocol"); 13 | testassert(class_getInstanceMethod(cls, sel_registerName("isProxy"))); 14 | testassert(class_getSuperclass(cls) == objc_getClass("NSObject")); 15 | 16 | succeed(__FILE__); 17 | } 18 | -------------------------------------------------------------------------------- /objc4-779.1/test/objectCopy.m: -------------------------------------------------------------------------------- 1 | // TEST_CONFIG MEM=mrc 2 | 3 | #include "test.h" 4 | #include 5 | 6 | @interface Test : NSObject { 7 | @public 8 | char bytes[32-sizeof(void*)]; 9 | } 10 | @end 11 | @implementation Test 12 | @end 13 | 14 | 15 | int main() 16 | { 17 | Test *o0 = [Test new]; 18 | [o0 retain]; 19 | Test *o1 = class_createInstance([Test class], 32); 20 | [o1 retain]; 21 | id o2 = object_copy(o0, 0); 22 | id o3 = object_copy(o1, 0); 23 | id o4 = object_copy(o1, 32); 24 | 25 | testassert(malloc_size(o0) == 32); 26 | testassert(malloc_size(o1) == 64); 27 | testassert(malloc_size(o2) == 32); 28 | testassert(malloc_size(o3) == 32); 29 | testassert(malloc_size(o4) == 64); 30 | 31 | testassert([o0 retainCount] == 2); 32 | testassert([o1 retainCount] == 2); 33 | testassert([o2 retainCount] == 1); 34 | testassert([o3 retainCount] == 1); 35 | testassert([o4 retainCount] == 1); 36 | 37 | succeed(__FILE__); 38 | } 39 | -------------------------------------------------------------------------------- /objc4-779.1/test/rawisa.m: -------------------------------------------------------------------------------- 1 | /* 2 | TEST_CFLAGS -Xlinker -sectcreate -Xlinker __DATA -Xlinker __objc_rawisa -Xlinker /dev/null 3 | TEST_ENV OBJC_PRINT_RAW_ISA=YES 4 | 5 | TEST_RUN_OUTPUT 6 | objc\[\d+\]: RAW ISA: disabling non-pointer isa because the app has a __DATA,__objc_rawisa section 7 | (.* RAW ISA: .*\n)* 8 | OK: rawisa.m(\n.* RAW ISA: .*)* 9 | OR 10 | (.* RAW ISA: .*\n)* 11 | no __DATA,__rawisa support 12 | OK: rawisa.m(\n.* RAW ISA: .*)* 13 | END 14 | 15 | "RAW ISA" is allowed after "OK" because of static destructors 16 | that provoke class realization. 17 | */ 18 | 19 | #include "test.h" 20 | 21 | int main() 22 | { 23 | fprintf(stderr, "\n"); 24 | #if ! (SUPPORT_NONPOINTER_ISA && TARGET_OS_OSX) 25 | // only 64-bit Mac supports this 26 | fprintf(stderr, "no __DATA,__rawisa support\n"); 27 | #endif 28 | succeed(__FILE__); 29 | } 30 | 31 | -------------------------------------------------------------------------------- /objc4-779.1/test/realizedClassGenerationCount.m: -------------------------------------------------------------------------------- 1 | // TEST_CONFIG 2 | 3 | #include "test.h" 4 | #include "testroot.i" 5 | 6 | #include 7 | 8 | extern uintptr_t objc_debug_realized_class_generation_count; 9 | 10 | int main() 11 | { 12 | testassert(objc_debug_realized_class_generation_count > 0); 13 | uintptr_t prev = objc_debug_realized_class_generation_count; 14 | 15 | void *handle = dlopen("/System/Library/Frameworks/Foundation.framework/Foundation", RTLD_LAZY); 16 | testassert(handle); 17 | Class c = objc_getClass("NSFileManager"); 18 | testassert(c); 19 | testassert(objc_debug_realized_class_generation_count > prev); 20 | 21 | prev = objc_debug_realized_class_generation_count; 22 | c = objc_allocateClassPair([TestRoot class], "Dynamic", 0); 23 | testassert(objc_debug_realized_class_generation_count > prev); 24 | prev = objc_debug_realized_class_generation_count; 25 | objc_registerClassPair(c); 26 | testassert(objc_debug_realized_class_generation_count == prev); 27 | 28 | succeed(__FILE__); 29 | } -------------------------------------------------------------------------------- /objc4-779.1/test/release-workaround.m: -------------------------------------------------------------------------------- 1 | // TEST_CONFIG ARCH=x86_64 MEM=mrc 2 | // TEST_CFLAGS -framework Foundation 3 | 4 | // rdar://20206767 5 | 6 | #include 7 | #include "test.h" 8 | 9 | 10 | @interface Test : NSObject @end 11 | @implementation Test 12 | @end 13 | 14 | 15 | int main() 16 | { 17 | id buf[1]; 18 | buf[0] = [Test class]; 19 | id obj = (id)buf; 20 | [obj retain]; 21 | [obj retain]; 22 | 23 | uintptr_t rax; 24 | 25 | [obj release]; 26 | asm("mov %%rax, %0" : "=r" (rax)); 27 | testassert(rax == 0); 28 | 29 | objc_release(obj); 30 | asm("mov %%rax, %0" : "=r" (rax)); 31 | testassert(rax == 0); 32 | 33 | succeed(__FILE__); 34 | } 35 | -------------------------------------------------------------------------------- /objc4-779.1/test/restartableRangesSynchronizeStress.m: -------------------------------------------------------------------------------- 1 | // TEST_CONFIG OS=macosx,iphoneos,tvos,watchos 2 | 3 | // This test checks that objc_msgSend's recovery path works correctly. 4 | // It continuously runs msgSend on some background threads, then 5 | // triggers the recovery path constantly as a stress test. 6 | 7 | #include "test.h" 8 | #include "testroot.i" 9 | #include 10 | 11 | struct Big { 12 | uintptr_t a, b, c, d, e, f, g; 13 | }; 14 | 15 | @interface C1: TestRoot 16 | @end 17 | @implementation C1 18 | - (id)idret { return nil; } 19 | - (double)fpret { return 0.0; } 20 | - (long double)lfpret { return 0.0; } 21 | - (struct Big)stret { return (struct Big){}; } 22 | @end 23 | 24 | @interface C2: C1 25 | @end 26 | @implementation C2 27 | - (id)idret { return [super idret]; } 28 | - (double)fpret { return [super fpret]; } 29 | - (long double)lfpret { return [super lfpret]; } 30 | - (struct Big)stret { return [super stret]; } 31 | @end 32 | 33 | EXTERN_C kern_return_t task_restartable_ranges_synchronize(task_t task); 34 | 35 | EXTERN_C void sendWithMsgLookup(id self, SEL _cmd); 36 | 37 | #if defined(__arm64__) && !__has_feature(ptrauth_calls) 38 | asm( 39 | "_sendWithMsgLookup: \n" 40 | " stp fp, lr, [sp, #-16]! \n" 41 | " mov fp, sp \n" 42 | " bl _objc_msgLookup \n" 43 | " mov sp, fp \n" 44 | " ldp fp, lr, [sp], #16 \n" 45 | " br x17 \n" 46 | ); 47 | #elif defined(__x86_64__) 48 | asm( 49 | "_sendWithMsgLookup: \n" 50 | " pushq %rbp \n" 51 | " movq %rsp, %rbp \n" 52 | " callq _objc_msgLookup \n" 53 | " popq %rbp \n" 54 | " jmpq *%r11 \n" 55 | ); 56 | #else 57 | // Just skip it. 58 | void sendWithMsgLookup(id self __unused, SEL _cmd __unused) {} 59 | #endif 60 | 61 | int main() { 62 | id obj = [C2 new]; 63 | for(int i = 0; i < 2; i++) { 64 | dispatch_async(dispatch_get_global_queue(0, 0), ^{ 65 | while(1) { 66 | [obj idret]; 67 | [obj fpret]; 68 | [obj lfpret]; 69 | [obj stret]; 70 | sendWithMsgLookup(obj, @selector(idret)); 71 | } 72 | }); 73 | } 74 | for(int i = 0; i < 1000000; i++) { 75 | task_restartable_ranges_synchronize(mach_task_self());; 76 | } 77 | succeed(__FILE__); 78 | } 79 | -------------------------------------------------------------------------------- /objc4-779.1/test/rr-autorelease-stacklogging.m: -------------------------------------------------------------------------------- 1 | // Test OBJC_DEBUG_POOL_ALLOCATION (which is also enabled by MallocStackLogging) 2 | 3 | // TEST_ENV OBJC_DEBUG_POOL_ALLOCATION=YES 4 | // TEST_CFLAGS -framework Foundation 5 | // TEST_CONFIG MEM=mrc 6 | 7 | #include "test.h" 8 | 9 | #define FOUNDATION 0 10 | #define NAME "rr-autorelease-stacklogging" 11 | #define DEBUG_POOL_ALLOCATION 1 12 | 13 | #include "rr-autorelease2.m" 14 | -------------------------------------------------------------------------------- /objc4-779.1/test/rr-autorelease.m: -------------------------------------------------------------------------------- 1 | // TEST_CFLAGS -framework Foundation 2 | // TEST_CONFIG MEM=mrc 3 | 4 | #include "test.h" 5 | 6 | #define FOUNDATION 0 7 | #define NAME "rr-autorelease" 8 | 9 | #include "rr-autorelease2.m" 10 | -------------------------------------------------------------------------------- /objc4-779.1/test/rr-nsautorelease.m: -------------------------------------------------------------------------------- 1 | // TEST_CFLAGS -framework Foundation 2 | // TEST_CONFIG MEM=mrc 3 | 4 | #define FOUNDATION 1 5 | #define NAME "rr-nsautorelease" 6 | 7 | #include "rr-autorelease2.m" 8 | -------------------------------------------------------------------------------- /objc4-779.1/test/rr-sidetable.m: -------------------------------------------------------------------------------- 1 | // TEST_CFLAGS -framework Foundation 2 | // TEST_CONFIG MEM=mrc ARCH=x86_64 3 | 4 | // Stress-test nonpointer isa's side table retain count transfers. 5 | 6 | // x86_64 only. arm64's side table limit is high enough that bugs 7 | // are harder to reproduce. 8 | 9 | #include "test.h" 10 | #import 11 | 12 | #define OBJECTS 1 13 | #define LOOPS 256 14 | #define THREADS 16 15 | #if __x86_64__ 16 | # define RC_HALF (1ULL<<7) 17 | #else 18 | # error sorry 19 | #endif 20 | #define RC_DELTA RC_HALF 21 | 22 | static bool Deallocated = false; 23 | @interface Deallocator : NSObject @end 24 | @implementation Deallocator 25 | -(void)dealloc { 26 | Deallocated = true; 27 | [super dealloc]; 28 | } 29 | @end 30 | 31 | // This is global to avoid extra retains by the dispatch block objects. 32 | static Deallocator *obj; 33 | 34 | int main() { 35 | dispatch_queue_t queue = 36 | dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0); 37 | 38 | for (size_t i = 0; i < OBJECTS; i++) { 39 | obj = [Deallocator new]; 40 | 41 | dispatch_apply(THREADS, queue, ^(size_t i __unused) { 42 | for (size_t a = 0; a < LOOPS; a++) { 43 | for (size_t b = 0; b < RC_DELTA; b++) { 44 | [obj retain]; 45 | } 46 | for (size_t b = 0; b < RC_DELTA; b++) { 47 | [obj release]; 48 | } 49 | } 50 | }); 51 | 52 | testassert(!Deallocated); 53 | [obj release]; 54 | testassert(Deallocated); 55 | Deallocated = false; 56 | } 57 | 58 | succeed(__FILE__); 59 | } 60 | -------------------------------------------------------------------------------- /objc4-779.1/test/sel.m: -------------------------------------------------------------------------------- 1 | /* 2 | TEST_BUILD_OUTPUT 3 | .*sel.m:\d+:\d+: warning: null passed to a callee that requires a non-null argument \[-Wnonnull\](\n.* note: expanded from macro 'testassert')? 4 | END 5 | */ 6 | 7 | #include "test.h" 8 | #include 9 | #include 10 | #include 11 | 12 | int main() 13 | { 14 | // Make sure @selector values are correctly fixed up 15 | testassert(@selector(foo) == sel_registerName("foo")); 16 | 17 | // sel_getName recognizes the zero SEL 18 | testassert(0 == strcmp("", sel_getName(0))); 19 | 20 | succeed(__FILE__); 21 | } 22 | -------------------------------------------------------------------------------- /objc4-779.1/test/setAssociatedObjectHook.m: -------------------------------------------------------------------------------- 1 | // TEST_CONFIG 2 | 3 | #include "test.h" 4 | #include "testroot.i" 5 | 6 | id sawObject; 7 | const void *sawKey; 8 | id sawValue; 9 | objc_AssociationPolicy sawPolicy; 10 | 11 | objc_hook_setAssociatedObject originalSetAssociatedObject; 12 | 13 | void hook(id _Nonnull object, const void * _Nonnull key, id _Nullable value, objc_AssociationPolicy policy) { 14 | sawObject = object; 15 | sawKey = key; 16 | sawValue = value; 17 | sawPolicy = policy; 18 | originalSetAssociatedObject(object, key, value, policy); 19 | } 20 | 21 | int main() { 22 | id obj = [TestRoot new]; 23 | id value = [TestRoot new]; 24 | const void *key = "key"; 25 | objc_setAssociatedObject(obj, key, value, OBJC_ASSOCIATION_RETAIN); 26 | testassert(sawObject == nil); 27 | testassert(sawKey == nil); 28 | testassert(sawValue == nil); 29 | testassert(sawPolicy == 0); 30 | 31 | id out = objc_getAssociatedObject(obj, key); 32 | testassert(out == value); 33 | 34 | objc_setHook_setAssociatedObject(hook, &originalSetAssociatedObject); 35 | 36 | key = "key2"; 37 | objc_setAssociatedObject(obj, key, value, OBJC_ASSOCIATION_RETAIN); 38 | testassert(sawObject == obj); 39 | testassert(sawKey == key); 40 | testassert(sawValue == value); 41 | testassert(sawPolicy == OBJC_ASSOCIATION_RETAIN); 42 | 43 | out = objc_getAssociatedObject(obj, key); 44 | testassert(out == value); 45 | 46 | succeed(__FILE__); 47 | } -------------------------------------------------------------------------------- /objc4-779.1/test/setSuper.m: -------------------------------------------------------------------------------- 1 | // TEST_CONFIG 2 | 3 | #include "test.h" 4 | #include "testroot.i" 5 | #include 6 | 7 | @interface Super1 : TestRoot @end 8 | @implementation Super1 9 | +(int)classMethod { return 1; } 10 | -(int)instanceMethod { return 10000; } 11 | @end 12 | 13 | @interface Super2 : TestRoot @end 14 | @implementation Super2 15 | +(int)classMethod { return 2; } 16 | -(int)instanceMethod { return 20000; } 17 | @end 18 | 19 | @interface Sub : Super1 @end 20 | @implementation Sub 21 | +(int)classMethod { return [super classMethod] + 100; } 22 | -(int)instanceMethod { 23 | return [super instanceMethod] + 1000000; 24 | } 25 | @end 26 | 27 | int main() 28 | { 29 | Class cls; 30 | Sub *obj = [Sub new]; 31 | 32 | testassert(101 == [[Sub class] classMethod]); 33 | testassert(1010000 == [obj instanceMethod]); 34 | 35 | cls = class_setSuperclass([Sub class], [Super2 class]); 36 | 37 | testassert(cls == [Super1 class]); 38 | testassert(object_getClass(cls) == object_getClass([Super1 class])); 39 | 40 | testassert(102 == [[Sub class] classMethod]); 41 | testassert(1020000 == [obj instanceMethod]); 42 | 43 | succeed(__FILE__); 44 | } 45 | -------------------------------------------------------------------------------- /objc4-779.1/test/super.m: -------------------------------------------------------------------------------- 1 | // TEST_CONFIG 2 | 3 | #include "test.h" 4 | #include "testroot.i" 5 | #include 6 | 7 | @interface Sub : TestRoot @end 8 | @implementation Sub @end 9 | 10 | int main() 11 | { 12 | // [super ...] messages are tested in msgSend.m 13 | 14 | testassert(class_getSuperclass([Sub class]) == [TestRoot class]); 15 | testassert(class_getSuperclass(object_getClass([Sub class])) == object_getClass([TestRoot class])); 16 | testassert(class_getSuperclass([TestRoot class]) == Nil); 17 | testassert(class_getSuperclass(object_getClass([TestRoot class])) == [TestRoot class]); 18 | testassert(class_getSuperclass(Nil) == Nil); 19 | 20 | succeed(__FILE__); 21 | } 22 | -------------------------------------------------------------------------------- /objc4-779.1/test/swiftMetadataInitializer.m: -------------------------------------------------------------------------------- 1 | // TEST_CONFIG MEM=mrc 2 | 3 | #include "test.h" 4 | #include "swift-class-def.m" 5 | 6 | 7 | SWIFT_CLASS(SwiftSuper, NSObject, initSuper); 8 | SWIFT_CLASS(SwiftSub, SwiftSuper, initSub); 9 | 10 | // _objc_swiftMetadataInitializer hooks for the fake Swift classes 11 | 12 | Class initSuper(Class cls __unused, void *arg __unused) 13 | { 14 | // This test provokes objc's callback out of superclass order. 15 | // SwiftSub's init is first. SwiftSuper's init is never called. 16 | 17 | fail("SwiftSuper's init should not have been called"); 18 | } 19 | 20 | bool isRealized(Class cls) 21 | { 22 | // check the is-realized bits directly 23 | 24 | #if __LP64__ 25 | # define mask (~(uintptr_t)7) 26 | #else 27 | # define mask (~(uintptr_t)3) 28 | #endif 29 | #define RW_REALIZED (1<<31) 30 | 31 | uintptr_t rw = ((uintptr_t *)cls)[4] & mask; // class_t->data 32 | return ((uint32_t *)rw)[0] & RW_REALIZED; // class_rw_t->flags 33 | } 34 | 35 | static int SubInits = 0; 36 | Class initSub(Class cls, void *arg) 37 | { 38 | testprintf("initSub callback\n"); 39 | 40 | testassert(SubInits == 0); 41 | SubInits++; 42 | testassert(arg == nil); 43 | testassert(0 == strcmp(class_getName(cls), "SwiftSub")); 44 | testassert(cls == RawSwiftSub); 45 | testassert(!isRealized(RawSwiftSuper)); 46 | testassert(!isRealized(RawSwiftSub)); 47 | 48 | testprintf("initSub beginning _objc_realizeClassFromSwift\n"); 49 | _objc_realizeClassFromSwift(cls, cls); 50 | testprintf("initSub finished _objc_realizeClassFromSwift\n"); 51 | 52 | testassert(isRealized(RawSwiftSuper)); 53 | testassert(isRealized(RawSwiftSub)); 54 | 55 | return cls; 56 | } 57 | 58 | 59 | int main() 60 | { 61 | testassert(SubInits == 0); 62 | testprintf("calling [SwiftSub class]\n"); 63 | [SwiftSub class]; 64 | testprintf("finished [SwiftSub class]\n"); 65 | testassert(SubInits == 1); 66 | [SwiftSuper class]; 67 | succeed(__FILE__); 68 | } 69 | -------------------------------------------------------------------------------- /objc4-779.1/test/swiftMetadataInitializerRealloc-dylib1.m: -------------------------------------------------------------------------------- 1 | #include "test.h" 2 | #include "swift-class-def.m" 3 | 4 | SWIFT_CLASS(RealSwiftDylib1A, NSObject, nop); 5 | SWIFT_STUB_CLASS(SwiftDylib1A, initSwiftDylib1A); 6 | 7 | SWIFT_CLASS(RealSwiftDylib1B, NSObject, nop); 8 | SWIFT_STUB_CLASS(SwiftDylib1B, initSwiftDylib1B); 9 | 10 | int Dylib1AInits = 0; 11 | 12 | @interface SwiftDylib1A: NSObject @end 13 | @interface SwiftDylib1B: NSObject @end 14 | 15 | @implementation SwiftDylib1A (Category) 16 | - (const char *)dylib1ACategoryInSameDylib { return "dylib1ACategoryInSameDylib"; } 17 | @end 18 | @implementation SwiftDylib1B (Category) 19 | - (const char *)dylib1BCategoryInSameDylib { return "dylib1BCategoryInSameDylib"; } 20 | @end 21 | 22 | EXTERN_C Class initSwiftDylib1A(Class cls, void *arg) 23 | { 24 | Dylib1AInits++; 25 | testassert(arg == nil); 26 | testassert(cls == RawSwiftDylib1A); 27 | 28 | if (Dylib1AInits == 1) 29 | _objc_realizeClassFromSwift(RawRealSwiftDylib1A, cls); 30 | 31 | return RawRealSwiftDylib1A; 32 | } 33 | 34 | int Dylib1BInits = 0; 35 | 36 | EXTERN_C Class initSwiftDylib1B(Class cls, void *arg) 37 | { 38 | Dylib1BInits++; 39 | testassert(arg == nil); 40 | testassert(cls == RawSwiftDylib1B); 41 | 42 | if (Dylib1BInits == 1) 43 | _objc_realizeClassFromSwift(RawRealSwiftDylib1B, cls); 44 | 45 | return RawRealSwiftDylib1B; 46 | } 47 | 48 | EXTERN_C Class objc_loadClassref(_Nullable Class * _Nonnull clsref); 49 | 50 | void Dylib1Test(void) { 51 | testassert((uintptr_t)SwiftDylib1AClassref & 1); 52 | Class SwiftDylib1A = objc_loadClassref(&SwiftDylib1AClassref); 53 | testassert(((uintptr_t)SwiftDylib1AClassref & 1) == 0); 54 | testassert(SwiftDylib1A == [SwiftDylib1A class]); 55 | testassert(SwiftDylib1A == SwiftDylib1AClassref); 56 | testassert(Dylib1AInits == 2); 57 | 58 | testassert((uintptr_t)SwiftDylib1BClassref & 1); 59 | Class SwiftDylib1B = objc_loadClassref(&SwiftDylib1BClassref); 60 | testassert(((uintptr_t)SwiftDylib1BClassref & 1) == 0); 61 | testassert(SwiftDylib1B == [SwiftDylib1B class]); 62 | testassert(SwiftDylib1B == SwiftDylib1BClassref); 63 | testassert(Dylib1BInits == 2); 64 | } 65 | -------------------------------------------------------------------------------- /objc4-779.1/test/swiftMetadataInitializerRealloc-dylib2.m: -------------------------------------------------------------------------------- 1 | #include "test.h" 2 | #include "swift-class-def.m" 3 | 4 | @interface SwiftDylib1A: NSObject @end 5 | @interface SwiftDylib1B: NSObject @end 6 | 7 | @interface NSObject (DylibCategories) 8 | - (char *)dylib1ACategoryInSameDylib; 9 | - (char *)dylib1BCategoryInSameDylib; 10 | - (char *)dylib1ACategoryInOtherDylib; 11 | - (char *)dylib1BCategoryInOtherDylib; 12 | - (char *)dylib1ACategoryInApp; 13 | - (char *)dylib1BCategoryInApp; 14 | + (void)testFromOtherDylib; 15 | @end 16 | 17 | @implementation SwiftDylib1A (Category) 18 | - (const char *)dylib1ACategoryInOtherDylib { return "dylib1ACategoryInOtherDylib"; } 19 | @end 20 | @implementation SwiftDylib1B (Category) 21 | - (const char *)dylib1BCategoryInOtherDylib { return "dylib1BCategoryInOtherDylib"; } 22 | @end 23 | 24 | SWIFT_STUB_CLASSREF(SwiftDylib1A); 25 | SWIFT_STUB_CLASSREF(SwiftDylib1B); 26 | 27 | Class objc_loadClassref(_Nullable Class * _Nonnull clsref); 28 | 29 | @implementation SwiftDylib1A (Test) 30 | + (void)testFromOtherDylib { 31 | Class SwiftDylib1A = objc_loadClassref(&SwiftDylib1AClassref); 32 | Class SwiftDylib1B = objc_loadClassref(&SwiftDylib1BClassref); 33 | testassert(strcmp([[SwiftDylib1A new] dylib1ACategoryInSameDylib], "dylib1ACategoryInSameDylib") == 0); 34 | testassert(strcmp([[SwiftDylib1B new] dylib1BCategoryInSameDylib], "dylib1BCategoryInSameDylib") == 0); 35 | testassert(strcmp([[SwiftDylib1A new] dylib1ACategoryInApp], "dylib1ACategoryInApp") == 0); 36 | testassert(strcmp([[SwiftDylib1B new] dylib1BCategoryInApp], "dylib1BCategoryInApp") == 0); 37 | testassert(strcmp([[SwiftDylib1A new] dylib1ACategoryInOtherDylib], "dylib1ACategoryInOtherDylib") == 0); 38 | testassert(strcmp([[SwiftDylib1B new] dylib1BCategoryInOtherDylib], "dylib1BCategoryInOtherDylib") == 0); 39 | } 40 | @end 41 | -------------------------------------------------------------------------------- /objc4-779.1/test/synchronized-counter.m: -------------------------------------------------------------------------------- 1 | // TEST_CONFIG 2 | 3 | #include "test.h" 4 | 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | // synchronized stress test 13 | // Single locked counter incremented by many threads. 14 | 15 | #if defined(__arm__) 16 | #define THREADS 16 17 | #define COUNT 1024*24 18 | #else 19 | // 64 / 1024*24 test takes about 20s on 4x2.6GHz Mac Pro 20 | #define THREADS 64 21 | #define COUNT 1024*24 22 | #endif 23 | 24 | static id lock; 25 | static int count; 26 | 27 | static void *threadfn(void *arg) 28 | { 29 | int n, d; 30 | int depth = 1 + (int)(intptr_t)arg % 4; 31 | 32 | for (n = 0; n < COUNT; n++) { 33 | // Lock 34 | for (d = 0; d < depth; d++) { 35 | int err = objc_sync_enter(lock); 36 | testassert(err == OBJC_SYNC_SUCCESS); 37 | } 38 | 39 | // Increment 40 | count++; 41 | 42 | // Unlock 43 | for (d = 0; d < depth; d++) { 44 | int err = objc_sync_exit(lock); 45 | testassert(err == OBJC_SYNC_SUCCESS); 46 | } 47 | } 48 | 49 | // Verify lack of objc pthread data (should have used sync fast cache) 50 | #ifdef __PTK_FRAMEWORK_OBJC_KEY0 51 | testassert(! pthread_getspecific(__PTK_FRAMEWORK_OBJC_KEY0)); 52 | #endif 53 | 54 | return NULL; 55 | } 56 | 57 | int main() 58 | { 59 | pthread_t threads[THREADS]; 60 | int t; 61 | int err; 62 | 63 | lock = [[NSObject alloc] init]; 64 | 65 | // Verify objc pthread data on this thread (from +initialize) 66 | // Worker threads shouldn't have any because of sync fast cache. 67 | #ifdef __PTK_FRAMEWORK_OBJC_KEY0 68 | testassert(pthread_getspecific(__PTK_FRAMEWORK_OBJC_KEY0)); 69 | #endif 70 | 71 | // Start the threads 72 | for (t = 0; t < THREADS; t++) { 73 | pthread_create(&threads[t], NULL, &threadfn, (void*)(intptr_t)t); 74 | } 75 | 76 | // Wait for threads to finish 77 | for (t = 0; t < THREADS; t++) { 78 | pthread_join(threads[t], NULL); 79 | } 80 | 81 | // Verify lock: should be available 82 | // Verify count: should be THREADS*COUNT 83 | err = objc_sync_enter(lock); 84 | testassert(err == OBJC_SYNC_SUCCESS); 85 | testassert(count == THREADS*COUNT); 86 | 87 | succeed(__FILE__); 88 | } 89 | -------------------------------------------------------------------------------- /objc4-779.1/test/taggedPointersDisabled.m: -------------------------------------------------------------------------------- 1 | /* 2 | TEST_ENV OBJC_DISABLE_TAGGED_POINTERS=YES 3 | TEST_CRASHES 4 | 5 | TEST_BUILD_OUTPUT 6 | .*taggedPointersDisabled.m:\d+:\d+: warning: null passed to a callee that requires a non-null argument \[-Wnonnull\] 7 | END 8 | 9 | TEST_RUN_OUTPUT 10 | objc\[\d+\]: tagged pointers are disabled 11 | objc\[\d+\]: HALTED 12 | OR 13 | OK: taggedPointersDisabled.m 14 | END 15 | */ 16 | 17 | #include "test.h" 18 | #include 19 | 20 | #if !OBJC_HAVE_TAGGED_POINTERS 21 | 22 | int main() 23 | { 24 | // provoke the same nullability warning as the real test 25 | objc_getClass(nil); 26 | 27 | succeed(__FILE__); 28 | } 29 | 30 | #else 31 | 32 | int main() 33 | { 34 | testassert(!_objc_taggedPointersEnabled()); 35 | _objc_registerTaggedPointerClass((objc_tag_index_t)0, nil); 36 | fail("should have crashed in _objc_registerTaggedPointerClass()"); 37 | } 38 | 39 | #endif 40 | -------------------------------------------------------------------------------- /objc4-779.1/test/taggedPointersTagObfuscationDisabled.m: -------------------------------------------------------------------------------- 1 | // TEST_ENV OBJC_DISABLE_TAG_OBFUSCATION=YES 2 | 3 | #include "test.h" 4 | #include 5 | 6 | #if !OBJC_HAVE_TAGGED_POINTERS 7 | 8 | int main() 9 | { 10 | succeed(__FILE__); 11 | } 12 | 13 | #else 14 | 15 | int main() 16 | { 17 | testassert(_objc_getTaggedPointerTag((void *)1) == 0); 18 | succeed(__FILE__); 19 | } 20 | 21 | #endif 22 | -------------------------------------------------------------------------------- /objc4-779.1/test/tbi.c: -------------------------------------------------------------------------------- 1 | // TEST_CONFIG OS=iphoneos ARCH=arm64 2 | 3 | #include "test.h" 4 | 5 | #ifndef __arm64__ 6 | #error wrong architecture for TBI hardware feature 7 | #endif 8 | 9 | volatile int x = 123456; 10 | 11 | int main(void) { 12 | testassert(*(int *)((unsigned long)&x | 0xFF00000000000000ul) == 123456); 13 | succeed(__FILE__); 14 | } 15 | -------------------------------------------------------------------------------- /objc4-779.1/test/timeout.pl: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl -w 2 | 3 | use strict; 4 | 5 | my $usage = "timeout \n"; 6 | my $timeout = shift || die $usage; 7 | alarm($timeout); 8 | exec @ARGV; 9 | die "exec failed: @ARGV"; 10 | -------------------------------------------------------------------------------- /objc4-779.1/test/unload.h: -------------------------------------------------------------------------------- 1 | #include "test.h" 2 | 3 | @interface SmallClass : TestRoot @end 4 | 5 | @interface BigClass : TestRoot @end 6 | 7 | -------------------------------------------------------------------------------- /objc4-779.1/test/unload2.m: -------------------------------------------------------------------------------- 1 | #include "unload.h" 2 | #include "testroot.i" 3 | #import 4 | 5 | @implementation SmallClass : TestRoot 6 | -(void)unload2_instance_method { } 7 | @end 8 | 9 | 10 | @implementation BigClass : TestRoot 11 | @end 12 | 13 | OBJC_ROOT_CLASS 14 | @interface UnusedClass { id isa; } @end 15 | @implementation UnusedClass @end 16 | 17 | 18 | @protocol SmallProtocol 19 | -(void)unload2_category_method; 20 | @end 21 | 22 | @interface SmallClass (Category) @end 23 | 24 | @implementation SmallClass (Category) 25 | -(void)unload2_category_method { } 26 | @end 27 | 28 | // This isn't really weak-import: we link with `-undefined dynamic_lookup` 29 | // instead of providing a valid definition at link time. 30 | // But it looks the same to the runtime. 31 | __attribute__((weak_import)) 32 | @interface ClassThatIsWeakImportAndMissing : TestRoot @end 33 | 34 | @interface SubclassOfMissingWeakImport : ClassThatIsWeakImportAndMissing @end 35 | @implementation SubclassOfMissingWeakImport 36 | -(void)unload2_category_method { } 37 | @end 38 | 39 | @interface ClassThatIsWeakImportAndMissing (Category) @end 40 | @implementation ClassThatIsWeakImportAndMissing (Category) 41 | -(void)unload2_category_method { } 42 | @end 43 | -------------------------------------------------------------------------------- /objc4-779.1/test/unload3.c: -------------------------------------------------------------------------------- 1 | // unload3: contains imageinfo but no other objc metadata 2 | // libobjc must not keep it open 3 | 4 | #include 5 | 6 | int fake[2] __attribute__((section("__DATA,__objc_imageinfo"))) 7 | = { 0, TARGET_OS_SIMULATOR ? (1<<5) : 0 }; 8 | 9 | // silence "no debug symbols in executable" warning 10 | void fn(void) { } 11 | -------------------------------------------------------------------------------- /objc4-779.1/test/unload4.m: -------------------------------------------------------------------------------- 1 | // unload4: contains some objc metadata other than imageinfo 2 | // libobjc must keep it open 3 | 4 | int fake2 __attribute__((section("__DATA,__objc_foo"))) = 0; 5 | 6 | // getsectiondata() falls over if __TEXT has no contents 7 | const char *unload4 = "unload4"; 8 | -------------------------------------------------------------------------------- /objc4-779.1/test/unwind.m: -------------------------------------------------------------------------------- 1 | // TEST_CONFIG 2 | 3 | #include "test.h" 4 | #include 5 | #include 6 | 7 | static int state; 8 | 9 | @interface Foo : NSObject @end 10 | @interface Bar : NSObject @end 11 | 12 | @interface Foo (Unimplemented) 13 | +(void)method; 14 | @end 15 | 16 | @implementation Bar @end 17 | 18 | @implementation Foo 19 | 20 | -(void)check { state++; } 21 | +(void)check { testassert(!"caught class object, not instance"); } 22 | 23 | static id exc; 24 | 25 | static void handler(id unused, void *ctx) __attribute__((used)); 26 | static void handler(id unused __unused, void *ctx __unused) 27 | { 28 | testassert(state == 3); state++; 29 | } 30 | 31 | +(BOOL) resolveClassMethod:(SEL)__unused name 32 | { 33 | testassert(state == 1); state++; 34 | #if TARGET_OS_OSX 35 | objc_addExceptionHandler(&handler, 0); 36 | testassert(state == 2); 37 | #else 38 | state++; // handler would have done this 39 | #endif 40 | state++; 41 | exc = [Foo new]; 42 | @throw exc; 43 | } 44 | 45 | 46 | @end 47 | 48 | int main() 49 | { 50 | // unwind exception and alt handler through objc_msgSend() 51 | 52 | PUSH_POOL { 53 | 54 | const int count = is_guardmalloc() ? 1000 : 100000; 55 | state = 0; 56 | for (int i = 0; i < count; i++) { 57 | @try { 58 | testassert(state == 0); state++; 59 | [Foo method]; 60 | testassert(0); 61 | } @catch (Bar *e) { 62 | testassert(0); 63 | } @catch (Foo *e) { 64 | testassert(e == exc); 65 | testassert(state == 4); state++; 66 | testassert(state == 5); [e check]; // state++ 67 | RELEASE_VAR(exc); 68 | } @catch (id e) { 69 | testassert(0); 70 | } @catch (...) { 71 | testassert(0); 72 | } @finally { 73 | testassert(state == 6); state++; 74 | } 75 | testassert(state == 7); state = 0; 76 | } 77 | 78 | } POP_POOL; 79 | 80 | succeed(__FILE__); 81 | } 82 | -------------------------------------------------------------------------------- /objc4-779.1/test/weak.h: -------------------------------------------------------------------------------- 1 | /* 2 | To test -weak-l or -weak-framework: 3 | * -DWEAK_IMPORT= 4 | * -DWEAK_FRAMEWORK=1 5 | * -UEMPTY when building the weak-not-missing library 6 | * -DEMPTY= when building the weak-missing library 7 | 8 | To test attribute((weak_import)): 9 | * -DWEAK_IMPORT=__attribute__((weak_import)) 10 | * -UWEAK_FRAMEWORK 11 | * -UEMPTY when building the weak-not-missing library 12 | * -DEMPTY= when building the weak-missing library 13 | 14 | */ 15 | 16 | #include "test.h" 17 | #include 18 | 19 | extern int state; 20 | 21 | WEAK_IMPORT OBJC_ROOT_CLASS 22 | @interface MissingRoot { 23 | id isa; 24 | } 25 | +(void) initialize; 26 | +(Class) class; 27 | +(id) alloc; 28 | -(id) init; 29 | -(void) dealloc; 30 | +(int) method; 31 | @end 32 | 33 | @interface MissingRoot (RR) 34 | -(id) retain; 35 | -(void) release; 36 | @end 37 | 38 | WEAK_IMPORT 39 | @interface MissingSuper : MissingRoot { 40 | @public 41 | int ivar; 42 | } 43 | @end 44 | 45 | OBJC_ROOT_CLASS 46 | @interface NotMissingRoot { 47 | id isa; 48 | } 49 | +(void) initialize; 50 | +(Class) class; 51 | +(id) alloc; 52 | -(id) init; 53 | -(void) dealloc; 54 | +(int) method; 55 | @end 56 | 57 | @interface NotMissingRoot (RR) 58 | -(id) retain; 59 | -(void) release; 60 | @end 61 | 62 | @interface NotMissingSuper : NotMissingRoot { 63 | @public 64 | int unused[100]; 65 | int ivar; 66 | } 67 | @end 68 | -------------------------------------------------------------------------------- /objc4-779.1/test/weakcopy.m: -------------------------------------------------------------------------------- 1 | // TEST_CFLAGS -fobjc-weak 2 | 3 | #include "test.h" 4 | 5 | #include "testroot.i" 6 | #include 7 | #include 8 | #include 9 | 10 | @interface Weak : TestRoot { 11 | @public 12 | __weak id value; 13 | } 14 | @end 15 | @implementation Weak 16 | @end 17 | 18 | Weak *oldObject; 19 | Weak *newObject; 20 | 21 | int main() 22 | { 23 | testonthread(^{ 24 | TestRoot *value; 25 | 26 | PUSH_POOL { 27 | value = [TestRoot new]; 28 | testassert(value); 29 | oldObject = [Weak new]; 30 | testassert(oldObject); 31 | 32 | oldObject->value = value; 33 | testassert(oldObject->value == value); 34 | 35 | newObject = [oldObject copy]; 36 | testassert(newObject); 37 | testassert(newObject->value == oldObject->value); 38 | 39 | newObject->value = nil; 40 | testassert(newObject->value == nil); 41 | testassert(oldObject->value == value); 42 | } POP_POOL; 43 | 44 | testcollect(); 45 | TestRootDealloc = 0; 46 | RELEASE_VAR(value); 47 | }); 48 | 49 | testcollect(); 50 | testassert(TestRootDealloc); 51 | 52 | #if __has_feature(objc_arc_weak) 53 | testassert(oldObject->value == nil); 54 | #endif 55 | testassert(newObject->value == nil); 56 | 57 | RELEASE_VAR(newObject); 58 | RELEASE_VAR(oldObject); 59 | 60 | succeed(__FILE__); 61 | return 0; 62 | } 63 | -------------------------------------------------------------------------------- /objc4-779.1/test/weakframework-missing.m: -------------------------------------------------------------------------------- 1 | /* 2 | TEST_BUILD 3 | $C{COMPILE} $DIR/weak2.m -DWEAK_FRAMEWORK=1 -DWEAK_IMPORT= -UEMPTY -dynamiclib -o libweakframework.dylib 4 | 5 | $C{COMPILE} $DIR/weakframework-missing.m -L. -weak-lweakframework -o weakframework-missing.exe 6 | 7 | $C{COMPILE} $DIR/weak2.m -DWEAK_FRAMEWORK=1 -DWEAK_IMPORT= -DEMPTY= -dynamiclib -o libweakframework.dylib 8 | 9 | END 10 | */ 11 | 12 | #define WEAK_FRAMEWORK 1 13 | #define WEAK_IMPORT 14 | #include "weak.m" 15 | -------------------------------------------------------------------------------- /objc4-779.1/test/weakframework-not-missing.m: -------------------------------------------------------------------------------- 1 | /* 2 | TEST_BUILD 3 | $C{COMPILE} $DIR/weak2.m -DWEAK_FRAMEWORK=1 -DWEAK_IMPORT= -UEMPTY -dynamiclib -o libweakframework.dylib 4 | 5 | $C{COMPILE} $DIR/weakframework-not-missing.m -L. -weak-lweakframework -o weakframework-not-missing.exe 6 | END 7 | */ 8 | 9 | #define WEAK_FRAMEWORK 1 10 | #define WEAK_IMPORT 11 | #include "weak.m" 12 | -------------------------------------------------------------------------------- /objc4-779.1/test/weakimport-missing.m: -------------------------------------------------------------------------------- 1 | /* 2 | TEST_BUILD 3 | $C{COMPILE} $DIR/weak2.m -UWEAK_FRAMEWORK -DWEAK_IMPORT=__attribute__\\(\\(weak_import\\)\\) -UEMPTY -dynamiclib -o libweakimport.dylib 4 | 5 | $C{COMPILE} $DIR/weakimport-missing.m -L. -weak-lweakimport -o weakimport-missing.exe 6 | 7 | $C{COMPILE} $DIR/weak2.m -UWEAK_FRAMEWORK -DWEAK_IMPORT=__attribute__\\(\\(weak_import\\)\\) -DEMPTY= -dynamiclib -o libweakimport.dylib 8 | END 9 | */ 10 | 11 | // #define WEAK_FRAMEWORK 12 | #define WEAK_IMPORT __attribute__((weak_import)) 13 | #include "weak.m" 14 | -------------------------------------------------------------------------------- /objc4-779.1/test/weakimport-not-missing.m: -------------------------------------------------------------------------------- 1 | /* 2 | TEST_BUILD 3 | $C{COMPILE} $DIR/weak2.m -UWEAK_FRAMEWORK -DWEAK_IMPORT=__attribute__\\(\\(weak_import\\)\\) -UEMPTY -dynamiclib -o libweakimport.dylib 4 | 5 | $C{COMPILE} $DIR/weakimport-not-missing.m -L. -weak-lweakimport -o weakimport-not-missing.exe 6 | END 7 | */ 8 | 9 | // #define WEAK_FRAMEWORK 10 | #define WEAK_IMPORT __attribute__((weak_import)) 11 | #include "weak.m" 12 | -------------------------------------------------------------------------------- /objc4-779.1/test/weakrace.m: -------------------------------------------------------------------------------- 1 | // TEST_CONFIG MEM=mrc 2 | 3 | #include "test.h" 4 | #include 5 | 6 | static semaphore_t go1; 7 | static semaphore_t go2; 8 | static semaphore_t done; 9 | 10 | #define VARCOUNT 100000 11 | static id obj; 12 | static id vars[VARCOUNT]; 13 | 14 | 15 | void *destroyer(void *arg __unused) 16 | { 17 | while (1) { 18 | semaphore_wait(go1); 19 | for (int i = 0; i < VARCOUNT; i++) { 20 | objc_destroyWeak(&vars[i]); 21 | } 22 | semaphore_signal(done); 23 | } 24 | } 25 | 26 | 27 | void *deallocator(void *arg __unused) 28 | { 29 | while (1) { 30 | semaphore_wait(go2); 31 | [obj release]; 32 | semaphore_signal(done); 33 | } 34 | } 35 | 36 | 37 | void cycle(void) 38 | { 39 | // rdar://12896779 objc_destroyWeak() versus weak clear in dealloc 40 | 41 | // Clean up from previous cycle - objc_destroyWeak() doesn't set var to nil 42 | for (int i = 0; i < VARCOUNT; i++) { 43 | vars[i] = nil; 44 | } 45 | 46 | obj = [NSObject new]; 47 | for (int i = 0; i < VARCOUNT; i++) { 48 | objc_storeWeak(&vars[i], obj); 49 | } 50 | 51 | // let destroyer start before deallocator runs 52 | semaphore_signal(go1); 53 | sched_yield(); 54 | semaphore_signal(go2); 55 | 56 | semaphore_wait(done); 57 | semaphore_wait(done); 58 | } 59 | 60 | 61 | int main() 62 | { 63 | semaphore_create(mach_task_self(), &go1, 0, 0); 64 | semaphore_create(mach_task_self(), &go2, 0, 0); 65 | semaphore_create(mach_task_self(), &done, 0, 0); 66 | 67 | pthread_t th[2]; 68 | pthread_create(&th[1], NULL, deallocator, NULL); 69 | pthread_create(&th[1], NULL, destroyer, NULL); 70 | 71 | for (int i = 0; i < 100; i++) { 72 | cycle(); 73 | } 74 | 75 | succeed(__FILE__); 76 | } 77 | -------------------------------------------------------------------------------- /objc4-779.1/test/zone.m: -------------------------------------------------------------------------------- 1 | // TEST_CONFIG 2 | 3 | #include "test.h" 4 | #include 5 | #include 6 | 7 | // Look for malloc zone "ObjC" iff OBJC_USE_INTERNAL_ZONE is set. 8 | // This fails if objc tries to allocate before checking its own 9 | // environment variables (rdar://6688423) 10 | 11 | int main() 12 | { 13 | if (is_guardmalloc()) { 14 | // guard malloc confuses this test 15 | succeed(__FILE__); 16 | } 17 | 18 | kern_return_t kr; 19 | vm_address_t *zones; 20 | unsigned int count, i; 21 | BOOL has_objc = NO, want_objc = NO; 22 | 23 | want_objc = (getenv("OBJC_USE_INTERNAL_ZONE") != NULL) ? YES : NO; 24 | testprintf("want objc %s\n", want_objc ? "YES" : "NO"); 25 | 26 | kr = malloc_get_all_zones(mach_task_self(), NULL, &zones, &count); 27 | testassert(!kr); 28 | for (i = 0; i < count; i++) { 29 | const char *name = malloc_get_zone_name((malloc_zone_t *)zones[i]); 30 | if (name) { 31 | BOOL is_objc = (0 == strcmp(name, "ObjC_Internal")) ? YES : NO; 32 | if (is_objc) has_objc = YES; 33 | testprintf("zone %s\n", name); 34 | } 35 | } 36 | 37 | testassert(want_objc == has_objc); 38 | 39 | succeed(__FILE__); 40 | } 41 | -------------------------------------------------------------------------------- /objc4-779.1/unexported_symbols: -------------------------------------------------------------------------------- 1 | .objc_class_name___IncompleteProtocol 2 | __Znam 3 | __ZnamRKSt9nothrow_t 4 | __Znwm 5 | __ZnwmRKSt9nothrow_t 6 | __ZdaPv 7 | __ZdaPvRKSt9nothrow_t 8 | __ZdlPv 9 | __ZdlPvRKSt9nothrow_t 10 | __ZTISt9bad_alloc 11 | __ZTISt9exception 12 | __ZTISt11logic_error 13 | __ZTISt12length_error 14 | __ZTSSt9bad_alloc 15 | __ZTSSt9exception 16 | __ZTSSt11logic_error 17 | __ZTSSt12length_error 18 | -------------------------------------------------------------------------------- /objc4-779.1/version.bat: -------------------------------------------------------------------------------- 1 | :: version.bat 2 | :: Writes version numbers from B&I into version.h for use by version.rc. 3 | 4 | @ECHO OFF 5 | 6 | :: Set default values for environment variables if not set by B&I 7 | IF "%OBJROOT%"=="" SET OBJROOT=. 8 | IF "%RC_PROJECTSOURCEVERSION%"=="" SET RC_PROJECTSOURCEVERSION=0.0 9 | IF "%RC_PROJECTBUILDVERSION%"=="" SET RC_PROJECTBUILDVERSION=0 10 | 11 | :: Get version numbers from environment variables 12 | SET major=1 13 | SET patch=0 14 | FOR /F "tokens=1* eol= delims=." %%i IN ("%RC_PROJECTSOURCEVERSION%") DO ( 15 | SET minor=%%i 16 | IF NOT "%%j"=="" SET patch=%%j 17 | ) 18 | SET build=%RC_PROJECTBUILDVERSION% 19 | 20 | ECHO version %major% . %minor% . %patch% . %build% 21 | 22 | :: Write version.h 23 | ECHO // This file is automatically generated by version.bat. > "%OBJROOT%\version.h" 24 | ECHO // DO NOT EDIT >> "%OBJROOT%\version.h" 25 | ECHO #define major %major% >> "%OBJROOT%\version.h" 26 | ECHO #define minor %minor% >> "%OBJROOT%\version.h" 27 | ECHO #define patch %patch% >> "%OBJROOT%\version.h" 28 | ECHO #define build %build% >> "%OBJROOT%\version.h" 29 | ECHO #define string "%major%,%minor%,%patch%,%build%" >> "%OBJROOT%\version.h" 30 | -------------------------------------------------------------------------------- /objc4-779.1/version.rc: -------------------------------------------------------------------------------- 1 | #include "Winver.h" 2 | 3 | // built by version.bat; sets variables major, minor, patch, build, string 4 | #include "version.h" 5 | 6 | VS_VERSION_INFO VERSIONINFO 7 | FILEVERSION major,minor,patch,build 8 | PRODUCTVERSION major,minor,patch,build 9 | FILEFLAGSMASK 0x17L 10 | #ifdef _DEBUG 11 | FILEFLAGS VS_FF_DEBUG 12 | #else 13 | FILEFLAGS 0x0L 14 | #endif 15 | FILEOS VOS_NT_WINDOWS32 16 | FILETYPE VFT_DLL 17 | FILESUBTYPE VFT2_UNKNOWN 18 | BEGIN 19 | BLOCK "StringFileInfo" 20 | BEGIN 21 | BLOCK "040904b0" 22 | BEGIN 23 | VALUE "CompanyName", "Apple Inc." 24 | VALUE "FileDescription", "Objective-C Runtime Library" 25 | VALUE "FileVersion", string 26 | VALUE "ProductVersion", string 27 | VALUE "ProductName", "objc4" 28 | VALUE "InternalName", "objc4" 29 | VALUE "LegalCopyright", "Copyright (C) 2007-2009, Apple Inc." 30 | VALUE "OriginalFilename", "objc.dll" 31 | END 32 | END 33 | BLOCK "VarFileInfo" 34 | BEGIN 35 | VALUE "Translation", 0x409, 1200 36 | END 37 | END 38 | 39 | -------------------------------------------------------------------------------- /objc4-runtime-750/README.md: -------------------------------------------------------------------------------- 1 | # objc4-750 2 | A project that can debug the objc4-750 using Xcdoe 10 in macOS Mojave. 3 | -------------------------------------------------------------------------------- /objc4-runtime-750/debug-objc/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // debug-objc 4 | // 5 | // Created by qingsong on 2018/4/8. 6 | // 7 | 8 | #import 9 | #include "runtime.h" 10 | 11 | @interface XXObject : NSObject 12 | 13 | @end 14 | 15 | @implementation XXObject 16 | 17 | + (void)initialize { 18 | NSLog(@"XXObject initialize"); 19 | } 20 | 21 | + (void)load { 22 | NSLog(@"XXObject load");} 23 | 24 | @end 25 | 26 | int main(int argc, const char * argv[]) { 27 | @autoreleasepool { 28 | // insert code here... 29 | NSLog(@"Hello, World!"); 30 | 31 | __unused XXObject *object = [XXObject new]; 32 | Class 33 | } 34 | return 0; 35 | } 36 | -------------------------------------------------------------------------------- /objc4-runtime-750/include/CrashReporterClient.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2010 Apple Inc. All rights reserved. 3 | * 4 | * @APPLE_LICENSE_HEADER_START@ 5 | * 6 | * This file contains Original Code and/or Modifications of Original Code 7 | * as defined in and that are subject to the Apple Public Source License 8 | * Version 2.0 (the 'License'). You may not use this file except in 9 | * compliance with the License. Please obtain a copy of the License at 10 | * http://www.opensource.apple.com/apsl/ and read it before using this 11 | * file. 12 | * 13 | * The Original Code and all software distributed under the License are 14 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER 15 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, 16 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. 18 | * Please see the License for the specific language governing rights and 19 | * limitations under the License. 20 | * 21 | * @APPLE_LICENSE_HEADER_END@ 22 | */ 23 | 24 | /*********************************************************************** 25 | * Not to be installed in /usr/local/include 26 | ***********************************************************************/ 27 | 28 | #ifndef _LIBC_CRASHREPORTERCLIENT_H 29 | #define _LIBC_CRASHREPORTERCLIENT_H 30 | 31 | #ifdef LIBC_NO_LIBCRASHREPORTERCLIENT 32 | 33 | /* Fake the CrashReporterClient API */ 34 | #define CRGetCrashLogMessage() 0 35 | #define CRSetCrashLogMessage(x) /* nothing */ 36 | 37 | #else /* !LIBC_NO_LIBCRASHREPORTERCLIENT */ 38 | 39 | /* Include the real CrashReporterClient.h */ 40 | #include_next 41 | 42 | #endif /* !LIBC_NO_LIBCRASHREPORTERCLIENT */ 43 | 44 | #endif /* _LIBC_CRASHREPORTERCLIENT_H */ 45 | -------------------------------------------------------------------------------- /objc4-runtime-750/include/System/machine/cpu_capabilities.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2000-2007 Apple Inc. All rights reserved. 3 | * 4 | * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ 5 | * 6 | * This file contains Original Code and/or Modifications of Original Code 7 | * as defined in and that are subject to the Apple Public Source License 8 | * Version 2.0 (the 'License'). You may not use this file except in 9 | * compliance with the License. The rights granted to you under the License 10 | * may not be used to create, or enable the creation or redistribution of, 11 | * unlawful or unlicensed copies of an Apple operating system, or to 12 | * circumvent, violate, or enable the circumvention or violation of, any 13 | * terms of an Apple operating system software license agreement. 14 | * 15 | * Please obtain a copy of the License at 16 | * http://www.opensource.apple.com/apsl/ and read it before using this file. 17 | * 18 | * The Original Code and all software distributed under the License are 19 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER 20 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, 21 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, 22 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. 23 | * Please see the License for the specific language governing rights and 24 | * limitations under the License. 25 | * 26 | * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ 27 | */ 28 | #ifdef PRIVATE 29 | 30 | #ifndef _MACHINE_CPU_CAPABILITIES_H 31 | #define _MACHINE_CPU_CAPABILITIES_H 32 | 33 | #ifdef KERNEL_PRIVATE 34 | #if defined (__i386__) || defined (__x86_64__) 35 | #include "i386/cpu_capabilities.h" 36 | #elif defined (__arm__) || defined (__arm64__) 37 | #include "arm/cpu_capabilities.h" 38 | #else 39 | #error architecture not supported 40 | #endif 41 | 42 | #else /* !KERNEL_PRIVATE -- System Framework header */ 43 | #if defined (__i386__) || defined(__x86_64__) 44 | #include 45 | #elif defined (__arm__) || defined(__arm64__) 46 | #include 47 | #else 48 | #error architecture not supported 49 | #endif 50 | #endif /* KERNEL_PRIVATE */ 51 | 52 | #endif /* _MACHINE_CPU_CAPABILITIES_H */ 53 | #endif /* PRIVATE */ 54 | -------------------------------------------------------------------------------- /objc4-runtime-750/include/os/base_private.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2008-2013 Apple Inc. All rights reserved. 3 | * 4 | * @APPLE_APACHE_LICENSE_HEADER_START@ 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | * 18 | * @APPLE_APACHE_LICENSE_HEADER_END@ 19 | */ 20 | 21 | #ifndef __OS_BASE_PRIVATE__ 22 | #define __OS_BASE_PRIVATE__ 23 | 24 | #include 25 | 26 | #ifndef os_fastpath 27 | #define os_fastpath(x) ((__typeof__(x))OS_EXPECT((long)(x), ~0l)) 28 | #endif 29 | #ifndef os_slowpath 30 | #define os_slowpath(x) ((__typeof__(x))OS_EXPECT((long)(x), 0l)) 31 | #endif 32 | #ifndef os_likely 33 | #define os_likely(x) OS_EXPECT(!!(x), 1) 34 | #endif 35 | #ifndef os_unlikely 36 | #define os_unlikely(x) OS_EXPECT(!!(x), 0) 37 | #endif 38 | 39 | #endif // __OS_BASE_PRIVATE__ 40 | -------------------------------------------------------------------------------- /objc4-runtime-750/include/sys/qos_private.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2014 Apple Inc. All rights reserved. 3 | * 4 | * @APPLE_LICENSE_HEADER_START@ 5 | * 6 | * This file contains Original Code and/or Modifications of Original Code 7 | * as defined in and that are subject to the Apple Public Source License 8 | * Version 2.0 (the 'License'). You may not use this file except in 9 | * compliance with the License. Please obtain a copy of the License at 10 | * http://www.opensource.apple.com/apsl/ and read it before using this 11 | * file. 12 | * 13 | * The Original Code and all software distributed under the License are 14 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER 15 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, 16 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. 18 | * Please see the License for the specific language governing rights and 19 | * limitations under the License. 20 | * 21 | * @APPLE_LICENSE_HEADER_END@ 22 | */ 23 | 24 | #ifndef _QOS_SYS_PRIVATE_H 25 | #define _QOS_SYS_PRIVATE_H 26 | 27 | /*! 28 | * @constant QOS_CLASS_MAINTENANCE 29 | * @abstract A QOS class which indicates work performed by this thread was not 30 | * initiated by the user and that the user may be unaware of the results. 31 | * @discussion Such work is requested to run at a priority far below other work 32 | * including significant I/O throttling. The use of this QOS class indicates 33 | * the work should be run in the most energy and thermally-efficient manner 34 | * possible, and may be deferred for a long time in order to preserve 35 | * system responsiveness for the user. 36 | * This is SPI for use by Spotlight and Time Machine only. 37 | */ 38 | #define QOS_CLASS_MAINTENANCE 0x05 39 | 40 | #endif //_QOS_SYS_PRIVATE_H 41 | -------------------------------------------------------------------------------- /objc4-runtime-750/interposable.txt: -------------------------------------------------------------------------------- 1 | _objc_release 2 | -------------------------------------------------------------------------------- /objc4-runtime-750/objc-debug/NSObject+Test.h: -------------------------------------------------------------------------------- 1 | // 2 | // NSObject+Test.h 3 | // objc-debug 4 | // 5 | // Created by 刘小壮 on 2019/4/27. 6 | // 7 | 8 | #import "TestObject.h" 9 | 10 | @interface NSObject (Test) 11 | @property (nonatomic, strong) TestObject *object; 12 | @end 13 | -------------------------------------------------------------------------------- /objc4-runtime-750/objc-debug/NSObject+Test.m: -------------------------------------------------------------------------------- 1 | // 2 | // NSObject+Test.m 3 | // objc-debug 4 | // 5 | // Created by 刘小壮 on 2019/4/27. 6 | // 7 | 8 | #import "NSObject+Test.h" 9 | #import 10 | 11 | static const char *AppDelegate_activityItemKey = "AppDelegate_activityItemKey"; 12 | 13 | @implementation NSObject (Test) 14 | 15 | - (void)setObject:(TestObject *)object { 16 | objc_setAssociatedObject(self, 17 | &AppDelegate_activityItemKey, 18 | object, 19 | OBJC_ASSOCIATION_RETAIN_NONATOMIC); 20 | } 21 | 22 | - (TestObject *)object { 23 | return objc_getAssociatedObject(self, &AppDelegate_activityItemKey); 24 | } 25 | 26 | @end 27 | -------------------------------------------------------------------------------- /objc4-runtime-750/objc-debug/TestObject.h: -------------------------------------------------------------------------------- 1 | // 2 | // TestObject.h 3 | // objc-debug 4 | // 5 | // Created by 灏 孙 on 2018/12/6. 6 | // 7 | 8 | #import 9 | 10 | NS_ASSUME_NONNULL_BEGIN 11 | 12 | @interface TestObject : NSObject 13 | 14 | @end 15 | 16 | NS_ASSUME_NONNULL_END 17 | -------------------------------------------------------------------------------- /objc4-runtime-750/objc-debug/TestObject.m: -------------------------------------------------------------------------------- 1 | // 2 | // TestObject.m 3 | // objc-debug 4 | // 5 | // Created by 灏 孙 on 2018/12/6. 6 | // 7 | 8 | #import "TestObject.h" 9 | 10 | @implementation TestObject 11 | 12 | - (void)dealloc { 13 | 14 | } 15 | 16 | @end 17 | -------------------------------------------------------------------------------- /objc4-runtime-750/objc-debug/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // objc-debug 4 | // 5 | // Created by 灏 孙 on 2018/12/6. 6 | // 7 | 8 | #import "NSObject+Test.h" 9 | 10 | int main(int argc, const char * argv[]) { 11 | @autoreleasepool { 12 | NSObject *object = [[NSObject alloc] init]; 13 | object.object = [[TestObject alloc] init]; 14 | object = nil; 15 | NSLog(@"hello world"); 16 | } 17 | return 0; 18 | } 19 | -------------------------------------------------------------------------------- /objc4-runtime-750/objc.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 9.00 3 | # Visual C++ Express 2005 4 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "objc", "objc.vcproj", "{B3408263-0CF1-47BE-83CC-56070EFC9BC1}" 5 | EndProject 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "objcrt", "objcrt\objcrt.vcproj", "{E38C1996-8B3D-4050-A4B2-DC85957B047D}" 7 | ProjectSection(ProjectDependencies) = postProject 8 | {B3408263-0CF1-47BE-83CC-56070EFC9BC1} = {B3408263-0CF1-47BE-83CC-56070EFC9BC1} 9 | EndProjectSection 10 | EndProject 11 | Global 12 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 13 | Debug|Win32 = Debug|Win32 14 | DebugDLL|Win32 = DebugDLL|Win32 15 | Release|Win32 = Release|Win32 16 | EndGlobalSection 17 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 18 | {B3408263-0CF1-47BE-83CC-56070EFC9BC1}.Debug|Win32.ActiveCfg = Debug|Win32 19 | {B3408263-0CF1-47BE-83CC-56070EFC9BC1}.Debug|Win32.Build.0 = Debug|Win32 20 | {B3408263-0CF1-47BE-83CC-56070EFC9BC1}.DebugDLL|Win32.ActiveCfg = DebugDLL|Win32 21 | {B3408263-0CF1-47BE-83CC-56070EFC9BC1}.DebugDLL|Win32.Build.0 = DebugDLL|Win32 22 | {B3408263-0CF1-47BE-83CC-56070EFC9BC1}.Release|Win32.ActiveCfg = Release|Win32 23 | {B3408263-0CF1-47BE-83CC-56070EFC9BC1}.Release|Win32.Build.0 = Release|Win32 24 | {E38C1996-8B3D-4050-A4B2-DC85957B047D}.Debug|Win32.ActiveCfg = Debug|Win32 25 | {E38C1996-8B3D-4050-A4B2-DC85957B047D}.Debug|Win32.Build.0 = Debug|Win32 26 | {E38C1996-8B3D-4050-A4B2-DC85957B047D}.DebugDLL|Win32.ActiveCfg = Debug|Win32 27 | {E38C1996-8B3D-4050-A4B2-DC85957B047D}.DebugDLL|Win32.Build.0 = Debug|Win32 28 | {E38C1996-8B3D-4050-A4B2-DC85957B047D}.Release|Win32.ActiveCfg = Release|Win32 29 | {E38C1996-8B3D-4050-A4B2-DC85957B047D}.Release|Win32.Build.0 = Release|Win32 30 | EndGlobalSection 31 | GlobalSection(SolutionProperties) = preSolution 32 | HideSolutionNode = FALSE 33 | EndGlobalSection 34 | EndGlobal 35 | -------------------------------------------------------------------------------- /objc4-runtime-750/objc.suo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DeveloperErenLiu/RuntimeAnalyze/acb7f2ce0dab8b88c759f1019a60dc3e69917b14/objc4-runtime-750/objc.suo -------------------------------------------------------------------------------- /objc4-runtime-750/objc.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /objc4-runtime-750/prebuild.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | 3 | echo prebuild: installing headers 4 | xcopy /Y "%ProjectDir%runtime\objc.h" "%DSTROOT%\AppleInternal\include\objc\" 5 | xcopy /Y "%ProjectDir%runtime\objc-api.h" "%DSTROOT%\AppleInternal\include\objc\" 6 | xcopy /Y "%ProjectDir%runtime\objc-auto.h" "%DSTROOT%\AppleInternal\include\objc\" 7 | xcopy /Y "%ProjectDir%runtime\objc-exception.h" "%DSTROOT%\AppleInternal\include\objc\" 8 | xcopy /Y "%ProjectDir%runtime\message.h" "%DSTROOT%\AppleInternal\include\objc\" 9 | xcopy /Y "%ProjectDir%runtime\runtime.h" "%DSTROOT%\AppleInternal\include\objc\" 10 | xcopy /Y "%ProjectDir%runtime\hashtable.h" "%DSTROOT%\AppleInternal\include\objc\" 11 | xcopy /Y "%ProjectDir%runtime\hashtable2.h" "%DSTROOT%\AppleInternal\include\objc\" 12 | xcopy /Y "%ProjectDir%runtime\maptable.h" "%DSTROOT%\AppleInternal\include\objc\" 13 | 14 | echo prebuild: setting version 15 | version 16 | -------------------------------------------------------------------------------- /objc4-runtime-750/runtime/Module/module.modulemap: -------------------------------------------------------------------------------- 1 | module ObjectiveC [system] [extern_c] { 2 | umbrella "." 3 | export * 4 | module * { 5 | export * 6 | } 7 | 8 | module NSObject { 9 | requires objc 10 | header "NSObject.h" 11 | export * 12 | } 13 | 14 | #if defined(BUILD_FOR_OSX) 15 | module List { 16 | // Uses @defs, which does not work in ObjC++ or non-ARC. 17 | requires objc, !objc_arc, !cplusplus 18 | header "List.h" 19 | export * 20 | } 21 | 22 | module Object { 23 | requires objc 24 | header "Object.h" 25 | export * 26 | } 27 | 28 | module Protocol { 29 | requires objc 30 | header "Protocol.h" 31 | export * 32 | } 33 | #endif 34 | 35 | #if !defined(BUILD_FOR_OSX) 36 | // These file are not available outside macOS. 37 | exclude header "hashtable.h" 38 | exclude header "hashtable2.h" 39 | #endif 40 | } 41 | -------------------------------------------------------------------------------- /objc4-runtime-750/runtime/NSObjCRuntime.h: -------------------------------------------------------------------------------- 1 | /* NSObjCRuntime.h 2 | Copyright (c) 1994-2012, Apple Inc. All rights reserved. 3 | */ 4 | 5 | #ifndef _OBJC_NSOBJCRUNTIME_H_ 6 | #define _OBJC_NSOBJCRUNTIME_H_ 7 | 8 | #include 9 | #include 10 | 11 | #if __LP64__ || TARGET_OS_WIN32 || NS_BUILD_32_LIKE_64 12 | typedef long NSInteger; 13 | typedef unsigned long NSUInteger; 14 | #else 15 | typedef int NSInteger; 16 | typedef unsigned int NSUInteger; 17 | #endif 18 | 19 | #define NSIntegerMax LONG_MAX 20 | #define NSIntegerMin LONG_MIN 21 | #define NSUIntegerMax ULONG_MAX 22 | 23 | #define NSINTEGER_DEFINED 1 24 | 25 | #ifndef NS_DESIGNATED_INITIALIZER 26 | #if __has_attribute(objc_designated_initializer) 27 | #define NS_DESIGNATED_INITIALIZER __attribute__((objc_designated_initializer)) 28 | #else 29 | #define NS_DESIGNATED_INITIALIZER 30 | #endif 31 | #endif 32 | 33 | #endif 34 | -------------------------------------------------------------------------------- /objc4-runtime-750/runtime/hashtable.h: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | -------------------------------------------------------------------------------- /objc4-runtime-750/runtime/objc-block-trampolines.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018 Apple Inc. All Rights Reserved. 3 | * 4 | * @APPLE_LICENSE_HEADER_START@ 5 | * 6 | * This file contains Original Code and/or Modifications of Original Code 7 | * as defined in and that are subject to the Apple Public Source License 8 | * Version 2.0 (the 'License'). You may not use this file except in 9 | * compliance with the License. Please obtain a copy of the License at 10 | * http://www.opensource.apple.com/apsl/ and read it before using this 11 | * file. 12 | * 13 | * The Original Code and all software distributed under the License are 14 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER 15 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, 16 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. 18 | * Please see the License for the specific language governing rights and 19 | * limitations under the License. 20 | * 21 | * @APPLE_LICENSE_HEADER_END@ 22 | */ 23 | 24 | 25 | #ifndef _OBJC_TRAMPOLINES_H 26 | #define _OBJC_TRAMPOLINES_H 27 | 28 | /* 29 | * WARNING DANGER HAZARD BEWARE EEK 30 | * 31 | * Everything in this file is for Apple Internal use only. 32 | * These will change in arbitrary OS updates and in unpredictable ways. 33 | * When your program breaks, you get to keep both pieces. 34 | */ 35 | 36 | /* 37 | * objc-block-trampolines.h: Symbols for IMP block trampolines 38 | */ 39 | 40 | #include 41 | 42 | OBJC_EXPORT const char _objc_blockTrampolineImpl 43 | OBJC_AVAILABLE(10.14, 12.0, 12.0, 5.0, 3.0); 44 | 45 | OBJC_EXPORT const char _objc_blockTrampolineStart 46 | OBJC_AVAILABLE(10.14, 12.0, 12.0, 5.0, 3.0); 47 | 48 | OBJC_EXPORT const char _objc_blockTrampolineLast 49 | OBJC_AVAILABLE(10.14, 12.0, 12.0, 5.0, 3.0); 50 | 51 | 52 | OBJC_EXPORT const char _objc_blockTrampolineImpl_stret 53 | OBJC_AVAILABLE(10.14, 12.0, 12.0, 5.0, 3.0) 54 | OBJC_ARM64_UNAVAILABLE; 55 | 56 | OBJC_EXPORT const char _objc_blockTrampolineStart_stret 57 | OBJC_AVAILABLE(10.14, 12.0, 12.0, 5.0, 3.0) 58 | OBJC_ARM64_UNAVAILABLE; 59 | 60 | OBJC_EXPORT const char _objc_blockTrampolineLast_stret 61 | OBJC_AVAILABLE(10.14, 12.0, 12.0, 5.0, 3.0) 62 | OBJC_ARM64_UNAVAILABLE; 63 | 64 | #endif 65 | -------------------------------------------------------------------------------- /objc4-runtime-750/runtime/objc-cache-old.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012 Apple Inc. All Rights Reserved. 3 | * 4 | * @APPLE_LICENSE_HEADER_START@ 5 | * 6 | * This file contains Original Code and/or Modifications of Original Code 7 | * as defined in and that are subject to the Apple Public Source License 8 | * Version 2.0 (the 'License'). You may not use this file except in 9 | * compliance with the License. Please obtain a copy of the License at 10 | * http://www.opensource.apple.com/apsl/ and read it before using this 11 | * file. 12 | * 13 | * The Original Code and all software distributed under the License are 14 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER 15 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, 16 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. 18 | * Please see the License for the specific language governing rights and 19 | * limitations under the License. 20 | * 21 | * @APPLE_LICENSE_HEADER_END@ 22 | */ 23 | 24 | #ifndef _OBJC_CACHE_OLD_H 25 | #define _OBJC_CACHE_OLD_H 26 | 27 | #include "objc-private.h" 28 | 29 | __BEGIN_DECLS 30 | 31 | extern IMP _cache_getImp(Class cls, SEL sel); 32 | extern Method _cache_getMethod(Class cls, SEL sel, IMP objc_msgForward_internal_imp); 33 | 34 | extern void flush_cache(Class cls); 35 | extern bool _cache_fill(Class cls, Method meth, SEL sel); 36 | extern void _cache_addForwardEntry(Class cls, SEL sel); 37 | extern IMP _cache_addIgnoredEntry(Class cls, SEL sel); 38 | extern void _cache_free(Cache cache); 39 | extern void _cache_collect(bool collectALot); 40 | 41 | __END_DECLS 42 | 43 | #endif 44 | -------------------------------------------------------------------------------- /objc4-runtime-750/runtime/objc-cache.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef _OBJC_CACHE_H 3 | #define _OBJC_CACHE_H 4 | 5 | #include "objc-private.h" 6 | 7 | __BEGIN_DECLS 8 | 9 | extern IMP cache_getImp(Class cls, SEL sel); 10 | 11 | extern void cache_fill(Class cls, SEL sel, IMP imp, id receiver); 12 | 13 | extern void cache_erase_nolock(Class cls); 14 | 15 | extern void cache_delete(Class cls); 16 | 17 | extern void cache_collect(bool collectALot); 18 | 19 | __END_DECLS 20 | 21 | #endif 22 | -------------------------------------------------------------------------------- /objc4-runtime-750/runtime/objc-class.h: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | -------------------------------------------------------------------------------- /objc4-runtime-750/runtime/objc-file-old.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2009 Apple Inc. All Rights Reserved. 3 | * 4 | * @APPLE_LICENSE_HEADER_START@ 5 | * 6 | * This file contains Original Code and/or Modifications of Original Code 7 | * as defined in and that are subject to the Apple Public Source License 8 | * Version 2.0 (the 'License'). You may not use this file except in 9 | * compliance with the License. Please obtain a copy of the License at 10 | * http://www.opensource.apple.com/apsl/ and read it before using this 11 | * file. 12 | * 13 | * The Original Code and all software distributed under the License are 14 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER 15 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, 16 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. 18 | * Please see the License for the specific language governing rights and 19 | * limitations under the License. 20 | * 21 | * @APPLE_LICENSE_HEADER_END@ 22 | */ 23 | 24 | #ifndef _OBJC_FILE_OLD_H 25 | #define _OBJC_FILE_OLD_H 26 | 27 | #if !__OBJC2__ 28 | 29 | #include "objc-os.h" 30 | 31 | struct objc_module; 32 | struct old_protocol; 33 | struct old_class; 34 | 35 | __BEGIN_DECLS 36 | 37 | extern struct objc_module *_getObjcModules(const header_info *hi, size_t *nmodules); 38 | extern SEL *_getObjcSelectorRefs(const header_info *hi, size_t *nmess); 39 | extern struct old_protocol **_getObjcProtocols(const header_info *hi, size_t *nprotos); 40 | extern Class *_getObjcClassRefs(const header_info *hi, size_t *nclasses); 41 | extern const char *_getObjcClassNames(const header_info *hi, size_t *size); 42 | 43 | using UnsignedInitializer = void(*)(void); 44 | extern UnsignedInitializer* getLibobjcInitializers(const headerType *mhdr, size_t *count); 45 | 46 | __END_DECLS 47 | 48 | #endif 49 | 50 | #endif 51 | -------------------------------------------------------------------------------- /objc4-runtime-750/runtime/objc-initialize.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2005-2006 Apple Inc. All Rights Reserved. 3 | * 4 | * @APPLE_LICENSE_HEADER_START@ 5 | * 6 | * This file contains Original Code and/or Modifications of Original Code 7 | * as defined in and that are subject to the Apple Public Source License 8 | * Version 2.0 (the 'License'). You may not use this file except in 9 | * compliance with the License. Please obtain a copy of the License at 10 | * http://www.opensource.apple.com/apsl/ and read it before using this 11 | * file. 12 | * 13 | * The Original Code and all software distributed under the License are 14 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER 15 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, 16 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. 18 | * Please see the License for the specific language governing rights and 19 | * limitations under the License. 20 | * 21 | * @APPLE_LICENSE_HEADER_END@ 22 | */ 23 | 24 | #ifndef _OBJC_INITIALIZE_H 25 | #define _OBJC_INITIALIZE_H 26 | 27 | #include "objc-private.h" 28 | 29 | __BEGIN_DECLS 30 | 31 | struct _objc_initializing_classes; 32 | 33 | extern void _class_initialize(Class cls); 34 | 35 | extern void _destroyInitializingClassList(struct _objc_initializing_classes *list); 36 | 37 | extern bool _thisThreadIsInitializingClass(Class cls); 38 | 39 | __END_DECLS 40 | 41 | #endif 42 | -------------------------------------------------------------------------------- /objc4-runtime-750/runtime/objc-load.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1999-2001, 2005-2006 Apple Inc. All Rights Reserved. 3 | * 4 | * @APPLE_LICENSE_HEADER_START@ 5 | * 6 | * This file contains Original Code and/or Modifications of Original Code 7 | * as defined in and that are subject to the Apple Public Source License 8 | * Version 2.0 (the 'License'). You may not use this file except in 9 | * compliance with the License. Please obtain a copy of the License at 10 | * http://www.opensource.apple.com/apsl/ and read it before using this 11 | * file. 12 | * 13 | * The Original Code and all software distributed under the License are 14 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER 15 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, 16 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. 18 | * Please see the License for the specific language governing rights and 19 | * limitations under the License. 20 | * 21 | * @APPLE_LICENSE_HEADER_END@ 22 | */ 23 | /* 24 | * objc-load.h 25 | * Copyright 1988-1996, NeXT Software, Inc. 26 | */ 27 | 28 | #ifndef _OBJC_LOAD_H_ 29 | #define _OBJC_LOAD_H_ 30 | 31 | #include 32 | 33 | #include 34 | 35 | /* dynamically loading Mach-O object files that contain Objective-C code */ 36 | 37 | OBJC_EXPORT long objc_loadModules ( 38 | char * _Nullable modlist[_Nullable], 39 | void * _Nullable errStream, 40 | void (* _Nullable class_callback) (Class _Nullable, Category _Nullable), 41 | /*headerType*/ struct mach_header * _Nullable * _Nullable hdr_addr, 42 | char * _Nullable debug_file 43 | ) OBJC2_UNAVAILABLE; 44 | 45 | OBJC_EXPORT int objc_loadModule ( 46 | char * _Nullable moduleName, 47 | void (* _Nullable class_callback) (Class _Nullable, Category _Nullable), 48 | int * _Nullable errorCode 49 | ) OBJC2_UNAVAILABLE; 50 | OBJC_EXPORT long objc_unloadModules( 51 | void * _Nullable errorStream, /* input (optional) */ 52 | void (* _Nullable unloadCallback)(Class _Nullable, Category _Nullable) /* input (optional) */ 53 | ) OBJC2_UNAVAILABLE; 54 | 55 | #endif /* _OBJC_LOAD_H_ */ 56 | -------------------------------------------------------------------------------- /objc4-runtime-750/runtime/objc-loadmethod.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2004-2006 Apple Inc. All Rights Reserved. 3 | * 4 | * @APPLE_LICENSE_HEADER_START@ 5 | * 6 | * This file contains Original Code and/or Modifications of Original Code 7 | * as defined in and that are subject to the Apple Public Source License 8 | * Version 2.0 (the 'License'). You may not use this file except in 9 | * compliance with the License. Please obtain a copy of the License at 10 | * http://www.opensource.apple.com/apsl/ and read it before using this 11 | * file. 12 | * 13 | * The Original Code and all software distributed under the License are 14 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER 15 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, 16 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. 18 | * Please see the License for the specific language governing rights and 19 | * limitations under the License. 20 | * 21 | * @APPLE_LICENSE_HEADER_END@ 22 | */ 23 | 24 | /*********************************************************************** 25 | * objc-loadmethod.h 26 | * Support for +load methods. 27 | **********************************************************************/ 28 | 29 | #ifndef _OBJC_LOADMETHOD_H 30 | #define _OBJC_LOADMETHOD_H 31 | 32 | #include "objc-private.h" 33 | 34 | __BEGIN_DECLS 35 | 36 | extern void add_class_to_loadable_list(Class cls); 37 | extern void add_category_to_loadable_list(Category cat); 38 | extern void remove_class_from_loadable_list(Class cls); 39 | extern void remove_category_from_loadable_list(Category cat); 40 | 41 | extern void call_load_methods(void); 42 | 43 | __END_DECLS 44 | 45 | #endif 46 | -------------------------------------------------------------------------------- /objc4-runtime-750/runtime/objc-locks-new.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2017 Apple Inc. All Rights Reserved. 3 | * 4 | * @APPLE_LICENSE_HEADER_START@ 5 | * 6 | * This file contains Original Code and/or Modifications of Original Code 7 | * as defined in and that are subject to the Apple Public Source License 8 | * Version 2.0 (the 'License'). You may not use this file except in 9 | * compliance with the License. Please obtain a copy of the License at 10 | * http://www.opensource.apple.com/apsl/ and read it before using this 11 | * file. 12 | * 13 | * The Original Code and all software distributed under the License are 14 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER 15 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, 16 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. 18 | * Please see the License for the specific language governing rights and 19 | * limitations under the License. 20 | * 21 | * @APPLE_LICENSE_HEADER_END@ 22 | */ 23 | 24 | /*********************************************************************** 25 | * objc-locks-new.h 26 | * Declarations of all locks used in the runtime. 27 | **********************************************************************/ 28 | 29 | #ifndef _OBJC_LOCKS_NEW_H 30 | #define _OBJC_LOCKS_NEW_H 31 | 32 | // fork() safety requires careful tracking of all locks used in the runtime. 33 | // Thou shalt not declare any locks outside this file. 34 | 35 | extern mutex_t runtimeLock; 36 | extern mutex_t DemangleCacheLock; 37 | 38 | #endif 39 | -------------------------------------------------------------------------------- /objc4-runtime-750/runtime/objc-locks-old.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2017 Apple Inc. All Rights Reserved. 3 | * 4 | * @APPLE_LICENSE_HEADER_START@ 5 | * 6 | * This file contains Original Code and/or Modifications of Original Code 7 | * as defined in and that are subject to the Apple Public Source License 8 | * Version 2.0 (the 'License'). You may not use this file except in 9 | * compliance with the License. Please obtain a copy of the License at 10 | * http://www.opensource.apple.com/apsl/ and read it before using this 11 | * file. 12 | * 13 | * The Original Code and all software distributed under the License are 14 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER 15 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, 16 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. 18 | * Please see the License for the specific language governing rights and 19 | * limitations under the License. 20 | * 21 | * @APPLE_LICENSE_HEADER_END@ 22 | */ 23 | 24 | /*********************************************************************** 25 | * objc-locks-old.h 26 | * Declarations of all locks used in the runtime. 27 | **********************************************************************/ 28 | 29 | #ifndef _OBJC_LOCKS_OLD_H 30 | #define _OBJC_LOCKS_OLD_H 31 | 32 | // fork() safety requires careful tracking of all locks used in the runtime. 33 | // Thou shalt not declare any locks outside this file. 34 | 35 | extern mutex_t classLock; 36 | extern mutex_t methodListLock; 37 | extern mutex_t NXUniqueStringLock; 38 | extern spinlock_t impLock; 39 | 40 | #endif 41 | -------------------------------------------------------------------------------- /objc4-runtime-750/runtime/objc-probes.d: -------------------------------------------------------------------------------- 1 | provider objc_runtime 2 | { 3 | probe objc_exception_throw(void *id); 4 | probe objc_exception_rethrow(); 5 | }; 6 | -------------------------------------------------------------------------------- /objc4-runtime-750/runtime/objc-references.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2008 Apple Inc. All Rights Reserved. 3 | * 4 | * @APPLE_LICENSE_HEADER_START@ 5 | * 6 | * This file contains Original Code and/or Modifications of Original Code 7 | * as defined in and that are subject to the Apple Public Source License 8 | * Version 2.0 (the 'License'). You may not use this file except in 9 | * compliance with the License. Please obtain a copy of the License at 10 | * http://www.opensource.apple.com/apsl/ and read it before using this 11 | * file. 12 | * 13 | * The Original Code and all software distributed under the License are 14 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER 15 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, 16 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. 18 | * Please see the License for the specific language governing rights and 19 | * limitations under the License. 20 | * 21 | * @APPLE_LICENSE_HEADER_END@ 22 | */ 23 | /* 24 | * objc-references.h 25 | */ 26 | 27 | #ifndef _OBJC_REFERENCES_H_ 28 | #define _OBJC_REFERENCES_H_ 29 | 30 | #include "objc-api.h" 31 | #include "objc-config.h" 32 | 33 | __BEGIN_DECLS 34 | 35 | extern void _object_set_associative_reference(id object, void *key, id value, uintptr_t policy); 36 | extern id _object_get_associative_reference(id object, void *key); 37 | extern void _object_remove_assocations(id object); 38 | 39 | __END_DECLS 40 | 41 | #endif 42 | -------------------------------------------------------------------------------- /objc4-runtime-750/runtime/objc-runtime.h: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | -------------------------------------------------------------------------------- /objc4-runtime-750/runtime/objc-sel-set.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2004 Apple Inc. All rights reserved. 3 | * 4 | * @APPLE_LICENSE_HEADER_START@ 5 | * 6 | * This file contains Original Code and/or Modifications of Original Code 7 | * as defined in and that are subject to the Apple Public Source License 8 | * Version 2.0 (the 'License'). You may not use this file except in 9 | * compliance with the License. Please obtain a copy of the License at 10 | * http://www.opensource.apple.com/apsl/ and read it before using this 11 | * file. 12 | * 13 | * The Original Code and all software distributed under the License are 14 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER 15 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, 16 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. 18 | * Please see the License for the specific language governing rights and 19 | * limitations under the License. 20 | * 21 | * @APPLE_LICENSE_HEADER_END@ 22 | */ 23 | 24 | /* 25 | * objc-sel-set.h 26 | * A set of SELs used for SEL uniquing. 27 | */ 28 | 29 | #ifndef _OBJC_SEL_SET_H_ 30 | #define _OBJC_SEL_SET_H_ 31 | 32 | #if !__OBJC2__ 33 | 34 | #include 35 | #include "objc-os.h" 36 | 37 | __BEGIN_DECLS 38 | 39 | struct __objc_sel_set; 40 | 41 | extern struct __objc_sel_set *__objc_sel_set_create(size_t selrefCount); 42 | extern SEL __objc_sel_set_get(struct __objc_sel_set *sset, SEL candidate); 43 | extern void __objc_sel_set_add(struct __objc_sel_set *sset, SEL value); 44 | 45 | __END_DECLS 46 | 47 | #endif 48 | 49 | #endif 50 | -------------------------------------------------------------------------------- /objc4-runtime-750/runtime/objc-sel-table.s: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #if __LP64__ 5 | # define PTR(x) .quad x 6 | #else 7 | # define PTR(x) .long x 8 | #endif 9 | 10 | .section __TEXT,__objc_opt_ro 11 | .align 3 12 | .private_extern __objc_opt_data 13 | __objc_opt_data: 14 | .long 15 /* table.version */ 15 | .long 0 /* table.flags */ 16 | .long 0 /* table.selopt_offset */ 17 | .long 0 /* table.headeropt_ro_offset */ 18 | .long 0 /* table.clsopt_offset */ 19 | .long 0 /* table.protocolopt_offset */ 20 | .long 0 /* table.headeropt_rw_offset */ 21 | .space PAGE_MAX_SIZE-28 22 | 23 | /* space for selopt, smax/capacity=1048576, blen/mask=524287+1 */ 24 | .space 4*(8+256) /* header and scramble */ 25 | .space 524288 /* mask tab */ 26 | .space 1048576 /* checkbytes */ 27 | .space 1048576*4 /* offsets */ 28 | 29 | /* space for clsopt, smax/capacity=131072, blen/mask=32767+1 */ 30 | .space 4*(8+256) /* header and scramble */ 31 | .space 32768 /* mask tab */ 32 | .space 131072 /* checkbytes */ 33 | .space 131072*12 /* offsets to name and class and header_info */ 34 | .space 512*8 /* some duplicate classes */ 35 | 36 | /* space for some demangled protocol names */ 37 | .space 1024 38 | 39 | /* space for protocolopt, smax/capacity=16384, blen/mask=8191+1 */ 40 | .space 4*(8+256) /* header and scramble */ 41 | .space 8192 /* mask tab */ 42 | .space 16384 /* checkbytes */ 43 | .space 16384*8 /* offsets */ 44 | 45 | /* space for 2048 header_info (RO) structures */ 46 | .space 8 + (2048*16) 47 | 48 | 49 | .section __DATA,__objc_opt_rw 50 | .align 3 51 | .private_extern __objc_opt_rw_data 52 | __objc_opt_rw_data: 53 | 54 | /* space for 2048 header_info (RW) structures */ 55 | .space 8 + (2048*8) 56 | 57 | /* space for 16384 protocols */ 58 | #if __LP64__ 59 | .space 16384 * 12 * 8 60 | #else 61 | .space 16384 * 12 * 4 62 | #endif 63 | 64 | 65 | /* section of pointers that the shared cache optimizer wants to know about */ 66 | .section __DATA,__objc_opt_ptrs 67 | .align 3 68 | 69 | #if TARGET_OS_OSX && __i386__ 70 | // old ABI 71 | .globl .objc_class_name_Protocol 72 | PTR(.objc_class_name_Protocol) 73 | #else 74 | // new ABI 75 | .globl _OBJC_CLASS_$_Protocol 76 | PTR(_OBJC_CLASS_$_Protocol) 77 | #endif 78 | -------------------------------------------------------------------------------- /objc4-runtime-750/runtime/objc-sync.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2002, 2006 Apple Inc. All Rights Reserved. 3 | * 4 | * @APPLE_LICENSE_HEADER_START@ 5 | * 6 | * This file contains Original Code and/or Modifications of Original Code 7 | * as defined in and that are subject to the Apple Public Source License 8 | * Version 2.0 (the 'License'). You may not use this file except in 9 | * compliance with the License. Please obtain a copy of the License at 10 | * http://www.opensource.apple.com/apsl/ and read it before using this 11 | * file. 12 | * 13 | * The Original Code and all software distributed under the License are 14 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER 15 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, 16 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. 18 | * Please see the License for the specific language governing rights and 19 | * limitations under the License. 20 | * 21 | * @APPLE_LICENSE_HEADER_END@ 22 | */ 23 | 24 | #ifndef __OBJC_SNYC_H_ 25 | #define __OBJC_SNYC_H_ 26 | 27 | #include 28 | 29 | 30 | /** 31 | * Begin synchronizing on 'obj'. 32 | * Allocates recursive pthread_mutex associated with 'obj' if needed. 33 | * 34 | * @param obj The object to begin synchronizing on. 35 | * 36 | * @return OBJC_SYNC_SUCCESS once lock is acquired. 37 | */ 38 | OBJC_EXPORT int 39 | objc_sync_enter(id _Nonnull obj) 40 | OBJC_AVAILABLE(10.3, 2.0, 9.0, 1.0, 2.0); 41 | 42 | /** 43 | * End synchronizing on 'obj'. 44 | * 45 | * @param obj The object to end synchronizing on. 46 | * 47 | * @return OBJC_SYNC_SUCCESS or OBJC_SYNC_NOT_OWNING_THREAD_ERROR 48 | */ 49 | OBJC_EXPORT int 50 | objc_sync_exit(id _Nonnull obj) 51 | OBJC_AVAILABLE(10.3, 2.0, 9.0, 1.0, 2.0); 52 | 53 | enum { 54 | OBJC_SYNC_SUCCESS = 0, 55 | OBJC_SYNC_NOT_OWNING_THREAD_ERROR = -1 56 | }; 57 | 58 | 59 | #endif // __OBJC_SYNC_H_ 60 | -------------------------------------------------------------------------------- /objc4-runtime-750/runtime/objcrt.h: -------------------------------------------------------------------------------- 1 | #ifndef _OBJC_RT_H_ 2 | #define _OBJC_RT_H_ 3 | 4 | #include 5 | 6 | 7 | typedef struct { 8 | int count; // number of pointer pairs that follow 9 | void *modStart; 10 | void *modEnd; 11 | void *protoStart; 12 | void *protoEnd; 13 | void *iiStart; 14 | void *iiEnd; 15 | void *selrefsStart; 16 | void *selrefsEnd; 17 | void *clsrefsStart; 18 | void *clsrefsEnd; 19 | } objc_sections; 20 | 21 | OBJC_EXPORT void *_objc_init_image(HMODULE image, const objc_sections *sects); 22 | OBJC_EXPORT void _objc_load_image(HMODULE image, void *hinfo); 23 | OBJC_EXPORT void _objc_unload_image(HMODULE image, void *hinfo); 24 | 25 | #endif 26 | -------------------------------------------------------------------------------- /objc4-runtime-750/unexported_symbols: -------------------------------------------------------------------------------- 1 | .objc_class_name___IncompleteProtocol 2 | __Znam 3 | __ZnamRKSt9nothrow_t 4 | __Znwm 5 | __ZnwmRKSt9nothrow_t 6 | __ZdaPv 7 | __ZdaPvRKSt9nothrow_t 8 | __ZdlPv 9 | __ZdlPvRKSt9nothrow_t 10 | __ZTISt9bad_alloc 11 | __ZTISt9exception 12 | __ZTISt11logic_error 13 | __ZTISt12length_error 14 | __ZTSSt9bad_alloc 15 | __ZTSSt9exception 16 | __ZTSSt11logic_error 17 | __ZTSSt12length_error 18 | -------------------------------------------------------------------------------- /objc4-runtime-750/version.bat: -------------------------------------------------------------------------------- 1 | :: version.bat 2 | :: Writes version numbers from B&I into version.h for use by version.rc. 3 | 4 | @ECHO OFF 5 | 6 | :: Set default values for environment variables if not set by B&I 7 | IF "%OBJROOT%"=="" SET OBJROOT=. 8 | IF "%RC_PROJECTSOURCEVERSION%"=="" SET RC_PROJECTSOURCEVERSION=0.0 9 | IF "%RC_PROJECTBUILDVERSION%"=="" SET RC_PROJECTBUILDVERSION=0 10 | 11 | :: Get version numbers from environment variables 12 | SET major=1 13 | SET patch=0 14 | FOR /F "tokens=1* eol= delims=." %%i IN ("%RC_PROJECTSOURCEVERSION%") DO ( 15 | SET minor=%%i 16 | IF NOT "%%j"=="" SET patch=%%j 17 | ) 18 | SET build=%RC_PROJECTBUILDVERSION% 19 | 20 | ECHO version %major% . %minor% . %patch% . %build% 21 | 22 | :: Write version.h 23 | ECHO // This file is automatically generated by version.bat. > "%OBJROOT%\version.h" 24 | ECHO // DO NOT EDIT >> "%OBJROOT%\version.h" 25 | ECHO #define major %major% >> "%OBJROOT%\version.h" 26 | ECHO #define minor %minor% >> "%OBJROOT%\version.h" 27 | ECHO #define patch %patch% >> "%OBJROOT%\version.h" 28 | ECHO #define build %build% >> "%OBJROOT%\version.h" 29 | ECHO #define string "%major%,%minor%,%patch%,%build%" >> "%OBJROOT%\version.h" 30 | -------------------------------------------------------------------------------- /objc4-runtime-750/version.rc: -------------------------------------------------------------------------------- 1 | #include "Winver.h" 2 | 3 | // built by version.bat; sets variables major, minor, patch, build, string 4 | #include "version.h" 5 | 6 | VS_VERSION_INFO VERSIONINFO 7 | FILEVERSION major,minor,patch,build 8 | PRODUCTVERSION major,minor,patch,build 9 | FILEFLAGSMASK 0x17L 10 | #ifdef _DEBUG 11 | FILEFLAGS VS_FF_DEBUG 12 | #else 13 | FILEFLAGS 0x0L 14 | #endif 15 | FILEOS VOS_NT_WINDOWS32 16 | FILETYPE VFT_DLL 17 | FILESUBTYPE VFT2_UNKNOWN 18 | BEGIN 19 | BLOCK "StringFileInfo" 20 | BEGIN 21 | BLOCK "040904b0" 22 | BEGIN 23 | VALUE "CompanyName", "Apple Inc." 24 | VALUE "FileDescription", "Objective-C Runtime Library" 25 | VALUE "FileVersion", string 26 | VALUE "ProductVersion", string 27 | VALUE "ProductName", "objc4" 28 | VALUE "InternalName", "objc4" 29 | VALUE "LegalCopyright", "Copyright (C) 2007-2009, Apple Inc." 30 | VALUE "OriginalFilename", "objc.dll" 31 | END 32 | END 33 | BLOCK "VarFileInfo" 34 | BEGIN 35 | VALUE "Translation", 0x409, 1200 36 | END 37 | END 38 | 39 | --------------------------------------------------------------------------------