<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Wed, May 6, 2015 at 12:51 AM, Will Newton <span dir="ltr"><<a href="mailto:will.newton@gmail.com" target="_blank">will.newton@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;padding-left:1ex;border-left-color:rgb(204,204,204);border-left-width:1px;border-left-style:solid"><div class="HOEnZb"><div class="h5">On Wed, May 6, 2015 at 6:22 AM, Chris Lattner <<a href="mailto:clattner@apple.com">clattner@apple.com</a>> wrote:<br>
> On May 5, 2015, at 6:47 PM, Daniel Dilts <<a href="mailto:diltsman@gmail.com">diltsman@gmail.com</a>> wrote:<br>
><br>
> Take a look at how debuggers have migrated through the years.  They too<br>
>><br>
>> used to have their own script format.  Now most (all?) popular debuggers<br>
>> do scripting through embedding an actual programming language.  This<br>
>> could be a better way forward for linkers as well -- embed Python in the<br>
>> linker, define a Python API for linkable item placement, entry point,<br>
>> symbol operations, etc..., and then you also have the rest of Python at<br>
>> your fingertips.<br>
><br>
><br>
> I mostly care about specifying address where specific symbols will be placed<br>
> and specifying the memory layout of the platform.   I normally use<br>
> __attribute__((section(""))) to place the symbols in their own sections and<br>
> then use the linker script to place the sections at the required addresses.<br>
> How would this be accomplished without linker scripts?<br>
><br>
><br>
> I’d prefer to use an "__attribute__((address(0x1234)))” myself.  That way<br>
> you can control platform specifics with #ifdefs.<br>
<br>
</div></div>But that way you have to do layout by hand in C. Generally you won't<br>
know the size of the preceding code or data so you won't know what<br>
address to put things at at the granularity of a single C level<br>
object/function. Better to say "put this in the ROM section" and set<br>
the address of the ROM section once in a linker script and let the<br>
linker do the layout.<br></blockquote><div><br></div><div>The real use case is on platforms, like ARM, where control registers are mapped to a specific address range.  Then it is useful to put an object that deals with the control registers at a specific address.  __attribute__((address(0x1234))) can be replaced with a platform specific linker script.  Which is better?  I don't know, I haven't spent any time comparing them. </div></div><br></div></div>