<div dir="ltr"><br><div class="gmail_extra"><br><br><div class="gmail_quote">2013/5/31 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:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
<div class="im">Peng Fan wrote:<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
hi,<br>
Now I have a idea about how to include local symbols in the RAP file,<br>
and try to not increase the size of the RAP file.<br>
<br>
1. About the relocations.<br>
The current layout for the relocations  is:<br>
| header | reloc entries|<br>
the first bit of header indicates whether it is rela or not. the<br>
remaining 30 bits indicates the number of reloc entries.<br>
<br>
But now I want to include elf object index for reloc entries and symbols<br>
to resolve conflicting local symbols. For example two objects both<br>
contains the ".LC0" symbols, how to figure out which ".LC0" symbol is<br>
needed for the reloc entry.<br>
<br>
I want to use the following layout for reloc part of RAP file .<br>
<br>
| header | counts(object 1) | reloc entries | counts(object 2) | reloc<br>
entries .....<br>
<br>
</blockquote>
<br></div>
It looks fine if we finally decide we need locals in a RAP file.<br>
<br>
Please note if the RAP format changes we need to change the RAP version number. The RAP header has a version number and currently it is hard coded in rtems-ld. I think this should be added as a const to the 'rap' namespace and formatted into the header. The target side needs to check which version it can support, ie up to a specific version and not higher. The version is an incrementing number. I will look at adding this soon.<div class="im">
<br>
<br></div></blockquote><div style>Thanks. I'll look into the rap part. </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
<div class="im">
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
The header still contains the total number of reloc entries just like<br>
the current implementation.<br>
2. About the local symbols.<br>
Now there is a 'symtab_size' variable to indicates how many global<br>
symbols are in the rap file.<br>
Because I want to include local symbols, I want to add a local symbol<br>
table after the global symbol table.<br>
| global_symtab_size | local_symtab_size | .......<br>
| global symbol table<br>
| object1 local_symtab_size | object1 local symbol table<br>
| object2 local_symtab_size| object2 local symbol table | ....<br>
<br>
My current implementation is each reloc entry contains an object index<br>
and each symbol contains an object index. But this may consume more<br>
space, I prepare to rewrite this using 1 and 2.<br>
However I am not sure whether this is ok.<br>
<br>
</blockquote>
<br></div>
I am still wondering if we need locals in the RAP file. Could some form of incremental linking pass in rtems-ld remove them ?<br>
<br></blockquote><div style>I am not sure whether using specific gcc options can remove this or not. </div><div style>I think if use specific options to remove them, there should be a lot work to be done to resolve the symbol table, strtab and reloc part of the linker. I want to use my current implementation to implement the other archs for loader just following the schedule in my proposal ,because the rtl-mdreloc-(arch).c is relatively independent to the symbols part. Any advice?</div>
<div style><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
Do you have a simple C piece of code with a compile command line that results in an ELF file with these local symbols ? I would like to understand why they are present.</blockquote><div><br></div><div style>The c code in file 3.c :</div>
<div>void hello(int arg)</div><div>{</div><div><span class="" style="white-space:pre">  </span>printf("Hello World\n");</div><div>}</div><div style>The compile command: </div><div style>arm-rtemseabi4.11-gcc 3.c -c -mcpu=cortex-a9 -mthumb -o 3.o</div>
<div style><br></div><div style> </div><div style>arm-rtemseabi4.11-objdump -Dr 3.o > 3.s<br></div><div style><br></div><div style>The disassemle code:</div><div style><div>3.o:     file format elf32-littlearm</div><div>
<br></div><div><br></div><div>Disassembly of section .text:</div><div><br></div><div>00000000 <hello>:</div><div>   0:<span class="" style="white-space:pre">     </span>b580      <span class="" style="white-space:pre">        </span>push<span class="" style="white-space:pre">      </span>{r7, lr}</div>
<div>   2:<span class="" style="white-space:pre">       </span>b082      <span class="" style="white-space:pre">        </span>sub<span class="" style="white-space:pre">       </span>sp, #8</div><div>   4:<span class="" style="white-space:pre">        </span>af00      <span class="" style="white-space:pre">        </span>add<span class="" style="white-space:pre">       </span>r7, sp, #0</div>
<div>   6:<span class="" style="white-space:pre">       </span>6078      <span class="" style="white-space:pre">        </span>str<span class="" style="white-space:pre">       </span>r0, [r7, #4]</div><div>   8:<span class="" style="white-space:pre">  </span>f240 0000 <span class="" style="white-space:pre">        </span>movw<span class="" style="white-space:pre">      </span>r0, #0</div>
<div><span class="" style="white-space:pre">    </span>8: R_ARM_THM_MOVW_ABS_NC<span class="" style="white-space:pre">  </span>.LC0</div><div>   c:<span class="" style="white-space:pre">  </span>f2c0 0000 <span class="" style="white-space:pre">        </span>movt<span class="" style="white-space:pre">      </span>r0, #0</div>
<div><span class="" style="white-space:pre">    </span>c: R_ARM_THM_MOVT_ABS<span class="" style="white-space:pre">     </span>.LC0</div><div>  10:<span class="" style="white-space:pre">  </span>f7ff fffe <span class="" style="white-space:pre">        </span>bl<span class="" style="white-space:pre">        </span>0 <puts></div>
<div><span class="" style="white-space:pre">    </span>10: R_ARM_THM_CALL<span class="" style="white-space:pre">        </span>puts</div><div>  14:<span class="" style="white-space:pre">  </span>f107 0708 <span class="" style="white-space:pre">        </span>add.w<span class="" style="white-space:pre">     </span>r7, r7, #8</div>
<div>  18:<span class="" style="white-space:pre">       </span>46bd      <span class="" style="white-space:pre">        </span>mov<span class="" style="white-space:pre">       </span>sp, r7</div><div>  1a:<span class="" style="white-space:pre">        </span>bd80      <span class="" style="white-space:pre">        </span>pop<span class="" style="white-space:pre">       </span>{r7, pc}</div>
<div><br></div><div>Disassembly of section .rodata:</div><div><br></div><div>00000000 <.LC0>:</div><div>   0:<span class="" style="white-space:pre">  </span>6c6c6548 <span class="" style="white-space:pre"> </span>cfstr64vs<span class="" style="white-space:pre"> </span>mvdx6, [ip], #-288<span class="" style="white-space:pre">        </span>; 0xfffffee0</div>
<div>   4:<span class="" style="white-space:pre">       </span>6f57206f <span class="" style="white-space:pre"> </span>svcvs<span class="" style="white-space:pre">     </span>0x0057206f</div><div>   8:<span class="" style="white-space:pre">    </span>00646c72 <span class="" style="white-space:pre"> </span>rsbeq<span class="" style="white-space:pre">     </span>r6, r4, r2, ror ip</div>
<div><br></div><div style>Using arm-rtemseabi4.11-readelf -s 3.o, I can see .LC0 is a local symbol:</div><div style><br></div><div style>7: 00000000  0 NOTYPE  LOCAL DEFAULT  5 .LC0<br></div><div style><br></div><div style>
If I do use use -mcpu=cortex-a9, the local symbol ".LC0" does not exist.</div><div style><br></div><div style>Thanks.</div></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
<span class=""><font color="#888888"><br>
<br>
Chris<br>
</font></span></blockquote></div><br></div></div>