[lld] r192945 - Fill the atom gap with INT 3 instead of NOP.

Rui Ueyama ruiu at google.com
Thu Oct 17 20:23:34 PDT 2013


Author: ruiu
Date: Thu Oct 17 22:23:33 2013
New Revision: 192945

URL: http://llvm.org/viewvc/llvm-project?rev=192945&view=rev
Log:
Fill the atom gap with INT 3 instead of NOP.

INT 3 (machine code 0xCC) will raise an interrupt when executed. That is better
for filling the gap than NOP because we want to stop the execution immediately
when the control reached to non-code address.

Modified:
    lld/trunk/lib/ReaderWriter/PECOFF/WriterPECOFF.cpp

Modified: lld/trunk/lib/ReaderWriter/PECOFF/WriterPECOFF.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/PECOFF/WriterPECOFF.cpp?rev=192945&r1=192944&r2=192945&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/PECOFF/WriterPECOFF.cpp (original)
+++ lld/trunk/lib/ReaderWriter/PECOFF/WriterPECOFF.cpp Thu Oct 17 22:23:33 2013
@@ -588,13 +588,13 @@ public:
   virtual void write(uint8_t *fileBuffer) {
     if (_atomLayouts.empty())
       return;
-    // Fill the section with NOP (0x90) rather than NUL, so that the
+    // Fill the section with INT 3 (0xCC) rather than NUL, so that the
     // disassembler will not interpret a garbage between atoms as the beginning
     // of multi-byte machine code. This does not change the behavior of
     // resulting binary but help debugging.
     uint8_t *start = fileBuffer + _atomLayouts.front()->_fileOffset;
     uint8_t *end = fileBuffer + _atomLayouts.back()->_fileOffset;
-    memset(start, 0x90, end - start);
+    memset(start, 0xCC, end - start);
 
     SectionChunk::write(fileBuffer);
   }





More information about the llvm-commits mailing list