Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8414181
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T01:05:57+00:00 2026-06-10T01:05:57+00:00

These days, I’ve been messing around with the Objective-C runtime, trying to find out

  • 0

These days, I’ve been messing around with the Objective-C runtime, trying to find out how some things work. In one of my “experiments”, I did the following: I got the following code which is in a file called test.m:

#import <objc/Object.h>

@interface MySuperClass: Object {

}
-(int) myMessage1;
@end

@interface MyClass: MySuperClass {
    int myIvar;
}
-(void) myMessage2;
@end

@implementation MyClass
-(void) myMessage2 {
  myIvar++;
}
@end

int main() {
    MyClass *myObject;
    myObject = [[MyClass alloc] init];
    [myObject myMessage2];

    return 0;
}

and tried to compile it with clang -fobjc-nonfragile-abi -fnext-runtime -o test test.m. As you can imagine, the compiler will generate a linking error message because I’m compiling an Objective-C file, but I’m not telling the linker to link it against an Objective-C runtime library (with the -lobjc option, for example). But I did that on purpose, to check out which objc runtime library symbols would be referenced and, thus, would be missing. And I got the following error message:

$ clang -fobjc-nonfragile-abi -fnext-runtime -o test test.m 
/tmp/test-jEfgSA.o:(__DATA, __objc_data+0x0): undefined reference to `OBJC_METACLASS_$_Object'
/tmp/test-jEfgSA.o:(__DATA, __objc_data+0x8): undefined reference to `OBJC_METACLASS_$_MySuperClass'
/tmp/test-jEfgSA.o:(__DATA, __objc_data+0x10): undefined reference to `_objc_empty_cache'
/tmp/test-jEfgSA.o:(__DATA, __objc_data+0x18): undefined reference to `_objc_empty_vtable'
/tmp/test-jEfgSA.o:(__DATA, __objc_data+0x30): undefined reference to `OBJC_CLASS_$_MySuperClass'
/tmp/test-jEfgSA.o:(__DATA, __objc_data+0x38): undefined reference to `_objc_empty_cache'
/tmp/test-jEfgSA.o:(__DATA, __objc_data+0x40): undefined reference to `_objc_empty_vtable'
/tmp/test-jEfgSA.o:(__DATA, __objc_msgrefs, coalesced+0x0): undefined reference to `objc_msgSend_fixup'
/tmp/test-jEfgSA.o:(__DATA, __objc_msgrefs, coalesced+0x10): undefined reference to `objc_msgSend_fixup'
/tmp/test-jEfgSA.o:(__DATA, __objc_msgrefs, coalesced+0x20): undefined reference to `objc_msgSend_fixup'
clang: error: linker command failed with exit code 1 (use -v to see invocation)

It’s easy to understand why some of the listed symbols are undefined. objc_msgSend_fixup, for example, refers to a runtime library function. _objc_empty_cache and _objc_empty_vtable are both runtime library structs declared in http://opensource.apple.com/source/objc4/objc4-532/runtime/objc-abi.h. However, OBJC_METACLASS_$_MySuperClass and OBJC_CLASS_$_MySuperClass are structs that represent a class that has been declared in test.m, so that there is no reference in the Objective-C runtime library to these symbols. They should be defined in teste.o, but it seems they’re not. So, why does this happen?

And one more thing: there is no broken reference to neither OBJC_METACLASS_$_MyClass nor OBJC_CLASS_$_MyClass. Therefore, there are broken references to Object and MySuperClass and both of them have subclasses in test.m, but there is no broken reference to MyClass, which has no subclass. So, why the linker seems to expect there to be references, in the runtime library, to the classes that have subclasses, but not to those that haven’t any?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T01:05:58+00:00Added an answer on June 10, 2026 at 1:05 am

    I found out that the OBJC_METACLASS_$_<my class name> symbols are defined in the object file only if there is an @implementation <my class name> statement. So, if I add, for example, the snippet:

    @implementation MySuperClass
    -(int) myMessage1 {
      return 0;
    }
    @end
    

    to test.m, the linker would generate the error message:

    $ clang -fobjc-nonfragile-abi -fnext-runtime -o class_teste class_teste.m 
    /tmp/class_teste-gDWfF6.o:(__DATA, __objc_data+0x0): undefined reference to `OBJC_METACLASS_$_Object'
    /tmp/class_teste-gDWfF6.o:(__DATA, __objc_data+0x8): undefined reference to `OBJC_METACLASS_$_Object'
    /tmp/class_teste-gDWfF6.o:(__DATA, __objc_data+0x10): undefined reference to `_objc_empty_cache'
    /tmp/class_teste-gDWfF6.o:(__DATA, __objc_data+0x18): undefined reference to `_objc_empty_vtable'
    /tmp/class_teste-gDWfF6.o:(__DATA, __objc_data+0x30): undefined reference to `OBJC_CLASS_$_Object'
    /tmp/class_teste-gDWfF6.o:(__DATA, __objc_data+0x38): undefined reference to `_objc_empty_cache'
    /tmp/class_teste-gDWfF6.o:(__DATA, __objc_data+0x40): undefined reference to `_objc_empty_vtable'
    /tmp/class_teste-gDWfF6.o:(__DATA, __objc_data+0x50): undefined reference to `OBJC_METACLASS_$_Object'
    /tmp/class_teste-gDWfF6.o:(__DATA, __objc_data+0x60): undefined reference to `_objc_empty_cache'
    /tmp/class_teste-gDWfF6.o:(__DATA, __objc_data+0x68): undefined reference to `_objc_empty_vtable'
    /tmp/class_teste-gDWfF6.o:(__DATA, __objc_data+0x88): undefined reference to `_objc_empty_cache'
    /tmp/class_teste-gDWfF6.o:(__DATA, __objc_data+0x90): undefined reference to `_objc_empty_vtable'
    /tmp/class_teste-gDWfF6.o:(__DATA, __objc_msgrefs, coalesced+0x0): undefined reference to `objc_msgSend_fixup'
    /tmp/class_teste-gDWfF6.o:(__DATA, __objc_msgrefs, coalesced+0x10): undefined reference to `objc_msgSend_fixup'
    /tmp/class_teste-gDWfF6.o:(__DATA, __objc_msgrefs, coalesced+0x20): undefined reference to `objc_msgSend_fixup'
    clang: error: linker command failed with exit code 1 (use -v to see invocation)
    

    which is pretty acceptable, since all these undefined symbols are part of the Objective-C runtime library. Since my first version of test.m was for testing purpose, I hadn’t added an implementation to the MySuperClass class as I thought it wouldn’t affect the object file’s symbols table. So, the problem has nothing to do with subclassing.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm doing some SQL tuning these days and find one weird sql during the
These days I design some algorithms in python, but find first two greatest value
in these days i'm playing with thread library and trying to implement some functions.
Playing around with Google Maps these days, with some directions. I have a map
I am working on some source code these days. In some codes, I find
These days I'm trying to put up some tests for my first serious Backbone
These days, we encountered a strange problem, some of our solr apps on tomcat
These days, I use Flex & Bison generated some codes to develop a SQL-parser
Agile methodologies are rather prevalent these days, but I cannot seem to find much
I installed integrity app these days. and found some issues. I follow this. $

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.