<html dir="ltr">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style id="owaParaStyle" type="text/css">P {margin-top:0;margin-bottom:0;}</style>
</head>
<body ocsi="0" fpstyle="1">
<div style="direction: ltr;font-family: Tahoma;color: #000000;font-size: 10pt;">
<pre class="western">Proposal for ELF text and data big endian support for direct object generation<br><br>Unless I am mistaken, currently big endian support in the MC layer for ELF <br>direct object generation is limited to ELF headers and tables like relocations. <br>Text and data section contents are still generated as individual bytes. <br>It looks as if the effort was started, but never completed.<br><br>The proposal is to extend the MCDataFragment class to include a container <br>of offset/size that one can traverse generating each element in the correct <br>endianess:<br><br>  // Pseudo code</pre>
<p style="margin-bottom: 0in;" align="LEFT"><font face="Monospace"><font size="2"><font color="#7f0055"><b>for</b></font><font color="#000000"> (iterator it = begin(), ie = end(); it != ie; ++it) {</font></font></font></p>
<pre class="western">     switch (it.getValueSize()) {<br>      default:<br>        assert(0 && "Invalid size!");<br>      case 1: OW->Write8 (uint8_t (it.getValue())); break;<br>      case 2: OW->Write16(uint16_t(it.getValue())); break;<br>      case 4: OW->Write32(uint32_t(it.getValue())); break;<br>      case 8: OW->Write64(uint64_t(it.getValue())); break;<br>      }<br>    }<br><br>Note: ObjectWriter has a set of endian correcting routines as use above.<br><br>The output routines like the snippet above would be in lib/MC/MCAssembler.cpp<br><br>There is an MCInstFragment, but it doesn't seem to be used. All text and data <br>seem to go through MCDataFragment.<br><br>The offset/size container would be filled at the <br>lib/Taget/<your target>/MCTargetDesc level. In <your targetMCCODEEmitter.cpp <br>for at least text. Some other source file for data.<br><br>It would be nice if someone could prove that the support is already there <br>and I don't have to do anything to get it, but if not, is the above <br>strawman reasonable? If so, I'll implement it and put it up for review.<br><br>Cheers,<br><br>Jack </pre>
</div>
</body>
</html>