[LLVMdev] Trouble Resolving Objective-C Symbols in lli

Andy Kitchen agimbleinthewabe at gmail.com
Thu Jul 19 00:57:49 PDT 2007


Hi there, I'm trying to run trivial Objective-C code that uses the
Foundation framework under MacOS X in lli. It seems that the code will
compile and
run using llc, however fails to work in lli.

SimpleFoundation.m:
----

#import <Foundation/Foundation.h>

int main (int argc, const char * argv[]) {
    NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];

    // insert code here...
    NSLog(@"Hello, World!");
    [pool release];
    return 0;
}

----

$ llvm-gcc -c -emit-llvm SimpleFoundation.m -o SimpleFoundation.bc
$ llc SimpleFoundation.bc -o SimpleFoundation.s
$ gcc /System/Library/Frameworks/Foundation.framework/Foundation
SimpleFoundation.s -o SimpleFoundation.exe
$ ./SimpleFoundation.exe

2007-07-19 17:42:32.667 SimpleFoundation.exe[2535] Hello, World!

$ lli -load=/System/Library/Frameworks/Foundation.framework/Foundation
SimpleFoundation.bc

Segmentation fault

$ lli -force-interpreter
-load=/System/Library/Frameworks/Foundation.framework/Foundation
SimpleFoundation.bc

Could not resolve external global address: .objc_class_name_NSAutoreleasePool
Abort trap

$ nm /System/Library/Frameworks/Foundation.framework/Foundation |
grep .objc_class_name_NSAutoreleasePool

00000000 A .objc_class_name_NSAutoreleasePool

It seems that when linked by GCC the symbols are found without any trouble
however when using lli, the symbols arn't resolved properly. I'm not really
sure what's causing this, I think it might be something to do with the fact
that this symbol doesn't start with an '_' for some funky reason.

Help is appreciated, I'm not sure if this is a bug in llvm or a problem with
the way I am using LLVM.



More information about the llvm-dev mailing list