[PECOFF] Remove COFF header from PE header for simplicity.
authorRui Ueyama <ruiu@google.com>
Tue, 11 Jun 2013 21:39:48 +0000 (21:39 +0000)
committerRui Ueyama <ruiu@google.com>
Tue, 11 Jun 2013 21:39:48 +0000 (21:39 +0000)
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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@183788 91177308-0d34-0410-b5e6-96231b3b80d8

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

index 013b14e62fd7c75f610a28572f2abfed0c0eda69..209aa76efde5c74a25cdd54374ee339e15b2e7eb 100644 (file)
@@ -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;
index 823b43ad938adea3f47177af086d70846260254c..d348b76a4468a6b85be382f81732239f832916b1 100644 (file)
@@ -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;