[cfe-dev] [LLVMdev] Extend llvm to fix global addresses

Peter Cooper peter_cooper at apple.com
Tue Dec 6 10:41:05 PST 2011


On Dec 6, 2011, at 6:55 AM, Joerg Sonnenberger wrote:

> On Mon, Dec 05, 2011 at 07:18:36PM -0800, Peter Cooper wrote:
>> It would be nice to add support for placing globals at fixed addresses in memory.  
> 
> I don't know. From my experience, the usefulness is very, very limited.
> As in: drivers are about the only thing that can make use of it.
Yeah, it would mostly be drivers, but there's also plenty of embedded processors out there
with minimal/no linkers.  In those situations the developer tends to have to hack the assembly
output from the compiler to lay out the globals manually.
> 
>> For example, low level driver code tends to contain things like this
>> 
>> *(int*)0x00001000
>> 
>> which is horrible.
> 
> The drivers I have seen can't work that way because they are written to
> cover more than one specific machine. As soon as you go anywhere near an
> IO abstraction, this doesn't apply anymore. As such, I think this
> feature primarily helps making ugly, unportable code differently ugly,
> unportable code.
Agreed on the ugliness, but at least it keeps it all in one place instead of defining the globals
in C but then having to also maintain a linker script somewhere else to define their addresses.
> 
> Joerg
> _______________________________________________
> 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 cfe-dev mailing list