[LLVMdev] Extend llvm to fix global addresses

Peter Cooper peter_cooper at apple.com
Mon Dec 5 19:18:36 PST 2011

Hi all

It would be nice to add support for placing globals at fixed addresses in memory.  

For example, low level driver code tends to contain things like this


which is horrible.

Alternatively people are using linker scripts and assembly hacks to put symbols at fixed addresses.

I propose we add first class support to this in the compiler.  Like addrspace(#) we should have something like fixedaddr(#) to put a symbol at the address specified (naming is open to suggestions)

Support for this would be needed in the following places:
Clang - with suggestions open to syntax, particularly if anyone knows of existing compilers with syntax for this
IR - "fixedaddr" as above with new attribute on globals (and probably on functions if there's a need to bind functions to fixed addresses too)
Object files - this might be possible within current formats like ELF by doing horrible things with relocations, but we'll have to experiment
Linker - like object file support, but additionally would be nice to improve them to the point where we can avoid using linker scripts to do this

Comments are very welcome.


More information about the llvm-dev mailing list