<p dir="ltr">Hello Simon,</p>
<p dir="ltr">Thank you very much for the suggestions; I'll start investigations on Monday.</p>
<p dir="ltr">Regards,<br>
Igor</p>
<div class="gmail_quote">31 окт. 2015 г. 18:20 пользователь "Simon Atanasyan" <<a href="mailto:simon@atanasyan.com">simon@atanasyan.com</a>> написал:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hello,<br>
<br>
On Sat, Oct 31, 2015 at 12:03 PM, Igor Kudrin <<a href="mailto:ikudrin.dev@gmail.com">ikudrin.dev@gmail.com</a>> wrote:<br>
> I'd like to study it and MIPS target looks promising for my goal.<br>
> I'd be happy to hear any comments for my patches and any advice<br>
> what to do next.<br>
<br>
Good point. As to me I would start from static linking a trivial Hello<br>
World application. To do that we need to fix at least the following<br>
issues:<br>
<br>
1. Handle R_MIPS_HI16 / R_MIPS_LO16 relocations<br>
<br>
The non-trivial thing here is that these relocations should be handled<br>
together. In short you need to keep and do not apply all R_MIPS_HI16<br>
relocations until you get R_MIPS_LO16 relocation with the same target.<br>
Then you calculate "combined" addend as (AHI << 16) + (short)ALO,<br>
where AHI is R_MIPS_HI16 addend and ALO is R_MIPS_LO16 addend, and use<br>
this "combined" addend to apply relocations.<br>
<br>
2. Handle R_MIPS_GOT16 relocation for local symbols<br>
<br>
In that case R_MIPS_GOT16 immediately followed with R_MIPS_LO16<br>
relocation. You need to calculate "combined" addend too. Then you use<br>
this addend to calculate a relocation result. The low 16-bits is<br>
written to the R_MIPS_LO16 relocation destination. The high 16-bits<br>
needs to be stored in the GOT. The corresponding GOT offset is written<br>
to the R_MIPS_GOT16 relocation destination. At the first step we can<br>
skip GOT size optimization and create new GOT entry for each new<br>
symbol targeted by the relocation. But obviously there will be many<br>
duplicated GOT entries because all symbols from a 64kb range has the<br>
same high 16-bits. As the second step we need to escape the<br>
duplication entries as much as possible.<br>
<br>
Right now I cannot allocate a time for active work on ELF -> ELF2<br>
porting. But going to do that later. Feel free to ask any questions,<br>
hints etc.<br>
<br>
Regards,<br>
Simon Atanasyan<br>
</blockquote></div>