[LLVMdev] Extend llvm to fix global addresses

John McCall rjmccall at apple.com
Tue Dec 6 14:32:31 PST 2011


(resent due to mailing list breakage)

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.

I agree that most code does not profit from specifying fixed addresses for objects.
Nonetheless, there is code which does.  Obvious examples:
 - boot-loaders
 - kernels
 - drivers
 - JITted code interacting with the runtime
 - code working with specialized address spaces

>> 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.

Your argument appears to be that this feature would have little use to you.
Noted, I guess.  We've spoken to several people who do write drivers and
other code like the above, and they seem pretty enthusiastic about the
idea.  If you have input about how best to design this, at any of the levels
Peter spelled out, that would be interesting.

John.



More information about the llvm-dev mailing list