<div dir="ltr"><div><div>Hi Dominique,<br><br></div>The output from readelf you have posted looks fine, so it looks like as far as generating your relocations in LLVM is concerned that is fine.<br><br>Unfortunately as GNU ld is built as a target specific linker and all that is stored in your ELF file is the relocation type (which looks like in your case to be type 1) and not the specifics (32-bit big endian value with no offset), there will need to be some changes made to GNU ld and have it built for your target, then calling it via myarch-ld. These changes don't necessarily need to be large, but they are unavoidable I'm afraid if you want something which will work reliably.<br>

<br></div>Thanks,<br>Simon<br></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Tue, Jun 24, 2014 at 5:01 PM, Dominique Torette <span dir="ltr"><<a href="mailto:Dominique.Torette@spacebel.be" target="_blank">Dominique.Torette@spacebel.be</a>></span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">





<div link="blue" vlink="purple" lang="EN-US">
<div>
<p class="MsoNormal">Hi,<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">I’m writing a ‘LLVM Integrated Assembler’ for an in-house 32bits micro controller.<u></u><u></u></p>
<p class="MsoNormal">As far as now, I’ve followed the instructions from Simon Cook (Embecosm) as described in  <a href="http://www.embecosm.com/appnotes/ean10/ean10-howto-llvmas-1.0.html" target="_blank">http://www.embecosm.com/appnotes/ean10/ean10-howto-llvmas-1.0.html</a><u></u><u></u></p>


<p class="MsoNormal">But, I don’t catch how to finalize the relocations.<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">In the case of my micro controller, relocation are only used for the ‘Jump’ instruction.<u></u><u></u></p>
<p class="MsoNormal">The ‘Jump’ instruction is composed of 32 bits opcode, followed bit a 32 bits absolute jump address.<u></u><u></u></p>
<p class="MsoNormal">When parsed, this jump address is saved as an expression.<u></u><u></u></p>
<p class="MsoNormal">Later, this expression is translated into a fixup. <u></u><u></u></p>
<p class="MsoNormal">Finally, the fixup is translated into a relocation type by the GetRelocType(). (I only have one relocation type.)<u></u><u></u></p>
<p class="MsoNormal">The generated ELF file includes the relocation records.  I can dump this relocation records with standard linux ‘readelf’ command.<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">Relocation section '.rela.text' at offset 0x470 contains 2 entries:<u></u><u></u></p>
<p class="MsoNormal">Offset     Info    Type            Sym.Value  Sym. Name + Addend<u></u><u></u></p>
<p class="MsoNormal">0000024c  00000101 unrecognized: 1       00000224   Lback + 0<u></u><u></u></p>
<p class="MsoNormal">00000254  00000101 unrecognized: 1       00000224   Lback + 0<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">So far, so good! But the relocation type are unrecognized and the standard linux ‘ld’ command reports an error.<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">ld: /tmp/branch.o: Relocations in generic ELF (EM: 201)<u></u><u></u></p>
<p class="MsoNormal">/tmp/branch.o: error adding symbols: File in wrong format<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">My understanding is that now I have to ‘open’ the GNU ‘ld’ sources files to add the relocation schema for my ‘jump’ instruction.<u></u><u></u></p>
<p class="MsoNormal">I  would like to avoid modifying the GNU ‘ld’ or the LLVM linker.<u></u><u></u></p>
<p class="MsoNormal">My relocation schema is quite simple: at relocation record offset, I have to write the Sym. Value on 32 bits big endian.<u></u><u></u></p>
<p class="MsoNormal">Is there such  simple relocation schema already built-in the GNU ‘ld’?<u></u><u></u></p>
<p class="MsoNormal">And how to activate it, by returning a relocation type in the GetRelocType()?<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">Thanks, in advance?       Dominique Torette.<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal" style="margin-bottom:12.0pt"><span style="font-size:12.0pt;font-family:"Times New Roman","serif""><br>
<br>
<br>
<br>
<br>
<br>
<u></u><u></u></span></p>
<table style="width:402.0pt" border="0" cellpadding="0" cellspacing="0" width="536">
<tbody>
<tr>
<td style="padding:0cm 0cm 0cm 0cm">
<p class="MsoNormal"><span style="font-size:12.0pt;font-family:"Times New Roman","serif""><img src="http://www.spacebel.be/wp-content/uploads/2011/06/image-sign-sbp.jpg" alt="http://www.spacebel.be/wp-content/uploads/2011/06/image-sign-sbp.jpg" height="49" width="536"></span><span style="font-size:12.0pt;font-family:"Times New Roman","serif""><u></u><u></u></span></p>


</td>
</tr>
<tr>
<td style="border:solid silver 1.0pt;padding:0cm 0cm 0cm 0cm">
<p class="MsoNormal" style="text-align:center" align="center">
<b><span style="font-size:10.0pt" lang="FR-BE">Dominique Torette</span></b><span style="font-size:10.0pt" lang="FR-BE">
<br>
System Architect<br>
Rue des Chasseurs Ardennais - Liège Science Park - B-4031 Angleur <br>
Tel: <a href="tel:%2B32%20%280%29%204%20361%2081%2011" value="+3243618111" target="_blank">+32 (0) 4 361 81 11</a> - Fax: <a href="tel:%2B32%20%280%29%204%20361%2081%2020" value="+3243618120" target="_blank">+32 (0) 4 361 81 20</a> <br>


</span><span style="font-size:10.0pt"><a href="http://www.spacebel.be/" target="_blank"><span style="color:blue" lang="FR-BE">www.spacebel.be</span></a></span><span style="font-size:12.0pt;font-family:"Times New Roman","serif"" lang="FR-BE"><u></u><u></u></span></p>


</td>
</tr>
</tbody>
</table>
<p class="MsoNormal"><span lang="FR-BE"><u></u> <u></u></span></p>
</div>
<br clear="all">
 ------------------------------------------------------------------------------<br>
<br>
E-MAIL DISCLAIMER<br>
<br>
The present message may contain confidential and/or legally privileged information. If you are not the intended addressee and in case of a transmission error, please notify the sender immediately and destroy this E-mail. Disclosure, reproduction or distribution of this document and its possible attachments is strictly forbidden.<br>


<br>
SPACEBEL denies all liability for incomplete, improper, inaccurate, intercepted, (partly) destroyed, lost and/or belated transmission of the current information given that unencrypted electronic transmission cannot currently be guaranteed to be secure or error free.<br>


Upon request or in conformity with formal, contractual agreements, an originally signed hard copy will be sent to you to confirm the information contained in this E-mail.<br>
<br>
SPACEBEL denies all liability where E-mail is used for private use.<br>
<br>
SPACEBEL cannot be held responsible for possible viruses that might corrupt this message and/or your computer system.<br>
 -------------------------------------------------------------------------------<br>
</div>

<br>_______________________________________________<br>
LLVM Developers mailing list<br>
<a href="mailto:LLVMdev@cs.uiuc.edu">LLVMdev@cs.uiuc.edu</a>         <a href="http://llvm.cs.uiuc.edu" target="_blank">http://llvm.cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev</a><br>
<br></blockquote></div><br></div>