Objective-C runtime library intended for use with Clang.
Clone or download
Permalink
Failed to load latest commit information.
ABIDoc Document a bit more of class structure and of type encodings. Mar 31, 2018
CMake Bump cmake minimum version. Jan 9, 2018
Test Add some more Windows build tweaks. Sep 6, 2018
objc Add missing file. Aug 2, 2018
.gitignore Add .gitignore. Mar 23, 2015
.travis.yml Enable Travis testing on OS X. Jul 14, 2016
ANNOUNCE Update some docs. Aug 7, 2018
ANNOUNCE.1.0 Added 1.1 announcement. Committed some work-in-progress clang-specifi… Jan 10, 2011
ANNOUNCE.1.1 Added 1.1 announcement. Committed some work-in-progress clang-specifi… Jan 10, 2011
ANNOUNCE.1.2 Added 1.2 release announcement. Feb 21, 2011
ANNOUNCE.1.3 Added note about aliases to release announcement. Apr 14, 2011
ANNOUNCE.1.4 Created 1.4 release announcement. May 6, 2011
ANNOUNCE.1.5 s/fifth/sixth Jul 23, 2011
ANNOUNCE.1.6 1.6 release announcement. Nov 23, 2011
ANNOUNCE.1.6.1 Archive 1.6.1 release announcement. Sep 4, 2012
ANNOUNCE.1.7 Fixed svn URL for 1.7 release announcement. May 16, 2013
ANNOUNCE.1.8 Fix copy and paste error in release announcement. Jul 12, 2015
ANNOUNCE.1.8.1 Added 1.8.1 release announcement to master branch. Aug 7, 2015
ANNOUNCE.1.9 Add 1.9 release announcement to 2.x series. Apr 28, 2018
API Added property_getName(). Added non-portable API documentation. Sep 21, 2010
CMakeLists.txt Make CMake install the dll on Windows. Sep 6, 2018
COPYING Removed last bits of legacy code from libobjc2. Added new exception h… Jun 29, 2010
INSTALL add assembler flags needed for cmake Jul 10, 2013
NSBlocks.m Initial pass at Windows support. Aug 1, 2018
Protocol2.m Add support for class properties in protocols. Apr 5, 2018
README.md Update some docs. Aug 7, 2018
abi_version.c Small object + ARC tweaks. Jul 26, 2011
alias.h Initial pass at Windows support. Aug 1, 2018
alias_table.c Initial pass at Windows support. Aug 1, 2018
arc.m Fix an integer underflow bug. Aug 1, 2018
asmconstants.h Initial pass at Windows support. Aug 1, 2018
associate.m Initial pass at Windows support. Aug 1, 2018
block_to_imp.c Improve block-to-IMP code on Windows. Aug 2, 2018
block_trampolines.S Make Win32 block trampolines SEH compatible. Aug 1, 2018
blocks_runtime.h Add objc/blocks_private.h header to expose some internals of the bloc… Mar 11, 2012
blocks_runtime.m Initial pass at Windows support. Aug 1, 2018
buffer.h Allow the buffered objects to be something other than a pointer. Jan 31, 2016
caps.c Initial pass at Windows support. Aug 1, 2018
category.h Rename legacy types. Mar 29, 2018
category_loader.c Correctly upgrade categories. Apr 11, 2018
class.h Improve ARC test and fix bugs it uncovered. Apr 14, 2018
class_table.c Allow double indirection for superclass pointers. Sep 14, 2018
cmake_uninstall.cmake.in Add uninstall target to CMake. Dec 22, 2012
common.S fix objc_msgSend.x86-32.S for win32 Mar 3, 2018
constant_string.h Stop treating NSObject as magic and do what OS X does with regard to … Feb 23, 2011
dtable.c Rename objc_slot and objc_slot_v1. May 20, 2018
dtable.h Initial pass at Windows support. Aug 1, 2018
dwarf_eh.h (Hopefully) fix C++ exception interop on ARM. Dec 25, 2015
eh_personality.c Merge branch 'master' into newabi Apr 11, 2018
eh_win32_msvc.cc The stuff that said 'DO NOT COMMIT THIS'? Aug 2, 2018
encoding2.c Initial pass at Windows support. Aug 1, 2018
gc_boehm.c Audit the runtime for direct access to variable-sized arrays. Mar 29, 2018
gc_none.c Use _aligned_malloc on Windows. Aug 1, 2018
gc_ops.h Fix malloc() / free() imbalance. Jul 31, 2011
hash_table.h Fix another bug in the hash table. Aug 6, 2018
hooks.c Added support for tracing message sends to the runtime. Jun 29, 2013
ivar.c Rework ivar offset calculation again. Aug 1, 2018
ivar.h Add the size field to the ivar structure. May 22, 2018
legacy.c Rework ivar offset calculation again. Aug 1, 2018
legacy.h Rename legacy types. Mar 29, 2018
legacy_malloc.c libobjc2: tweaks to build on Windows Sep 3, 2010
loader.c Improve protocol reference loading. Aug 6, 2018
loader.h Rename method_list.h to method.h Mar 30, 2018
lock.h Fix LOCK_SCOPE to allow multiple locks per scope. Apr 11, 2018
method.h Add method markers. Mar 30, 2018
module.h Change [1] to [] for variable length structure elements (C99 - silenc… Jul 12, 2011
mutation.m Fix enumeration mutation function prototype to match what clang expec… Feb 12, 2011
nsobject.h Added support for associative references. Modified sync code to use t… Apr 15, 2011
objc_msgSend.S Tweak objc_msgSend to work correctly on win32. Aug 1, 2018
objc_msgSend.aarch64.S Use the correct compare instruction. Dec 28, 2015
objc_msgSend.arm.S Don’t use a NEON instruction on ARM variants that don’t have NEON. Jan 29, 2016
objc_msgSend.mips.S Use register names that don't make LLVM whine, rather than the correct Dec 24, 2015
objc_msgSend.x86-32.S Tweak objc_msgSend to work correctly on win32. Aug 1, 2018
objc_msgSend.x86-64.S Tweak objc_msgSend to work correctly on win32. Aug 1, 2018
objcxx_eh.cc Remove the need to include C++ <exception> May 22, 2018
objcxx_eh.h Clang++ provides its own exception types on Linux. (#68) Apr 10, 2018
pool.h Print some memory usage statistics on exit if LIBOBJC_MEMORY_PROFILE is Jan 15, 2013
properties.h Document a bit more of class structure and of type encodings. Mar 31, 2018
properties.m Initial pass at Windows support. Aug 1, 2018
protocol.c Improve protocol table locking. Aug 6, 2018
protocol.h Add support for class properties in protocols. Apr 5, 2018
runtime.c Fix a bug in hidden class deletion. May 22, 2018
safewindows.h win32: use native threading APIs instead of pthreads Mar 1, 2018
sarray2.c Dom't build an unused private function. Apr 14, 2018
sarray2.h Fix typo in comment. Dec 24, 2015
selector.h Initial start of documenting the ABI. Dec 30, 2017
selector_table.c Rename method_list.h to method.h Mar 30, 2018
sendmsg2.c Rename objc_slot and objc_slot_v1. May 20, 2018
spinlock.h win32: use native threading APIs instead of pthreads Mar 1, 2018
statics_loader.c Allow the buffered objects to be something other than a pointer. Jan 31, 2016
string_hash.h Implemented support for __weak with ARC. Jun 29, 2011
type_encoding_cases.h Fix type encoding of blocks. Aug 22, 2011
unistd.h Initial pass at Windows support. Aug 1, 2018
unwind-arm.h Add missing declaration to ARM unwind header. Jan 29, 2016
unwind-itanium.h Implement ARM EH support, fix objc_msgSend() to work on ARM. Nov 9, 2011
unwind.h Implement ARM EH support, fix objc_msgSend() to work on ARM. Nov 9, 2011
visibility.h Initial pass at Windows support. Aug 1, 2018

README.md

GNUstep Objective-C Runtime

Build Status

The GNUstep Objective-C runtime was designed as a drop-in replacement for the GCC runtime. It supports three ABIs:

  • The old GCC ABI, which provides support for Objective-C 1.0 features. This can be selected via the -fobjc-runtime=gcc flag in Clang or by compiling with GCC.
  • The initial GNUstep non-fragile ABI, which was intended to be compatible with the GCC ABI, but provide support for modern Objective-C features. This can be selected with the -fobjc-runtime=gnustep-1.9 flag in Clang.
  • The modern (v2) ABI, which provides richer reflection metadata, smaller binaries and reduced memory usage. This is selected with the -fobjc-runtime=gnustep-2.0 flag in Clang 7.0 or later.

The runtime can be built without support for older ABIs by setting the OLDABI_COMPAT flag to OFF in CMake configuration. This will result in a smaller binary, which will not link against code using the older ABIs.

All ABIs support the following feature above and beyond the GCC runtime:

  • The modern Objective-C runtime APIs, initially introduced with OS X 10.5.
  • Blocks (closures).
  • Synthesised property accessors.
  • Efficient support for @synchronized()
  • Type-dependent dispatch, eliminating stack corruption from mismatched selectors.
  • Support for the associated reference APIs introduced with Mac OS X 10.6.
  • Support for the automatic reference counting APIs introduced with Mac OS X 10.7

History

Early work on the GNUstep runtime combined code from the GCC Objective-C runtime, the Étoilé Objective-C runtime, Remy Demarest's blocks runtime for OS X 10.5, and the Étoilé Objective-C 2 API compatibility framework. All of these aside from the GCC runtime were MIT licensed, although the GPL'd code present in the GCC runtime meant that the combined work had to remain under the GPL.

Since then, all of the GCC code has been removed, leaving the remaining files all MIT licensed, and allowing the entire work to be MIT licensed.

The exception handling code uses a header file implementing the generic parts of the Itanium EH ABI. This file comes from PathScale's libcxxrt. PathScale kindly allowed it to be MIT licensed for inclusion here.

Various parts of Windows support were contributed by the WinObjC team at Microsoft.

Type-Dependent Dispatch

Traditionally, Objective-C method lookup is done entirely on the name of the method. This is problematic when the sender and receiver of the method disagree on the types of a method.

For example, consider a trivial case where you have two methods with the same name, one taking an integer, the other taking a floating point value. Both will pass their argument in a register on most platforms, but not the same register. If the sender thinks it is calling one, but is really calling the other, then the receiver will look in the wrong register and use a nonsense value. The compiler will often not warn about this.

This is a relatively benign example, but if the mismatch is between methods taking or returning a structure and those only using scalar arguments and return then the call frame layout will be so different that the result will be stack corruption, possibly leading to security holes.

If you compile the GNUstep runtime with type-dependent dispatch enabled, then sending a message with a typed selector will only ever invoke a method with the same types. Sending a message with an untyped selector will invoke any method with a matching name, although the slot returned from the lookup function will contain the types, allowing the caller to check them and construct a valid call frame, if required.

If a lookup with a typed selector matches a method with the wrong types, the runtime will call a handler. This handler, by default, prints a helpful message and exits. LanguageKit provides an alternative version which dynamically generates a new method performing the required boxing and calling the original.