<?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>topic How to place stack at the start of RAM using Coldfire linker file. in Classic/Legacy CodeWarrior</title>
    <link>https://community.nxp.com/t5/Classic-Legacy-CodeWarrior/How-to-place-stack-at-the-start-of-RAM-using-Coldfire-linker/m-p/242307#M6517</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I would like to place my stack at the bottom of RAM, before any other data segments, to protect against stack overflow problems.&amp;nbsp; How can I tell the linker to reserve some space at the beginning of RAM for my stack?&amp;nbsp; When I try as described below, the Flash programmer rejects the resulting S19 file.&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;By default, the linker file places the stack right above the data segment.&amp;nbsp; But in that situation, if the stack overflows (growing down due to nesting function calls too deeply or an unexpected worst case of many ISRs at the same time) this will lead to silently overwriting parts of the data segment.&amp;nbsp; I don't want to &lt;STRONG&gt;detect&lt;/STRONG&gt; this via writing some sentinel values to the stack and occasionally checking to see if they have been overwritten.&amp;nbsp; I want to &lt;STRONG&gt;prevent&lt;/STRONG&gt; my data from being (possibly undetectably) overwritten.&amp;nbsp; If the stack is located at the bottom of RAM instead of the top, then when the stack overflows below the start of physical RAM, I will get an immediate exception and hardware reset.&amp;nbsp; The fact that my processor is resetting because of a stack overflow indicates that my code still has a problem that needs to be fixed, but a hardware reset will prevent the program from silently just continuing to run after data corruption.&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is an extract from my .LCF file for Codewarrior for Coldfire 7.2.2. &lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; .text :&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; {&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; *(.init)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; *(.text)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; *(.rodata)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em; font-family: 'courier new', courier;"&gt;&amp;nbsp; } &amp;gt; rom&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; .stack :&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; {&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ___SP_END = .;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; . = . + ___stack_size;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; . = ALIGN(4);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; __SP_INIT = .;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ___SP_AFTER_RESET = __SP_INIT;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; } &amp;gt; ram&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em; font-family: 'courier new', courier;"&gt;&amp;nbsp; .data : AT(___DATA_ROM) &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; {&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ___DATA_RAM = .;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; *(.data)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em; font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; . = ALIGN(4);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ___DATA_END = .;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; } &amp;gt;&amp;gt; ram&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The .xMAP shows that the stack is located at the beginning of RAM. Yay!&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;But the resulting .S19 file is filled with records that explicitly write ___stack_size worth of 0 bytes to RAM.&amp;nbsp; That wouldn't really be a problem, but the Flash Programmer gets mad at the S19 file because it is only allows specifying Flash locations not RAM locations.&amp;nbsp; The LCF file does not use ZERO_FILL_UNINITIALIZED.&amp;nbsp; It seems to be that line ". = . + ___stack_size" that moves the location has the side effect of writing all those 0 bytes.&amp;nbsp; Here is an extract of the generated S19 file.&amp;nbsp; You've got the end of the .text segment and then all those explicit zeroes starting at RAM 0x20000000.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="line-height: 1.5em; font-size: 10pt; font-family: 'courier new', courier;"&gt;S325000114A04572726F723A20466C61736820636F7079206661696C6564000A3F3F3F0A446FEF&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;S325000114C0776E6C6F6164204661696C6564000000000001AC002020202020202020202828FE&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;S325000114E0282828202020202020202020202020202020202020881010101010101010101005&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;S325000115001010101010444444444444444444441010101010101041414141414101010101D2&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;S325000115200101010101010101010101010101010110101010101042424242424202020202A0&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;S321000115400202020202020202020202020202020210101010200000000000000008&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;S325200000000000000000000000000000000000000000000000000000000000000000000000BA&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;S3252000002000000000000000000000000000000000000000000000000000000000000000009A&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;S3252000004000000000000000000000000000000000000000000000000000000000000000007A&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;S3252000006000000000000000000000000000000000000000000000000000000000000000005A&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;S3252000008000000000000000000000000000000000000000000000000000000000000000003A&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;S325200000A000000000000000000000000000000000000000000000000000000000000000001A&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;S325200000C00000000000000000000000000000000000000000000000000000000000000000FA&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;S325200000E00000000000000000000000000000000000000000000000000000000000000000DA&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;S325200001000000000000000000000000000000000000000000000000000000000000000000B9&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;S32520000120000000000000000000000000000000000000000000000000000000000000000099&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How do I tell the linker to reserve some space at the beginning of RAM for my stack without causing all those 0 bytes to be written to the S19 file?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 18 Feb 2014 18:32:36 GMT</pubDate>
    <dc:creator>cstevens</dc:creator>
    <dc:date>2014-02-18T18:32:36Z</dc:date>
    <item>
      <title>How to place stack at the start of RAM using Coldfire linker file.</title>
      <link>https://community.nxp.com/t5/Classic-Legacy-CodeWarrior/How-to-place-stack-at-the-start-of-RAM-using-Coldfire-linker/m-p/242307#M6517</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I would like to place my stack at the bottom of RAM, before any other data segments, to protect against stack overflow problems.&amp;nbsp; How can I tell the linker to reserve some space at the beginning of RAM for my stack?&amp;nbsp; When I try as described below, the Flash programmer rejects the resulting S19 file.&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;By default, the linker file places the stack right above the data segment.&amp;nbsp; But in that situation, if the stack overflows (growing down due to nesting function calls too deeply or an unexpected worst case of many ISRs at the same time) this will lead to silently overwriting parts of the data segment.&amp;nbsp; I don't want to &lt;STRONG&gt;detect&lt;/STRONG&gt; this via writing some sentinel values to the stack and occasionally checking to see if they have been overwritten.&amp;nbsp; I want to &lt;STRONG&gt;prevent&lt;/STRONG&gt; my data from being (possibly undetectably) overwritten.&amp;nbsp; If the stack is located at the bottom of RAM instead of the top, then when the stack overflows below the start of physical RAM, I will get an immediate exception and hardware reset.&amp;nbsp; The fact that my processor is resetting because of a stack overflow indicates that my code still has a problem that needs to be fixed, but a hardware reset will prevent the program from silently just continuing to run after data corruption.&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is an extract from my .LCF file for Codewarrior for Coldfire 7.2.2. &lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; .text :&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; {&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; *(.init)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; *(.text)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; *(.rodata)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em; font-family: 'courier new', courier;"&gt;&amp;nbsp; } &amp;gt; rom&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; .stack :&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; {&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ___SP_END = .;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; . = . + ___stack_size;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; . = ALIGN(4);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; __SP_INIT = .;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ___SP_AFTER_RESET = __SP_INIT;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; } &amp;gt; ram&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em; font-family: 'courier new', courier;"&gt;&amp;nbsp; .data : AT(___DATA_ROM) &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; {&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ___DATA_RAM = .;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; *(.data)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em; font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; . = ALIGN(4);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ___DATA_END = .;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; } &amp;gt;&amp;gt; ram&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The .xMAP shows that the stack is located at the beginning of RAM. Yay!&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;But the resulting .S19 file is filled with records that explicitly write ___stack_size worth of 0 bytes to RAM.&amp;nbsp; That wouldn't really be a problem, but the Flash Programmer gets mad at the S19 file because it is only allows specifying Flash locations not RAM locations.&amp;nbsp; The LCF file does not use ZERO_FILL_UNINITIALIZED.&amp;nbsp; It seems to be that line ". = . + ___stack_size" that moves the location has the side effect of writing all those 0 bytes.&amp;nbsp; Here is an extract of the generated S19 file.&amp;nbsp; You've got the end of the .text segment and then all those explicit zeroes starting at RAM 0x20000000.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="line-height: 1.5em; font-size: 10pt; font-family: 'courier new', courier;"&gt;S325000114A04572726F723A20466C61736820636F7079206661696C6564000A3F3F3F0A446FEF&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;S325000114C0776E6C6F6164204661696C6564000000000001AC002020202020202020202828FE&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;S325000114E0282828202020202020202020202020202020202020881010101010101010101005&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;S325000115001010101010444444444444444444441010101010101041414141414101010101D2&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;S325000115200101010101010101010101010101010110101010101042424242424202020202A0&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;S321000115400202020202020202020202020202020210101010200000000000000008&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;S325200000000000000000000000000000000000000000000000000000000000000000000000BA&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;S3252000002000000000000000000000000000000000000000000000000000000000000000009A&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;S3252000004000000000000000000000000000000000000000000000000000000000000000007A&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;S3252000006000000000000000000000000000000000000000000000000000000000000000005A&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;S3252000008000000000000000000000000000000000000000000000000000000000000000003A&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;S325200000A000000000000000000000000000000000000000000000000000000000000000001A&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;S325200000C00000000000000000000000000000000000000000000000000000000000000000FA&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;S325200000E00000000000000000000000000000000000000000000000000000000000000000DA&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;S325200001000000000000000000000000000000000000000000000000000000000000000000B9&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;S32520000120000000000000000000000000000000000000000000000000000000000000000099&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How do I tell the linker to reserve some space at the beginning of RAM for my stack without causing all those 0 bytes to be written to the S19 file?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 18 Feb 2014 18:32:36 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Classic-Legacy-CodeWarrior/How-to-place-stack-at-the-start-of-RAM-using-Coldfire-linker/m-p/242307#M6517</guid>
      <dc:creator>cstevens</dc:creator>
      <dc:date>2014-02-18T18:32:36Z</dc:date>
    </item>
    <item>
      <title>Re: How to place stack at the start of RAM using Coldfire linker file.</title>
      <link>https://community.nxp.com/t5/Classic-Legacy-CodeWarrior/How-to-place-stack-at-the-start-of-RAM-using-Coldfire-linker/m-p/242308#M6518</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi C Stevens,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Please note that in the project you can find references to&amp;nbsp; ___SP_INIT(3 underscores), __SP_INIT(2 underscores), _SP_INIT(1 underscores).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In startcf.c you will find the following code&lt;SPAN style="color: #3f7f5f; font-size: 10pt;"&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;/* &lt;SPAN style="text-decoration: underline;"&gt;Pre&lt;/SPAN&gt;-&lt;SPAN style="text-decoration: underline;"&gt;init&lt;/SPAN&gt; SP, in case memory for stack is not valid it should be setup using &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P align="left"&gt;MEMORY_INIT before __initialize_hardware is called &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P align="left"&gt;*/&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P align="left"&gt;lea __SP_AFTER_RESET,a7;&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P align="left"&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;&lt;SPAN style="color: #3f7f5f; font-size: 10pt;"&gt;/* &lt;SPAN style="text-decoration: underline;"&gt;initialize&lt;/SPAN&gt; memory */&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;MEMORY_INIT&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P align="left"&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P align="left"&gt; &lt;SPAN style="color: #3f7f5f; font-size: 10pt;"&gt;/* &lt;SPAN style="text-decoration: underline;"&gt;initialize&lt;/SPAN&gt; any hardware specific issues */&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P align="left"&gt;jsr __initialize_hardware &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P align="left"&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;&lt;SPAN style="color: #3f7f5f; font-size: 10pt;"&gt;/* setup the stack pointer */&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;lea _SP_INIT,a7&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Please notice that _SP_INIT(with one underscore) located in startcf.c references __SP_INIT (with 2 underscores) located in .lcf. And this is the value that the stack pointer will use as base in the rest of the application.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope this helps.&lt;/P&gt;&lt;P&gt;Carlos&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 25 Feb 2014 23:19:15 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Classic-Legacy-CodeWarrior/How-to-place-stack-at-the-start-of-RAM-using-Coldfire-linker/m-p/242308#M6518</guid>
      <dc:creator>Carlos_Musich</dc:creator>
      <dc:date>2014-02-25T23:19:15Z</dc:date>
    </item>
    <item>
      <title>Re: How to place stack at the start of RAM using Coldfire linker file.</title>
      <link>https://community.nxp.com/t5/Classic-Legacy-CodeWarrior/How-to-place-stack-at-the-start-of-RAM-using-Coldfire-linker/m-p/242309#M6519</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I was not asking how to reference the stack pointer from C.&amp;nbsp; I was asking why does Codewarrior fill up my S19 file with a bunch of explicit 0 bytes when I attempt to place the stack at the bottom of RAM instead of the top of RAM.&amp;nbsp; The 0 bytes wouldn't even be a problem to me except that the flash programmer doesn't like seeing an S19 file that references RAM.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 06 Mar 2014 18:29:13 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Classic-Legacy-CodeWarrior/How-to-place-stack-at-the-start-of-RAM-using-Coldfire-linker/m-p/242309#M6519</guid>
      <dc:creator>cstevens</dc:creator>
      <dc:date>2014-03-06T18:29:13Z</dc:date>
    </item>
    <item>
      <title>Re: Re: How to place stack at the start of RAM using Coldfire linker file.</title>
      <link>https://community.nxp.com/t5/Classic-Legacy-CodeWarrior/How-to-place-stack-at-the-start-of-RAM-using-Coldfire-linker/m-p/242310#M6520</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Stevens:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Did you resolve this?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I think you are correct that the address relocation (.) causes those 0's. But I do not see why you used that syntax. You can simply use symbols/tags without moving the location counter, like next:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_text_macro jive_macro_code _jivemacro_uid_13953946886194096" jivemacro_uid="_13953946886194096" modifiedtitle="true"&gt;
&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;
&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; .stack :&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; {&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ___SP_END = .;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ___SP_INIT = ___SP_END + ___stack_size - 4;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; . = ALIGN(4);&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; } &amp;gt; ram&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;
&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; __SP_INIT = ___SP_INIT;
&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-size: 10pt; font-family: 'courier new', courier;"&gt;&amp;nbsp; .data : AT(___DATA_ROM) &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; {&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ___DATA_RAM = .;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; *(.data)&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-size: 10pt; font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; . = ALIGN(4);&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ___DATA_END = .;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; } &amp;gt;&amp;gt; ram&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;
&lt;/SPAN&gt;&lt;/P&gt;

&lt;/PRE&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;Jorge Gonzalez&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;-----------------------------------------------------------------------------------------------------------------------&lt;BR /&gt;Note: If this post answers your question, please click the Correct Answer button. Thank you!&lt;BR /&gt;-----------------------------------------------------------------------------------------------------------------------&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 21 Mar 2014 09:43:46 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Classic-Legacy-CodeWarrior/How-to-place-stack-at-the-start-of-RAM-using-Coldfire-linker/m-p/242310#M6520</guid>
      <dc:creator>Jorge_Gonzalez</dc:creator>
      <dc:date>2014-03-21T09:43:46Z</dc:date>
    </item>
    <item>
      <title>Re: Re: How to place stack at the start of RAM using Coldfire linker file.</title>
      <link>https://community.nxp.com/t5/Classic-Legacy-CodeWarrior/How-to-place-stack-at-the-start-of-RAM-using-Coldfire-linker/m-p/242311#M6521</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If you do that then no space is reserved for the stack.&amp;nbsp; Yes you have created a symbol __SP_INIT at . + stacksize, but you will notice that the .stack section itself is 0 bytes long and the .data section now starts at the same location at the .stack section.&amp;nbsp; You have placed your stack and your data sections in the same RAM locations at the same time -- certainly not good.&amp;nbsp; Now the stack is guaranteed to overwrite the data!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 21 Mar 2014 16:37:14 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Classic-Legacy-CodeWarrior/How-to-place-stack-at-the-start-of-RAM-using-Coldfire-linker/m-p/242311#M6521</guid>
      <dc:creator>cstevens</dc:creator>
      <dc:date>2014-03-21T16:37:14Z</dc:date>
    </item>
    <item>
      <title>Re: Re: Re: How to place stack at the start of RAM using Coldfire linker file.</title>
      <link>https://community.nxp.com/t5/Classic-Legacy-CodeWarrior/How-to-place-stack-at-the-start-of-RAM-using-Coldfire-linker/m-p/242312#M6522</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Actually you are correct, I did not think of that, sorry. Then the trick would be to create a new memory segment just for the stack. Something like the next: (not sure what device you have, so it is just an example):&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Lets assume you will have 0x1000 of stack.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="_jivemacro_uid_13954247034206702 jive_text_macro jive_macro_code" jivemacro_uid="_13954247034206702"&gt;
&lt;P&gt;MEMORY&lt;/P&gt;
&lt;P&gt;{&lt;/P&gt;
&lt;P&gt;&amp;nbsp; # ... flash segments ... #&lt;/P&gt;
&lt;P&gt;&amp;nbsp; ram&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; (RWX) :&amp;nbsp; ORIGIN = 0x20001400,&amp;nbsp; LENGTH = 0x00004C00&amp;nbsp; # Make sure that ram length is TOTAL RAM - STACK&lt;/P&gt;
&lt;P&gt;&amp;nbsp; stack_ram (RWX) :&amp;nbsp; ORIGIN = 0x20000400,&amp;nbsp; LENGTH = 0x00001000&amp;nbsp; # NEW segment&lt;/P&gt;
&lt;P&gt;}&lt;/P&gt;


&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;then:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_text_macro jive_macro_code _jivemacro_uid_13954247034062507" jivemacro_uid="_13954247034062507" modifiedtitle="true"&gt;
&lt;P&gt;&amp;nbsp; .stack :&lt;/P&gt;
&lt;P&gt;&amp;nbsp; {&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ___SP_END = .;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ___SP_INIT = ___SP_END + ___stack_size - 4;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; . = ALIGN(4);&lt;/P&gt;
&lt;P&gt;&amp;nbsp; } &amp;gt;&amp;gt; stack_ram&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; __SP_INIT = ___SP_INIT;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; .data : AT(___DATA_ROM)&lt;/P&gt;
&lt;P&gt;&amp;nbsp; {&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ___DATA_RAM = .;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; *(.data)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; . = ALIGN(4);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ___DATA_END = .;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; } &amp;gt;&amp;gt; ram&lt;/P&gt;


&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope this helps!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;Jorge Gonzalez&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;-----------------------------------------------------------------------------------------------------------------------&lt;BR /&gt;Note: If this post answers your question, please click the Correct Answer button. Thank you!&lt;BR /&gt;-----------------------------------------------------------------------------------------------------------------------&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 21 Mar 2014 17:54:23 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Classic-Legacy-CodeWarrior/How-to-place-stack-at-the-start-of-RAM-using-Coldfire-linker/m-p/242312#M6522</guid>
      <dc:creator>Jorge_Gonzalez</dc:creator>
      <dc:date>2014-03-21T17:54:23Z</dc:date>
    </item>
  </channel>
</rss>

