<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>CodeWarrior for MCUのトピックRe: Assigning fixed absolute address for a function?</title>
    <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/Assigning-fixed-absolute-address-for-a-function/m-p/157352#M4151</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;Hello&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;using a user defined section and placing it in the appropriate address is the only way you can get a function allocated at an absolute address.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;There is no reason to manually adjust the size of the section to the function length.&lt;/DIV&gt;&lt;DIV&gt;In your PRM file you can tell that you want to place this section plus some others in that segment.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;For instance in your placement BLOCK you can write:&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; COMPAT_40a2,&amp;nbsp;AnotherSectio, OneMoreSection &amp;nbsp;INTO COMPAT_40a2;&lt;BR /&gt;&lt;/DIV&gt;&lt;DIV&gt;Further more you can even write&lt;/DIV&gt;&lt;DIV&gt;&lt;DIV&gt;&amp;nbsp; COMPAT_40a2,&amp;nbsp;AnotherSection, OneMoreSection &amp;nbsp;INTO COMPAT_40a2, AnotherSegment;&lt;BR /&gt;&lt;/DIV&gt;&lt;DIV&gt;Function stored in COMPAT_40a2 will always be allocated in COMPAT_40a2. Then the linker will fill the rest of the code into the specified segments.&lt;/DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;CrasyCat&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 21 May 2008 18:08:51 GMT</pubDate>
    <dc:creator>CrasyCat</dc:creator>
    <dc:date>2008-05-21T18:08:51Z</dc:date>
    <item>
      <title>Assigning fixed absolute address for a function?</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/Assigning-fixed-absolute-address-for-a-function/m-p/157351#M4150</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Plenty of examples floating around for placing a variable at a specific memory address but finding examples of controlling the address of a function to be lacking. At least in the 8/16 side of the house.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Have inherited a bootloader in an S12NE64 that calls a function at 0x40a2. Would like to discuss options on how to place my function at that address.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;So far have created a SEGMENT and used #pragma to place my function in that CODE_SEG.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;COMPAT_40a2 = READ_ONLY 0x0040a2 TO 0x007fff FILL 0xff;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The above under SEGMENTS, the following under PLACEMENT doesn't seem right, but works:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;COMPAT_40a2 INTO COMPAT_40a2;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;This works, but it doesn't have the feel of control that I desire. The only reason my function is at 0x40a2 is that its the only one in that SEGMENT. OK, I can manually adjust the size of the segment and keep that routine as the only one placed there, but I'd like some cleaner means of control. Is there?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 20 May 2008 21:45:20 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/Assigning-fixed-absolute-address-for-a-function/m-p/157351#M4150</guid>
      <dc:creator>dkelly</dc:creator>
      <dc:date>2008-05-20T21:45:20Z</dc:date>
    </item>
    <item>
      <title>Re: Assigning fixed absolute address for a function?</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/Assigning-fixed-absolute-address-for-a-function/m-p/157352#M4151</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;Hello&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;using a user defined section and placing it in the appropriate address is the only way you can get a function allocated at an absolute address.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;There is no reason to manually adjust the size of the section to the function length.&lt;/DIV&gt;&lt;DIV&gt;In your PRM file you can tell that you want to place this section plus some others in that segment.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;For instance in your placement BLOCK you can write:&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; COMPAT_40a2,&amp;nbsp;AnotherSectio, OneMoreSection &amp;nbsp;INTO COMPAT_40a2;&lt;BR /&gt;&lt;/DIV&gt;&lt;DIV&gt;Further more you can even write&lt;/DIV&gt;&lt;DIV&gt;&lt;DIV&gt;&amp;nbsp; COMPAT_40a2,&amp;nbsp;AnotherSection, OneMoreSection &amp;nbsp;INTO COMPAT_40a2, AnotherSegment;&lt;BR /&gt;&lt;/DIV&gt;&lt;DIV&gt;Function stored in COMPAT_40a2 will always be allocated in COMPAT_40a2. Then the linker will fill the rest of the code into the specified segments.&lt;/DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;CrasyCat&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 21 May 2008 18:08:51 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/Assigning-fixed-absolute-address-for-a-function/m-p/157352#M4151</guid>
      <dc:creator>CrasyCat</dc:creator>
      <dc:date>2008-05-21T18:08:51Z</dc:date>
    </item>
    <item>
      <title>Re: Assigning fixed absolute address for a function?</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/Assigning-fixed-absolute-address-for-a-function/m-p/157353#M4152</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;"Function stored in COMPAT_40a2 will always be allocated in COMPAT_40a2."&lt;BR /&gt;&lt;BR /&gt;I'm concerned about your use of "in" because I'm looking for "at". Can't be "in" the general volume of COMPAT_40a2, I need the function to start exactly at 0x40a2.&lt;BR /&gt;&lt;BR /&gt;Am guessing you are saying that I should define a section, say, MUST_BE_0x40a2 and #pragma CODE_SEG MUST_BE_0x40a2 my function. And only that function, no others.&lt;BR /&gt;&lt;BR /&gt;Then define a SEGMENT which starts at 0x40a2 and list my MUST_BE_0x40a2 SECTION as the first member and will be assured that its always placed first at 0x40a2? This seems to work.&lt;BR /&gt;&lt;BR /&gt;The argument to #pragma CODE_SEG doesn't have to exist to compile, only to link. At link time if its not listed in PLACEMENT it silently falls into DEFAULT_ROM.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Am a bit fuzzy as to the difference between SECTIONS and SEGMENTS. The words seem interchangeable in the .PRM file and elsewhere. Digging through the help system I initially thought SEGMENTS were an ELF thing and SECTIONS were a Freescale/Hiwire thing. Then found enlightening statements to the effect, "Sections go in segments. Section is a group of objects. A segment is a memory region which is not necessarily contiguous."&lt;BR /&gt;&lt;BR /&gt;So I'm thinking "#pragma CODE_SEG" accepts either a segment or a section as its argument?&lt;BR /&gt;&lt;BR /&gt;That a section is a Freescale thing. That multiple sections can be grouped into an ELF segment when the object file is written.&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 21 May 2008 22:35:33 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/Assigning-fixed-absolute-address-for-a-function/m-p/157353#M4152</guid>
      <dc:creator>dkelly</dc:creator>
      <dc:date>2008-05-21T22:35:33Z</dc:date>
    </item>
    <item>
      <title>Re: Assigning fixed absolute address for a function?</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/Assigning-fixed-absolute-address-for-a-function/m-p/157354#M4153</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;FONT color="#330000"&gt;The term "section" is a used by the ELF object file format definition, so I'm using it for the names of the "sections" in the ELF file.&lt;/FONT&gt;&lt;FONT color="#330000"&gt;&lt;BR /&gt;&lt;/FONT&gt;&lt;FONT color="#330000"&gt;Therefore a #pragma CONST_SEG is expecting a section name, and those sections names are listed in the prm in the PLACEMENT area, where the content of each section is assigned into possibly multiple segments.&lt;/FONT&gt;&lt;FONT color="#330000"&gt;&lt;BR /&gt;&lt;/FONT&gt;&lt;FONT color="#330000"&gt;So segment names only appear in the prm where they name a particular memory area in a SEGMENTS block, and where they are used on the right side of one or multiple entries in the PLACEMENT block on the right side of the INTO.&lt;/FONT&gt;&lt;FONT color="#330000"&gt;&lt;BR /&gt;&lt;/FONT&gt;&lt;FONT color="#330000"&gt;&lt;BR /&gt;&lt;/FONT&gt;&lt;FONT color="#330000"&gt;So that is how I think the terminology should be used for ELF. Note that historically in the&amp;nbsp; today not used HIWARE object file format, the terms segment and section have been used differently, and that is a reason where a some of the confusion is originated.&lt;/FONT&gt;&lt;FONT color="#330000"&gt;&lt;BR /&gt;&lt;/FONT&gt;&lt;FONT color="#330000"&gt;One such topic, for example is why the pragma is called CONST_SE&lt;/FONT&gt;&lt;FONT color="#ff0000"&gt;G &lt;FONT color="#330000"&gt;(and not CONST_SE&lt;/FONT&gt;C&lt;FONT color="#330000"&gt;), that is just because how the terms have been used initially with the HIWARE object file format and the pragma name was kept when switching to ELF later on.&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#ff0000"&gt;&lt;FONT color="#330000"&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#ff0000"&gt;&lt;FONT color="#330000"&gt;&lt;BR /&gt;Note also that while you can use the same name for segments as for sections as in the original post, I would usually not recommend that. By using a distinct name, it is clear which identifiers have to match, and which ones not.&lt;BR /&gt;So I would rather use COMPAT_40A2_SECTION INTO COMPAT_40A2_SEGMENT, or something like that.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Daniel&lt;BR /&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 22 May 2008 08:44:28 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/Assigning-fixed-absolute-address-for-a-function/m-p/157354#M4153</guid>
      <dc:creator>CompilerGuru</dc:creator>
      <dc:date>2008-05-22T08:44:28Z</dc:date>
    </item>
  </channel>
</rss>

