<div dir="ltr"><div>Ideally we should call PECOFFLinkingContext::getMachineType() to dispatch to support ARM, but I didn't bother to do that because ARM Windows support is very very distant goal. There's no code for Windows on non-x86 architecture written at this moment yet.</div>

</div><div class="gmail_extra"><br><br><div class="gmail_quote">On Thu, Oct 17, 2013 at 3:51 PM, Sean Silva <span dir="ltr"><<a href="mailto:silvas@purdue.edu" target="_blank">silvas@purdue.edu</a>></span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">WIll this code realistically one ever have to deal with x86? Is there some target flag you need to check?<span class="HOEnZb"><font color="#888888"><div>

<br></div><div>-- Sean Silva</div></font></span></div><div class="HOEnZb"><div class="h5"><div class="gmail_extra"><br><br><div class="gmail_quote">
On Thu, Oct 17, 2013 at 6:45 PM, Rui Ueyama <span dir="ltr"><<a href="mailto:ruiu@google.com" target="_blank">ruiu@google.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">


Author: ruiu<br>
Date: Thu Oct 17 17:45:16 2013<br>
New Revision: 192930<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=192930&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=192930&view=rev</a><br>
Log:<br>
Fill gap in .text with NOP.<br>
<br>
Modified:<br>
    lld/trunk/lib/ReaderWriter/PECOFF/WriterPECOFF.cpp<br>
<br>
Modified: lld/trunk/lib/ReaderWriter/PECOFF/WriterPECOFF.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/PECOFF/WriterPECOFF.cpp?rev=192930&r1=192929&r2=192930&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/PECOFF/WriterPECOFF.cpp?rev=192930&r1=192929&r2=192930&view=diff</a><br>



==============================================================================<br>
--- lld/trunk/lib/ReaderWriter/PECOFF/WriterPECOFF.cpp (original)<br>
+++ lld/trunk/lib/ReaderWriter/PECOFF/WriterPECOFF.cpp Thu Oct 17 17:45:16 2013<br>
@@ -585,6 +585,20 @@ void SectionHeaderTableChunk::write(uint<br>
 // \brief A TextSectionChunk represents a .text section.<br>
 class TextSectionChunk : public SectionChunk {<br>
 public:<br>
+  virtual void write(uint8_t *fileBuffer) {<br>
+    if (_atomLayouts.empty())<br>
+      return;<br>
+    // Fill the section with NOP (0x90) rather than NUL, so that the<br>
+    // disassembler will not interpret a garbage between atoms as the beginning<br>
+    // of multi-byte machine code. This does not change the behavior of<br>
+    // resulting binary but help debugging.<br>
+    uint8_t *start = fileBuffer + _atomLayouts.front()->_fileOffset;<br>
+    uint8_t *end = fileBuffer + _atomLayouts.back()->_fileOffset;<br>
+    memset(start, 0x90, end - start);<br>
+<br>
+    SectionChunk::write(fileBuffer);<br>
+  }<br>
+<br>
   TextSectionChunk(const File &linkedFile)<br>
       : SectionChunk(".text", characteristics) {<br>
     buildContents(linkedFile, [](const DefinedAtom *atom) {<br>
<br>
<br>
_______________________________________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@cs.uiuc.edu" target="_blank">llvm-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits</a><br>
</blockquote></div><br></div>
</div></div></blockquote></div><br></div>