[PATCH] [PECOFF] Remove COFF header from PE header for simplicity.

Rui Ueyama ruiu at google.com
Mon Jun 10 16:58:10 PDT 2013


Hi Bigcheese,

COFF header is always present both in executable and in object file. PE header
is present only in executable. So the natural way to handle PE/COFF file is
treating COFF is mandatory header and PE is optional. Current data structre
does not allow it, because PE header includes COFF header. Removing COFF
header will simplify the code to handle PE/COFF files.

http://llvm-reviews.chandlerc.com/D952

Files:
  include/llvm/Object/COFF.h
  include/llvm/Support/COFF.h

Index: include/llvm/Object/COFF.h
===================================================================
--- include/llvm/Object/COFF.h
+++ include/llvm/Object/COFF.h
@@ -57,10 +57,8 @@
   support::ulittle16_t Characteristics;
 };
 
-/// The 32-bit PE header that usually immediately follows the DOS header.
+/// The 32-bit PE header that follows the COFF header.
 struct pe32_header {
-  support::ulittle32_t Signature;
-  coff_file_header COFFHeader;
   support::ulittle16_t Magic;
   uint8_t  MajorLinkerVersion;
   uint8_t  MinorLinkerVersion;
@@ -93,10 +91,8 @@
   support::ulittle32_t NumberOfRvaAndSize;
 };
 
-/// The 64-bit PE header that usually immediately follows the DOS header.
+/// The 64-bit PE header that follows the COFF header.
 struct pe32plus_header {
-  support::ulittle32_t Signature;
-  coff_file_header COFFHeader;
   support::ulittle16_t Magic;
   uint8_t  MajorLinkerVersion;
   uint8_t  MinorLinkerVersion;
Index: include/llvm/Support/COFF.h
===================================================================
--- include/llvm/Support/COFF.h
+++ include/llvm/Support/COFF.h
@@ -30,6 +30,9 @@
 namespace llvm {
 namespace COFF {
 
+  // The PE signature bytes that follows the DOS stub header.
+  static const char PEMagic[] = { 'P', 'E', '\0', '\0' };
+
   // Sizes in bytes of various things in the COFF format.
   enum {
     HeaderSize     = 20,
@@ -448,8 +451,6 @@
   };
 
   struct PEHeader {
-    uint32_t Signature;
-    header COFFHeader;
     uint16_t Magic;
     uint8_t  MajorLinkerVersion;
     uint8_t  MinorLinkerVersion;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D952.1.patch
Type: text/x-patch
Size: 1562 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20130610/2900e9b1/attachment.bin>


More information about the llvm-commits mailing list