[LLVMdev] Assign symbol the address of a section

Chris Lattner clattner at apple.com
Mon May 11 10:24:37 PDT 2009


On May 11, 2009, at 10:02 AM, Matt Renzelmann wrote:
> Hello,
>
> The binaries produced by LLVM and other compilers divide code up into
> various sections, e.g. the .text section.
>
> What is the recommended approach to assigning a symbol the address  
> of a
> section using LLVM?  Using GCC/LD, you can do this with a linker  
> script,
> e.g. in a linker script you can do:
>
>  _text = .;
>  _stext = .;
>
> These symbols are then available in the corresponding C code using an
> "extern" definition.  But, LLVM doesn't support linker scripts--so  
> what's
> the trick?

Hi Matt,

I don't know of a straight-forward way to do this.  However, you can  
probably use module-level inline asm to do the trick.

-Chris



More information about the llvm-dev mailing list