<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">The base image is built just like a standard RTEMS binary with the "Init" function. In my base image, I do some basic initialization, then I initialize and run the shell startup script. The base image uses the BSP linker script, which already locates it in an absolute location in memory. You may need to adjust the base image linker script to allow for some room to locate your applications. <div>The shell startup script will mount the eeprom/flash file system, then load and execute the first loadable binary image. </div><div>The loader can be a program that parses the elf file and copies the code and data to ram ( and clears the BSS ).</div><div><br></div><div>The loadable binary files are linked with a rule similar to this:</div><div><br></div><div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Menlo; ">APP1_ADDRESS  =      <span style="color: #2832cf">0x01730000</span></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Menlo; ">APP1_ENTRYPT  =      APP1_AppMain</div></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Menlo; "><br></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Menlo; "><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Menlo; ">app1.elf: rtems.elf  app1.o </div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Menlo; "><span class="Apple-tab-span" style="white-space:pre">  </span>$(LINKER) $(APP_LD_FLAGS) -Rrtems.elf  -Ttext $(APP1_ADDRESS) -e$(APP1_ENTRYPT) -o app1.elf app1.o </div><div><br></div><div><font class="Apple-style-span" face="Helvetica" size="3">Note that you do not need to link in any libs, because they should be in the base rtems.elf image. </font></div><div><font class="Apple-style-span" face="Helvetica" size="3"><br></font></div><div><font class="Apple-style-span" face="Helvetica" size="3">You have to carefully manage the memory map where you locate each task. If one of them grows it will overlap the next task's space.</font></div><div><font class="Apple-style-span" face="Helvetica" size="3"><br></font></div><div><font class="Apple-style-span" face="Helvetica" size="3">I also failed to mention the CEXP solution earlier:</font></div><div><font class="Apple-style-span" face="Helvetica" size="3"><a href="http://www.slac.stanford.edu/%7Estrauman/rtems/cexp/index.html">http://www.slac.stanford.edu/%7Estrauman/rtems/cexp/index.html</a></font></div><div><span class="Apple-style-span" style="font-family: Helvetica; font-size: medium; ">This loader has worked well for me. I could not use it on my current application due to memory constraints. </span></div><div><font class="Apple-style-span" face="Helvetica" size="3"><br></font></div><div><font class="Apple-style-span" face="Helvetica" size="3">So that all being said, I would still rather use a dynamic loader. Micro-managing the memory map and trying to determine what needs to be re-linked is a pain!</font></div><div><font class="Apple-style-span" face="Helvetica" size="3"><br></font></div><div><font class="Apple-style-span" face="Helvetica" size="3">Alan</font></div><div><font class="Apple-style-span" face="Helvetica" size="3"><br></font></div></div><div><br><div><div><div><div>On Sep 26, 2011, at 8:58 AM, Oleg Moroz wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div><div style="color:#000; background-color:#fff; font-family:times new roman, new york, times, serif;font-size:12pt"><div><span><div style="font-family: Arial, Helvetica, sans-serif; font-size: 12px; ">Can you send me scripts to build base image with absolute memory addresses?</div></span></div><div><blockquote style="border-left: 2px solid rgb(16, 16, 255); margin-left: 5px; padding-left: 5px;"><div style="font-size: 12pt; font-family: 'times new roman', 'new york', times, serif; "><div style="font-size: 12pt; font-family: 'times new roman', 'new york', times, serif; "><font size="2" face="Arial"><hr size="1"><b><span style="font-weight:bold;">From:</span></b> "Cudmore, Alan P. (GSFC-5820)" <<a href="mailto:alan.p.cudmore@nasa.gov">alan.p.cudmore@nasa.gov</a>><br><b><span style="font-weight: bold;">To:</span></b> Oleg Moroz <<a href="mailto:oleg_moroz@yahoo.com">oleg_moroz@yahoo.com</a>><br><b><span style="font-weight: bold;">Cc:</span></b> Rtems
 <<a href="mailto:rtems-users@rtems.org">rtems-users@rtems.org</a>><br><b><span style="font-weight: bold;">Sent:</span></b> Monday, September 26, 2011 4:47 PM<br><b><span style="font-weight: bold;">Subject:</span></b> Re: Отв.: Shared library link<br></font><br><meta http-equiv="x-dns-prefetch-control" content="off"><div id="yiv673346489"><div>I have a current RTEMS application that uses your method of separate binary image for each task.</div><div><br></div><div>Our application was developed under vxWorks which has a dynamic object loader. On RTEMS, I build a base "kernel image" that includes the BSP, startup code, network stack, and any functions that I need from the C or Math libraries. </div><div><br></div><div>Each application ( which is one or more RTEMS tasks ) is linked to an absolute memory location ( as you describe with your segmentation below ). Each task binary sets it's base address using the -T link option, it sets it's entry point using the -e link option, then it
 resolves it's external references by using the -R option to refer to the base image.</div><div><br></div><div>We developed a "static loader" which loads the binary file from a file system at runtime, and returns the application entry point. The base image/startup code can then create the RTEMS task to start the application.</div><div><br></div><div>This all works very well, but it does have drawbacks:</div><div>1. You must include any functions that your application needs into your base image. This can be done by a reference to a symbol. </div><div>2. If anything changes in the base image, you must re-link and re-load all of your applications or they will crash.</div><div><br></div><div>We intend to replace this in the future with the dynamic loader that Chris has mentioned.</div><div><br></div><div>Alan</div><div><br></div><br><div><div>On Sep 26, 2011, at 3:05 AM, Oleg Moroz wrote:</div><br class="yiv673346489Apple-interchange-newline"><blockquote type="cite"><div><div style="color: rgb(0, 0, 0); background-color: rgb(255, 255, 255); font-size: 12pt; font-family: 'times new roman', 'new york', times, serif; "><div style="font-size: 12pt; font-family: times, serif; ">Thanks for answer. Sorry for my english.</div><div style="font-size: 12pt; font-family: times, serif; "><br></div><div style="font-size: 12pt; font-family: times, serif; ">>What happens when the size of the code changes ?<br></div><div style="font-size: 12pt; font-family: times, serif; "><br></div><div style="font-size: 12pt; font-family: times, serif; ">I'm developing my application with memory "segmentation". I mean:</div><div style="font-size: 12pt; font-family: times, serif; "><br></div><div style="font-size: 12pt; font-family: times, serif; ">0x40000000</div><div style="font-size: 12pt; font-family: times, serif; ">--------------</div><div style="font-size: 12pt;
 font-family: times, serif; ">main task</div><div style="font-size: 12pt; font-family: times, serif; ">--------------</div><div style="font-size: 12pt; font-family: times, serif; "><br></div><div style="font-size: 12pt; font-family: times, serif; ">0x40001000 (for example)</div><div style="font-size: 12pt; font-family: times, serif; ">-------------</div><div style="font-size: 12pt; font-family: times, serif; ">second task</div><div style="font-size: 12pt; font-family: times, serif; ">-------------</div><div style="font-size: 12pt; font-family: times, serif; "><br></div><div style="font-size: 12pt; font-family: times, serif; "><div>0x40002000</div><div>-------------</div><div>third task</div><div>-------------</div></div><div style="font-size: 12pt; font-family: times, serif; "><br></div><div style="font-size: 12pt; font-family: times, serif; ">0x4000f000</div><div style="font-size: 12pt; font-family: times, serif; ">------------</div><div style="font-size: 12pt; font-family: times, serif; ">functions like printf() and other common functions and data</div><div style="font-size: 12pt; font-family: times, serif; ">------------</div><div style="font-size: 12pt; font-family: times, serif; "><br></div><div style="font-size: 12pt; font-family: times, serif; "><br></div><div style="font-size: 12pt; font-family: times, serif; ">0x40001000-0x40000000 > sizeof(main task)</div><div style="font-size: 12pt; font-family: times, serif; ">0x40002000-0x40001000 > sizeof(second task)</div><div style="font-size: 12pt; font-family: times, serif; ">......</div><div style="font-size: 12pt; font-family: times, serif; "><br></div><div><font class="yiv673346489Apple-style-span" size="3">I mean what i must manually locate all of this tasks in memory, and allocate memory "segment" for every task. It will be doing by main task that could load task code from EEPROM. I'm trying to create mechanism
 to </font>dynamically<font class="yiv673346489Apple-style-span" size="3"> loading and unloading tasks like it did in usual OSes with processes. This mechanism need not be universally. It only for this project
 now. </font></div><div><br></div><div><span class="yiv673346489Apple-style-span" style="font-size:16px;">>I suggest you take a look at:<br>><br>></span><span class="yiv673346489Apple-style-span" style="font-size:16px;"><a rel="nofollow" target="_blank" href="http://www.rtems.org/ftp/pub/rtems/people/chrisj/rtl/">http://www.rtems.org/ftp/pub/rtems/people/chrisj/rtl/</a></span></div><div><br></div><div>Thanks. Now i'm downloading archive from this directory, and will see what is it.</div><div><br></div><div><br></div><div><span class="yiv673346489Apple-style-span" style="font-size:16px;">>In the traditional definition dynamic and static libraries are not the same type of code. They can varying depending on the specific method used by the operating system. As Joel stated RTEMS is a single address space or processes and will not support the Unix </span></div><div><span class="yiv673346489Apple-style-span" style="font-size:16px;">>(ELF) shared library model. It adds overhead for no gain.
 Given this I am not sure I understand your sentence. For example have you built shared RTEMS libraries (the tools will let you do this) and static libraries and are you attempting to mix the results ?</span></div><div><span class="yiv673346489Apple-style-span" style="font-size:16px;"><br></span></div><div>I will try.<br><blockquote style="font-size: 12pt; border-left-width: 2px; border-left-style: solid; border-left-color: rgb(16, 16, 255); margin-left: 5px; padding-left: 5px; font-family: times, serif; "><div style="font-size: 12pt; font-family: times, serif; "><div style="font-size: 12pt; font-family: times, serif; "><font size="2" face="Arial"><hr size="1"><b><span style="font-weight:bold;">From:</span></b> Chris Johns <<a rel="nofollow" ymailto="mailto:chrisj@rtems.org" target="_blank" href="mailto:chrisj@rtems.org">chrisj@rtems.org</a>><br><b><span style="font-weight:bold;">To:</span></b> Oleg Moroz <<a rel="nofollow" ymailto="mailto:oleg_moroz@yahoo.com" target="_blank" href="mailto:oleg_moroz@yahoo.com">oleg_moroz@yahoo.com</a>><br><b><span style="
font-weight:bold;">Cc:</span></b> Rtems <<a rel="nofollow" ymailto="mailto:rtems-users@rtems.org" target="_blank" href="mailto:rtems-users@rtems.org">rtems-users@rtems.org</a>><br><b><span style="font-weight:bold;">Sent:</span></b> Monday, September 26, 2011 2:48 AM<br><b><span style="font-weight:bold;">Subject:</span></b> Re: Отв.: Shared library link<br></font><br>On 24/09/11 4:01 PM, Oleg Moroz wrote:<br>> Okay. The reason why i want extract functions from shared or static<br>> library is dynamical achange parts of code.<br><br>In the traditional definition dynamic and static libraries are not the same type of code. They can varying depending on the specific method used by the operating system. As Joel stated RTEMS is a single address space or processes and will not support the Unix (ELF) shared library model. It adds overhead for no gain. Given this I am not sure I understand your sentence. For example have you built shared RTEMS
 libraries (the tools will let you do this) and static libraries and are you attempting to mix the results ?<br><br>> Now i
 have small app than<br>> can parse elf file and extract machine code of ever Task (or another<br>> functions).<br><br>I suggest you take a look at:<br><br> <a rel="nofollow" target="_blank" href="http://www.rtems.org/ftp/pub/rtems/people/chrisj/rtl/">http://www.rtems.org/ftp/pub/rtems/people/chrisj/rtl/</a><br><br>I have a host based linker in development. I thought I had a copy on the server but I do not. I will upload a version soon.<br><br>The path I have taken to create a runtime link editor in RTEMS that can load ELF relocatable object files directly or from archive files and resolve any external symbols as well as export any suitable symbols. This is all via the dlopen call. I have an RTEMS linker in development which handles the dependence resolution providing a suitable meta-data format. This project is still in development.<br><br>Note, this RTEMS project uses waf so check the README.<br><br>> Problem is what the addresses of all
 functions in
 the<br>> recompiled project (with some bug fixes or functionality added) are not<br>> the same with original project.<br><br>The object files are relocatable. You need a link editor to locate the object files and fix up the addresses.<br><br>> I must fix it manually, but this is the<br>> easiest way to make an error. I think than i can create the library with<br>> all functions. and addresses of that funcs are constant.<br><br>What happens when the size of the code changes ?<br><br>> after this i<br>> could link it with my extracted updated task. extract task again,<br>> and overwrite it on working RTEMS. Maybe linker or compiler has some<br>> command switch? Something like - Ttext=0x40100000<br><br>Sorry, but I do not understand this.<br><br>Chris<br><br><br></div></div></blockquote></div></div></div>_______________________________________________<br>rtems-users mailing list<br><a rel="nofollow" ymailto="mailto:rtems-users@rtems.org" target="_blank" href="mailto:rtems-users@rtems.org">rtems-users@rtems.org</a><br><a href="http://www.rtems.org/mailman/listinfo/rtems-users">http://www.rtems.org/mailman/listinfo/rtems-users</a><br></blockquote></div><br></div><meta http-equiv="x-dns-prefetch-control" content="on"><br><br></div></div></blockquote></div></div></div>_______________________________________________<br>rtems-users mailing list<br><a href="mailto:rtems-users@rtems.org">rtems-users@rtems.org</a><br>http://www.rtems.org/mailman/listinfo/rtems-users<br></blockquote></div><br></div></div></div></body></html>