[lld] r192930 - Fill gap in .text with NOP.
Sean Silva
silvas at purdue.edu
Thu Oct 17 15:51:52 PDT 2013
WIll this code realistically one ever have to deal with x86? Is there some
target flag you need to check?
-- Sean Silva
On Thu, Oct 17, 2013 at 6:45 PM, Rui Ueyama <ruiu at google.com> wrote:
> 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) {
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20131017/18980dc2/attachment.html>
More information about the llvm-commits
mailing list