<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=iso-8859-1">
<meta name=Generator content="Microsoft Word 12 (filtered medium)">
<style>
<!--
/* Font Definitions */
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@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:0cm;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri","sans-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;}
span.E-MailFormatvorlage17
        {mso-style-type:personal;
        font-family:"Calibri","sans-serif";
        color:windowtext;}
span.E-MailFormatvorlage18
        {mso-style-type:personal-reply;
        font-family:"Calibri","sans-serif";
        color:#002060;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-size:10.0pt;}
@page Section1
        {size:612.0pt 792.0pt;
        margin:70.85pt 70.85pt 2.0cm 70.85pt;}
div.Section1
        {page:Section1;}
-->
</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=DE link=blue vlink=purple>
<div class=Section1>
<p class=MsoNormal><span style='color:#002060'>Hello<o:p></o:p></span></p>
<p class=MsoNormal><span style='color:#002060'><o:p> </o:p></span></p>
<p class=MsoNormal><span lang=EN-US style='color:#002060'>Further testing
showed that manipulating the parameter <i>heap_base</i> is somewhat critical:
it seems to render the image defective in some cases for whatever reason. The
ELF Weaver patches information about the image’s properties into the data
structure <i>init_struct</i>, and this may become inconsistent (just a guess).<o:p></o:p></span></p>
<p class=MsoNormal><span lang=EN-US style='color:#002060'>But changing the heap
size seems to be less critical, but has an interesting impact on the segment
allocation. Here an example, when setting the heap size to 0x38000:<o:p></o:p></span></p>
<p class=MsoNormal style='margin-left:35.4pt'><span lang=EN-US
style='font-size:9.0pt;font-family:"Courier New";color:#002060'>Program
Headers:<o:p></o:p></span></p>
<p class=MsoNormal style='margin-left:35.4pt'><span lang=EN-US
style='font-size:9.0pt;font-family:"Courier New";color:#002060'>
Type Offset VirtAddr PhysAddr FileSiz MemSiz Flg Align<o:p></o:p></span></p>
<p class=MsoNormal style='margin-left:35.4pt'><span lang=EN-US
style='font-size:9.0pt;font-family:"Courier New";color:#002060'>
LOAD 0x008000 0xf0000000 0x20000000 0x2022c 0x2390c RWE 0x8000<o:p></o:p></span></p>
<p class=MsoNormal style='margin-left:35.4pt'><span lang=EN-US
style='font-size:9.0pt;font-family:"Courier New";color:#002060'>
LOAD 0x02c000 0xf0024000 0x20024000 0x06000 0x06000 RW 0x8000<o:p></o:p></span></p>
<p class=MsoNormal style='margin-left:35.4pt'><span lang=EN-US
style='font-size:9.0pt;font-family:"Courier New";color:#002060'>
LOAD 0x038000 0x90000000 0x200c8000 0x0dfaf 0x0dfaf R E 0x8000<o:p></o:p></span></p>
<p class=MsoNormal style='margin-left:35.4pt'><span lang=EN-US
style='font-size:9.0pt;font-family:"Courier New";color:#002060'>
LOAD 0x046000 0x90016000 0x2002b000 0x00234 0x00364 RW 0x8000<o:p></o:p></span></p>
<p class=MsoNormal style='margin-left:35.4pt'><span lang=EN-US
style='font-size:9.0pt;font-family:"Courier New";color:#002060'>
LOAD 0x048000 0x90100000 0x20088000 0x0526f 0x0526f R E 0x8000<o:p></o:p></span></p>
<p class=MsoNormal style='margin-left:35.4pt'><span lang=EN-US
style='font-size:9.0pt;font-family:"Courier New";color:#002060'>
LOAD 0x04d270 0x9010d270 0x2002f270 0x00118 0x00238 RW 0x8000<o:p></o:p></span></p>
<p class=MsoNormal style='margin-left:35.4pt'><span lang=EN-US
style='font-size:9.0pt;font-family:"Courier New";color:#002060'>
LOAD 0x050000 0x90200000 0x200d8000 0x055ef 0x055ef R E 0x8000<o:p></o:p></span></p>
<p class=MsoNormal style='margin-left:35.4pt'><span lang=EN-US
style='font-size:9.0pt;font-family:"Courier New";color:#002060'>
LOAD 0x0555f0 0x9020d5f0 0x200d75f0 0x00148 0x00518 RW 0x8000<o:p></o:p></span></p>
<p class=MsoNormal style='margin-left:35.4pt'><span lang=EN-US
style='font-size:9.0pt;font-family:"Courier New";color:#002060'> </span><span
style='font-size:9.0pt;font-family:"Courier New";color:#002060'>LOAD
0x058000 0x90300000 0x20114000 0x05df8 0x05df8 R E 0x8000<o:p></o:p></span></p>
<p class=MsoNormal style='margin-left:35.4pt'><span style='font-size:9.0pt;
font-family:"Courier New";color:#002060'> LOAD 0x05e000 0x9030e000
0x20111000 0x00254 0x00440 RW 0x8000<o:p></o:p></span></p>
<p class=MsoNormal style='margin-left:35.4pt'><span style='font-size:9.0pt;
font-family:"Courier New";color:#002060'> </span><span lang=EN-US
style='font-size:9.0pt;font-family:"Courier New";color:#002060'>LOAD
0x060000 0x90400000 0x20130000 0x0598b 0x0598b R E 0x8000<o:p></o:p></span></p>
<p class=MsoNormal style='margin-left:35.4pt'><span lang=EN-US
style='font-size:9.0pt;font-family:"Courier New";color:#002060'>
LOAD 0x06598c 0x9040d98c 0x2011b98c 0x00130 0x00220 RW 0x8000<o:p></o:p></span></p>
<p class=MsoNormal style='margin-left:35.4pt'><span lang=EN-US
style='font-size:9.0pt;font-family:"Courier New";color:#002060'>
LOAD 0x066000 0x90056000 0x20136000 0x03000 0x03000 RW 0x1000<o:p></o:p></span></p>
<p class=MsoNormal><span lang=EN-US style='color:#002060'>Surprise: the 4 MB
hole has disappeared! In general, all segments carrying <i>.text</i> and <i>.rodata</i>
sections and some of the segments carrying <i>.data</i> and <i>.bss</i>
sections have become new offsets, although the sizes did not change (the email
below does not show the latest state of VSPI and SPI_TEST). Here another example
with heap size = 0x48000:<o:p></o:p></span></p>
<p class=MsoNormal style='margin-left:35.4pt'><span lang=EN-US
style='font-size:9.0pt;font-family:"Courier New";color:#002060'>Program
Headers:<o:p></o:p></span></p>
<p class=MsoNormal style='margin-left:35.4pt'><span lang=EN-US
style='font-size:9.0pt;font-family:"Courier New";color:#002060'>
Type Offset VirtAddr PhysAddr FileSiz MemSiz Flg Align<o:p></o:p></span></p>
<p class=MsoNormal style='margin-left:35.4pt'><span lang=EN-US
style='font-size:9.0pt;font-family:"Courier New";color:#002060'>
LOAD 0x008000 0xf0000000 0x20000000 0x2022c 0x2390c RWE 0x8000<o:p></o:p></span></p>
<p class=MsoNormal style='margin-left:35.4pt'><span lang=EN-US
style='font-size:9.0pt;font-family:"Courier New";color:#002060'>
LOAD 0x02c000 0xf0024000 0x20024000 0x06000 0x06000 RW 0x8000<o:p></o:p></span></p>
<p class=MsoNormal style='margin-left:35.4pt'><span lang=EN-US
style='font-size:9.0pt;font-family:"Courier New";color:#002060'>
LOAD 0x038000 0x90000000 0x200d8000 0x0dfaf 0x0dfaf R E 0x8000<o:p></o:p></span></p>
<p class=MsoNormal style='margin-left:35.4pt'><span lang=EN-US
style='font-size:9.0pt;font-family:"Courier New";color:#002060'>
LOAD 0x046000 0x90016000 0x2002b000 0x00234 0x00364 RW 0x8000<o:p></o:p></span></p>
<p class=MsoNormal style='margin-left:35.4pt'><span lang=EN-US
style='font-size:9.0pt;font-family:"Courier New";color:#002060'>
LOAD 0x048000 0x90100000 0x20088000 0x0526f 0x0526f R E 0x8000<o:p></o:p></span></p>
<p class=MsoNormal style='margin-left:35.4pt'><span lang=EN-US
style='font-size:9.0pt;font-family:"Courier New";color:#002060'>
LOAD 0x04d270 0x9010d270 0x2002f270 0x00118 0x00238 RW 0x8000<o:p></o:p></span></p>
<p class=MsoNormal style='margin-left:35.4pt'><span lang=EN-US
style='font-size:9.0pt;font-family:"Courier New";color:#002060'> </span><span
style='font-size:9.0pt;font-family:"Courier New";color:#002060'>LOAD
0x050000 0x90200000 0x200e8000 0x055ef 0x055ef R E 0x8000<o:p></o:p></span></p>
<p class=MsoNormal style='margin-left:35.4pt'><span style='font-size:9.0pt;
font-family:"Courier New";color:#002060'> LOAD 0x0555f0 0x9020d5f0
0x200e75f0 0x00148 0x00518 RW 0x8000<o:p></o:p></span></p>
<p class=MsoNormal style='margin-left:35.4pt'><span style='font-size:9.0pt;
font-family:"Courier New";color:#002060'> LOAD 0x058000 0x90300000
0x20124000 0x05df8 0x05df8 R E 0x8000<o:p></o:p></span></p>
<p class=MsoNormal style='margin-left:35.4pt'><span style='font-size:9.0pt;
font-family:"Courier New";color:#002060'> LOAD 0x05e000 0x9030e000
0x20121000 0x00254 0x00440 RW 0x8000<o:p></o:p></span></p>
<p class=MsoNormal style='margin-left:35.4pt'><span style='font-size:9.0pt;
font-family:"Courier New";color:#002060'> </span><span lang=EN-US
style='font-size:9.0pt;font-family:"Courier New";color:#002060'>LOAD
0x060000 0x90400000 0x20140000 0x0598b 0x0598b R E 0x8000<o:p></o:p></span></p>
<p class=MsoNormal style='margin-left:35.4pt'><span lang=EN-US
style='font-size:9.0pt;font-family:"Courier New";color:#002060'>
LOAD 0x06598c 0x9040d98c 0x2012b98c 0x00130 0x00220 RW 0x8000<o:p></o:p></span></p>
<p class=MsoNormal style='margin-left:35.4pt'><span lang=EN-US
style='font-size:9.0pt;font-family:"Courier New";color:#002060'>
LOAD 0x066000 0x90056000 0x20146000 0x03000 0x03000 RW 0x1000<o:p></o:p></span></p>
<p class=MsoNormal><span lang=EN-US style='color:#002060'>The segment offsets
have changed again, so that the overall image size has grown by 64 kB, although
the segment sizes are the same. Finally an attempt with heap size = 0x3C000:<o:p></o:p></span></p>
<p class=MsoNormal style='margin-left:35.4pt'><span lang=EN-US
style='font-size:9.0pt;font-family:"Courier New";color:#002060'>Program
Headers:<o:p></o:p></span></p>
<p class=MsoNormal style='margin-left:35.4pt'><span lang=EN-US
style='font-size:9.0pt;font-family:"Courier New";color:#002060'>
Type Offset VirtAddr PhysAddr FileSiz MemSiz Flg Align<o:p></o:p></span></p>
<p class=MsoNormal style='margin-left:35.4pt'><span lang=EN-US
style='font-size:9.0pt;font-family:"Courier New";color:#002060'>
LOAD 0x008000 0xf0000000 0x20000000 0x2022c 0x2390c RWE 0x8000<o:p></o:p></span></p>
<p class=MsoNormal style='margin-left:35.4pt'><span lang=EN-US
style='font-size:9.0pt;font-family:"Courier New";color:#002060'> LOAD 0x02c000
0xf0024000 0x20024000 0x06000 0x06000 RW 0x8000<o:p></o:p></span></p>
<p class=MsoNormal style='margin-left:35.4pt'><span lang=EN-US
style='font-size:9.0pt;font-family:"Courier New";color:#002060'>
LOAD 0x038000 0x90000000 0x200d0000 0x0dfaf 0x0dfaf R E 0x8000<o:p></o:p></span></p>
<p class=MsoNormal style='margin-left:35.4pt'><span lang=EN-US
style='font-size:9.0pt;font-family:"Courier New";color:#002060'>
LOAD 0x046000 0x90016000 0x2002b000 0x00234 0x00364 RW 0x8000<o:p></o:p></span></p>
<p class=MsoNormal style='margin-left:35.4pt'><span lang=EN-US
style='font-size:9.0pt;font-family:"Courier New";color:#002060'>
LOAD 0x048000 0x90100000 0x20088000 0x0526f 0x0526f R E 0x8000<o:p></o:p></span></p>
<p class=MsoNormal style='margin-left:35.4pt'><span lang=EN-US
style='font-size:9.0pt;font-family:"Courier New";color:#002060'>
LOAD 0x04d270 0x9010d270 0x2002f270 0x00118 0x00238 RW 0x8000<o:p></o:p></span></p>
<p class=MsoNormal style='margin-left:35.4pt'><span lang=EN-US
style='font-size:9.0pt;font-family:"Courier New";color:#002060'>
LOAD 0x050000 0x90200000 0x20100000 0x055ef 0x055ef R E 0x8000<o:p></o:p></span></p>
<p class=MsoNormal style='margin-left:35.4pt'><span lang=EN-US
style='font-size:9.0pt;font-family:"Courier New";color:#002060'>
LOAD 0x0555f0 0x9020d5f0 0x200cd5f0 0x00148 0x00518 RW 0x8000<o:p></o:p></span></p>
<p class=MsoNormal style='margin-left:35.4pt'><span lang=EN-US
style='font-size:9.0pt;font-family:"Courier New";color:#002060'> </span><span
style='font-size:9.0pt;font-family:"Courier New";color:#002060'>LOAD
0x058000 0x90300000 0x20108000 0x05df8 0x05df8 R E 0x8000<o:p></o:p></span></p>
<p class=MsoNormal style='margin-left:35.4pt'><span style='font-size:9.0pt;
font-family:"Courier New";color:#002060'> LOAD 0x05e000 0x9030e000
0x200df000 0x00254 0x00440 RW 0x8000<o:p></o:p></span></p>
<p class=MsoNormal style='margin-left:35.4pt'><span style='font-size:9.0pt;
font-family:"Courier New";color:#002060'> </span><span lang=EN-US
style='font-size:9.0pt;font-family:"Courier New";color:#002060'>LOAD
0x060000 0x90400000 0x20130000 0x0598b 0x0598b R E 0x8000<o:p></o:p></span></p>
<p class=MsoNormal style='margin-left:35.4pt'><span lang=EN-US
style='font-size:9.0pt;font-family:"Courier New";color:#002060'>
LOAD 0x06598c 0x9040d98c 0x2010f98c 0x00130 0x00220 RW 0x8000<o:p></o:p></span></p>
<p class=MsoNormal style='margin-left:35.4pt'><span lang=EN-US
style='font-size:9.0pt;font-family:"Courier New";color:#002060'>
LOAD 0x066000 0x90056000 0x20138000 0x03000 0x03000 RW 0x1000<o:p></o:p></span></p>
<p class=MsoNormal><span lang=EN-US style='color:#002060'>Segment offsets are
different again, and compared to the ‘heap size = 0x38000’ the
image is 8 kB bigger.<o:p></o:p></span></p>
<p class=MsoNormal><span lang=EN-US style='color:#002060'>The conclusion is
that the memory allocation algorithm carried out be the GNU loader under
control of the ELF Adorn and ELF Weaver tools is somewhat unpredictable, and I
do not see why the manipulation of the heap size has such a significant effect.
As long as the heap size is not a multiple of 1M, the image is compact, i. e
does not show the 4 MB hole. I do not believe that this behaviour is
intentional; it looks more likely that there is a bug in the tool chain
responsible for the image allocation. Who can shed light on this?<o:p></o:p></span></p>
<p class=MsoNormal><span lang=EN-US style='color:#002060'>I forgot the reason
behind this research: we had to make the binary image fit into a 2 MB NOR
flash, and this was difficult with the original image layout.<o:p></o:p></span></p>
<p class=MsoNormal><span lang=EN-US style='color:#002060'><o:p> </o:p></span></p>
<p class=MsoNormal><span lang=EN-US style='color:#002060'>Regards<o:p></o:p></span></p>
<p class=MsoNormal><span lang=EN-US style='color:#002060'>Frank<o:p></o:p></span></p>
<div style='border:none;border-left:solid blue 1.5pt;padding:0cm 0cm 0cm 4.0pt'>
<div>
<div style='border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0cm 0cm 0cm'>
<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"'>
developer-bounces@okl4.org [mailto:developer-bounces@okl4.org] <b>On Behalf Of </b>Frank
Kaiser<br>
<b>Sent:</b> Friday, September 19, 2008 4:22 PM<br>
<b>To:</b> developer@okl4.org<br>
<b>Subject:</b> [okl4-developer] OKL4 v2.1: About memory layout<o:p></o:p></span></p>
</div>
</div>
<p class=MsoNormal><o:p> </o:p></p>
<p class=MsoNormal>Hello<o:p></o:p></p>
<p class=MsoNormal><o:p> </o:p></p>
<p class=MsoNormal><span lang=EN-US>Since the U-Boot of my ATMEL ARM platform
is not able to load ELF images, I have to convert them to binaries. This is
automatically done when specifying ‘<i>boot_binary = True</i>’ in
the machine’s class definition. With additional drivers the
Pistachio/Iguana ELF image bypasses the size of 1 MB, and close to that point
the size of of the binary jumps to more than 5 MB. This was a surprise and a
shortcoming, since I have an unreliable Ethernet interface on one hardware.
Downloading >5 MB thru a serial line with 115 kbit/s takes >15 minutes
which I cannot afford. So I started looking for the reason of the image
increase.<o:p></o:p></span></p>
<p class=MsoNormal><i><span lang=EN-US>Readelf</span></i><span lang=EN-US>
showed a gap of 4 MB in the ELF image like this:<o:p></o:p></span></p>
<p class=MsoNormal style='margin-left:35.4pt'><span lang=EN-US
style='font-size:9.0pt;font-family:"Courier New"'>Program Headers:<o:p></o:p></span></p>
<p class=MsoNormal style='margin-left:35.4pt'><span lang=EN-US
style='font-size:9.0pt;font-family:"Courier New"'> Type
Offset VirtAddr
PhysAddr FileSiz MemSiz Flg Align<o:p></o:p></span></p>
<p class=MsoNormal style='margin-left:35.4pt'><span lang=EN-US
style='font-size:9.0pt;font-family:"Courier New"'>
LOAD 0x008000
0xf0000000 0x20000000 0x2022c 0x2390c RWE 0x8000<o:p></o:p></span></p>
<p class=MsoNormal style='margin-left:35.4pt'><span lang=EN-US
style='font-size:9.0pt;font-family:"Courier New"'>
LOAD 0x02c000
0xf0024000 0x20024000 0x06000 0x06000 RW 0x8000<o:p></o:p></span></p>
<p class=MsoNormal style='margin-left:35.4pt'><span lang=EN-US
style='font-size:9.0pt;font-family:"Courier New"'>
LOAD 0x038000
0x90000000 0x20088000 0x0dfaf 0x0dfaf R E 0x8000<o:p></o:p></span></p>
<p class=MsoNormal style='margin-left:35.4pt'><span lang=EN-US
style='font-size:9.0pt;font-family:"Courier New"'>
LOAD 0x046000
0x90016000 0x2002b000 0x00234 0x00364 RW 0x8000<o:p></o:p></span></p>
<p class=MsoNormal style='margin-left:35.4pt'><span lang=EN-US
style='font-size:9.0pt;font-family:"Courier New"'>
LOAD 0x048000
0x90100000 0x20098000 0x0526f 0x0526f R E 0x8000<o:p></o:p></span></p>
<p class=MsoNormal style='margin-left:35.4pt'><span lang=EN-US
style='font-size:9.0pt;font-family:"Courier New"'>
LOAD 0x04d270
0x9010d270 0x2002f270 0x00118 0x00238 RW 0x8000<o:p></o:p></span></p>
<p class=MsoNormal style='margin-left:35.4pt'><span lang=EN-US
style='font-size:9.0pt;font-family:"Courier New"'> LOAD
0x050000 0x90200000 0x200c0000 0x0559f 0x0559f R E 0x8000<o:p></o:p></span></p>
<p class=MsoNormal style='margin-left:35.4pt'><span lang=EN-US
style='font-size:9.0pt;font-family:"Courier New"'>
LOAD 0x0555a0
0x9020d5a0 0x2009f5a0 0x00148 0x00518 RW 0x8000<o:p></o:p></span></p>
<p class=MsoNormal style='margin-left:35.4pt'><span lang=EN-US
style='font-size:9.0pt;font-family:"Courier New"'> </span><span
style='font-size:9.0pt;font-family:"Courier New"'>LOAD
0x058000 0x90300000 0x200e0000 0x06313 0x06313 R E 0x8000<o:p></o:p></span></p>
<p class=MsoNormal style='margin-left:35.4pt'><span style='font-size:9.0pt;
font-family:"Courier New"'>
LOAD 0x05e314 0x9030e314
0x200c9314 0x00244 0x00430 RW 0x8000<o:p></o:p></span></p>
<p class=MsoNormal style='margin-left:35.4pt'><span style='font-size:9.0pt;
font-family:"Courier New"'>
LOAD 0x060000
0x90400000 0x200e8000 0x0529f 0x0529f R E 0x8000<o:p></o:p></span></p>
<p class=MsoNormal style='margin-left:35.4pt'><span style='font-size:9.0pt;
font-family:"Courier New"'> </span><span lang=EN-US style='font-size:
9.0pt;font-family:"Courier New"'>LOAD
0x0652a0 0x9040d2a0 0x200cd2a0 0x00120 0x00210 RW 0x8000<o:p></o:p></span></p>
<p class=MsoNormal style='margin-left:35.4pt'><span lang=EN-US
style='font-size:9.0pt;font-family:"Courier New"'>
LOAD 0x066000
0x90056000 0x20510000 0x03000 0x03000 RW 0x1000<o:p></o:p></span></p>
<p class=MsoNormal style='margin-left:35.4pt'><span lang=EN-US
style='font-size:9.0pt;font-family:"Courier New"'>Section to Segment mapping:<o:p></o:p></span></p>
<p class=MsoNormal style='margin-left:35.4pt'><span lang=EN-US
style='font-size:9.0pt;font-family:"Courier New"'> Segment Sections...<o:p></o:p></span></p>
<p class=MsoNormal style='margin-left:35.4pt'><span lang=EN-US
style='font-size:9.0pt;font-family:"Courier New"'>
00 kernel.text kernel.rodata kernel.kdebug kernel.init
kernel.roinit kernel.data kernel.got kernel.got.plt kernel.kdebug-data
kernel.bss <o:p></o:p></span></p>
<p class=MsoNormal style='margin-left:35.4pt'><span lang=EN-US
style='font-size:9.0pt;font-family:"Courier New"'> </span><span
style='font-size:9.0pt;font-family:"Courier New"'>01
kernel.kspace kernel.traps kernel.utcb_page <o:p></o:p></span></p>
<p class=MsoNormal style='margin-left:35.4pt'><span style='font-size:9.0pt;
font-family:"Courier New"'> 02
ig_server.text ig_server.rodata <o:p></o:p></span></p>
<p class=MsoNormal style='margin-left:35.4pt'><span style='font-size:9.0pt;
font-family:"Courier New"'> 03
ig_server.data ig_server.got ig_server.bss <o:p></o:p></span></p>
<p class=MsoNormal style='margin-left:35.4pt'><span style='font-size:9.0pt;
font-family:"Courier New"'> </span><span lang=EN-US
style='font-size:9.0pt;font-family:"Courier New"'>04
event.text event.rodata <o:p></o:p></span></p>
<p class=MsoNormal style='margin-left:35.4pt'><span lang=EN-US
style='font-size:9.0pt;font-family:"Courier New"'>
05 event.data event.got event.bss <o:p></o:p></span></p>
<p class=MsoNormal style='margin-left:35.4pt'><span lang=EN-US
style='font-size:9.0pt;font-family:"Courier New"'>
06 vostimer.text vostimer.rodata <o:p></o:p></span></p>
<p class=MsoNormal style='margin-left:35.4pt'><span lang=EN-US
style='font-size:9.0pt;font-family:"Courier New"'>
07 vostimer.data vostimer.got vostimer.bss <o:p></o:p></span></p>
<p class=MsoNormal style='margin-left:35.4pt'><span lang=EN-US
style='font-size:9.0pt;font-family:"Courier New"'>
08 vspi.text vspi.rodata <o:p></o:p></span></p>
<p class=MsoNormal style='margin-left:35.4pt'><span lang=EN-US
style='font-size:9.0pt;font-family:"Courier New"'>
09 vspi.data vspi.got vspi.bss <o:p></o:p></span></p>
<p class=MsoNormal style='margin-left:35.4pt'><span lang=EN-US
style='font-size:9.0pt;font-family:"Courier New"'>
10 spi_test.text spi_test.rodata <o:p></o:p></span></p>
<p class=MsoNormal style='margin-left:35.4pt'><span lang=EN-US
style='font-size:9.0pt;font-family:"Courier New"'>
11 spi_test.data spi_test.got spi_test.bss <o:p></o:p></span></p>
<p class=MsoNormal style='margin-left:35.4pt'><span lang=EN-US
style='font-size:9.0pt;font-family:"Courier New"'>
12 bootinfo<o:p></o:p></span></p>
<p class=MsoNormal><span lang=EN-US>Checking the page tables with the kernel
debugger shows that 4 memory block à 1 MB between 0x20100000 and 0x20500000 are
allocated by the kernel. Obviously is this the kernel heap.<o:p></o:p></span></p>
<p class=MsoNormal><span lang=EN-US>In section 4.4.3 of the ELF Weaver Manual
it is explained that by default the heap will have a size of 4 MB and that it
will be allocated close to the kernel. The above layout shows that the heap is
placed in the next 1 MB segment after the kernel sections. The outcome of this
placement is that a binary created from this segment allocation must contain
the 4 MB kernel heap, because the <i>bootinfo</i> section is located beyond.<o:p></o:p></span></p>
<p class=MsoNormal><span lang=EN-US>The placement of the kernel heap, as
outlined in the manual, is motivated by addressing constraints, for instance,
of the ARM architecture. However, such constraints only apply to virtual
addresses, which are seen by the CPU core, not the physical ones, which are
seen by the MMU. For fulfilling an addressing constraint it should be
sufficient to set the heap’s virtual address close to the kernel’s
virtual address, so the heap could be placed at the end of the physically
allocated memory, thus keeping the binary image small.<o:p></o:p></span></p>
<p class=MsoNormal><span lang=EN-US>By default the build system does not write
heap parameters to the file <i>weaver.xml</i>, although doing so is supported.
In <i>tools/build.py</i> there is the class <b>WeaverKernel</b> which can take
the parameter <b>heap</b> on instantiation to set the kernel heap size. The
class’ method <b>element()</b> recognizes the attribute <b>heap_base</b>
to set the heap’s physical start address. The class <b>WeaverKernel</b>
is used in the kernel’s <i>SConscript</i> file. Adding “heap =
…” to the call results in setting the heap size in <i>weaver.xml</i>.
With a subsequent “weaver.heap_base = …” the heap start
address can be set.<o:p></o:p></span></p>
<p class=MsoNormal><span lang=EN-US>The problem is to determine a sufficient
value for the start address, since when parsing the kernel’s <i>SConscript</i>
file, the physical size of the image is not yet known. It is wishful to derive
the start address from the overall image size including the <i>bootinfo</i>
section. It should be possible to calculate that in the main <i>SConstruct</i>
file after all <i>SConscript</i> files have been parsed, but I have not yet
found out how to do this.<o:p></o:p></span></p>
<p class=MsoNormal><span lang=EN-US>While playing with the heap attributes I
found that the ELF Weaver generates an error message when the heap’s
distance to the kernel code is bigger than 64M. Based on my assumption that the
physical addresses are not relevant, I wonder why this is the case.<o:p></o:p></span></p>
<p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p>
<p class=MsoNormal><span lang=EN-US>Regards<o:p></o:p></span></p>
<p class=MsoNormal><span lang=EN-US>Frank<o:p></o:p></span></p>
</div>
</div>
</body>
</html>