<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="Generator" content="Microsoft Word 14 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
        {font-family:Wingdings;
        panose-1:5 0 0 0 0 0 0 0 0 0;}
@font-face
        {font-family:Wingdings;
        panose-1:5 0 0 0 0 0 0 0 0 0;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:Tahoma;
        panose-1:2 11 6 4 3 5 4 4 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman","serif";}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
p.MsoListParagraph, li.MsoListParagraph, div.MsoListParagraph
        {mso-style-priority:34;
        margin-top:0in;
        margin-right:0in;
        margin-bottom:0in;
        margin-left:.5in;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman","serif";}
span.EmailStyle18
        {mso-style-type:personal-reply;
        font-family:"Calibri","sans-serif";
        color:#1F497D;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-family:"Calibri","sans-serif";}
@page WordSection1
        {size:8.5in 11.0in;
        margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
        {page:WordSection1;}
/* List Definitions */
@list l0
        {mso-list-id:1383480046;
        mso-list-type:hybrid;
        mso-list-template-ids:-115674742 1145857186 67698691 67698693 67698689 67698691 67698693 67698689 67698691 67698693;}
@list l0:level1
        {mso-level-start-at:0;
        mso-level-number-format:bullet;
        mso-level-text:;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-.25in;
        mso-ansi-font-size:12.0pt;
        font-family:Wingdings;
        mso-fareast-font-family:Calibri;
        mso-bidi-font-family:"Times New Roman";
        color:windowtext;}
@list l0:level2
        {mso-level-number-format:bullet;
        mso-level-text:o;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-.25in;
        font-family:"Courier New";}
@list l0:level3
        {mso-level-number-format:bullet;
        mso-level-text:;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-.25in;
        font-family:Wingdings;}
@list l0:level4
        {mso-level-number-format:bullet;
        mso-level-text:;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-.25in;
        font-family:Symbol;}
@list l0:level5
        {mso-level-number-format:bullet;
        mso-level-text:o;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-.25in;
        font-family:"Courier New";}
@list l0:level6
        {mso-level-number-format:bullet;
        mso-level-text:;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-.25in;
        font-family:Wingdings;}
@list l0:level7
        {mso-level-number-format:bullet;
        mso-level-text:;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-.25in;
        font-family:Symbol;}
@list l0:level8
        {mso-level-number-format:bullet;
        mso-level-text:o;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-.25in;
        font-family:"Courier New";}
@list l0:level9
        {mso-level-number-format:bullet;
        mso-level-text:;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-.25in;
        font-family:Wingdings;}
ol
        {margin-bottom:0in;}
ul
        {margin-bottom:0in;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang="EN-US" link="blue" vlink="purple">
<div class="WordSection1">
<p class="MsoListParagraph" style="text-indent:-.25in;mso-list:l0 level1 lfo1"><![if !supportLists]><span style="font-family:Wingdings"><span style="mso-list:Ignore">Ø<span style="font:7.0pt "Times New Roman""> 
</span></span></span><![endif]>In the above scenario I believe you will end up having to write a linker script anyway.<span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">That’s right, there will be a base linker script to describe the memory layout of the target architecture and dictate generally where code and data sections
 go. <o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">What the location attribute helps you to avoid is having to edit the linker script account for a specific data object that requires specific placement that
 may occur in the middle of other data sections.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">The linker would be responsible for entertaining placement requests from input metadata as well as instructions from the linker command file. Typically, a linker
 will try to honor more constrained placement requests before more general ones (e.g. a specific address placement request would be handled before a request to place a section in a region of memory). The linker should be able to arbitrate the scenarios that
 you call out below, generating an error diagnostic when placement instructions conflict or cannot be honored.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoListParagraph" style="text-indent:-.25in;mso-list:l0 level1 lfo1"><![if !supportLists]><span style="font-family:Wingdings"><span style="mso-list:Ignore">Ø<span style="font:7.0pt "Times New Roman""> 
</span></span></span><![endif]><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">If a user attempt to locate a function at 0x1000, data at 0x2000, another function at 0x3000, and another data at 0x4000. Should we create four segments
 for each function and data?<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">Yes, the linker would take into account all four specific placement requests, try to honor them, then place other code and data according to linker script guidelines
 around them.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">I am not advocating that the use of a location attribute would eliminate the need for a linker command file, but it does help the user to express specific placement
 for specific pieces of code or data when they need to. If a user doesn’t require a piece of data or code to exist at a specific address, then they ought not attach a location attribute to it.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">~ Todd<o:p></o:p></span></p>
<p class="MsoNormal"><a name="_MailEndCompose"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"><o:p> </o:p></span></a></p>
<p class="MsoNormal"><b><span style="font-size:10.0pt;font-family:"Tahoma","sans-serif"">From:</span></b><span style="font-size:10.0pt;font-family:"Tahoma","sans-serif""> Rui Ueyama [mailto:ruiu@google.com]
<br>
<b>Sent:</b> Thursday, May 9, 2019 7:03 AM<br>
<b>To:</b> Snider, Todd<br>
<b>Cc:</b> James Y Knight; llvm-dev<br>
<b>Subject:</b> Re: [llvm-dev] [EXTERNAL] Re: RFC - a proposal to support additional symbol metadata in ELF object files in the ARM compiler<o:p></o:p></span></p>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<div>
<p class="MsoNormal"><strong>From: </strong>Snider, Todd <<a href="mailto:t-snider@ti.com">t-snider@ti.com</a>><o:p></o:p></p>
</div>
<div>
<div>
<p class="MsoNormal" style="margin-bottom:12.0pt"><strong>Date: </strong>Thu, May 9, 2019 at 3:53 AM<br>
<strong>To: </strong>Rui Ueyama, James Y Knight<br>
<strong>Cc: </strong>llvm-dev<o:p></o:p></p>
</div>
<blockquote style="border:none;border-left:solid #CCCCCC 1.0pt;padding:0in 0in 0in 6.0pt;margin-left:4.8pt;margin-right:0in">
<div>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"> </span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">James, Rui,</span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"> </span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">If we are only talking about addressable hardware registers, peripherals, etc., then the absolute
 address symbol is one way to facilitate access to a symbol associated with a specific address.</span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"> </span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">And yes, I would agree that data or code can be placed at a specific address using linker scripts,
 but it is not the most user-friendly of solutions.</span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"> </span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">Consider a simple example, say ex1.c contains:</span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"> </span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">  int xyz __attribute__((section(“.bss:xyz”))) = 10;</span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"> </span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">The compiler will generate a definition of xyz into the section “.bss:xyz”, in the linker script
 something like this can be added to dictate the placement:</span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"> </span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">   .special_bss: { ex1.o(.bss:xyz); } > 0x1000</span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"> </span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">This is straightforward, but now there is a coupling between the application’s source code and the
 linker script.</span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"> </span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">I think the location attribute gives a developer a cleaner, more concise means of expressing a placement
 constraint on a piece of code or data.</span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"> </span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">Even using the location attribute on the above example shows this,</span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"> </span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">int xyz __attribute__((location(0x1000))) = 10;</span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"> </span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">In addition to the definition of xyz in its own section, the compiler will emit metadata that the
 linker understands as a specific placement instruction for xyz’s section. No edit of a linker script is needed.</span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"> </span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">The use cases where I’ve seen the location attribute be particularly helpful are instances where
 code in ROM or a boot loader needs to access code or data at a particular address. For example, a boot routine in ROM may have security requirements for code and data that is loaded into FLASH memory and may have hardcoded addresses that it accesses to perform
 the security check. The code that is to be loaded into that FLASH memory can use location attributes to reserve space for the data objects at the specific addresses that the boot routine needs to access. In this instance using location attributes helps to
 reduce the maintenance that a developer may otherwise have to do with linker scripts.</span><o:p></o:p></p>
</div>
</div>
</blockquote>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">In the above scenario I believe you will end up having to write a linker script anyway. If you write a program that reside in a flash memory at a specific location, I think not only some specific data but the entire program needs to be
 instructed how to lay it out. There might be a scenario that you don't care about how other parts of your program are located in memory, but what if the address of the flash memory collides with the default layout? What is the expected behavior?<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">There are many tricky scenarios that I do not know what is the expected behavior:<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal"> - If a user attempt to locate a function at 0x1000, data at 0x2000, another function at 0x3000, and another data at 0x4000. Should we create four segments for each function and data?<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"> - What if a specified location collides with other data's specified location?<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"> - What if a specified location collides with the default layout?<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"> - What if a user attempts to put data and function to the same page?<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">I think if you can just say "place this piece of data at address 0xXXXX" and everything automagically works, it's great, but putting some piece of data at a specific location have global effect how other pieces of data and functions are
 laid out, so it looks like that kind of directive underspecifies what we actually want.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<blockquote style="border:none;border-left:solid #CCCCCC 1.0pt;padding:0in 0in 0in 6.0pt;margin-left:4.8pt;margin-right:0in">
<div>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">I mentioned earlier in this thread that a motivation for the location attribute is to allow the user
 to avoid messing with a linker command file or script. While the location attribute does not provide new functionality, I am arguing that the location attribute provides enough value in terms of usability improvements vs. existing methods to justify adding
 support for it.</span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"> </span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">~ Todd</span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><a name="m_8458191205725922989__MailEndCompose"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"> </span></a><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><b><span style="font-size:10.0pt;font-family:"Tahoma","sans-serif"">From:</span></b><span style="font-size:10.0pt;font-family:"Tahoma","sans-serif""> Rui Ueyama [mailto:<a href="mailto:ruiu@google.com" target="_blank">ruiu@google.com</a>]
<br>
<b>Sent:</b> Tuesday, May 7, 2019 1:43 AM<br>
<b>To:</b> James Y Knight<br>
<b>Cc:</b> Snider, Todd; llvm-dev<br>
<b>Subject:</b> Re: [llvm-dev] [EXTERNAL] Re: RFC - a proposal to support additional symbol metadata in ELF object files in the ARM compiler</span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"> <o:p></o:p></p>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto">I have the same question as James has. It seems to me that you can name any address using an absolute symbol, and that should suffice to handle memory-mapped peripherals and such.
 If you really need to define data (whether it's in .data or .bss) or a function at a fixed memory address, that's not something you can do with absolute symbols (but you can do with linker scripts), but is this what you really want?<o:p></o:p></p>
</div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"> <o:p></o:p></p>
<div>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;margin-bottom:12.0pt"><strong>From:
</strong>James Y Knight via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>><br>
<strong>Date: </strong>Tue, May 7, 2019 at 2:39 AM<br>
<strong>To: </strong>Snider, Todd<br>
<strong>Cc: </strong>llvm-dev<o:p></o:p></p>
</div>
<blockquote style="border:none;border-left:solid #CCCCCC 1.0pt;padding:0in 0in 0in 6.0pt;margin-left:4.8pt;margin-top:5.0pt;margin-right:0in;margin-bottom:5.0pt">
<div>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto">I don't think it's a "trick" at all -- it's just a definition of the symbol at an absolute address. That's what absolute symbols are for. (You can also use ".size sym, 4" ".type
 sym, object", if you want to let the linker know that the symbol refers to 4 bytes of data. I'm not sure if that's part of your concern about it not being real?)<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"> <o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto">For the use-case of accessing memory-mapped peripheral registers, this functionality seems already sufficient. Do you disagree?<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"> <o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto">However, if you have a requirement to place initialized data at a fixed address, then this pre-existing functionality does not address that requirement. But, I'm not sure what use-cases
 you're thinking of where this is a requirement. Can you talk about what you have in mind?<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"> <o:p></o:p></p>
</div>
</div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"> <o:p></o:p></p>
<div>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto">On Mon, May 6, 2019 at 9:10 AM Snider, Todd <<a href="mailto:t-snider@ti.com" target="_blank">t-snider@ti.com</a>> wrote:<o:p></o:p></p>
</div>
<blockquote style="border:none;border-left:solid #CCCCCC 1.0pt;padding:0in 0in 0in 6.0pt;margin-left:4.8pt;margin-top:5.0pt;margin-right:0in;margin-bottom:5.0pt">
<div>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"> </span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><a name="m_8458191205725922989_m_6368112708812974"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">James,</span></a><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"> </span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">What you are doing below is tricking the compiler into believing that it is dealing with a real int
 object that has actual space allocated to it in x2.o, but sym is not defined as a real data object in x1.o</span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"> </span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">Thanks, but that doesn’t really address my use case. I still contend that associating a placement
 address with an actual data object (whether it be initialized or not) or function, where the symbol is defined in a section containing the definition of the data object or function, is a useful feature for customers.</span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"> </span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">~ Todd</span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"> </span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><b><span style="font-size:10.0pt;font-family:"Tahoma","sans-serif"">From:</span></b><span style="font-size:10.0pt;font-family:"Tahoma","sans-serif""> James Y Knight [mailto:</span><a href="mailto:jyknight@google.com" target="_blank"><span style="font-size:10.0pt;font-family:"Tahoma","sans-serif"">jyknight@google.com</span></a><span style="font-size:10.0pt;font-family:"Tahoma","sans-serif"">]
<br>
<b>Sent:</b> Friday, May 3, 2019 4:35 PM<br>
<b>To:</b> Snider, Todd; Peter Smith; Finkel, Hal J.; llvm-dev<br>
<b>Subject:</b> Re: [llvm-dev] [EXTERNAL] Re: RFC - a proposal to support additional symbol metadata in ELF object files in the ARM compiler</span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"> <o:p></o:p></p>
<div>
<div>
<div>
<div>
<div>
<div>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto">It should result in an object file with a global absolute symbol. E.g. (here I'm building on x86-64 linux):<o:p></o:p></p>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"> <o:p></o:p></p>
</div>
<div>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="font-family:"Courier New";color:black">$ echo '.globl sym; sym = 0x600' | as -o /tmp/x1.o</span><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="font-family:"Courier New";color:black">$ nm /tmp/x1.o</span><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;margin-bottom:12.0pt"><span style="font-family:"Courier New";color:black">0000000000000600 A sym</span><o:p></o:p></p>
</div>
</div>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto">Compiling a binary that uses this, for demonstration:<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="font-family:"Courier New";color:black">$ printf $'extern int sym; int main() { sym = 5; }' | clang -c -xc - -o /tmp/x2.o</span><o:p></o:p></p>
</div>
<div>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="font-family:"Courier New";color:black">$ clang -o /tmp/x /tmp/x1.o /tmp/x2.o</span><o:p></o:p></p>
</div>
</div>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"> <o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto">And, hey, let's run it and see it crash...<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"> <o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="font-family:"Courier New";color:black">$ gdb /tmp/x</span><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="font-family:"Courier New";color:black">...</span><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="font-family:"Courier New";color:black">(gdb) run</span><o:p></o:p></p>
</div>
<div>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="font-family:"Courier New";color:black">Starting program: /tmp/x </span><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"> <o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="font-family:"Courier New";color:black">Program received signal SIGSEGV, Segmentation fault.</span><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="font-family:"Courier New";color:black">0x0000000000400486 in main ()</span><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="font-family:"Courier New";color:black">(gdb) p $_siginfo._sifields._sigfault.si_addr</span><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="font-family:"Courier New";color:black">$1 = (void *) 0x600</span><o:p></o:p></p>
</div>
</div>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;margin-bottom:12.0pt"><span style="font-family:"Courier New";color:black">(gdb) x/i $pc
<br>
=> 0x400486 <main+6>:   movl   $0x5,0x600</span><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="font-family:"Arial","sans-serif";color:black">Yep, crashed writing to 0x600, the invalid address we expected.</span><o:p></o:p></p>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"> <o:p></o:p></p>
<div>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto">On Fri, May 3, 2019 at 5:06 PM Snider, Todd <<a href="mailto:t-snider@ti.com" target="_blank">t-snider@ti.com</a>> wrote:<o:p></o:p></p>
</div>
<blockquote style="border:none;border-left:solid #CCCCCC 1.0pt;padding:0in 0in 0in 6.0pt;margin-left:4.8pt;margin-top:5.0pt;margin-right:0in;margin-bottom:5.0pt">
<div>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">Hi James,</span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"> </span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">Can you explain further the existing mechanisms in clang for expressing placement instructions for
 an extern symbol? I tried the “.globl a; a = 0x1000" asm source suggestion and did not see any information in the resulting object file that the linker could interpret as a placement instruction.</span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"> </span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">With regards to your argument about not needing or being able to pre-initialize data: even if a global
 object is not explicitly initialized, it may be generated into a section that is zero initialized at load or run time. In such cases, the location attribute is often combined with a “noinit” attribute that some compilers support which tells the linker to not
 initialize a specific object.</span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"> </span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">~ Todd</span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"> </span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><b><span style="font-size:10.0pt;font-family:"Tahoma","sans-serif"">From:</span></b><span style="font-size:10.0pt;font-family:"Tahoma","sans-serif""> James Y Knight [mailto:<a href="mailto:jyknight@google.com" target="_blank">jyknight@google.com</a>]
<br>
<b>Sent:</b> Friday, May 3, 2019 3:26 PM<br>
<b>To:</b> Snider, Todd<br>
<b>Cc:</b> Peter Smith; Finkel, Hal J.; llvm-dev<br>
<b>Subject:</b> Re: [llvm-dev] [EXTERNAL] Re: RFC - a proposal to support additional symbol metadata in ELF object files in the ARM compiler</span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"> <o:p></o:p></p>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto">The need to place an extern symbol at a particular fixed address can already be done just by emitting an absolute symbol. This works today, no object-file modifications needed. The
 source-level attribute isn't really necessary either, although having it does make things marginally nicer. (Without it, you can just emit ".globl a; a = 0x1000" assembly, either in module-level inline-asm, or a separate assembly file).<o:p></o:p></p>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"> <o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto">But the new functionality provided by this proposed extension is the allowance for placing *initialized* data at a fixed address. That seems like a rather strange requirement to
 me. You don't need (and, generally can't even reasonably HAVE) pre-initialized data for something like a memory-mapped peripheral register. Perhaps you could say why this would be a widely useful feature for the embedded processors you're concerned about?<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"> <o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto">The one case I'm aware of where fixed-placement initialized data is useful is when setting the "fuses" on an embedded CPU. The fuses are probably not actually in accessible memory
 at all. But, from the point-of-view of the flash programming system if you write flash data to a particular address, it will write to the config fuses instead. Expressing the fuse configuration as initialized data in the code, rather than separate metadata,
 can be convenient. But, for that, an ELF extension isn't needed -- you only have one of those, and it's specified by the platform, which can simply provide the required linker config.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"> <o:p></o:p></p>
</div>
</div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"> <o:p></o:p></p>
<div>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto">On Fri, May 3, 2019 at 10:42 AM Snider, Todd via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>> wrote:<o:p></o:p></p>
</div>
<blockquote style="border:none;border-left:solid #CCCCCC 1.0pt;padding:0in 0in 0in 6.0pt;margin-left:4.8pt;margin-top:5.0pt;margin-right:0in;margin-bottom:5.0pt">
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto">Our motivation for the "location" or "at" attribute is really as simple as allowing the user to avoid having to mess with a linker command file.<br>
<br>
Working on an application for an embedded processor, they may have special hardware features on their board (I/O ports, peripheral register as Peter mentioned, etc) that they know must reside at a specific memory address.<br>
<br>
The location attribute makes it easy for the user to express to the linker a constraint on the placement of an object without having to manage the placement themselves in the linker command file.<br>
<br>
~ Todd<br>
<br>
-----Original Message-----<br>
From: Peter Smith [mailto:<a href="mailto:peter.smith@linaro.org" target="_blank">peter.smith@linaro.org</a>]
<br>
Sent: Wednesday, May 1, 2019 10:27 AM<br>
To: Finkel, Hal J.<br>
Cc: Christof Douma; Snider, Todd; llvm-dev<br>
Subject: [EXTERNAL] Re: [llvm-dev] RFC - a proposal to support additional symbol metadata in ELF object files in the ARM compiler<br>
<br>
On Wed, 1 May 2019 at 15:03, Finkel, Hal J. <<a href="mailto:hfinkel@anl.gov" target="_blank">hfinkel@anl.gov</a>> wrote:<br>
><br>
> On 5/1/19 7:22 AM, Christof Douma via llvm-dev wrote:<br>
> > Hi Snider.<br>
> ><br>
> > As you and Peter mentioned there are indeed toolchains that allow location placement from within the C/C++ source code, using attributes or similar. I always wonder if such extension is worth the effort. There are downsides like the non-standard ways of
 communicating this information to the linker, different places that control location of things (linker and compiler sources). I would love to understand more of what is problematic in the more common approach for placement that is already available.<br>
> ><br>
> > The conceptual model I follow is that the C/C++ source describes the semantics of the program, and the linker sources (LD scripts or similar, depending on the toolchain in use) describe the placement of the program on the system/device. This gives rise
 to two common ways for placement that are used a lot that work without any non-standard extensions:<br>
> ><br>
> > * Define a variable in C/C++ in a dedicated section that a linker can move individually ('section' attribute in the compiler, and regular section placement in the linker).<br>
> > * Define a symbol in the linker at a certain place and used an extern declaration in C/C++. At this point you can either take the address of it (commonly used) or use it as a regular object (less common).<br>
> ><br>
> > I am very interested to hear what the weakness in these methods are, to understand the need of a 'location' attribute.<br>
><br>
><br>
> I like the idea of these fixed-location variables being defined as<br>
> actual global variables. The optimizer can actually reason about them<br>
> that way. The common alternative that I've seen is that programmers<br>
> don't generate variables at all, but rather, do something like this:<br>
><br>
>   #define DEV_DATA (*((volatile unsigned long *)(0x2000A000)))<br>
><br>
> and the optimizer needs to make very pessimistic assumptions about the<br>
> aliasing, etc. in this case. However, in the end, do we actually want<br>
> symbols that the linker resolves? Or do we want the immediate address?<br>
> Would the latter be more efficient?<br>
><br>
> Having to define sections for each of these variables and then maintain<br>
> the location mappings in a linker script can be annoying -- on the other<br>
> hand, if you target multiple systems for which the addresses might be<br>
> different then having the locations in a separate file might be best anyway.<br>
><br>
> What I don't understand about this proposal is how general it is. How<br>
> much of what is specified in a linker script can be specified this way?<br>
> Do we really just want a way to embed linker-script fragments into an<br>
> object file?<br>
><br>
<br>
I suspect that clang/llvm will be agnostic with respect to what can be<br>
done in the linker. In effect the linker is given the instruction to<br>
place a section at a particular address and it is up to the linker to<br>
work out how to do that or error if it can't.<br>
<br>
The majority of the cases I've seen this used for are memory mapped<br>
peripheral registers that typically live way outside the normal memory<br>
map covered by the linker script. These cases are not too difficult to<br>
handle as the linker can generate its own fragment of linker script<br>
(or equivalent) from the Input Section. The more difficult case is<br>
where the location is in the middle of an existing OutputSection and<br>
this can involve changes to the linker's layout to flow non-location<br>
sections around it, this is a fertile source of corner case bugs. How<br>
much or little of this to support might be best left to the linker.<br>
<br>
Embedding linker script fragments is an interesting idea, and could<br>
mean that any linker that supports GNU linker scripts could use the<br>
feature. I think that there would be a number of challenges:<br>
- Precedence of section selectors, i.e. how to stop an earlier linker<br>
script pattern from matching the location, I guess a tempname style<br>
section name might help, although wildcards might pick it up.<br>
- The linker script fragment would need to not clash with an existing<br>
OutputSection. I think that this could work for memory mapped<br>
peripherals but it wouldn't for some of the other use cases that a<br>
linker might want to support.<br>
- Embedded ELF linkers may not support GNU Linker Script syntax.<br>
Although custom targets could change the linker script format as they<br>
see fit.<br>
<br>
Will be interesting to hear what use cases Todd had in mind.<br>
<br>
Peter<br>
>  -Hal<br>
><br>
> ><br>
> > Thanks,<br>
> > Christof<br>
> ><br>
> > <span style="font-family:"Tahoma","sans-serif""></span>On 30/04/2019, 16:51, "llvm-dev on behalf of Peter Smith via llvm-dev" <<a href="mailto:llvm-dev-bounces@lists.llvm.org" target="_blank">llvm-dev-bounces@lists.llvm.org</a> on behalf of
<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>> wrote:<br>
> ><br>
> >     On Tue, 30 Apr 2019 at 16:17, Snider, Todd via llvm-dev<br>
> >     <<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>> wrote:<br>
> >     ><br>
> >     ><br>
> >     ><br>
> >     > Hello All,<br>
> >     ><br>
> >     ><br>
> >     ><br>
> >     > In ARM embedded applications, there are some compilers that support useful function and variable attributes that help the compiler communicate information about symbols to downstream object consumers (i.e. linkers).<br>
> >     ><br>
> >     ><br>
> >     ><br>
> >     > One such attribute is the “location” attribute. This attribute can be applied to a global or local static data object or a function to indicate to the linker that the definition of the data object or function should be placed at a specific address
 in memory.<br>
> >     ><br>
> >     ><br>
> >     ><br>
> >     > For example, in the following code:<br>
> >     ><br>
> >     ><br>
> >     ><br>
> >     > #include <stdio.h><br>
> >     ><br>
> >     ><br>
> >     ><br>
> >     > extern int a;<br>
> >     ><br>
> >     > int a __attribute__((location(0x1000))) = 4;<br>
> >     ><br>
> >     ><br>
> >     ><br>
> >     > struct bstruct<br>
> >     ><br>
> >     > {<br>
> >     ><br>
> >     >     int f1;<br>
> >     ><br>
> >     >     int f2;<br>
> >     ><br>
> >     > };<br>
> >     ><br>
> >     ><br>
> >     ><br>
> >     > struct bstruct b __attribute__((location(0x1004))) = {10, 12};<br>
> >     ><br>
> >     > double c __attribute__((location(0x1010))) = 1.0;<br>
> >     ><br>
> >     > char d[] __attribute__((location(0x2000)))  = {1, 2, 3, 4};<br>
> >     ><br>
> >     > void foo(double x) __attribute((location(0x4000)));<br>
> >     ><br>
> >     ><br>
> >     ><br>
> >     > void foo(double x) { printf("%f\n", x); }<br>
> >     ><br>
> >     ><br>
> >     ><br>
> >     > A location attribute has been applied to several  data objects and the function “foo.”  The compiler would then encode information into the compiled object file that tells the downstream linker about these memory placement constraints on the data
 objects and function.<br>
> >     ><br>
> >     ><br>
> >     ><br>
> >     > Without extending the ELF object format, how would this work?<br>
> >     ><br>
> >     ><br>
> >     ><br>
> >     > I propose to encode metadata information about a symbol in special absolute symbols, “__sym_attr_metadata.<int>”, that the linker can recognize when scanning the symbol table for an incoming object file. In an ELF symbol table entry:<br>
> >     ><br>
> >     ><br>
> >     ><br>
> >     > typedef struct {<br>
> >     ><br>
> >     >        Elf32_Word     st_name;<br>
> >     ><br>
> >     >        Elf32_Addr     st_value;<br>
> >     ><br>
> >     >        Elf32_Word     st_size;<br>
> >     ><br>
> >     >        unsigned char  st_info;<br>
> >     ><br>
> >     >        unsigned char  st_other;<br>
> >     ><br>
> >     >        Elf32_Half     st_shndx;<br>
> >     ><br>
> >     > } Elf32_Sym;<br>
> >     ><br>
> >     ><br>
> >     ><br>
> >     > typedef struct {<br>
> >     ><br>
> >     >        Elf64_Word     st_name;<br>
> >     ><br>
> >     >        unsigned char  st_info;<br>
> >     ><br>
> >     >        unsigned char  st_other;<br>
> >     ><br>
> >     >        Elf64_Half     st_shndx;<br>
> >     ><br>
> >     >        Elf64_Addr     st_value;<br>
> >     ><br>
> >     >        Elf64_Xword    st_size;<br>
> >     ><br>
> >     > } Elf64_Sym;<br>
> >     ><br>
> >     ><br>
> >     ><br>
> >     > The st_size and st_value fields could be used to represent attribute information about a given symbol:<br>
> >     ><br>
> >     ><br>
> >     ><br>
> >     > The st_size field can be split into an attribute ID and a symbol index for the symbol that the attribute applies to<br>
> >     ><br>
> >     > attribute ID: bits 0..7<br>
> >     > symbol index: bits 8..31<br>
> >     ><br>
> >     > The st_value field can contain the value associated with the attribute (i.e. the address argument of a location attribute)<br>
> >     ><br>
> >     ><br>
> >     ><br>
> >     > If the compiler is generating assembly code, a new directive similar to the .eabi_attribute can be used:<br>
> >     ><br>
> >     ><br>
> >     ><br>
> >     >         .symbol_attribute <symbol name>, <attribute kind>, <attribute value><br>
> >     ><br>
> >     ><br>
> >     ><br>
> >     > Where:<br>
> >     ><br>
> >     > symbol name - will unambiguously identify the symbol that the attribute/value pair applies to<br>
> >     > attribute kind - is an unsigned integer between 1 and 255 that specifies the kind of attribute to be applied to the symbol<br>
> >     ><br>
> >     > I propose a starting base set of 2 attribute IDs: used (1), location (2)<br>
> >     > the compiler will emit the integer constant that identifies the attribute kind<br>
> >     ><br>
> >     > attribute value - a value that is appropriate for the specified attribute kind<br>
> >     ><br>
> >     ><br>
> >     ><br>
> >     > Thoughts? Comments? Concerns?<br>
> >     ><br>
> ><br>
> >     Hello Todd,<br>
> ><br>
> >     Thanks for bringing this up, I've got a few comments for you based on<br>
> >     the implementation of a similar attribute in another Embedded Compiler<br>
> >     (<a href="http://infocenter.arm.com/help/topic/com.arm.doc.dui0472m/chr1359124981140.html" target="_blank">http://infocenter.arm.com/help/topic/com.arm.doc.dui0472m/chr1359124981140.html</a>).<br>
> >      In that case it was __attribute__((at(address))) but the name is not<br>
> >     that important.<br>
> ><br>
> >     The communication with the linker in that case was via section name<br>
> >     and not symbol, from memory at(<address>) translated to a section name<br>
> >     of .ARM.__at_<address>. For us this had some advantages:<br>
> >     - We could use __attribute__((section(".ARM.__at_<address>")))  when<br>
> >     the compiler didn't support the attribute, it also needed no support<br>
> >     in the assembler. This wasn't ideal as it is nice to be able to use<br>
> >     expressions for the address, but it gets you most of the way there.<br>
> >     - In practice you'd likely need a separate section for each variable<br>
> >     to avoid problems at link time. For example if you had two variables<br>
> >     with non-contiguous locations you'd most likely not want these in the<br>
> >     same section so this mapped quite well to something similar to<br>
> >     __attribute__((section(name))).<br>
> >     - We did find some properties of __attribute__((section("name")))<br>
> >     inconvenient, especially that variables would come out as SHT_PROGBITS<br>
> >     when in many cases the user wanted SHT_NOBITS (memory mapped<br>
> >     peripheral), we had our custom attribute fix that.<br>
> ><br>
> >     If you used a section name rather than a symbol then you may not need<br>
> >     any backend changes and it would generalise over all ELF targets.<br>
> >     Linker support is another question entirely though.<br>
> ><br>
> >     Peter<br>
> ><br>
> >     ><br>
> >     ><br>
> >     > The anticipated next steps would be to add support for the location attribute and update the ARM/ELF LLVM back-end to support encoding the used attribute with the new mechanism.<br>
> >     ><br>
> >     ><br>
> >     ><br>
> >     > ~ Todd Snider<br>
> >     ><br>
> >     ><br>
> >     ><br>
> >     > Code Generation Tools Group<br>
> >     ><br>
> >     > Texas Instruments Incorporated<br>
> >     ><br>
> >     ><br>
> >     ><br>
> >     ><br>
> >     ><br>
> >     > _______________________________________________<br>
> >     > LLVM Developers mailing list<br>
> >     > <a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a><br>
> >     > <a href="https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" target="_blank">
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a><br>
> >     _______________________________________________<br>
> >     LLVM Developers mailing list<br>
> >     <a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a><br>
> >     <a href="https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" target="_blank">https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a><br>
> ><br>
> ><br>
> > IMPORTANT NOTICE: The contents of this email and any attachments are confidential and may also be privileged. If you are not the intended recipient, please notify the sender immediately and do not disclose the contents to any other person, use it for any
 purpose, or store or copy the information in any medium. Thank you.<br>
> > _______________________________________________<br>
> > LLVM Developers mailing list<br>
> > <a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a><br>
> > <a href="https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" target="_blank">
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a><br>
><br>
> --<br>
> Hal Finkel<br>
> Lead, Compiler Technology and Programming Languages<br>
> Leadership Computing Facility<br>
> Argonne National Laboratory<br>
><br>
_______________________________________________<br>
LLVM Developers mailing list<br>
<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a><br>
<a href="https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" target="_blank">https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a><o:p></o:p></p>
</blockquote>
</div>
</div>
</div>
</blockquote>
</div>
</div>
</div>
</blockquote>
</div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto">_______________________________________________<br>
LLVM Developers mailing list<br>
<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a><br>
<a href="https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" target="_blank">https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a><o:p></o:p></p>
</blockquote>
</div>
</div>
</div>
</blockquote>
</div>
</div>
</div>
</body>
</html>