[llvm] r241387 - Object/COFF: Do not rely on VirtualSize being 0 in object files.
Rui Ueyama
ruiu at google.com
Mon Jul 6 09:58:59 PDT 2015
Yes I can. Will do.
On Sun, Jul 5, 2015 at 7:20 PM, Rafael EspĂndola <rafael.espindola at gmail.com
> wrote:
> Can we add a test with a file created by a buggy writer?
>
> On 3 July 2015 at 23:25, Rui Ueyama <ruiu at google.com> wrote:
> > Author: ruiu
> > Date: Fri Jul 3 22:25:51 2015
> > New Revision: 241387
> >
> > URL: http://llvm.org/viewvc/llvm-project?rev=241387&view=rev
> > Log:
> > Object/COFF: Do not rely on VirtualSize being 0 in object files.
> >
> > Modified:
> > llvm/trunk/lib/Object/COFFObjectFile.cpp
> >
> > Modified: llvm/trunk/lib/Object/COFFObjectFile.cpp
> > URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Object/COFFObjectFile.cpp?rev=241387&r1=241386&r2=241387&view=diff
> >
> ==============================================================================
> > --- llvm/trunk/lib/Object/COFFObjectFile.cpp (original)
> > +++ llvm/trunk/lib/Object/COFFObjectFile.cpp Fri Jul 3 22:25:51 2015
> > @@ -918,19 +918,15 @@ uint64_t COFFObjectFile::getSectionSize(
> > // whether or not we have an executable image.
> > //
> > // For object files, SizeOfRawData contains the size of section's
> data;
> > - // VirtualSize is always zero.
> > + // VirtualSize should be zero but isn't due to buggy COFF writers.
> > //
> > // For executables, SizeOfRawData *must* be a multiple of
> FileAlignment; the
> > // actual section size is in VirtualSize. It is possible for
> VirtualSize to
> > // be greater than SizeOfRawData; the contents past that point should
> be
> > // considered to be zero.
> > - uint32_t SectionSize;
> > - if (Sec->VirtualSize)
> > - SectionSize = std::min(Sec->VirtualSize, Sec->SizeOfRawData);
> > - else
> > - SectionSize = Sec->SizeOfRawData;
> > -
> > - return SectionSize;
> > + if (getDOSHeader())
> > + return std::min(Sec->VirtualSize, Sec->SizeOfRawData);
> > + return Sec->SizeOfRawData;
> > }
> >
> > std::error_code
> >
> >
> > _______________________________________________
> > 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/20150706/fd356317/attachment.html>
More information about the llvm-commits
mailing list