<div dir="ltr"><br><div class="gmail_extra"><div class="gmail_quote">On Thu, Jul 6, 2017 at 10:23 AM, Chris Johns <span dir="ltr"><<a href="mailto:chrisj@rtems.org" target="_blank">chrisj@rtems.org</a>></span> wrote:<br><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><span class="gmail-">
> I load the object file dl.o that uses printf. dl.o.<br>
<br>
</span>Symbol table?<br></blockquote><div><br></div><div>I load it using dlopen() function.<br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<span class="gmail-"><br>
> dl.c contains rtems_main and printf functions.<br>
<br>
</span>I assume you mean the 'dl.c' contains a reference to the 'printf' symbol and not<br>
the 'printf' code.<br></blockquote><div> <br>Yes.<br></div><div> <span class="gmail-"></span><br><span class="gmail-"></span></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><span class="gmail-">
i386-rtems4.11-gcc -B$(RTEMS_MAKEFILE_PATH)lib/ -specs bsp_specs -qrtems<br>
-mtune=i486 -O2 -g \<br>
-Wall -Wmissing-prototypes -Wimplicit-function-<wbr>declaration -Wstrict-prototypes \<br>
-Wnested-externs \<br>
</span> -Wl,-Ttext,0x00100000 -mtune=i486 -o kernel.pre init.o filesystem.o<br>
<span class="gmail-"><br>
rtems-syms -e -c "-mtune=i486 -O2 -g -Wall -Wmissing-prototypes \<br>
-Wimplicit-function-<wbr>declaration -Wstrict-prototypes -Wnested-externs" -o \<br>
dl-sym.o dl.pre<br>
<br>
</span>Lets rewrite this command to reference the kernel we linked above in phase 1 of<br>
the 2-pass link process:<br>
<span class="gmail-"><br>
rtems-syms -e -c "-mtune=i486 -O2 -g -Wall -Wmissing-prototypes \<br>
-Wimplicit-function-<wbr>declaration -Wstrict-prototypes -Wnested-externs" -o \<br>
</span> kernel-sym.o kernel.pre<br>
<br>
You have now created an 'embedded' symbol table for the kernel. This object file<br>
is a table of [address, string] where the 'address' is the symbol's address in<br>
the kernel and the 'string' is the symbol. As an object these are unresolved<br>
until you link it to the kernel in phase 2 of the link process. When we do the<br>
linker will fill in the correct addresses for us:<br>
<span class="gmail-"><br>
i386-rtems4.11-gcc -B$(RTEMS_MAKEFILE_PATH)lib/ -specs bsp_specs -qrtems \<br>
-mtune=i486 -O2 -g \<br>
-Wall -Wmissing-prototypes -Wimplicit-function-<wbr>declaration -Wstrict-prototypes \<br>
-Wnested-externs \<br>
</span> -Wl,-Ttext,0x00100000 -mtune=i486 -o kernel.exe init.o filesystem.o \<br>
kernel-sym.o<br>
<br>
Now run 'kernel.exe' on your target.<br>
<br>
Note, I have changed your use of 'dl' to 'kernel' in these commands because it<br>
is the kernel that matters and not the code you are going to load at run time.<br>
The kernel will be able to load any code, even code you have not yet written so<br>
'dl.c' and 'dl.o' is just an example. You will not need to re-link the kernel<br>
again to load other files.<br>
<span class="gmail-HOEnZb"><font color="#888888"><br>
Chris<br></font></span></blockquote><div><br></div><div>Chris, thanks a lot. I think that It works!!!<br></div><div><br></div><div>Before I noticed this email I decided to try another method. I didn't use 2-pass linking. I just created kernel-sym.o and loaded it by the kernel (using dlopen) before loading the dl.o. I don't know if it is right but It also helped.<br></div><div>As I understand now these two methods are described in rtems-syms documentation (<a href="https://ftp.rtems.org/pub/rtems/people/chrisj/docs/user/tools/symbols.html">https://ftp.rtems.org/pub/rtems/people/chrisj/docs/user/tools/symbols.html</a>). I just didn't understand how to use them. <br></div></div>At the moment I don't understand the difference between the kernel.pre and kernel.exe (kernel.pre linked against symbol table) but I'll get it later.<br></div><div class="gmail_extra"><br> <i>if I could point you to some quality documentation I would<br>
however I cannot at this point in time.<br><br></i></div><div class="gmail_extra">To be honest, I didn't read all documentation about rtl. I began to read sources to understand how it works. I thought that may be I could try to add some simple examples (in addition to dl-0x) to rtems-syms documentation to make it more clear for such new users as I am. Is it possible? How to do it? Via new tickets at <a href="http://devel.rtems.org">devel.rtems.org</a> or somehow else?<br><br></div><div class="gmail_extra">Best regards,<br></div><div class="gmail_extra">Pavel Zhdanov.<br></div></div>