[PATCH] Preliminary support for dynamically loadable coff objects

Zachary Turner zturner at google.com
Tue Feb 24 11:08:14 PST 2015


REPOSITORY
  rL LLVM

================
Comment at: lib/Object/COFFObjectFile.cpp:376
@@ -366,3 +375,3 @@
   const coff_section *Sec = toSec(Ref);
-  return Sec->Characteristics & COFF::IMAGE_SCN_CNT_UNINITIALIZED_DATA;
+  return Sec->SizeOfRawData == 0;
 }
----------------
majnemer wrote:
> AndyAyers wrote:
> > majnemer wrote:
> > > AndyAyers wrote:
> > > > majnemer wrote:
> > > > > What's the rationale for this change?
> > > > I thought it better matched the intent of the comment in ObjectFile.h:
> > > > 
> > > >   // A section is 'virtual' if its contents aren't present in the object image.
> > > > 
> > > > For coff this means the section has no raw data, regardless of section characteristics. In practice it probably doesn't matter so I'd be happy to revert this if you prefer.
> > > Compiling `char x[300];` as C++ with MSVC 2015 results in a .bss section with `SizeOfRawData` set to 0x12c.
> > > 
> > > The relevant text from the COFF spec is:
> > > > The size of the section (for object files) or the size of the initialized data on disk (for image files).
> > > 
> > > Heh, I guess my formulation of `isSectionVirtual` was more appropriate for object files while yours is better for executables.
> > Perhaps a better check is if PointerToRawData is zero, this should work in both obj and pe cases?
> Yes, I think that would work perfectly.
I'm following this from the sidelines as I don't know much in this area, but I think it would be good to have a comment summarizing the takeaway from this discussion at the point you add the check for PointerToRawData == 0

http://reviews.llvm.org/D7793

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/






More information about the llvm-commits mailing list