<div dir="ltr">It works when I add a 'int rtems(int argc, char **argv)' function. Thanks.</div><div class="gmail_extra"><br><br><div class="gmail_quote">2013/4/20 Chris Johns <span dir="ltr"><<a href="mailto:chrisj@rtems.org" target="_blank">chrisj@rtems.org</a>></span><br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="im">Peng Fan wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
    Added the code, I can see the three files: libx.a shell-init  x.rap<br>
<br>
    Here appears another problem:<br>
<br>
    When"rap ld ./x.rap", it tells"error: loading: (0)"<br>
<br>
    When"dlo x.rap","error: duplicate global symbol: hello". However,  dlo libx.a:xa.c.1.o and dlo libx.a:x-long-name-to-create-<u></u>gnu-extension-in-archive.c.1.o is ok.<br>
<br>
<br>
Tried to find why "When "rap ld ./x.rap", it tells "error: loading: (0)""<br>
</blockquote>
<br></div>
Did you grep for the string and set a break point in it and then look at the back trace ? This is a pretty bad error message. Something is wrong here.<div class="im"><br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
I trace rtld using sparc-rtems4.11-gdb.<br>
In rap.c, there are two functions to do the loading ,linking and finding<br>
symbol job, dlopen foucsing on loading and resolving symbols, while<br>
dlsym returns the symbol address.<br>
</blockquote>
<br></div>
Correct.<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="im">
When debugging dlopen returns sucessfully, but "init = dlsym<br></div>
(app->handle, "*rtems*");" returns with "init=NULL".Thus rap load failed.<br>
</blockquote>
<br>
What is "*rtems*" ? Wild cards will not work.<div class="im"><br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
In dlsym, It first try find the symbol in it's local "global_table".<br>
</blockquote>
<br></div>
Correct.<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="im">
In<br>
x.rap, It's global_table includes "hello", "w_writeln" ,"x_writeln",<br>
"y_writeln", "z_writeln", "public", "my_main". with no one matches<br></div>
"*rtems*". Then It tries to find the symbol in global symbol which maybe<div class="im"><br>
generated in rtld-gsyms.c using a hash method.However, it still can not<br>
find the    match "rtems" symbol. Thus, failed.<br>
</div></blockquote>
<br>
Oh ok I get what is happening, yes this is correct. The symbols is 'rtems' and it is a kind of 'main' for the RTEMS application. It is nothing more than that. The x.rap is a progression and I ended up testing the whole think with a waf based libbsdports that create a RAP image. I need to get this out onto a server somewhere.<div class="im">
<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
I do not know the "rtems" symbol means what. I see it is assigned to<br>
init, and then init(*, *). I am confusing  about why "rtems".<br>
<br>
</blockquote>
<br></div>
This is understandable because I failed to add the reason to the doco. As I said this is an RTEMS Application's main. I did not want to use main because this has a well known and understood use.<br>
<br>
Well done on getting this far. If you add an 'rtems' function to the x.rap and have it print something the load should work.<span class="HOEnZb"><font color="#888888"><br>
<br>
Chris<br>
</font></span></blockquote></div><br></div>