Skip to content

Objective-C runtime library intended for use with Clang.

License

Notifications You must be signed in to change notification settings

qmfrederik/libobjc2

This branch is 3 commits behind gnustep/libobjc2:refs/heads/master.

Folders and files

NameName
Last commit message
Last commit date
Nov 14, 2024
Mar 31, 2018
Apr 26, 2024
Nov 19, 2024
Nov 19, 2024
Jun 6, 2024
Apr 15, 2024
Jan 13, 2024
Jan 10, 2011
Jan 10, 2011
Feb 21, 2011
Apr 14, 2011
May 6, 2011
Jul 23, 2011
Nov 23, 2011
Sep 4, 2012
May 16, 2013
Jul 12, 2015
Aug 7, 2015
Apr 28, 2018
Apr 26, 2019
Aug 23, 2020
Sep 21, 2010
Jan 7, 2019
Jan 7, 2019
Nov 19, 2024
Jun 29, 2010
Apr 15, 2024
Jun 6, 2024
Jun 6, 2024
Feb 19, 2023
Dec 30, 2023
Feb 19, 2023
Feb 12, 2019
Feb 12, 2019
Jun 6, 2024
Feb 12, 2024
Jul 10, 2019
Feb 12, 2024
Feb 12, 2024
Mar 11, 2012
Jun 6, 2024
Jun 6, 2024
Jan 31, 2016
Oct 22, 2024
Feb 12, 2019
Mar 29, 2018
Apr 11, 2018
Oct 22, 2024
Nov 18, 2024
Dec 22, 2012
Dec 31, 2023
Feb 23, 2011
Feb 12, 2024
Feb 12, 2019
Dec 25, 2015
Dec 31, 2023
Apr 27, 2020
Aug 24, 2023
Sep 5, 2024
Nov 19, 2024
Feb 19, 2023
Feb 19, 2023
Jan 2, 2019
Nov 28, 2020
Feb 19, 2023
Apr 1, 2019
Oct 22, 2024
Mar 29, 2018
Sep 3, 2010
Dec 28, 2023
Oct 22, 2024
Oct 22, 2024
Feb 19, 2023
Oct 22, 2024
Jul 12, 2011
May 11, 2021
Apr 15, 2011
Jan 1, 2024
Apr 26, 2024
Mar 30, 2019
Dec 24, 2015
Jan 1, 2024
Dec 31, 2023
Nov 18, 2024
Feb 21, 2024
Feb 27, 2024
Mar 22, 2024
Feb 21, 2024
Jan 15, 2013
Feb 19, 2023
Jul 23, 2024
Apr 1, 2019
Feb 19, 2023
Oct 22, 2024
Oct 22, 2024
Apr 27, 2021
Mar 1, 2018
Jan 2, 2019
Dec 24, 2015
Oct 22, 2024
Jan 22, 2024
Feb 12, 2024
Mar 1, 2018
Jan 31, 2016
Jun 29, 2011
Feb 10, 2019
Dec 15, 2020
Dec 31, 2023
Nov 9, 2011
Feb 12, 2019

Repository files navigation

GNUstep Objective-C Runtime

Linux and Windows CI: Libobjc2 CI

FreeBSD CI: 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.

About

Objective-C runtime library intended for use with Clang.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C 46.1%
  • Objective-C 25.7%
  • C++ 6.8%
  • Assembly 6.0%
  • Objective-C++ 4.2%
  • TeX 4.1%
  • Other 7.1%