[llvm] r183788 - [PECOFF] Remove COFF header from PE header for simplicity.

Rui Ueyama ruiu at google.com
Tue Jun 11 14:39:48 PDT 2013


Author: ruiu
Date: Tue Jun 11 16:39:48 2013
New Revision: 183788

URL: http://llvm.org/viewvc/llvm-project?rev=183788&view=rev
Log:
[PECOFF] Remove COFF header from PE header for simplicity.

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.

Reviewers: Bigcheese

CC: llvm-commits

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

Modified:
    llvm/trunk/include/llvm/Object/COFF.h
    llvm/trunk/include/llvm/Support/COFF.h

Modified: llvm/trunk/include/llvm/Object/COFF.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Object/COFF.h?rev=183788&r1=183787&r2=183788&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Object/COFF.h (original)
+++ llvm/trunk/include/llvm/Object/COFF.h Tue Jun 11 16:39:48 2013
@@ -57,10 +57,8 @@ struct coff_file_header {
   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 @@ struct pe32_header {
   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;

Modified: llvm/trunk/include/llvm/Support/COFF.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/COFF.h?rev=183788&r1=183787&r2=183788&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Support/COFF.h (original)
+++ llvm/trunk/include/llvm/Support/COFF.h Tue Jun 11 16:39:48 2013
@@ -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 @@ namespace COFF {
   };
 
   struct PEHeader {
-    uint32_t Signature;
-    header COFFHeader;
     uint16_t Magic;
     uint8_t  MajorLinkerVersion;
     uint8_t  MinorLinkerVersion;





More information about the llvm-commits mailing list