Add PE Section headers, add PE lit testcases
diff --git a/src/pe.cc b/src/pe.cc
index 02824ba..cdf1958 100644
--- a/src/pe.cc
+++ b/src/pe.cc
@@ -12,56 +12,56 @@
 // See the License for the specific language governing permissions and
 // limitations under the License.
 
-#include "bloaty.h"
 #include "absl/strings/substitute.h"
+#include "bloaty.h"
 #include "util.h"
 
 using absl::string_view;
+using std::string;
 
 namespace bloaty {
 namespace pe {
-const uint16_t dos_magic = 0x5A4D;  // MZ
+constexpr uint16_t dos_magic = 0x5A4D;  // MZ
 
+// From LIEF/include/LIEF/PE/Structures.hpp.in
 //! Sizes in bytes of various things in the COFF format.
-enum class StructSizes {
-  kHeader16Size = 20,
-  kHeader32Size = 56,
-  kNameSize = 8,
-  kSymbol16Size = 18,
-  kSymbol32Size = 20,
-  kSectionSize = 40,
-  kRelocationSize = 10,
-  kBaseRelocationBlockSize = 8,
-  kImportDirectoryTableEntrySize = 20,
-  kResourceDirectoryTableSize = 16,
-  kResourceDirectoryEntriesSize = 8,
-  kResourceDataEntrySize = 16,
-};
+constexpr size_t kHeader16Size = 20;
+constexpr size_t kHeader32Size = 56;
+constexpr size_t kNameSize = 8;
+constexpr size_t kSymbol16Size = 18;
+constexpr size_t kSymbol32Size = 20;
+constexpr size_t kSectionSize = 40;
+constexpr size_t kRelocationSize = 10;
+constexpr size_t kBaseRelocationBlockSize = 8;
+constexpr size_t kImportDirectoryTableEntrySize = 20;
+constexpr size_t kResourceDirectoryTableSize = 16;
+constexpr size_t kResourceDirectoryEntriesSize = 8;
+constexpr size_t kResourceDataEntrySize = 16;
 
+#include "third_party/lief_pe/pe_enums.h"
 #include "third_party/lief_pe/pe_structures.h"
 
-static_assert(static_cast<size_t>(StructSizes::kSectionSize) ==
-                  sizeof(pe_section),
+static_assert(kSectionSize == sizeof(pe_section),
               "Compiler options broke LIEF struct layout");
-static_assert(static_cast<size_t>(StructSizes::kRelocationSize) ==
-                  sizeof(pe_relocation),
+static_assert(kRelocationSize == sizeof(pe_relocation),
               "Compiler options broke LIEF struct layout");
-static_assert(static_cast<size_t>(StructSizes::kBaseRelocationBlockSize) ==
-                  sizeof(pe_base_relocation_block),
+static_assert(kBaseRelocationBlockSize == sizeof(pe_base_relocation_block),
               "Compiler options broke LIEF struct layout");
-static_assert(
-    static_cast<size_t>(StructSizes::kImportDirectoryTableEntrySize) ==
-        sizeof(pe_import),
-    "Compiler options broke LIEF struct layout");
-static_assert(static_cast<size_t>(StructSizes::kResourceDirectoryTableSize) ==
+static_assert(kImportDirectoryTableEntrySize == sizeof(pe_import),
+              "Compiler options broke LIEF struct layout");
+static_assert(kResourceDirectoryTableSize ==
                   sizeof(pe_resource_directory_table),
               "Compiler options broke LIEF struct layout");
-static_assert(static_cast<size_t>(StructSizes::kResourceDirectoryEntriesSize) ==
+static_assert(kResourceDirectoryEntriesSize ==
                   sizeof(pe_resource_directory_entries),
               "Compiler options broke LIEF struct layout");
-static_assert(static_cast<size_t>(StructSizes::kResourceDataEntrySize) ==
-                  sizeof(pe_resource_data_entry),
+static_assert(kResourceDataEntrySize == sizeof(pe_resource_data_entry),
               "Compiler options broke LIEF struct layout");
+static_assert(kSymbol16Size == sizeof(pe_symbol),
+              "Compiler options broke LIEF struct layout");
+
+static_assert(sizeof(PE_TYPE) == sizeof(uint16_t),
+              "Compiler options broke PE_TYPE size");
 
 class PeFile {
  public:
@@ -70,10 +70,10 @@
   bool IsOpen() const { return ok_; }
 
   string_view entire_file() const { return data_; }
-  string_view header_region() const { return header_region_; }
+  string_view pe_headers() const { return pe_headers_; }
+  string_view section_headers() const { return section_headers_; }
 
   uint32_t section_count() const { return section_count_; }
-  string_view section_headers() const { return section_headers_; }
   string_view section_header(size_t n) const {
     return StrictSubstr(section_headers_, n * sizeof(pe_section),
                         sizeof(pe_section));
@@ -92,9 +92,10 @@
 
   pe_dos_header dos_header_;
   pe_header pe_header_;
-  string_view header_region_;
-  uint32_t section_count_;
+
+  string_view pe_headers_;
   string_view section_headers_;
+  uint32_t section_count_;
 };
 
 bool PeFile::Initialize() {
@@ -109,9 +110,16 @@
     return false;
   }
 
-  string_view exe_header =
-      GetRegion(dos_header_.AddressOfNewExeHeader, sizeof(pe_header));
-  memcpy(&pe_header_, exe_header.data(), exe_header.size());
+  PE_TYPE Magic;
+  auto pe_end =
+      CheckedAdd(dos_header_.AddressOfNewExeHeader, sizeof(pe_header_));
+  if (CheckedAdd(pe_end, sizeof(Magic)) > data_.size()) {
+    // Cannot fit the headers / magic from optional header
+    return false;
+  }
+
+  memcpy(&pe_header_, data_.data() + dos_header_.AddressOfNewExeHeader,
+         sizeof(pe_header_));
 
   if (!std::equal(pe_header_.signature, pe_header_.signature + sizeof(PE_Magic),
                   std::begin(PE_Magic))) {
@@ -119,13 +127,20 @@
     return false;
   }
 
-  // TODO(mj): Parse PE header further to determine this
-  is_64bit_ = false;
+  memcpy(&Magic, data_.data() + pe_end, sizeof(Magic));
+
+  if (Magic != PE_TYPE::PE32 && Magic != PE_TYPE::PE32_PLUS) {
+    // Unknown PE magic
+    return false;
+  }
+
+  is_64bit_ = Magic == PE_TYPE::PE32_PLUS;
 
   section_count_ = pe_header_.NumberOfSections;
 
+  // TODO(mj): Figure out if we should trust SizeOfOptionalHeader here
   const uint32_t sections_offset = dos_header_.AddressOfNewExeHeader +
-                                   sizeof(pe_header) +
+                                   sizeof(pe_header_) +
                                    pe_header_.SizeOfOptionalHeader;
 
   auto sections_size = CheckedMul(section_count_, sizeof(pe_section));
@@ -134,7 +149,7 @@
     return false;
   }
 
-  header_region_ = GetRegion(0, sections_offset);
+  pe_headers_ = GetRegion(0, sections_offset);
   section_headers_ = GetRegion(sections_offset, sections_size);
 
   return true;
@@ -142,8 +157,7 @@
 
 class Section {
  public:
-  std::string name;
-  string_view data;
+  string name;
 
   uint32_t raw_offset() const { return header_.PointerToRawData; }
   uint32_t raw_size() const { return header_.SizeOfRawData; }
@@ -154,15 +168,12 @@
   Section(string_view header_data) {
     assert(header_data.size() == sizeof(header_));
     memcpy(&header_, header_data.data(), sizeof(header_));
-    data = header_data;
 
     // TODO(mj): Handle long section names:
     // For longer names, this member contains a forward slash (/) followed by an
     // ASCII representation of a decimal number that is an offset into the
     // string table.
-    name = std::string(
-        header_.Name,
-        strnlen(header_.Name, static_cast<size_t>(StructSizes::kNameSize)));
+    name = string(header_.Name, strnlen(header_.Name, kNameSize));
   }
 
  private:
@@ -190,14 +201,14 @@
 }
 
 void AddCatchAll(const PeFile& pe, RangeSink* sink) {
-  // The last-line fallback to make sure we cover the entire VM space.
   assert(pe.IsOpen());
 
-  auto begin = pe.header_region().data() - sink->input_file().data().data();
-  sink->AddRange("pe_catchall", "[PE Headers]", begin,
-                 pe.header_region().size(), pe.header_region());
+  auto begin = pe.pe_headers().data() - sink->input_file().data().data();
+  sink->AddRange("pe_catchall", "[PE Headers]", begin, pe.pe_headers().size(),
+                 pe.pe_headers());
+
   begin = pe.section_headers().data() - sink->input_file().data().data();
-  sink->AddRange("pe_catchall", "[PE Headers]", begin,
+  sink->AddRange("pe_catchall", "[PE Section Headers]", begin,
                  pe.section_headers().size(), pe.section_headers());
 
   // The last-line fallback to make sure we cover the entire file.
@@ -227,8 +238,8 @@
         case DataSource::kRawSymbols:
         case DataSource::kShortSymbols:
         case DataSource::kFullSymbols:
-          // TODO(mj): Generate symbols from debug info, exports and other known
-          // structures
+          // TODO(mj): Generate symbols from debug info, exports, imports, tls
+          // data, relocations, resources ...
         case DataSource::kArchiveMembers:
         case DataSource::kCompileUnits:
         case DataSource::kInlines:
@@ -239,8 +250,7 @@
     }
   }
 
-  bool GetDisassemblyInfo(absl::string_view /*symbol*/,
-                          DataSource /*symbol_source*/,
+  bool GetDisassemblyInfo(string_view /*symbol*/, DataSource /*symbol_source*/,
                           DisassemblyInfo* /*info*/) const override {
     WARN("PE files do not support disassembly yet");
     return false;
diff --git a/tests/PE/sections/empty-pe32-dll.test b/tests/PE/sections/empty-pe32-dll.test
new file mode 100644
index 0000000..2229ba8
--- /dev/null
+++ b/tests/PE/sections/empty-pe32-dll.test
@@ -0,0 +1,90 @@
+# RUN: %yaml2obj %s -o %t.obj
+# RUN: %bloaty --raw-map %t.obj | %FileCheck %s --dump-input fail
+
+--- !COFF
+OptionalHeader:
+  AddressOfEntryPoint: 4096
+  ImageBase:       268435456
+  SectionAlignment: 4096
+  FileAlignment:   512
+  MajorOperatingSystemVersion: 4
+  MinorOperatingSystemVersion: 0
+  MajorImageVersion: 0
+  MinorImageVersion: 0
+  MajorSubsystemVersion: 4
+  MinorSubsystemVersion: 0
+  Subsystem:       IMAGE_SUBSYSTEM_WINDOWS_GUI
+  DLLCharacteristics: [  ]
+  SizeOfStackReserve: 1048576
+  SizeOfStackCommit: 4096
+  SizeOfHeapReserve: 1048576
+  SizeOfHeapCommit: 4096
+  ExportTable:
+    RelativeVirtualAddress: 0
+    Size:            0
+  ImportTable:
+    RelativeVirtualAddress: 0
+    Size:            0
+  ResourceTable:
+    RelativeVirtualAddress: 0
+    Size:            0
+  ExceptionTable:
+    RelativeVirtualAddress: 0
+    Size:            0
+  CertificateTable:
+    RelativeVirtualAddress: 0
+    Size:            0
+  BaseRelocationTable:
+    RelativeVirtualAddress: 0
+    Size:            0
+  Debug:
+    RelativeVirtualAddress: 0
+    Size:            0
+  Architecture:
+    RelativeVirtualAddress: 0
+    Size:            0
+  GlobalPtr:
+    RelativeVirtualAddress: 0
+    Size:            0
+  TlsTable:
+    RelativeVirtualAddress: 0
+    Size:            0
+  LoadConfigTable:
+    RelativeVirtualAddress: 0
+    Size:            0
+  BoundImport:
+    RelativeVirtualAddress: 0
+    Size:            0
+  IAT:
+    RelativeVirtualAddress: 0
+    Size:            0
+  DelayImportDescriptor:
+    RelativeVirtualAddress: 0
+    Size:            0
+  ClrRuntimeHeader:
+    RelativeVirtualAddress: 0
+    Size:            0
+header:
+  Machine:         IMAGE_FILE_MACHINE_I386
+  Characteristics: [ IMAGE_FILE_EXECUTABLE_IMAGE, IMAGE_FILE_LINE_NUMS_STRIPPED, IMAGE_FILE_LOCAL_SYMS_STRIPPED, IMAGE_FILE_32BIT_MACHINE, IMAGE_FILE_DEBUG_STRIPPED, IMAGE_FILE_DLL ]
+sections:
+  - Name:            .text
+    Characteristics: [ IMAGE_SCN_CNT_CODE, IMAGE_SCN_MEM_EXECUTE, IMAGE_SCN_MEM_READ ]
+    VirtualAddress:  4096
+    VirtualSize:     24
+    SectionData:     5589E581EC0000000090B801000000E900000000C9C20C00
+symbols:         []
+...
+
+# CHECK: FILE MAP:
+# CHECK: 000-178	        376		[PE Headers]
+# CHECK: 178-1a0	         40		[PE Section Headers]
+# CHECK: 1a0-200	         96		[Unmapped]
+# CHECK: 200-400	        512		.text
+
+# CHECK: VM MAP:
+# CHECK: 0000-0178	        376		[PE Headers]
+# CHECK: 0178-01a0	         40		[PE Section Headers]
+# CHECK: 01a0-1000	       3680		[-- Nothing mapped --]
+# CHECK: 1000-1018	         24		.text
+
diff --git a/tests/PE/sections/empty-pe32-exe.test b/tests/PE/sections/empty-pe32-exe.test
new file mode 100644
index 0000000..051659a
--- /dev/null
+++ b/tests/PE/sections/empty-pe32-exe.test
@@ -0,0 +1,90 @@
+# RUN: %yaml2obj %s -o %t.obj
+# RUN: %bloaty --raw-map %t.obj | %FileCheck %s --dump-input fail
+
+--- !COFF
+OptionalHeader:
+  AddressOfEntryPoint: 4096
+  ImageBase:       4194304
+  SectionAlignment: 4096
+  FileAlignment:   512
+  MajorOperatingSystemVersion: 4
+  MinorOperatingSystemVersion: 0
+  MajorImageVersion: 0
+  MinorImageVersion: 0
+  MajorSubsystemVersion: 4
+  MinorSubsystemVersion: 0
+  Subsystem:       IMAGE_SUBSYSTEM_WINDOWS_CUI
+  DLLCharacteristics: [  ]
+  SizeOfStackReserve: 1048576
+  SizeOfStackCommit: 4096
+  SizeOfHeapReserve: 1048576
+  SizeOfHeapCommit: 4096
+  ExportTable:
+    RelativeVirtualAddress: 0
+    Size:            0
+  ImportTable:
+    RelativeVirtualAddress: 0
+    Size:            0
+  ResourceTable:
+    RelativeVirtualAddress: 0
+    Size:            0
+  ExceptionTable:
+    RelativeVirtualAddress: 0
+    Size:            0
+  CertificateTable:
+    RelativeVirtualAddress: 0
+    Size:            0
+  BaseRelocationTable:
+    RelativeVirtualAddress: 0
+    Size:            0
+  Debug:
+    RelativeVirtualAddress: 0
+    Size:            0
+  Architecture:
+    RelativeVirtualAddress: 0
+    Size:            0
+  GlobalPtr:
+    RelativeVirtualAddress: 0
+    Size:            0
+  TlsTable:
+    RelativeVirtualAddress: 0
+    Size:            0
+  LoadConfigTable:
+    RelativeVirtualAddress: 0
+    Size:            0
+  BoundImport:
+    RelativeVirtualAddress: 0
+    Size:            0
+  IAT:
+    RelativeVirtualAddress: 0
+    Size:            0
+  DelayImportDescriptor:
+    RelativeVirtualAddress: 0
+    Size:            0
+  ClrRuntimeHeader:
+    RelativeVirtualAddress: 0
+    Size:            0
+header:
+  Machine:         IMAGE_FILE_MACHINE_I386
+  Characteristics: [ IMAGE_FILE_RELOCS_STRIPPED, IMAGE_FILE_EXECUTABLE_IMAGE, IMAGE_FILE_LINE_NUMS_STRIPPED, IMAGE_FILE_LOCAL_SYMS_STRIPPED, IMAGE_FILE_32BIT_MACHINE, IMAGE_FILE_DEBUG_STRIPPED ]
+sections:
+  - Name:            .text
+    Characteristics: [ IMAGE_SCN_CNT_CODE, IMAGE_SCN_MEM_EXECUTE, IMAGE_SCN_MEM_READ ]
+    VirtualAddress:  4096
+    VirtualSize:     24
+    SectionData:     5589E581EC0000000090B800000000E900000000C9C30000
+symbols:         []
+...
+
+# CHECK: FILE MAP:
+# CHECK: 000-178	        376		[PE Headers]
+# CHECK: 178-1a0	         40		[PE Section Headers]
+# CHECK: 1a0-200	         96		[Unmapped]
+# CHECK: 200-400	        512		.text
+
+# CHECK: VM MAP:
+# CHECK: 0000-0178	        376		[PE Headers]
+# CHECK: 0178-01a0	         40		[PE Section Headers]
+# CHECK: 01a0-1000	       3680		[-- Nothing mapped --]
+# CHECK: 1000-1018	         24		.text
+
diff --git a/tests/PE/sections/empty-pe64-dll.test b/tests/PE/sections/empty-pe64-dll.test
new file mode 100644
index 0000000..2f775f6
--- /dev/null
+++ b/tests/PE/sections/empty-pe64-dll.test
@@ -0,0 +1,98 @@
+# RUN: %yaml2obj %s -o %t.obj
+# RUN: %bloaty --raw-map %t.obj | %FileCheck %s --dump-input fail
+
+--- !COFF
+OptionalHeader:
+  AddressOfEntryPoint: 4096
+  ImageBase:       268435456
+  SectionAlignment: 4096
+  FileAlignment:   512
+  MajorOperatingSystemVersion: 4
+  MinorOperatingSystemVersion: 0
+  MajorImageVersion: 0
+  MinorImageVersion: 0
+  MajorSubsystemVersion: 4
+  MinorSubsystemVersion: 0
+  Subsystem:       IMAGE_SUBSYSTEM_WINDOWS_GUI
+  DLLCharacteristics: [  ]
+  SizeOfStackReserve: 1048576
+  SizeOfStackCommit: 4096
+  SizeOfHeapReserve: 1048576
+  SizeOfHeapCommit: 4096
+  ExportTable:
+    RelativeVirtualAddress: 0
+    Size:            0
+  ImportTable:
+    RelativeVirtualAddress: 0
+    Size:            0
+  ResourceTable:
+    RelativeVirtualAddress: 0
+    Size:            0
+  ExceptionTable:
+    RelativeVirtualAddress: 8192
+    Size:            12
+  CertificateTable:
+    RelativeVirtualAddress: 0
+    Size:            0
+  BaseRelocationTable:
+    RelativeVirtualAddress: 0
+    Size:            0
+  Debug:
+    RelativeVirtualAddress: 0
+    Size:            0
+  Architecture:
+    RelativeVirtualAddress: 0
+    Size:            0
+  GlobalPtr:
+    RelativeVirtualAddress: 0
+    Size:            0
+  TlsTable:
+    RelativeVirtualAddress: 0
+    Size:            0
+  LoadConfigTable:
+    RelativeVirtualAddress: 0
+    Size:            0
+  BoundImport:
+    RelativeVirtualAddress: 0
+    Size:            0
+  IAT:
+    RelativeVirtualAddress: 0
+    Size:            0
+  DelayImportDescriptor:
+    RelativeVirtualAddress: 0
+    Size:            0
+  ClrRuntimeHeader:
+    RelativeVirtualAddress: 0
+    Size:            0
+header:
+  Machine:         IMAGE_FILE_MACHINE_AMD64
+  Characteristics: [ IMAGE_FILE_EXECUTABLE_IMAGE, IMAGE_FILE_LINE_NUMS_STRIPPED, IMAGE_FILE_LOCAL_SYMS_STRIPPED, IMAGE_FILE_LARGE_ADDRESS_AWARE, IMAGE_FILE_DEBUG_STRIPPED, IMAGE_FILE_DLL ]
+sections:
+  - Name:            .text
+    Characteristics: [ IMAGE_SCN_CNT_CODE, IMAGE_SCN_MEM_EXECUTE, IMAGE_SCN_MEM_READ ]
+    VirtualAddress:  4096
+    VirtualSize:     32
+    SectionData:     554889E54881EC00000000B801000000E900000000C9C3000104020504030150
+  - Name:            .pdata
+    Characteristics: [ IMAGE_SCN_CNT_INITIALIZED_DATA, IMAGE_SCN_MEM_READ ]
+    VirtualAddress:  8192
+    VirtualSize:     12
+    SectionData:     0B1000001710000018100000
+symbols:         []
+...
+
+# CHECK: FILE MAP:
+# CHECK: 000-188	        392		[PE Headers]
+# CHECK: 188-1d8	         80		[PE Section Headers]
+# CHECK: 1d8-200	         40		[Unmapped]
+# CHECK: 200-400	        512		.text
+# CHECK: 400-600	        512		.pdata
+
+# CHECK: VM MAP:
+# CHECK: 0000-0188	        392		[PE Headers]
+# CHECK: 0188-01d8	         80		[PE Section Headers]
+# CHECK: 01d8-1000	       3624		[-- Nothing mapped --]
+# CHECK: 1000-1020	         32		.text
+# CHECK: 1020-2000	       4064		[-- Nothing mapped --]
+# CHECK: 2000-200c	         12		.pdata
+
diff --git a/tests/PE/sections/empty-pe64-exe.test b/tests/PE/sections/empty-pe64-exe.test
new file mode 100644
index 0000000..15e1f3a
--- /dev/null
+++ b/tests/PE/sections/empty-pe64-exe.test
@@ -0,0 +1,98 @@
+# RUN: %yaml2obj %s -o %t.obj
+# RUN: %bloaty --raw-map %t.obj | %FileCheck %s --dump-input fail
+
+--- !COFF
+OptionalHeader:
+  AddressOfEntryPoint: 4096
+  ImageBase:       4194304
+  SectionAlignment: 4096
+  FileAlignment:   512
+  MajorOperatingSystemVersion: 4
+  MinorOperatingSystemVersion: 0
+  MajorImageVersion: 0
+  MinorImageVersion: 0
+  MajorSubsystemVersion: 4
+  MinorSubsystemVersion: 0
+  Subsystem:       IMAGE_SUBSYSTEM_WINDOWS_CUI
+  DLLCharacteristics: [  ]
+  SizeOfStackReserve: 1048576
+  SizeOfStackCommit: 4096
+  SizeOfHeapReserve: 1048576
+  SizeOfHeapCommit: 4096
+  ExportTable:
+    RelativeVirtualAddress: 0
+    Size:            0
+  ImportTable:
+    RelativeVirtualAddress: 0
+    Size:            0
+  ResourceTable:
+    RelativeVirtualAddress: 0
+    Size:            0
+  ExceptionTable:
+    RelativeVirtualAddress: 8192
+    Size:            12
+  CertificateTable:
+    RelativeVirtualAddress: 0
+    Size:            0
+  BaseRelocationTable:
+    RelativeVirtualAddress: 0
+    Size:            0
+  Debug:
+    RelativeVirtualAddress: 0
+    Size:            0
+  Architecture:
+    RelativeVirtualAddress: 0
+    Size:            0
+  GlobalPtr:
+    RelativeVirtualAddress: 0
+    Size:            0
+  TlsTable:
+    RelativeVirtualAddress: 0
+    Size:            0
+  LoadConfigTable:
+    RelativeVirtualAddress: 0
+    Size:            0
+  BoundImport:
+    RelativeVirtualAddress: 0
+    Size:            0
+  IAT:
+    RelativeVirtualAddress: 0
+    Size:            0
+  DelayImportDescriptor:
+    RelativeVirtualAddress: 0
+    Size:            0
+  ClrRuntimeHeader:
+    RelativeVirtualAddress: 0
+    Size:            0
+header:
+  Machine:         IMAGE_FILE_MACHINE_AMD64
+  Characteristics: [ IMAGE_FILE_RELOCS_STRIPPED, IMAGE_FILE_EXECUTABLE_IMAGE, IMAGE_FILE_LINE_NUMS_STRIPPED, IMAGE_FILE_LOCAL_SYMS_STRIPPED, IMAGE_FILE_LARGE_ADDRESS_AWARE, IMAGE_FILE_DEBUG_STRIPPED ]
+sections:
+  - Name:            .text
+    Characteristics: [ IMAGE_SCN_CNT_CODE, IMAGE_SCN_MEM_EXECUTE, IMAGE_SCN_MEM_READ ]
+    VirtualAddress:  4096
+    VirtualSize:     32
+    SectionData:     554889E54881EC00000000B800000000E900000000C9C3000104020504030150
+  - Name:            .pdata
+    Characteristics: [ IMAGE_SCN_CNT_INITIALIZED_DATA, IMAGE_SCN_MEM_READ ]
+    VirtualAddress:  8192
+    VirtualSize:     12
+    SectionData:     0B1000001710000018100000
+symbols:         []
+...
+
+# CHECK: FILE MAP:
+# CHECK: 000-188	        392		[PE Headers]
+# CHECK: 188-1d8	         80		[PE Section Headers]
+# CHECK: 1d8-200	         40		[Unmapped]
+# CHECK: 200-400	        512		.text
+# CHECK: 400-600	        512		.pdata
+
+# CHECK: VM MAP:
+# CHECK: 0000-0188	        392		[PE Headers]
+# CHECK: 0188-01d8	         80		[PE Section Headers]
+# CHECK: 01d8-1000	       3624		[-- Nothing mapped --]
+# CHECK: 1000-1020	         32		.text
+# CHECK: 1020-2000	       4064		[-- Nothing mapped --]
+# CHECK: 2000-200c	         12		.pdata
+
diff --git a/tests/PE/sections/simple-pe32-dll.test b/tests/PE/sections/simple-pe32-dll.test
new file mode 100644
index 0000000..066ef08
--- /dev/null
+++ b/tests/PE/sections/simple-pe32-dll.test
@@ -0,0 +1,106 @@
+# RUN: %yaml2obj %s -o %t.obj
+# RUN: %bloaty --raw-map %t.obj | %FileCheck %s --dump-input fail
+
+--- !COFF
+OptionalHeader:
+  AddressOfEntryPoint: 4160
+  ImageBase:       268435456
+  SectionAlignment: 4096
+  FileAlignment:   512
+  MajorOperatingSystemVersion: 4
+  MinorOperatingSystemVersion: 0
+  MajorImageVersion: 0
+  MinorImageVersion: 0
+  MajorSubsystemVersion: 4
+  MinorSubsystemVersion: 0
+  Subsystem:       IMAGE_SUBSYSTEM_WINDOWS_GUI
+  DLLCharacteristics: [  ]
+  SizeOfStackReserve: 1048576
+  SizeOfStackCommit: 4096
+  SizeOfHeapReserve: 1048576
+  SizeOfHeapCommit: 4096
+  ExportTable:
+    RelativeVirtualAddress: 8304
+    Size:            366
+  ImportTable:
+    RelativeVirtualAddress: 8224
+    Size:            40
+  ResourceTable:
+    RelativeVirtualAddress: 0
+    Size:            0
+  ExceptionTable:
+    RelativeVirtualAddress: 0
+    Size:            0
+  CertificateTable:
+    RelativeVirtualAddress: 0
+    Size:            0
+  BaseRelocationTable:
+    RelativeVirtualAddress: 12288
+    Size:            16
+  Debug:
+    RelativeVirtualAddress: 0
+    Size:            0
+  Architecture:
+    RelativeVirtualAddress: 0
+    Size:            0
+  GlobalPtr:
+    RelativeVirtualAddress: 0
+    Size:            0
+  TlsTable:
+    RelativeVirtualAddress: 0
+    Size:            0
+  LoadConfigTable:
+    RelativeVirtualAddress: 0
+    Size:            0
+  BoundImport:
+    RelativeVirtualAddress: 0
+    Size:            0
+  IAT:
+    RelativeVirtualAddress: 8264
+    Size:            8
+  DelayImportDescriptor:
+    RelativeVirtualAddress: 0
+    Size:            0
+  ClrRuntimeHeader:
+    RelativeVirtualAddress: 0
+    Size:            0
+header:
+  Machine:         IMAGE_FILE_MACHINE_I386
+  Characteristics: [ IMAGE_FILE_EXECUTABLE_IMAGE, IMAGE_FILE_LINE_NUMS_STRIPPED, IMAGE_FILE_LOCAL_SYMS_STRIPPED, IMAGE_FILE_32BIT_MACHINE, IMAGE_FILE_DEBUG_STRIPPED, IMAGE_FILE_DLL ]
+sections:
+  - Name:            .text
+    Characteristics: [ IMAGE_SCN_CNT_CODE, IMAGE_SCN_MEM_EXECUTE, IMAGE_SCN_MEM_READ ]
+    VirtualAddress:  4096
+    VirtualSize:     160
+    SectionData:     5589E581EC0000000090B80020001050E88300000083C404C9C35589E581EC0000000090B80920001050E86900000083C404B800000000E900000000C9C210005589E581EC04000000908B4510508B450C508B450850E8250000008945FC8B45FCE900000000C9C20C00000000000000000000000000000000000000000000005589E581EC0000000090B801000000E900000000C9C20C00FF25482000100000
+  - Name:            .data
+    Characteristics: [ IMAGE_SCN_CNT_INITIALIZED_DATA, IMAGE_SCN_MEM_READ, IMAGE_SCN_MEM_WRITE ]
+    VirtualAddress:  8192
+    VirtualSize:     480
+    SectionData:     637572696F757321004D61726B204A616E73656E00000000000000000000000050200000000000000000000058200000482000000000000000000000000000000000000000000000632000000000000063200000000000006D73766372742E646C6C00000070757473000000000000000000000000000000000000001A210000010000000D0000000D00000098200000CC20000000210000801000001A1000004010000000300000003000000030000000300000003000000030000020200000E0210000981000000010000027210000332100003F2100004D2100005E210000712100008221000095210000A9210000BF210000C6210000CB210000D221000000000100020003000400050006000700080009000A000B000C00706533325F7374642E646C6C005F446C6C4D61696E403132005F446C6C4D61696E403136005F5F646C6C7374617274403132005F5F66696E695F61727261795F656E64005F5F66696E695F61727261795F7374617274005F5F696E69745F61727261795F656E64005F5F696E69745F61727261795F7374617274005F5F707265696E69745F61727261795F656E64005F5F707265696E69745F61727261795F7374617274005F6564617461005F656E64005F65746578740068656C6C6F5F7468657265000000
+  - Name:            .reloc
+    Characteristics: [ IMAGE_SCN_CNT_INITIALIZED_DATA, IMAGE_SCN_MEM_DISCARDABLE, IMAGE_SCN_MEM_READ ]
+    VirtualAddress:  12288
+    VirtualSize:     16
+    SectionData:     00100000100000000B3025309A300000
+symbols:         []
+...
+
+# CHECK: FILE MAP:
+# CHECK: 000-178	        376		[PE Headers]
+# CHECK: 178-1f0	        120		[PE Section Headers]
+# CHECK: 1f0-200	         16		[Unmapped]
+# CHECK: 200-400	        512		.text
+# CHECK: 400-600	        512		.data
+# CHECK: 600-800	        512		.reloc
+
+# CHECK: VM MAP:
+# CHECK: 0000-0178	        376		[PE Headers]
+# CHECK: 0178-01f0	        120		[PE Section Headers]
+# CHECK: 01f0-1000	       3600		[-- Nothing mapped --]
+# CHECK: 1000-10a0	        160		.text
+# CHECK: 10a0-2000	       3936		[-- Nothing mapped --]
+# CHECK: 2000-21e0	        480		.data
+# CHECK: 21e0-3000	       3616		[-- Nothing mapped --]
+# CHECK: 3000-3010	         16		.reloc
+
diff --git a/tests/PE/sections/simple-pe32-exe.test b/tests/PE/sections/simple-pe32-exe.test
new file mode 100644
index 0000000..40d5c5d
--- /dev/null
+++ b/tests/PE/sections/simple-pe32-exe.test
@@ -0,0 +1,98 @@
+# RUN: %yaml2obj %s -o %t.obj
+# RUN: %bloaty --raw-map %t.obj | %FileCheck %s --dump-input fail
+
+--- !COFF
+OptionalHeader:
+  AddressOfEntryPoint: 4160
+  ImageBase:       4194304
+  SectionAlignment: 4096
+  FileAlignment:   512
+  MajorOperatingSystemVersion: 4
+  MinorOperatingSystemVersion: 0
+  MajorImageVersion: 0
+  MinorImageVersion: 0
+  MajorSubsystemVersion: 4
+  MinorSubsystemVersion: 0
+  Subsystem:       IMAGE_SUBSYSTEM_WINDOWS_CUI
+  DLLCharacteristics: [  ]
+  SizeOfStackReserve: 1048576
+  SizeOfStackCommit: 4096
+  SizeOfHeapReserve: 1048576
+  SizeOfHeapCommit: 4096
+  ExportTable:
+    RelativeVirtualAddress: 0
+    Size:            0
+  ImportTable:
+    RelativeVirtualAddress: 8224
+    Size:            40
+  ResourceTable:
+    RelativeVirtualAddress: 0
+    Size:            0
+  ExceptionTable:
+    RelativeVirtualAddress: 0
+    Size:            0
+  CertificateTable:
+    RelativeVirtualAddress: 0
+    Size:            0
+  BaseRelocationTable:
+    RelativeVirtualAddress: 0
+    Size:            0
+  Debug:
+    RelativeVirtualAddress: 0
+    Size:            0
+  Architecture:
+    RelativeVirtualAddress: 0
+    Size:            0
+  GlobalPtr:
+    RelativeVirtualAddress: 0
+    Size:            0
+  TlsTable:
+    RelativeVirtualAddress: 0
+    Size:            0
+  LoadConfigTable:
+    RelativeVirtualAddress: 0
+    Size:            0
+  BoundImport:
+    RelativeVirtualAddress: 0
+    Size:            0
+  IAT:
+    RelativeVirtualAddress: 8264
+    Size:            36
+  DelayImportDescriptor:
+    RelativeVirtualAddress: 0
+    Size:            0
+  ClrRuntimeHeader:
+    RelativeVirtualAddress: 0
+    Size:            0
+header:
+  Machine:         IMAGE_FILE_MACHINE_I386
+  Characteristics: [ IMAGE_FILE_RELOCS_STRIPPED, IMAGE_FILE_EXECUTABLE_IMAGE, IMAGE_FILE_LINE_NUMS_STRIPPED, IMAGE_FILE_LOCAL_SYMS_STRIPPED, IMAGE_FILE_32BIT_MACHINE, IMAGE_FILE_DEBUG_STRIPPED ]
+sections:
+  - Name:            .text
+    Characteristics: [ IMAGE_SCN_CNT_CODE, IMAGE_SCN_MEM_EXECUTE, IMAGE_SCN_MEM_READ ]
+    VirtualAddress:  4096
+    VirtualSize:     464
+    SectionData:     5589E581EC0000000090B80020400050E87B01000083C404B800000000E900000000C9C3000000000000000000000000000000000000000000000000000000005589E581EC2C000000908D45E850E8FE00000083C404B8000000008945D4B80000030050B80000010050E82901000083C408B80100000050E82301000083C4048D45D450B800000000508D45DC508D45E0508D45E450E80D01000083C4148B45DC508B45E0508B45E450E851FFFFFF83C40C8945D88B45D850E8F200000083C404C9C30000000000000000000000000000000000000000000000000000000000872C24558D6C24045189E981E90010000085012D001000003D001000007DEC29C1850189E089CC8B08FF60048B45ECC3E8F7FFFFFF8B008B00C3E8EDFFFFFF50E8EBFFFFFF50E88D00000081C408000000C38B65E8E8D6FFFFFF50E880000000FFFFFFFF1A11400032114000E977000000558B6C24088D44240C89450031C089450464A100000000894508B84C11400089450CB84011400089451031C08945148D450864A3000000005DC30000000000FF25482040000000FF254C2040000000FF25502040000000FF25542040000000FF25582040000000FF255C2040000000FF25602040000000FF25642040000000
+  - Name:            .data
+    Characteristics: [ IMAGE_SCN_CNT_INITIALIZED_DATA, IMAGE_SCN_MEM_READ, IMAGE_SCN_MEM_WRITE ]
+    VirtualAddress:  8192
+    VirtualSize:     256
+    SectionData:     4D61726B204A616E73656E0000000000000000000000000000000000000000006C2000000000000000000000902000004820000000000000000000000000000000000000000000009B200000A2200000AF200000C0200000D0200000D7200000E5200000ED200000000000009B200000A2200000AF200000C0200000D0200000D7200000E5200000ED200000000000006D73766372742E646C6C000000707574730000005F636F6E74726F6C66700000005F5F7365745F6170705F747970650000005F5F6765746D61696E61726773000000657869740000005F5863707446696C7465720000005F657869740000005F6578636570745F68616E646C65723300
+symbols:         []
+...
+
+# CHECK: FILE MAP:
+# CHECK: 000-178	        376		[PE Headers]
+# CHECK: 178-1c8	         80		[PE Section Headers]
+# CHECK: 1c8-200	         56		[Unmapped]
+# CHECK: 200-400	        512		.text
+# CHECK: 400-600	        512		.data
+
+# CHECK: VM MAP:
+# CHECK: 0000-0178	        376		[PE Headers]
+# CHECK: 0178-01c8	         80		[PE Section Headers]
+# CHECK: 01c8-1000	       3640		[-- Nothing mapped --]
+# CHECK: 1000-11d0	        464		.text
+# CHECK: 11d0-2000	       3632		[-- Nothing mapped --]
+# CHECK: 2000-2100	        256		.data
+
diff --git a/tests/PE/sections/simple-pe64-dll.test b/tests/PE/sections/simple-pe64-dll.test
new file mode 100644
index 0000000..7533ab0
--- /dev/null
+++ b/tests/PE/sections/simple-pe64-dll.test
@@ -0,0 +1,105 @@
+# RUN: %yaml2obj %s -o %t.obj
+# RUN: %bloaty --raw-map %t.obj | %FileCheck %s --dump-input fail
+
+--- !COFF
+OptionalHeader:
+  AddressOfEntryPoint: 4192
+  ImageBase:       268435456
+  SectionAlignment: 4096
+  FileAlignment:   512
+  MajorOperatingSystemVersion: 4
+  MinorOperatingSystemVersion: 0
+  MajorImageVersion: 0
+  MinorImageVersion: 0
+  MajorSubsystemVersion: 4
+  MinorSubsystemVersion: 0
+  Subsystem:       IMAGE_SUBSYSTEM_WINDOWS_GUI
+  DLLCharacteristics: [  ]
+  SizeOfStackReserve: 1048576
+  SizeOfStackCommit: 4096
+  SizeOfHeapReserve: 1048576
+  SizeOfHeapCommit: 4096
+  ExportTable:
+    RelativeVirtualAddress: 8320
+    Size:            336
+  ImportTable:
+    RelativeVirtualAddress: 8224
+    Size:            40
+  ResourceTable:
+    RelativeVirtualAddress: 0
+    Size:            0
+  ExceptionTable:
+    RelativeVirtualAddress: 12288
+    Size:            36
+  CertificateTable:
+    RelativeVirtualAddress: 0
+    Size:            0
+  BaseRelocationTable:
+    RelativeVirtualAddress: 0
+    Size:            0
+  Debug:
+    RelativeVirtualAddress: 0
+    Size:            0
+  Architecture:
+    RelativeVirtualAddress: 0
+    Size:            0
+  GlobalPtr:
+    RelativeVirtualAddress: 0
+    Size:            0
+  TlsTable:
+    RelativeVirtualAddress: 0
+    Size:            0
+  LoadConfigTable:
+    RelativeVirtualAddress: 0
+    Size:            0
+  BoundImport:
+    RelativeVirtualAddress: 0
+    Size:            0
+  IAT:
+    RelativeVirtualAddress: 8264
+    Size:            16
+  DelayImportDescriptor:
+    RelativeVirtualAddress: 0
+    Size:            0
+  ClrRuntimeHeader:
+    RelativeVirtualAddress: 0
+    Size:            0
+header:
+  Machine:         IMAGE_FILE_MACHINE_AMD64
+  Characteristics: [ IMAGE_FILE_EXECUTABLE_IMAGE, IMAGE_FILE_LINE_NUMS_STRIPPED, IMAGE_FILE_LOCAL_SYMS_STRIPPED, IMAGE_FILE_LARGE_ADDRESS_AWARE, IMAGE_FILE_DEBUG_STRIPPED, IMAGE_FILE_DLL ]
+sections:
+  - Name:            .text
+    Characteristics: [ IMAGE_SCN_CNT_CODE, IMAGE_SCN_MEM_EXECUTE, IMAGE_SCN_MEM_READ ]
+    VirtualAddress:  4096
+    VirtualSize:     168
+    SectionData:     554889E54881EC20000000488D0DEE0F0000E889000000C9C30000000104020504030150554889E54881EC2000000048894D10488955184C8945204C894D28488D0DC30F0000E855000000B800000000E900000000C9C3000000000000000000554889E54881EC3000000048894D10488955184C894520488B45204989C08B5518488B4D10E89AFFFFFF8945FC8B45FCE900000000C9C3000104020504030150FF25A20F00000000
+  - Name:            .data
+    Characteristics: [ IMAGE_SCN_CNT_INITIALIZED_DATA, IMAGE_SCN_MEM_READ, IMAGE_SCN_MEM_WRITE ]
+    VirtualAddress:  8192
+    VirtualSize:     480
+    SectionData:     637572696F757321004D61726B204A616E73656E0000000000000000000000005820000000000000000000006820000048200000000000000000000000000000000000000000000073200000000000000000000000000000732000000000000000000000000000006D73766372742E646C6C000000707574730000000000000000000000000000000000000020210000010000000C0000000C000000A8200000D820000008210000241000000040000000400000004000000040000000400000004000006010000020200000E0210000A0100000001000002D2100003521000046210000592100006A2100007D21000091210000A7210000B1210000B8210000BD210000C421000000000100020003000400050006000700080009000A000B00706536345F7374642E646C6C00446C6C4D61696E005F5F66696E695F61727261795F656E64005F5F66696E695F61727261795F7374617274005F5F696E69745F61727261795F656E64005F5F696E69745F61727261795F7374617274005F5F707265696E69745F61727261795F656E64005F5F707265696E69745F61727261795F7374617274005F646C6C7374617274005F6564617461005F656E64005F65746578740068656C6C6F5F74686572650000000000000000000000000000000000
+  - Name:            .pdata
+    Characteristics: [ IMAGE_SCN_CNT_INITIALIZED_DATA, IMAGE_SCN_MEM_READ ]
+    VirtualAddress:  12288
+    VirtualSize:     36
+    SectionData:     0B100000191000001C1000002F100000571000001C1000006B1000009710000098100000
+symbols:         []
+...
+
+# CHECK: FILE MAP:
+# CHECK: 000-188	        392		[PE Headers]
+# CHECK: 188-200	        120		[PE Section Headers]
+# CHECK: 200-400	        512		.text
+# CHECK: 400-600	        512		.data
+# CHECK: 600-800	        512		.pdata
+
+# CHECK: VM MAP:
+# CHECK: 0000-0188	        392		[PE Headers]
+# CHECK: 0188-0200	        120		[PE Section Headers]
+# CHECK: 0200-1000	       3584		[-- Nothing mapped --]
+# CHECK: 1000-10a8	        168		.text
+# CHECK: 10a8-2000	       3928		[-- Nothing mapped --]
+# CHECK: 2000-21e0	        480		.data
+# CHECK: 21e0-3000	       3616		[-- Nothing mapped --]
+# CHECK: 3000-3024	         36		.pdata
+
diff --git a/tests/PE/sections/simple-pe64-exe.test b/tests/PE/sections/simple-pe64-exe.test
new file mode 100644
index 0000000..f44c9bb
--- /dev/null
+++ b/tests/PE/sections/simple-pe64-exe.test
@@ -0,0 +1,105 @@
+# RUN: %yaml2obj %s -o %t.obj
+# RUN: %bloaty --raw-map %t.obj | %FileCheck %s --dump-input fail
+
+--- !COFF
+OptionalHeader:
+  AddressOfEntryPoint: 4160
+  ImageBase:       4194304
+  SectionAlignment: 4096
+  FileAlignment:   512
+  MajorOperatingSystemVersion: 4
+  MinorOperatingSystemVersion: 0
+  MajorImageVersion: 0
+  MinorImageVersion: 0
+  MajorSubsystemVersion: 4
+  MinorSubsystemVersion: 0
+  Subsystem:       IMAGE_SUBSYSTEM_WINDOWS_CUI
+  DLLCharacteristics: [  ]
+  SizeOfStackReserve: 1048576
+  SizeOfStackCommit: 4096
+  SizeOfHeapReserve: 1048576
+  SizeOfHeapCommit: 4096
+  ExportTable:
+    RelativeVirtualAddress: 0
+    Size:            0
+  ImportTable:
+    RelativeVirtualAddress: 8224
+    Size:            40
+  ResourceTable:
+    RelativeVirtualAddress: 0
+    Size:            0
+  ExceptionTable:
+    RelativeVirtualAddress: 12288
+    Size:            24
+  CertificateTable:
+    RelativeVirtualAddress: 0
+    Size:            0
+  BaseRelocationTable:
+    RelativeVirtualAddress: 0
+    Size:            0
+  Debug:
+    RelativeVirtualAddress: 0
+    Size:            0
+  Architecture:
+    RelativeVirtualAddress: 0
+    Size:            0
+  GlobalPtr:
+    RelativeVirtualAddress: 0
+    Size:            0
+  TlsTable:
+    RelativeVirtualAddress: 0
+    Size:            0
+  LoadConfigTable:
+    RelativeVirtualAddress: 0
+    Size:            0
+  BoundImport:
+    RelativeVirtualAddress: 0
+    Size:            0
+  IAT:
+    RelativeVirtualAddress: 8264
+    Size:            48
+  DelayImportDescriptor:
+    RelativeVirtualAddress: 0
+    Size:            0
+  ClrRuntimeHeader:
+    RelativeVirtualAddress: 0
+    Size:            0
+header:
+  Machine:         IMAGE_FILE_MACHINE_AMD64
+  Characteristics: [ IMAGE_FILE_RELOCS_STRIPPED, IMAGE_FILE_EXECUTABLE_IMAGE, IMAGE_FILE_LINE_NUMS_STRIPPED, IMAGE_FILE_LOCAL_SYMS_STRIPPED, IMAGE_FILE_LARGE_ADDRESS_AWARE, IMAGE_FILE_DEBUG_STRIPPED ]
+sections:
+  - Name:            .text
+    Characteristics: [ IMAGE_SCN_CNT_CODE, IMAGE_SCN_MEM_EXECUTE, IMAGE_SCN_MEM_READ ]
+    VirtualAddress:  4096
+    VirtualSize:     232
+    SectionData:     554889E54881EC20000000488D0DEE0F0000E8A9000000B800000000E900000000C9C30001040205040301500000000000000000000000000000000000000000554889E54881EC50000000B8000000008945E0BA00000300B900000100E866000000B901000000E864000000488D45E04889442420B8000000004989C1488D45E84989C0488D55F0488D4DFCE847000000488B45E84989C0488B55F08B4DFCE85CFFFFFF8945E48B4DE4E831000000C9C3000000010402050403015000000000FF25820F00000000FF25820F00000000FF25820F00000000FF25820F00000000FF25820F00000000
+  - Name:            .data
+    Characteristics: [ IMAGE_SCN_CNT_INITIALIZED_DATA, IMAGE_SCN_MEM_READ, IMAGE_SCN_MEM_WRITE ]
+    VirtualAddress:  8192
+    VirtualSize:     256
+    SectionData:     4D61726B204A616E73656E000000000000000000000000000000000000000000782000000000000000000000A8200000482000000000000000000000000000000000000000000000B320000000000000BA20000000000000C720000000000000D820000000000000E8200000000000000000000000000000B320000000000000BA20000000000000C720000000000000D820000000000000E82000000000000000000000000000006D73766372742E646C6C000000707574730000005F636F6E74726F6C66700000005F5F7365745F6170705F747970650000005F5F6765746D61696E6172677300000065786974000000000000000000000000000000000000
+  - Name:            .pdata
+    Characteristics: [ IMAGE_SCN_CNT_INITIALIZED_DATA, IMAGE_SCN_MEM_READ ]
+    VirtualAddress:  12288
+    VirtualSize:     24
+    SectionData:     0B10000023100000241000004B100000B1100000B4100000
+symbols:         []
+...
+
+# CHECK: FILE MAP:
+# CHECK: 000-188	        392		[PE Headers]
+# CHECK: 188-200	        120		[PE Section Headers]
+# CHECK: 200-400	        512		.text
+# CHECK: 400-600	        512		.data
+# CHECK: 600-800	        512		.pdata
+
+# CHECK: VM MAP:
+# CHECK: 0000-0188	        392		[PE Headers]
+# CHECK: 0188-0200	        120		[PE Section Headers]
+# CHECK: 0200-1000	       3584		[-- Nothing mapped --]
+# CHECK: 1000-10e8	        232		.text
+# CHECK: 10e8-2000	       3864		[-- Nothing mapped --]
+# CHECK: 2000-2100	        256		.data
+# CHECK: 2100-3000	       3840		[-- Nothing mapped --]
+# CHECK: 3000-3018	         24		.pdata
+
diff --git a/third_party/lief_pe/METADATA b/third_party/lief_pe/METADATA
index f0cd410..85e6cab 100644
--- a/third_party/lief_pe/METADATA
+++ b/third_party/lief_pe/METADATA
@@ -2,7 +2,7 @@
 description:
     "This contains structures as defined by the LIEF project to parse PE headers."
     "They only contain struct and constant definitions (no code) and their"
-    "contents are almost entirely derivable from the ELF standard."
+    "contents are almost entirely derivable from the PE standard."
 
 third_party {
   url {
@@ -21,5 +21,6 @@
   }
   local_modifications:
       "Renamed include/LIEF/PE/structures.inc to third_party/lief_pe/pe_structures.h"
+      "Manually extracted some enums from include/LIEF/PE/enums.hpp.in to third_party/lief_pe/pe_enums.h"
       "Added license header to the file."
 }
diff --git a/third_party/lief_pe/pe_enums.h b/third_party/lief_pe/pe_enums.h
new file mode 100644
index 0000000..0c26897
--- /dev/null
+++ b/third_party/lief_pe/pe_enums.h
@@ -0,0 +1,36 @@
+/* Copyright 2017 - 2021 R. Thomas
+ * Copyright 2017 - 2021 Quarkslab
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+enum class PE_SECTION_TYPES : uint8_t {
+  TEXT       = 0,
+  TLS        = 1,
+  IMPORT     = 2,
+  DATA       = 3,
+  BSS        = 4,
+  RESOURCE   = 5,
+  RELOCATION = 6,
+  EXPORT     = 7,
+  DEBUG      = 8,
+  LOAD_CONFIG = 9,
+  UNKNOWN     = 10
+};
+
+enum class PE_TYPE : uint16_t {
+    PE32      = 0x10b, ///< 32bits
+    PE32_PLUS = 0x20b  ///< 64 bits
+};
+