GCC Newspaper
NOVEMBER 30, 2026
Date
/
Architectures
Components
Topics
News & Policy
Other
objc

objc: Correct __objc_class_name_CLASS reference

objc: Fixes static linking issues by correcting a metadata reference in Objective-C runtime.

This commit corrects a critical metadata reference in the Objective-C runtime that was broken by a previous change affecting static linking. Typos in the metadata generation caused the class-name reference to incorrectly point to itself, preventing necessary classes from being linked. This issue was only apparent during static linking, as dynamic linking’s runtime registration masked the problem. The fix changes the reference from <Class> = &<Class> to the correct __objc_class_ref_<Class> = &__objc_class_name_<Class>, ensuring proper class resolution and linkage.

In Details

The Objective-C runtime's metadata generation for static linking was broken by r17-2156-g6317befec9. Specifically, the handle_class_ref function in objc-gnu-runtime-abi-01.cc generated a self-referential symbol for class names (<Class> = &<Class>) instead of the required __objc_class_ref_<Class> = &__objc_class_name_<Class>. This commit corrects this by splitting the decl variable used for both declaration and reference, ensuring static linking pulls in the correct class metadata. A new test case specifically targets static linking behavior.

For Context
objc
Objective-C, an object-oriented programming language that adds Smalltalk-style messaging to the C programming language.
static linking
A process where the linker copies all required code from libraries directly into the executable file. This results in larger executables but removes external dependencies on shared libraries at runtime.
metadata
Data that provides information about other data. In this context, it refers to information about Objective-C classes and their properties used by the runtime.
runtime
The part of a system that performs services for programs while they are executing. The Objective-C runtime handles object messaging, memory management, and dynamic features.
DSO
Dynamically Shared Object. Similar to a DLL on Windows or a shared object (.so) on Unix-like systems, it's a library that can be loaded at runtime.
__objc_class_ref_<Class>
A symbol generated by the Objective-C compiler/runtime that represents a reference to the metadata of a class named <Class>. This is used for dynamic dispatch and other runtime operations.
__objc_class_name_<Class>
A symbol generated by the Objective-C compiler/runtime that holds the name of a class named <Class>.
Filed Under: Objective-Cstatic linkingruntimemetadata