[LLVMdev] Objective-C code in lli

Chris Lattner clattner at apple.com
Mon Oct 19 08:54:54 PDT 2009


On Oct 19, 2009, at 5:32 AM, Eric Brunstad wrote:

> Hi,
>
> What would be an estimate for the amount of work required to  
> implement this?  Where would I get started if I were to implement it?
>
> My goal is to run Objective-C programs in the interpreter so I can  
> provide an application-sandbox by disallowing the invocation of  
> certain C-functions and also by disallowing the invocation of  
> certain Objective-C methods.

I don't really know.  I'd start by reading up on the ObjC runtime  
interfaces and grabbing a copy of it from the open darwin site.  See  
what it does at startup time to register metadata and do the  
equivalent of that.

Alternatively, you can try running apps and debug specific failures.

-Chris

>
> Thanks,
>
> Eric
>
> On Oct 19, 2009, at 12:01 AM, Chris Lattner wrote:
>
>>
>> On Oct 18, 2009, at 6:32 PM, Eric Brunstad wrote:
>>
>>> Hi,
>>>
>>> Is it possible to run Objective-C code in lli?  lli does not seem  
>>> to want to load Foundation.framework.
>>
>> It is definitely possible, but we're not there yet.  LLI would have  
>> to know about objective-c metadata to register it properly with the  
>> runtime.  This is important for things like classes etc.  This  
>> isn't conceptually hard, but noone has done it yet.
>>
>> -Chris
>>
>>>
>>> Please see below.
>>>
>>> Thanks,
>>>
>>> Eric Brunstad
>>>
>>> #import <Foundation/Foundation.h>
>>>
>>> int main(int argc, char *argv[])
>>> {
>>> 	NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
>>> 	NSLog(@"test!");
>>> 	[pool drain];
>>> 	return EXIT_SUCCESS;
>>> }
>>>
>>> cmu-351714:llvm-2.5 ericbrunstad$ /Users/ericbrunstad/Downloads/ 
>>> llvm-2.5/Release/bin/lli -force-interpreter=true -stats  /Users/ 
>>> ericbrunstad/Desktop/test/test.o -load=/System/Library/Frameworks/ 
>>> Foundation.framework/Foundation
>>>
>>> Could not resolve external global address:  
>>> __CFConstantStringClassReference
>>> 0   lli               0x0000000100687556 (anonymous  
>>> namespace)::SignalHandler(int) + 470
>>> 1   libSystem.B.dylib 0x00007fff83ee10aa _sigtramp + 26
>>> 2   libSystem.B.dylib 0x0000000100a0b4ba _sigtramp + 2092082218
>>> 3   lli               0x00000001001e8374  
>>> llvm::ExecutionEngine::emitGlobals() + 6164
>>> 4   lli               0x00000001001dbd69  
>>> llvm::Interpreter::Interpreter(llvm::ModuleProvider*) + 185
>>> 5   lli               0x00000001001dbdd8 llvm::Interpreter::create 
>>> (llvm::ModuleProvider*, std::string*, bool) + 56
>>> 6   lli               0x0000000100010803 main + 243
>>> 7   lli               0x00000001000106e8 start + 52
>>>
>>> _______________________________________________
>>> LLVM Developers mailing list
>>> LLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.edu
>>> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
>>
>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20091019/c5816ec7/attachment.html>


More information about the llvm-dev mailing list