[lld] r192930 - Fill gap in .text with NOP.
Rui Ueyama
ruiu at google.com
Thu Oct 17 15:45:16 PDT 2013
Author: ruiu
Date: Thu Oct 17 17:45:16 2013
New Revision: 192930
URL: http://llvm.org/viewvc/llvm-project?rev=192930&view=rev
Log:
Fill gap in .text with NOP.
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=192930&r1=192929&r2=192930&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/PECOFF/WriterPECOFF.cpp (original)
+++ lld/trunk/lib/ReaderWriter/PECOFF/WriterPECOFF.cpp Thu Oct 17 17:45:16 2013
@@ -585,6 +585,20 @@ void SectionHeaderTableChunk::write(uint
// \brief A TextSectionChunk represents a .text section.
class TextSectionChunk : public SectionChunk {
public:
+ virtual void write(uint8_t *fileBuffer) {
+ if (_atomLayouts.empty())
+ return;
+ // Fill the section with NOP (0x90) 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);
+
+ SectionChunk::write(fileBuffer);
+ }
+
TextSectionChunk(const File &linkedFile)
: SectionChunk(".text", characteristics) {
buildContents(linkedFile, [](const DefinedAtom *atom) {
More information about the llvm-commits
mailing list