<html>
<body>
Hi Richard,<br><br>
In the map file below the 'bss' area starts immediately after the 'data'
area at 0x0218. However the space between 0x0218-&gt;0x02ff remains
unused and the first use of 'bss' is at address 0x0400. I assume this is
because the area 'mydata' is sitting in between, but it does leave some
unused RAM.<br><br>
It won't affect Jeff as he appears to have plenty of RAM to play with.
Also it is a simple test and doesn't have much stuff in the data area.
The most important lesson to be learnt here is that personalised data
areas should always be placed at the start of the RAM area so that the
'data' &amp; 'bss' areas can be contiguous allowing the linker to manage
them correctly.<br><br>
All the best for now,<br>
John<br>
&nbsp; <br><br>
At 03:43 04/07/2007, you wrote:<br>
<blockquote type=cite class=cite cite="">Eh? What's the problem?
Initialized globals go to the &quot;data&quot; area and non-initialized
globals (which default to zero-initialized) go to the &quot;bss&quot;
area. The linker do not change the ordering of the variables within each
area (although it may do that according to Standard C rules but this will
cause some problems with some code and also generally not a high priority
optimization). Can you explain further what I am missing?<br><br>
At 03:10 PM 7/1/2007, John Baraclough wrote:<br>
<blockquote type=cite class=cite cite="">Hi Jeff,<br><br>
I've been doing a little more investigation and there is some strange
behaviour with the linker.<br><br>
I have a small test program for a mega2561, with the following lines of
code:<br><br>
<font face="Courier New, Courier" color="#0000FF"><b>long</b>
MoreWasteSpace[200];<br><br>
<b>const</b> <b>unsigned</b> <b>char</b> *Months[12] =<br>
{<br>
&nbsp; <i>&quot;Jan&quot;</i>,<br>
&nbsp; <i>&quot;Feb&quot;</i>,<br>
&nbsp; <i>&quot;Mar&quot;</i>,<br>
&nbsp; <i>&quot;Apr&quot;</i>,<br>
&nbsp; <i>&quot;May&quot;</i>,<br>
&nbsp; <i>&quot;Jun&quot;</i>,<br>
&nbsp; <i>&quot;Jul&quot;</i>,<br>
&nbsp; <i>&quot;Aug&quot;</i>,<br>
&nbsp; <i>&quot;Sep&quot;</i>,<br>
&nbsp; <i>&quot;Oct&quot;</i>,<br>
&nbsp; <i>&quot;Nov&quot;</i>,<br>
&nbsp; <i>&quot;Dec&quot;<br>
</i>} ; <br><br>
<b>int</b> WasteSpace[100];<br>
<b>char</b> Date[20];<br><br>
#pragma data:mydata<br>
&nbsp; <b>unsigned</b> <b>char</b> BootFlags;<br>
&nbsp; <b>unsigned</b> <b>char</b> BootBuffer[24];<br>
#pragma data:data<br><br>
<br>
</font>I have added the following linker directive:<br><br>
<font face="Courier New, Courier" color="#0000FF">-bmydata:0x0300.0x031f
-bdata:0x200.0x21f:0x0400.0x21ff<br><br>
<br>
</font>This is an excerpt from the map file which shows the utilisation
of RAM.<br><br>
<font face="Courier New, Courier" color="#0000FF">
Area&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
Addr&nbsp;&nbsp; Size&nbsp;&nbsp; Decimal Bytes (Attributes)<br>
--------------------------------&nbsp;&nbsp; ----&nbsp;&nbsp;
----&nbsp;&nbsp; ------- ----- ------------<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
data&nbsp;&nbsp; 0200&nbsp;&nbsp; 0018 =&nbsp;&nbsp;&nbsp;&nbsp; 24.
bytes (rel,con,ram)<br><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Addr&nbsp; Global Symbol<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; -----&nbsp;
--------------------------------<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 0200&nbsp; _Months<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 0200&nbsp; __data_start<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 0218&nbsp; __data_end<br><br>
Area&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
Addr&nbsp;&nbsp; Size&nbsp;&nbsp; Decimal Bytes (Attributes)<br>
--------------------------------&nbsp;&nbsp; ----&nbsp;&nbsp;
----&nbsp;&nbsp; ------- ----- ------------<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
bss&nbsp;&nbsp; 0218&nbsp;&nbsp; 0417 =&nbsp;&nbsp; 1047. bytes
(rel,con,ram)<br><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Addr&nbsp; Global Symbol<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; -----&nbsp;
--------------------------------<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 0218&nbsp; __bss_start<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 0400&nbsp; _Date<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 0414&nbsp; _WasteSpace<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 04DC&nbsp; _MoreWasteSpace<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 0815&nbsp; __bss_end<br><br>
Area&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
Start&nbsp; End&nbsp;&nbsp;&nbsp; Decimal Bytes (Attributes)<br>
--------------------------------&nbsp;&nbsp; ----&nbsp;&nbsp;
----&nbsp;&nbsp; ------- ----- ------------<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
vector&nbsp;&nbsp; 0000&nbsp;&nbsp; 0004 =&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
4. bytes (abs,ovr,rom)<br><br>
Area&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
Addr&nbsp;&nbsp; Size&nbsp;&nbsp; Decimal Bytes (Attributes)<br>
--------------------------------&nbsp;&nbsp; ----&nbsp;&nbsp;
----&nbsp;&nbsp; ------- ----- ------------<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
mydata&nbsp;&nbsp; 0300&nbsp;&nbsp; 0019 =&nbsp;&nbsp;&nbsp;&nbsp; 25.
bytes (rel,con,ram)<br><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Addr&nbsp; Global Symbol<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; -----&nbsp;
--------------------------------<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 0300&nbsp; _BootFlags<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 0301&nbsp; _BootBuffer<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 0319&nbsp; __mydata_end<br><br>
<br>
</font>I would have expected the linker to use as much of the space below
0x0300 as possible before utilising the space above 0x0400. However it
only appears to put the array of constant string pointers in there and
then immediately jump to 0x400 to continue. I'm afraid the linker does
not appear to be quite as efficient as it could be at utilising split
areas of RAM.<br><br>
All the best for now,<br>
John<br><br>
<br>
At 22:40 29/06/2007, you wrote:<br>
<blockquote type=cite class=cite cite="">Content-class:
urn:content-classes:message<br>
Content-Type: multipart/alternative;<br>
<x-tab>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</x-tab>
boundary=&quot;----_=_NextPart_001_01C7BA96.1C96999D&quot;<br>
<br>
<font size=2 color="#000080">John,<br>
&nbsp;<br>
Thanks again, this list is a real knowledge base and blessing.<br>
&nbsp;<br>
Thanks<br>
Jeff<br>
&nbsp;<br>
</font><font face="Times New Roman, Times" color="#000080"><b>Jeff
Milender<br>
Sr. Electronic Design Engineer<br>
</b>Cargo Systems<br>
Goodrich Interiors<br>
2604 Highway 20 North<br>
Jamestown, ND 58401<br>
Tel: 701-253-7569<br>
<a href="mailto:jeff.milender@goodrich.com">jeff.milender@goodrich.com</a>
 <br>
</font><font face="Times New Roman, Times" size=2 color="#000080">
<a href="http://www.goodrich.com/" eudora="autourl">www.goodrich.com</a>
</font></blockquote>_______________________________________________<br>
Icc-avr mailing list<br>
Icc-avr@imagecraft.com<br>
<a href="http://dragonsgate.net/mailman/listinfo/icc-avr" eudora="autourl">
http://dragonsgate.net/mailman/listinfo/icc-avr</a></blockquote><br>
// richard (This email is for mailing lists. To reach me directly, please
use richard at imagecraft.com) <br>
_______________________________________________<br>
Icc-avr mailing list<br>
Icc-avr@imagecraft.com<br>
<a href="http://dragonsgate.net/mailman/listinfo/icc-avr" eudora="autourl">
http://dragonsgate.net/mailman/listinfo/icc-avr</a></blockquote></body>
</html>