[LLVMdev] Understanding resolving external/built-in function references

James Molloy james.molloy at arm.com
Mon Jun 6 04:01:55 PDT 2011


Hi Bill,

It depends on how your bitcode is loaded. It can be loaded either by llc,
which outputs pure ELF/Mach-O, in which case those function references get
turned into relocations that the linker (ld, Gold) applies.

If you're loading bitcode via the JIT, it uses dlsym() to try and introspect
your runtime environment to find the symbol.

The simple answer is that LLVM bitcode cannot be "loaded and run" as-is - it
needs to be converted to machine code and relocations are processed at this
time.

Hope this answers your question,

James

> -----Original Message-----
> From: llvmdev-bounces at cs.uiuc.edu [mailto:llvmdev-bounces at cs.uiuc.edu]
> On Behalf Of Bill Kelly
> Sent: 06 June 2011 11:52
> To: llvmdev at cs.uiuc.edu
> Subject: [LLVMdev] Understanding resolving external/built-in function
> references
> 
> Hi,
> 
> I'm new to LLVM, so I hope my question is well-formed.
> 
> Given a printf("Hello World") program saved as bitcode,
> I'm attempting to understand how LLVM resolves links to
> built-in functions like printf() when the bitcode is
> loaded.
> 
> I'm supposing something along the lines of a
> Linker::ItemList may exist somewhere which provides
> names and addresses of built-in functions(?)
> 
> On a related note, I'm wondering how one would make
> one's own built-in functions like myprintf() or such,
> available so that bitcode, when loaded, could link
> with them?
> 
> (Apologies if this is an RTFM.)
> 
> 
> Thanks for any help,
> 
> Bill
> 
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev








More information about the llvm-dev mailing list