LLDB  mainline
ObjectFilePECOFF.cpp
Go to the documentation of this file.
1 //===-- ObjectFilePECOFF.cpp ----------------------------------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
9 #include "ObjectFilePECOFF.h"
10 #include "PECallFrameInfo.h"
11 #include "WindowsMiniDump.h"
12 
13 #include "lldb/Core/FileSpecList.h"
14 #include "lldb/Core/Module.h"
15 #include "lldb/Core/ModuleSpec.h"
17 #include "lldb/Core/Section.h"
18 #include "lldb/Core/StreamFile.h"
21 #include "lldb/Symbol/ObjectFile.h"
22 #include "lldb/Target/Process.h"
24 #include "lldb/Target/Target.h"
25 #include "lldb/Utility/ArchSpec.h"
27 #include "lldb/Utility/FileSpec.h"
28 #include "lldb/Utility/LLDBLog.h"
29 #include "lldb/Utility/Log.h"
31 #include "lldb/Utility/Timer.h"
32 #include "lldb/Utility/UUID.h"
33 
34 #include "llvm/BinaryFormat/COFF.h"
35 #include "llvm/Object/COFFImportFile.h"
36 #include "llvm/Support/CRC.h"
37 #include "llvm/Support/Error.h"
38 #include "llvm/Support/FormatAdapters.h"
39 #include "llvm/Support/Host.h"
40 #include "llvm/Support/MemoryBuffer.h"
41 
42 #define IMAGE_DOS_SIGNATURE 0x5A4D // MZ
43 #define IMAGE_NT_SIGNATURE 0x00004550 // PE00
44 #define OPT_HEADER_MAGIC_PE32 0x010b
45 #define OPT_HEADER_MAGIC_PE32_PLUS 0x020b
46 
47 using namespace lldb;
48 using namespace lldb_private;
49 
51 
52 namespace {
53 
54 static constexpr OptionEnumValueElement g_abi_enums[] = {
55  {
56  llvm::Triple::UnknownEnvironment,
57  "default",
58  "Use default target (if it is Windows) or MSVC",
59  },
60  {
61  llvm::Triple::MSVC,
62  "msvc",
63  "MSVC ABI",
64  },
65  {
66  llvm::Triple::GNU,
67  "gnu",
68  "MinGW / Itanium ABI",
69  },
70 };
71 
72 #define LLDB_PROPERTIES_objectfilepecoff
73 #include "ObjectFilePECOFFProperties.inc"
74 
75 enum {
76 #define LLDB_PROPERTIES_objectfilepecoff
77 #include "ObjectFilePECOFFPropertiesEnum.inc"
78 };
79 
80 class PluginProperties : public Properties {
81 public:
82  static ConstString GetSettingName() {
84  }
85 
86  PluginProperties() {
87  m_collection_sp = std::make_shared<OptionValueProperties>(GetSettingName());
88  m_collection_sp->Initialize(g_objectfilepecoff_properties);
89  }
90 
91  llvm::Triple::EnvironmentType ABI() const {
92  return (llvm::Triple::EnvironmentType)
93  m_collection_sp->GetPropertyAtIndexAsEnumeration(
94  nullptr, ePropertyABI, llvm::Triple::UnknownEnvironment);
95  }
96 
97  OptionValueDictionary *ModuleABIMap() const {
98  return m_collection_sp->GetPropertyAtIndexAsOptionValueDictionary(
99  nullptr, ePropertyModuleABIMap);
100  }
101 };
102 
103 static PluginProperties &GetGlobalPluginProperties() {
104  static PluginProperties g_settings;
105  return g_settings;
106 }
107 
108 } // namespace
109 
110 static bool GetDebugLinkContents(const llvm::object::COFFObjectFile &coff_obj,
111  std::string &gnu_debuglink_file,
112  uint32_t &gnu_debuglink_crc) {
113  static ConstString g_sect_name_gnu_debuglink(".gnu_debuglink");
114  for (const auto &section : coff_obj.sections()) {
115  auto name = section.getName();
116  if (!name) {
117  llvm::consumeError(name.takeError());
118  continue;
119  }
120  if (*name == g_sect_name_gnu_debuglink.GetStringRef()) {
121  auto content = section.getContents();
122  if (!content) {
123  llvm::consumeError(content.takeError());
124  return false;
125  }
126  DataExtractor data(
127  content->data(), content->size(),
128  coff_obj.isLittleEndian() ? eByteOrderLittle : eByteOrderBig, 4);
129  lldb::offset_t gnu_debuglink_offset = 0;
130  gnu_debuglink_file = data.GetCStr(&gnu_debuglink_offset);
131  // Align to the next 4-byte offset
132  gnu_debuglink_offset = llvm::alignTo(gnu_debuglink_offset, 4);
133  data.GetU32(&gnu_debuglink_offset, &gnu_debuglink_crc, 1);
134  return true;
135  }
136  }
137  return false;
138 }
139 
140 static UUID GetCoffUUID(llvm::object::COFFObjectFile &coff_obj) {
141  const llvm::codeview::DebugInfo *pdb_info = nullptr;
142  llvm::StringRef pdb_file;
143 
144  // First, prefer to use the PDB build id. LLD generates this even for mingw
145  // targets without PDB output, and it does not get stripped either.
146  if (!coff_obj.getDebugPDBInfo(pdb_info, pdb_file) && pdb_info) {
147  if (pdb_info->PDB70.CVSignature == llvm::OMF::Signature::PDB70) {
148  UUID::CvRecordPdb70 info;
149  memcpy(&info.Uuid, pdb_info->PDB70.Signature, sizeof(info.Uuid));
150  info.Age = pdb_info->PDB70.Age;
151  return UUID(info);
152  }
153  }
154 
155  std::string gnu_debuglink_file;
156  uint32_t gnu_debuglink_crc;
157 
158  // The GNU linker normally does not write a PDB build id (unless requested
159  // with the --build-id option), so we should fall back to using the crc
160  // from .gnu_debuglink if it exists, just like how ObjectFileELF does it.
161  if (!GetDebugLinkContents(coff_obj, gnu_debuglink_file, gnu_debuglink_crc)) {
162  // If there is no .gnu_debuglink section, then this may be an object
163  // containing DWARF debug info for .gnu_debuglink, so calculate the crc of
164  // the object itself.
165  auto raw_data = coff_obj.getData();
167  "Calculating module crc32 %s with size %" PRIu64 " KiB",
168  FileSpec(coff_obj.getFileName()).GetLastPathComponent().AsCString(),
169  static_cast<lldb::offset_t>(raw_data.size()) / 1024);
170  gnu_debuglink_crc = llvm::crc32(0, llvm::arrayRefFromStringRef(raw_data));
171  }
172  // Use 4 bytes of crc from the .gnu_debuglink section.
173  llvm::support::ulittle32_t data(gnu_debuglink_crc);
174  return UUID(&data, sizeof(data));
175 }
176 
178 
180  PluginManager::RegisterPlugin(GetPluginNameStatic(),
181  GetPluginDescriptionStatic(), CreateInstance,
182  CreateMemoryInstance, GetModuleSpecifications,
183  SaveCore, DebuggerInitialize);
184 }
185 
187  if (!PluginManager::GetSettingForObjectFilePlugin(
188  debugger, PluginProperties::GetSettingName())) {
189  const bool is_global_setting = true;
190  PluginManager::CreateSettingForObjectFilePlugin(
191  debugger, GetGlobalPluginProperties().GetValueProperties(),
192  ConstString("Properties for the PE/COFF object-file plug-in."),
193  is_global_setting);
194  }
195 }
196 
198  PluginManager::UnregisterPlugin(CreateInstance);
199 }
200 
202  return "Portable Executable and Common Object File Format object file reader "
203  "(32 and 64 bit)";
204 }
205 
207  const lldb::ModuleSP &module_sp, DataBufferSP data_sp,
208  lldb::offset_t data_offset, const lldb_private::FileSpec *file_p,
209  lldb::offset_t file_offset, lldb::offset_t length) {
210  FileSpec file = file_p ? *file_p : FileSpec();
211  if (!data_sp) {
212  data_sp = MapFileData(file, length, file_offset);
213  if (!data_sp)
214  return nullptr;
215  data_offset = 0;
216  }
217 
218  if (!ObjectFilePECOFF::MagicBytesMatch(data_sp))
219  return nullptr;
220 
221  // Update the data to contain the entire file if it doesn't already
222  if (data_sp->GetByteSize() < length) {
223  data_sp = MapFileData(file, length, file_offset);
224  if (!data_sp)
225  return nullptr;
226  }
227 
228  auto objfile_up = std::make_unique<ObjectFilePECOFF>(
229  module_sp, data_sp, data_offset, file_p, file_offset, length);
230  if (!objfile_up || !objfile_up->ParseHeader())
231  return nullptr;
232 
233  // Cache coff binary.
234  if (!objfile_up->CreateBinary())
235  return nullptr;
236  return objfile_up.release();
237 }
238 
240  const lldb::ModuleSP &module_sp, lldb::WritableDataBufferSP data_sp,
241  const lldb::ProcessSP &process_sp, lldb::addr_t header_addr) {
242  if (!data_sp || !ObjectFilePECOFF::MagicBytesMatch(data_sp))
243  return nullptr;
244  auto objfile_up = std::make_unique<ObjectFilePECOFF>(
245  module_sp, data_sp, process_sp, header_addr);
246  if (objfile_up.get() && objfile_up->ParseHeader()) {
247  return objfile_up.release();
248  }
249  return nullptr;
250 }
251 
253  const lldb_private::FileSpec &file, lldb::DataBufferSP &data_sp,
254  lldb::offset_t data_offset, lldb::offset_t file_offset,
256  const size_t initial_count = specs.GetSize();
257  if (!data_sp || !ObjectFilePECOFF::MagicBytesMatch(data_sp))
258  return initial_count;
259 
260  Log *log = GetLog(LLDBLog::Object);
261 
262  if (data_sp->GetByteSize() < length)
263  if (DataBufferSP full_sp = MapFileData(file, -1, file_offset))
264  data_sp = std::move(full_sp);
265  auto binary = llvm::object::createBinary(llvm::MemoryBufferRef(
266  toStringRef(data_sp->GetData()), file.GetFilename().GetStringRef()));
267 
268  if (!binary) {
269  LLDB_LOG_ERROR(log, binary.takeError(),
270  "Failed to create binary for file ({1}): {0}", file);
271  return initial_count;
272  }
273 
274  auto *COFFObj = llvm::dyn_cast<llvm::object::COFFObjectFile>(binary->get());
275  if (!COFFObj)
276  return initial_count;
277 
278  ModuleSpec module_spec(file);
279  ArchSpec &spec = module_spec.GetArchitecture();
280  lldb_private::UUID &uuid = module_spec.GetUUID();
281  if (!uuid.IsValid())
282  uuid = GetCoffUUID(*COFFObj);
283 
284  static llvm::Triple::EnvironmentType default_env = [] {
285  auto def_target = llvm::Triple(
286  llvm::Triple::normalize(llvm::sys::getDefaultTargetTriple()));
287  if (def_target.getOS() == llvm::Triple::Win32 &&
288  def_target.getEnvironment() != llvm::Triple::UnknownEnvironment)
289  return def_target.getEnvironment();
290  return llvm::Triple::MSVC;
291  }();
292 
293  // Check for a module-specific override.
294  OptionValueSP module_env_option;
295  const auto *map = GetGlobalPluginProperties().ModuleABIMap();
296  if (map->GetNumValues() > 0) {
297  // Step 1: Try with the exact file name.
298  auto name = file.GetLastPathComponent();
299  module_env_option = map->GetValueForKey(name);
300  if (!module_env_option) {
301  // Step 2: Try with the file name in lowercase.
302  auto name_lower = name.GetStringRef().lower();
303  module_env_option =
304  map->GetValueForKey(ConstString(llvm::StringRef(name_lower)));
305  }
306  if (!module_env_option) {
307  // Step 3: Try with the file name with ".debug" suffix stripped.
308  auto name_stripped = name.GetStringRef();
309  if (name_stripped.consume_back_insensitive(".debug")) {
310  module_env_option = map->GetValueForKey(ConstString(name_stripped));
311  if (!module_env_option) {
312  // Step 4: Try with the file name in lowercase with ".debug" suffix
313  // stripped.
314  auto name_lower = name_stripped.lower();
315  module_env_option =
316  map->GetValueForKey(ConstString(llvm::StringRef(name_lower)));
317  }
318  }
319  }
320  }
321  llvm::Triple::EnvironmentType env;
322  if (module_env_option)
323  env =
324  (llvm::Triple::EnvironmentType)module_env_option->GetEnumerationValue();
325  else
326  env = GetGlobalPluginProperties().ABI();
327 
328  if (env == llvm::Triple::UnknownEnvironment)
329  env = default_env;
330 
331  switch (COFFObj->getMachine()) {
332  case MachineAmd64:
333  spec.SetTriple("x86_64-pc-windows");
334  spec.GetTriple().setEnvironment(env);
335  specs.Append(module_spec);
336  break;
337  case MachineX86:
338  spec.SetTriple("i386-pc-windows");
339  spec.GetTriple().setEnvironment(env);
340  specs.Append(module_spec);
341  break;
342  case MachineArmNt:
343  spec.SetTriple("armv7-pc-windows");
344  spec.GetTriple().setEnvironment(env);
345  specs.Append(module_spec);
346  break;
347  case MachineArm64:
348  spec.SetTriple("aarch64-pc-windows");
349  spec.GetTriple().setEnvironment(env);
350  specs.Append(module_spec);
351  break;
352  default:
353  break;
354  }
355 
356  return specs.GetSize() - initial_count;
357 }
358 
359 bool ObjectFilePECOFF::SaveCore(const lldb::ProcessSP &process_sp,
360  const lldb_private::FileSpec &outfile,
361  lldb::SaveCoreStyle &core_style,
363  core_style = eSaveCoreFull;
364  return SaveMiniDump(process_sp, outfile, error);
365 }
366 
367 bool ObjectFilePECOFF::MagicBytesMatch(DataBufferSP data_sp) {
368  DataExtractor data(data_sp, eByteOrderLittle, 4);
369  lldb::offset_t offset = 0;
370  uint16_t magic = data.GetU16(&offset);
371  return magic == IMAGE_DOS_SIGNATURE;
372 }
373 
375  // TODO: We need to complete this mapping of COFF symbol types to LLDB ones.
376  // For now, here's a hack to make sure our function have types.
377  const auto complex_type =
378  coff_symbol_type >> llvm::COFF::SCT_COMPLEX_TYPE_SHIFT;
379  if (complex_type == llvm::COFF::IMAGE_SYM_DTYPE_FUNCTION) {
380  return lldb::eSymbolTypeCode;
381  }
382  const auto base_type = coff_symbol_type & 0xff;
383  if (base_type == llvm::COFF::IMAGE_SYM_TYPE_NULL &&
384  complex_type == llvm::COFF::IMAGE_SYM_DTYPE_NULL) {
385  // Unknown type. LLD and GNU ld uses this for variables on MinGW, so
386  // consider these symbols to be data to enable printing.
387  return lldb::eSymbolTypeData;
388  }
390 }
391 
393  if (m_binary)
394  return true;
395 
396  Log *log = GetLog(LLDBLog::Object);
397 
398  auto binary = llvm::object::createBinary(llvm::MemoryBufferRef(
399  toStringRef(m_data.GetData()), m_file.GetFilename().GetStringRef()));
400  if (!binary) {
401  LLDB_LOG_ERROR(log, binary.takeError(),
402  "Failed to create binary for file ({1}): {0}", m_file);
403  return false;
404  }
405 
406  // Make sure we only handle COFF format.
407  m_binary =
408  llvm::unique_dyn_cast<llvm::object::COFFObjectFile>(std::move(*binary));
409  if (!m_binary)
410  return false;
411 
412  LLDB_LOG(log, "this = {0}, module = {1} ({2}), file = {3}, binary = {4}",
413  this, GetModule().get(), GetModule()->GetSpecificationDescription(),
414  m_file.GetPath(), m_binary.get());
415  return true;
416 }
417 
418 ObjectFilePECOFF::ObjectFilePECOFF(const lldb::ModuleSP &module_sp,
419  DataBufferSP data_sp,
420  lldb::offset_t data_offset,
421  const FileSpec *file,
422  lldb::offset_t file_offset,
423  lldb::offset_t length)
424  : ObjectFile(module_sp, file, file_offset, length, data_sp, data_offset),
425  m_dos_header(), m_coff_header(), m_coff_header_opt(), m_sect_headers(),
426  m_image_base(LLDB_INVALID_ADDRESS), m_entry_point_address(),
427  m_deps_filespec() {}
428 
429 ObjectFilePECOFF::ObjectFilePECOFF(const lldb::ModuleSP &module_sp,
430  WritableDataBufferSP header_data_sp,
431  const lldb::ProcessSP &process_sp,
432  addr_t header_addr)
433  : ObjectFile(module_sp, process_sp, header_addr, header_data_sp),
434  m_dos_header(), m_coff_header(), m_coff_header_opt(), m_sect_headers(),
435  m_image_base(LLDB_INVALID_ADDRESS), m_entry_point_address(),
436  m_deps_filespec() {}
437 
439 
441  ModuleSP module_sp(GetModule());
442  if (module_sp) {
443  std::lock_guard<std::recursive_mutex> guard(module_sp->GetMutex());
444  m_sect_headers.clear();
446  lldb::offset_t offset = 0;
447 
449  offset = m_dos_header.e_lfanew;
450  uint32_t pe_signature = m_data.GetU32(&offset);
451  if (pe_signature != IMAGE_NT_SIGNATURE)
452  return false;
453  if (ParseCOFFHeader(m_data, &offset, m_coff_header)) {
454  if (m_coff_header.hdrsize > 0)
455  ParseCOFFOptionalHeader(&offset);
456  ParseSectionHeaders(offset);
457  }
459  return true;
460  }
461  }
462  return false;
463 }
464 
466  bool value_is_offset) {
467  bool changed = false;
468  ModuleSP module_sp = GetModule();
469  if (module_sp) {
470  size_t num_loaded_sections = 0;
471  SectionList *section_list = GetSectionList();
472  if (section_list) {
473  if (!value_is_offset) {
474  value -= m_image_base;
475  }
476 
477  const size_t num_sections = section_list->GetSize();
478  size_t sect_idx = 0;
479 
480  for (sect_idx = 0; sect_idx < num_sections; ++sect_idx) {
481  // Iterate through the object file sections to find all of the sections
482  // that have SHF_ALLOC in their flag bits.
483  SectionSP section_sp(section_list->GetSectionAtIndex(sect_idx));
484  if (section_sp && !section_sp->IsThreadSpecific()) {
486  section_sp, section_sp->GetFileAddress() + value))
487  ++num_loaded_sections;
488  }
489  }
490  changed = num_loaded_sections > 0;
491  }
492  }
493  return changed;
494 }
495 
497 
499  return (m_coff_header.flags & llvm::COFF::IMAGE_FILE_DLL) == 0;
500 }
501 
504  return 8;
506  return 4;
507  return 4;
508 }
509 
510 // NeedsEndianSwap
511 //
512 // Return true if an endian swap needs to occur when extracting data from this
513 // file.
515 #if defined(__LITTLE_ENDIAN__)
516  return false;
517 #else
518  return true;
519 #endif
520 }
521 // ParseDOSHeader
524  bool success = false;
525  lldb::offset_t offset = 0;
526  success = data.ValidOffsetForDataOfSize(0, sizeof(dos_header));
527 
528  if (success) {
529  dos_header.e_magic = data.GetU16(&offset); // Magic number
531 
532  if (success) {
533  dos_header.e_cblp = data.GetU16(&offset); // Bytes on last page of file
534  dos_header.e_cp = data.GetU16(&offset); // Pages in file
535  dos_header.e_crlc = data.GetU16(&offset); // Relocations
537  data.GetU16(&offset); // Size of header in paragraphs
539  data.GetU16(&offset); // Minimum extra paragraphs needed
541  data.GetU16(&offset); // Maximum extra paragraphs needed
542  dos_header.e_ss = data.GetU16(&offset); // Initial (relative) SS value
543  dos_header.e_sp = data.GetU16(&offset); // Initial SP value
544  dos_header.e_csum = data.GetU16(&offset); // Checksum
545  dos_header.e_ip = data.GetU16(&offset); // Initial IP value
546  dos_header.e_cs = data.GetU16(&offset); // Initial (relative) CS value
548  data.GetU16(&offset); // File address of relocation table
549  dos_header.e_ovno = data.GetU16(&offset); // Overlay number
550 
551  dos_header.e_res[0] = data.GetU16(&offset); // Reserved words
552  dos_header.e_res[1] = data.GetU16(&offset); // Reserved words
553  dos_header.e_res[2] = data.GetU16(&offset); // Reserved words
554  dos_header.e_res[3] = data.GetU16(&offset); // Reserved words
555 
557  data.GetU16(&offset); // OEM identifier (for e_oeminfo)
559  data.GetU16(&offset); // OEM information; e_oemid specific
560  dos_header.e_res2[0] = data.GetU16(&offset); // Reserved words
561  dos_header.e_res2[1] = data.GetU16(&offset); // Reserved words
562  dos_header.e_res2[2] = data.GetU16(&offset); // Reserved words
563  dos_header.e_res2[3] = data.GetU16(&offset); // Reserved words
564  dos_header.e_res2[4] = data.GetU16(&offset); // Reserved words
565  dos_header.e_res2[5] = data.GetU16(&offset); // Reserved words
566  dos_header.e_res2[6] = data.GetU16(&offset); // Reserved words
567  dos_header.e_res2[7] = data.GetU16(&offset); // Reserved words
568  dos_header.e_res2[8] = data.GetU16(&offset); // Reserved words
569  dos_header.e_res2[9] = data.GetU16(&offset); // Reserved words
570 
572  data.GetU32(&offset); // File address of new exe header
573  }
574  }
575  if (!success)
576  memset(&dos_header, 0, sizeof(dos_header));
577  return success;
578 }
579 
580 // ParserCOFFHeader
582  lldb::offset_t *offset_ptr,
584  bool success =
585  data.ValidOffsetForDataOfSize(*offset_ptr, sizeof(coff_header));
586  if (success) {
587  coff_header.machine = data.GetU16(offset_ptr);
588  coff_header.nsects = data.GetU16(offset_ptr);
589  coff_header.modtime = data.GetU32(offset_ptr);
590  coff_header.symoff = data.GetU32(offset_ptr);
591  coff_header.nsyms = data.GetU32(offset_ptr);
592  coff_header.hdrsize = data.GetU16(offset_ptr);
593  coff_header.flags = data.GetU16(offset_ptr);
594  }
595  if (!success)
596  memset(&coff_header, 0, sizeof(coff_header));
597  return success;
598 }
599 
601  bool success = false;
602  const lldb::offset_t end_offset = *offset_ptr + m_coff_header.hdrsize;
603  if (*offset_ptr < end_offset) {
604  success = true;
605  m_coff_header_opt.magic = m_data.GetU16(offset_ptr);
610  m_coff_header_opt.bss_size = m_data.GetU32(offset_ptr);
611  m_coff_header_opt.entry = m_data.GetU32(offset_ptr);
613 
614  const uint32_t addr_byte_size = GetAddressByteSize();
615 
616  if (*offset_ptr < end_offset) {
618  // PE32 only
620  } else
622 
623  if (*offset_ptr < end_offset) {
625  m_data.GetMaxU64(offset_ptr, addr_byte_size);
637  m_coff_header_opt.checksum = m_data.GetU32(offset_ptr);
641  m_data.GetMaxU64(offset_ptr, addr_byte_size);
643  m_data.GetMaxU64(offset_ptr, addr_byte_size);
645  m_data.GetMaxU64(offset_ptr, addr_byte_size);
647  m_data.GetMaxU64(offset_ptr, addr_byte_size);
649  uint32_t num_data_dir_entries = m_data.GetU32(offset_ptr);
651  m_coff_header_opt.data_dirs.resize(num_data_dir_entries);
652  uint32_t i;
653  for (i = 0; i < num_data_dir_entries; i++) {
654  m_coff_header_opt.data_dirs[i].vmaddr = m_data.GetU32(offset_ptr);
655  m_coff_header_opt.data_dirs[i].vmsize = m_data.GetU32(offset_ptr);
656  }
657 
659  }
660  }
661  }
662  // Make sure we are on track for section data which follows
663  *offset_ptr = end_offset;
664  return success;
665 }
666 
668  return addr.GetFileAddress() - m_image_base;
669 }
670 
672  SectionList *sect_list = GetSectionList();
673  if (!sect_list)
674  return Address(GetFileAddress(rva));
675 
676  return Address(GetFileAddress(rva), sect_list);
677 }
678 
680  return m_image_base + rva;
681 }
682 
684  if (!size)
685  return {};
686 
687  if (m_data.ValidOffsetForDataOfSize(offset, size))
688  return DataExtractor(m_data, offset, size);
689 
690  ProcessSP process_sp(m_process_wp.lock());
691  DataExtractor data;
692  if (process_sp) {
693  auto data_up = std::make_unique<DataBufferHeap>(size, 0);
694  Status readmem_error;
695  size_t bytes_read =
696  process_sp->ReadMemory(m_image_base + offset, data_up->GetBytes(),
697  data_up->GetByteSize(), readmem_error);
698  if (bytes_read == size) {
699  DataBufferSP buffer_sp(data_up.release());
700  data.SetData(buffer_sp, 0, buffer_sp->GetByteSize());
701  }
702  }
703  return data;
704 }
705 
707  Address addr = GetAddress(rva);
708  SectionSP sect = addr.GetSection();
709  if (!sect)
710  return {};
711  rva = sect->GetFileOffset() + addr.GetOffset();
712 
713  return ReadImageData(rva, size);
714 }
715 
716 // ParseSectionHeaders
718  uint32_t section_header_data_offset) {
719  const uint32_t nsects = m_coff_header.nsects;
720  m_sect_headers.clear();
721 
722  if (nsects > 0) {
723  const size_t section_header_byte_size = nsects * sizeof(section_header_t);
724  DataExtractor section_header_data =
725  ReadImageData(section_header_data_offset, section_header_byte_size);
726 
727  lldb::offset_t offset = 0;
728  if (section_header_data.ValidOffsetForDataOfSize(
729  offset, section_header_byte_size)) {
730  m_sect_headers.resize(nsects);
731 
732  for (uint32_t idx = 0; idx < nsects; ++idx) {
733  const void *name_data = section_header_data.GetData(&offset, 8);
734  if (name_data) {
735  memcpy(m_sect_headers[idx].name, name_data, 8);
736  m_sect_headers[idx].vmsize = section_header_data.GetU32(&offset);
737  m_sect_headers[idx].vmaddr = section_header_data.GetU32(&offset);
738  m_sect_headers[idx].size = section_header_data.GetU32(&offset);
739  m_sect_headers[idx].offset = section_header_data.GetU32(&offset);
740  m_sect_headers[idx].reloff = section_header_data.GetU32(&offset);
741  m_sect_headers[idx].lineoff = section_header_data.GetU32(&offset);
742  m_sect_headers[idx].nreloc = section_header_data.GetU16(&offset);
743  m_sect_headers[idx].nline = section_header_data.GetU16(&offset);
744  m_sect_headers[idx].flags = section_header_data.GetU32(&offset);
745  }
746  }
747  }
748  }
749 
750  return !m_sect_headers.empty();
751 }
752 
754  llvm::StringRef hdr_name(sect.name, std::size(sect.name));
755  hdr_name = hdr_name.split('\0').first;
756  if (hdr_name.consume_front("/")) {
757  lldb::offset_t stroff;
758  if (!to_integer(hdr_name, stroff, 10))
759  return "";
760  lldb::offset_t string_file_offset =
761  m_coff_header.symoff + (m_coff_header.nsyms * 18) + stroff;
762  if (const char *name = m_data.GetCStr(&string_file_offset))
763  return name;
764  return "";
765  }
766  return hdr_name;
767 }
768 
770  SectionList *sect_list = GetSectionList();
771  rva_symbol_list_t sorted_exports = AppendFromExportTable(sect_list, symtab);
772  AppendFromCOFFSymbolTable(sect_list, symtab, sorted_exports);
773 }
774 
775 static bool RVASymbolListCompareRVA(const std::pair<uint32_t, uint32_t> &a,
776  const std::pair<uint32_t, uint32_t> &b) {
777  return a.first < b.first;
778 }
779 
781  SectionList *sect_list, Symtab &symtab,
782  const ObjectFilePECOFF::rva_symbol_list_t &sorted_exports) {
783  const uint32_t num_syms = m_binary->getNumberOfSymbols();
784  if (num_syms == 0)
785  return;
786  // Check that this is not a bigobj; we do not support bigobj.
787  if (m_binary->getSymbolTableEntrySize() !=
788  sizeof(llvm::object::coff_symbol16))
789  return;
790 
791  Log *log = GetLog(LLDBLog::Object);
792  symtab.Reserve(symtab.GetNumSymbols() + num_syms);
793  for (const auto &sym_ref : m_binary->symbols()) {
794  const auto coff_sym_ref = m_binary->getCOFFSymbol(sym_ref);
795  auto name_or_error = sym_ref.getName();
796  if (auto err = name_or_error.takeError()) {
797  LLDB_LOG(log,
798  "ObjectFilePECOFF::AppendFromCOFFSymbolTable - failed to get "
799  "symbol table entry name: {0}",
800  llvm::fmt_consume(std::move(err)));
801  continue;
802  }
803  const llvm::StringRef sym_name = *name_or_error;
804  Symbol symbol;
805  symbol.GetMangled().SetValue(ConstString(sym_name));
806  int16_t section_number =
807  static_cast<int16_t>(coff_sym_ref.getSectionNumber());
808  if (section_number >= 1) {
809  symbol.GetAddressRef() = Address(
810  sect_list->FindSectionByID(section_number), coff_sym_ref.getValue());
811  const auto symbol_type = MapSymbolType(coff_sym_ref.getType());
812  symbol.SetType(symbol_type);
813 
814  // Check for duplicate of exported symbols:
815  const uint32_t symbol_rva = symbol.GetAddressRef().GetFileAddress() -
817  const auto &first_match = std::lower_bound(
818  sorted_exports.begin(), sorted_exports.end(),
819  std::make_pair(symbol_rva, 0), RVASymbolListCompareRVA);
820  for (auto it = first_match;
821  it != sorted_exports.end() && it->first == symbol_rva; ++it) {
822  Symbol *exported = symtab.SymbolAtIndex(it->second);
823  if (symbol_type != lldb::eSymbolTypeInvalid)
824  exported->SetType(symbol_type);
825  if (exported->GetMangled() == symbol.GetMangled()) {
826  symbol.SetExternal(true);
827  // We don't want the symbol to be duplicated (e.g. when running
828  // `disas -n func`), but we also don't want to erase this entry (to
829  // preserve the original symbol order), so we mark it as additional.
831  } else {
832  // It is possible for a symbol to be exported in a different name
833  // from its original. In this case keep both entries so lookup using
834  // either names will work. If this symbol has an invalid type, replace
835  // it with the type from the export symbol.
836  if (symbol.GetType() == lldb::eSymbolTypeInvalid)
837  symbol.SetType(exported->GetType());
838  }
839  }
840  } else if (section_number == llvm::COFF::IMAGE_SYM_ABSOLUTE) {
841  symbol.GetAddressRef() = Address(coff_sym_ref.getValue());
843  }
844  symtab.AddSymbol(symbol);
845  }
846 }
847 
850  Symtab &symtab) {
851  const auto *export_table = m_binary->getExportTable();
852  if (!export_table)
853  return {};
854  const uint32_t num_syms = export_table->AddressTableEntries;
855  if (num_syms == 0)
856  return {};
857 
858  Log *log = GetLog(LLDBLog::Object);
859  rva_symbol_list_t export_list;
860  symtab.Reserve(symtab.GetNumSymbols() + num_syms);
861  // Read each export table entry, ordered by ordinal instead of by name.
862  for (const auto &entry : m_binary->export_directories()) {
863  llvm::StringRef sym_name;
864  if (auto err = entry.getSymbolName(sym_name)) {
865  LLDB_LOG(log,
866  "ObjectFilePECOFF::AppendFromExportTable - failed to get export "
867  "table entry name: {0}",
868  llvm::fmt_consume(std::move(err)));
869  continue;
870  }
871  Symbol symbol;
872  // Note: symbol name may be empty if it is only exported by ordinal.
873  symbol.GetMangled().SetValue(ConstString(sym_name));
874 
875  uint32_t ordinal;
876  llvm::cantFail(entry.getOrdinal(ordinal));
877  symbol.SetID(ordinal);
878 
879  bool is_forwarder;
880  llvm::cantFail(entry.isForwarder(is_forwarder));
881  if (is_forwarder) {
882  // Forwarder exports are redirected by the loader transparently, but keep
883  // it in symtab and make a note using the symbol name.
884  llvm::StringRef forwarder_name;
885  if (auto err = entry.getForwardTo(forwarder_name)) {
886  LLDB_LOG(log,
887  "ObjectFilePECOFF::AppendFromExportTable - failed to get "
888  "forwarder name of forwarder export '{0}': {1}",
889  sym_name, llvm::fmt_consume(std::move(err)));
890  continue;
891  }
892  llvm::SmallString<256> new_name = {symbol.GetDisplayName().GetStringRef(),
893  " (forwarded to ", forwarder_name,
894  ")"};
895  symbol.GetMangled().SetDemangledName(ConstString(new_name.str()));
896  symbol.SetDemangledNameIsSynthesized(true);
897  }
898 
899  uint32_t function_rva;
900  if (auto err = entry.getExportRVA(function_rva)) {
901  LLDB_LOG(log,
902  "ObjectFilePECOFF::AppendFromExportTable - failed to get "
903  "address of export entry '{0}': {1}",
904  sym_name, llvm::fmt_consume(std::move(err)));
905  continue;
906  }
907  // Skip the symbol if it doesn't look valid.
908  if (function_rva == 0 && sym_name.empty())
909  continue;
910  symbol.GetAddressRef() =
911  Address(m_coff_header_opt.image_base + function_rva, sect_list);
912 
913  // An exported symbol may be either code or data. Guess by checking whether
914  // the section containing the symbol is executable.
916  if (!is_forwarder)
917  if (auto section_sp = symbol.GetAddressRef().GetSection())
918  if (section_sp->GetPermissions() & ePermissionsExecutable)
920  symbol.SetExternal(true);
921  uint32_t idx = symtab.AddSymbol(symbol);
922  export_list.push_back(std::make_pair(function_rva, idx));
923  }
924  std::stable_sort(export_list.begin(), export_list.end(),
926  return export_list;
927 }
928 
929 std::unique_ptr<CallFrameInfo> ObjectFilePECOFF::CreateCallFrameInfo() {
930  if (llvm::COFF::EXCEPTION_TABLE >= m_coff_header_opt.data_dirs.size())
931  return {};
932 
933  data_directory data_dir_exception =
934  m_coff_header_opt.data_dirs[llvm::COFF::EXCEPTION_TABLE];
935  if (!data_dir_exception.vmaddr)
936  return {};
937 
938  if (m_coff_header.machine != llvm::COFF::IMAGE_FILE_MACHINE_AMD64)
939  return {};
940 
941  return std::make_unique<PECallFrameInfo>(*this, data_dir_exception.vmaddr,
942  data_dir_exception.vmsize);
943 }
944 
946  // TODO: determine this for COFF
947  return false;
948 }
949 
951  const section_header_t &sect) {
952  ConstString const_sect_name(sect_name);
953  static ConstString g_code_sect_name(".code");
954  static ConstString g_CODE_sect_name("CODE");
955  static ConstString g_data_sect_name(".data");
956  static ConstString g_DATA_sect_name("DATA");
957  static ConstString g_bss_sect_name(".bss");
958  static ConstString g_BSS_sect_name("BSS");
959 
960  if (sect.flags & llvm::COFF::IMAGE_SCN_CNT_CODE &&
961  ((const_sect_name == g_code_sect_name) ||
962  (const_sect_name == g_CODE_sect_name))) {
963  return eSectionTypeCode;
964  }
965  if (sect.flags & llvm::COFF::IMAGE_SCN_CNT_INITIALIZED_DATA &&
966  ((const_sect_name == g_data_sect_name) ||
967  (const_sect_name == g_DATA_sect_name))) {
968  if (sect.size == 0 && sect.offset == 0)
969  return eSectionTypeZeroFill;
970  else
971  return eSectionTypeData;
972  }
973  if (sect.flags & llvm::COFF::IMAGE_SCN_CNT_UNINITIALIZED_DATA &&
974  ((const_sect_name == g_bss_sect_name) ||
975  (const_sect_name == g_BSS_sect_name))) {
976  if (sect.size == 0)
977  return eSectionTypeZeroFill;
978  else
979  return eSectionTypeData;
980  }
981 
982  SectionType section_type =
983  llvm::StringSwitch<SectionType>(sect_name)
984  .Case(".debug", eSectionTypeDebug)
985  .Case(".stabstr", eSectionTypeDataCString)
986  .Case(".reloc", eSectionTypeOther)
987  .Case(".debug_abbrev", eSectionTypeDWARFDebugAbbrev)
988  .Case(".debug_aranges", eSectionTypeDWARFDebugAranges)
989  .Case(".debug_frame", eSectionTypeDWARFDebugFrame)
990  .Case(".debug_info", eSectionTypeDWARFDebugInfo)
991  .Case(".debug_line", eSectionTypeDWARFDebugLine)
992  .Case(".debug_loc", eSectionTypeDWARFDebugLoc)
993  .Case(".debug_loclists", eSectionTypeDWARFDebugLocLists)
994  .Case(".debug_macinfo", eSectionTypeDWARFDebugMacInfo)
995  .Case(".debug_names", eSectionTypeDWARFDebugNames)
996  .Case(".debug_pubnames", eSectionTypeDWARFDebugPubNames)
997  .Case(".debug_pubtypes", eSectionTypeDWARFDebugPubTypes)
998  .Case(".debug_ranges", eSectionTypeDWARFDebugRanges)
999  .Case(".debug_str", eSectionTypeDWARFDebugStr)
1000  .Case(".debug_types", eSectionTypeDWARFDebugTypes)
1001  // .eh_frame can be truncated to 8 chars.
1002  .Cases(".eh_frame", ".eh_fram", eSectionTypeEHFrame)
1003  .Case(".gosymtab", eSectionTypeGoSymtab)
1004  .Default(eSectionTypeInvalid);
1005  if (section_type != eSectionTypeInvalid)
1006  return section_type;
1007 
1008  if (sect.flags & llvm::COFF::IMAGE_SCN_CNT_CODE)
1009  return eSectionTypeCode;
1010  if (sect.flags & llvm::COFF::IMAGE_SCN_CNT_INITIALIZED_DATA)
1011  return eSectionTypeData;
1012  if (sect.flags & llvm::COFF::IMAGE_SCN_CNT_UNINITIALIZED_DATA) {
1013  if (sect.size == 0)
1014  return eSectionTypeZeroFill;
1015  else
1016  return eSectionTypeData;
1017  }
1018  return eSectionTypeOther;
1019 }
1020 
1021 void ObjectFilePECOFF::CreateSections(SectionList &unified_section_list) {
1022  if (m_sections_up)
1023  return;
1024  m_sections_up = std::make_unique<SectionList>();
1025  ModuleSP module_sp(GetModule());
1026  if (module_sp) {
1027  std::lock_guard<std::recursive_mutex> guard(module_sp->GetMutex());
1028 
1029  SectionSP header_sp = std::make_shared<Section>(
1030  module_sp, this, ~user_id_t(0), ConstString("PECOFF header"),
1033  /*file_offset*/ 0, m_coff_header_opt.header_size,
1035  /*flags*/ 0);
1036  header_sp->SetPermissions(ePermissionsReadable);
1037  m_sections_up->AddSection(header_sp);
1038  unified_section_list.AddSection(header_sp);
1039 
1040  const uint32_t nsects = m_sect_headers.size();
1041  ModuleSP module_sp(GetModule());
1042  for (uint32_t idx = 0; idx < nsects; ++idx) {
1043  llvm::StringRef sect_name = GetSectionName(m_sect_headers[idx]);
1044  ConstString const_sect_name(sect_name);
1045  SectionType section_type = GetSectionType(sect_name, m_sect_headers[idx]);
1046 
1047  SectionSP section_sp(new Section(
1048  module_sp, // Module to which this section belongs
1049  this, // Object file to which this section belongs
1050  idx + 1, // Section ID is the 1 based section index.
1051  const_sect_name, // Name of this section
1052  section_type,
1054  m_sect_headers[idx].vmaddr, // File VM address == addresses as
1055  // they are found in the object file
1056  m_sect_headers[idx].vmsize, // VM size in bytes of this section
1057  m_sect_headers[idx]
1058  .offset, // Offset to the data for this section in the file
1059  m_sect_headers[idx]
1060  .size, // Size in bytes of this section as found in the file
1061  m_coff_header_opt.sect_alignment, // Section alignment
1062  m_sect_headers[idx].flags)); // Flags for this section
1063 
1064  uint32_t permissions = 0;
1065  if (m_sect_headers[idx].flags & llvm::COFF::IMAGE_SCN_MEM_EXECUTE)
1066  permissions |= ePermissionsExecutable;
1067  if (m_sect_headers[idx].flags & llvm::COFF::IMAGE_SCN_MEM_READ)
1068  permissions |= ePermissionsReadable;
1069  if (m_sect_headers[idx].flags & llvm::COFF::IMAGE_SCN_MEM_WRITE)
1070  permissions |= ePermissionsWritable;
1071  section_sp->SetPermissions(permissions);
1072 
1073  m_sections_up->AddSection(section_sp);
1074  unified_section_list.AddSection(section_sp);
1075  }
1076  }
1077 }
1078 
1080  if (m_uuid.IsValid())
1081  return m_uuid;
1082 
1083  if (!CreateBinary())
1084  return UUID();
1085 
1087  return m_uuid;
1088 }
1089 
1090 llvm::Optional<FileSpec> ObjectFilePECOFF::GetDebugLink() {
1091  std::string gnu_debuglink_file;
1092  uint32_t gnu_debuglink_crc;
1093  if (GetDebugLinkContents(*m_binary, gnu_debuglink_file, gnu_debuglink_crc))
1094  return FileSpec(gnu_debuglink_file);
1095  return llvm::None;
1096 }
1097 
1099  ModuleSP module_sp(GetModule());
1100  if (!module_sp)
1101  return 0;
1102 
1103  std::lock_guard<std::recursive_mutex> guard(module_sp->GetMutex());
1104  if (m_deps_filespec)
1105  return m_deps_filespec->GetSize();
1106 
1107  // Cache coff binary if it is not done yet.
1108  if (!CreateBinary())
1109  return 0;
1110 
1111  Log *log = GetLog(LLDBLog::Object);
1112  LLDB_LOG(log, "this = {0}, module = {1} ({2}), file = {3}, binary = {4}",
1113  this, GetModule().get(), GetModule()->GetSpecificationDescription(),
1114  m_file.GetPath(), m_binary.get());
1115 
1116  m_deps_filespec = FileSpecList();
1117 
1118  for (const auto &entry : m_binary->import_directories()) {
1119  llvm::StringRef dll_name;
1120  // Report a bogus entry.
1121  if (llvm::Error e = entry.getName(dll_name)) {
1122  LLDB_LOGF(log,
1123  "ObjectFilePECOFF::ParseDependentModules() - failed to get "
1124  "import directory entry name: %s",
1125  llvm::toString(std::move(e)).c_str());
1126  continue;
1127  }
1128 
1129  // At this moment we only have the base name of the DLL. The full path can
1130  // only be seen after the dynamic loading. Our best guess is Try to get it
1131  // with the help of the object file's directory.
1132  llvm::SmallString<128> dll_fullpath;
1133  FileSpec dll_specs(dll_name);
1134  dll_specs.SetDirectory(m_file.GetDirectory());
1135 
1136  if (!llvm::sys::fs::real_path(dll_specs.GetPath(), dll_fullpath))
1137  m_deps_filespec->EmplaceBack(dll_fullpath);
1138  else {
1139  // Known DLLs or DLL not found in the object file directory.
1140  m_deps_filespec->EmplaceBack(dll_name);
1141  }
1142  }
1143  return m_deps_filespec->GetSize();
1144 }
1145 
1147  auto num_modules = ParseDependentModules();
1148  auto original_size = files.GetSize();
1149 
1150  for (unsigned i = 0; i < num_modules; ++i)
1151  files.AppendIfUnique(m_deps_filespec->GetFileSpecAtIndex(i));
1152 
1153  return files.GetSize() - original_size;
1154 }
1155 
1158  return m_entry_point_address;
1159 
1160  if (!ParseHeader() || !IsExecutable())
1161  return m_entry_point_address;
1162 
1163  SectionList *section_list = GetSectionList();
1165 
1166  if (!section_list)
1167  m_entry_point_address.SetOffset(file_addr);
1168  else
1170  section_list);
1171  return m_entry_point_address;
1172 }
1173 
1175  return Address(GetSectionList()->GetSectionAtIndex(0), 0);
1176 }
1177 
1178 // Dump
1179 //
1180 // Dump the specifics of the runtime file container (such as any headers
1181 // segments, sections, etc).
1183  ModuleSP module_sp(GetModule());
1184  if (module_sp) {
1185  std::lock_guard<std::recursive_mutex> guard(module_sp->GetMutex());
1186  s->Printf("%p: ", static_cast<void *>(this));
1187  s->Indent();
1188  s->PutCString("ObjectFilePECOFF");
1189 
1190  ArchSpec header_arch = GetArchitecture();
1191 
1192  *s << ", file = '" << m_file
1193  << "', arch = " << header_arch.GetArchitectureName() << "\n";
1194 
1195  SectionList *sections = GetSectionList();
1196  if (sections)
1197  sections->Dump(s->AsRawOstream(), s->GetIndentLevel(), nullptr, true,
1198  UINT32_MAX);
1199 
1200  if (m_symtab_up)
1201  m_symtab_up->Dump(s, nullptr, eSortOrderNone);
1202 
1203  if (m_dos_header.e_magic)
1205  if (m_coff_header.machine) {
1207  if (m_coff_header.hdrsize)
1209  }
1210  s->EOL();
1211  DumpSectionHeaders(s);
1212  s->EOL();
1213 
1215  s->EOL();
1216  }
1217 }
1218 
1219 // DumpDOSHeader
1220 //
1221 // Dump the MS-DOS header to the specified output stream
1223  s->PutCString("MSDOS Header\n");
1224  s->Printf(" e_magic = 0x%4.4x\n", header.e_magic);
1225  s->Printf(" e_cblp = 0x%4.4x\n", header.e_cblp);
1226  s->Printf(" e_cp = 0x%4.4x\n", header.e_cp);
1227  s->Printf(" e_crlc = 0x%4.4x\n", header.e_crlc);
1228  s->Printf(" e_cparhdr = 0x%4.4x\n", header.e_cparhdr);
1229  s->Printf(" e_minalloc = 0x%4.4x\n", header.e_minalloc);
1230  s->Printf(" e_maxalloc = 0x%4.4x\n", header.e_maxalloc);
1231  s->Printf(" e_ss = 0x%4.4x\n", header.e_ss);
1232  s->Printf(" e_sp = 0x%4.4x\n", header.e_sp);
1233  s->Printf(" e_csum = 0x%4.4x\n", header.e_csum);
1234  s->Printf(" e_ip = 0x%4.4x\n", header.e_ip);
1235  s->Printf(" e_cs = 0x%4.4x\n", header.e_cs);
1236  s->Printf(" e_lfarlc = 0x%4.4x\n", header.e_lfarlc);
1237  s->Printf(" e_ovno = 0x%4.4x\n", header.e_ovno);
1238  s->Printf(" e_res[4] = { 0x%4.4x, 0x%4.4x, 0x%4.4x, 0x%4.4x }\n",
1239  header.e_res[0], header.e_res[1], header.e_res[2], header.e_res[3]);
1240  s->Printf(" e_oemid = 0x%4.4x\n", header.e_oemid);
1241  s->Printf(" e_oeminfo = 0x%4.4x\n", header.e_oeminfo);
1242  s->Printf(" e_res2[10] = { 0x%4.4x, 0x%4.4x, 0x%4.4x, 0x%4.4x, 0x%4.4x, "
1243  "0x%4.4x, 0x%4.4x, 0x%4.4x, 0x%4.4x, 0x%4.4x }\n",
1244  header.e_res2[0], header.e_res2[1], header.e_res2[2],
1245  header.e_res2[3], header.e_res2[4], header.e_res2[5],
1246  header.e_res2[6], header.e_res2[7], header.e_res2[8],
1247  header.e_res2[9]);
1248  s->Printf(" e_lfanew = 0x%8.8x\n", header.e_lfanew);
1249 }
1250 
1251 // DumpCOFFHeader
1252 //
1253 // Dump the COFF header to the specified output stream
1255  s->PutCString("COFF Header\n");
1256  s->Printf(" machine = 0x%4.4x\n", header.machine);
1257  s->Printf(" nsects = 0x%4.4x\n", header.nsects);
1258  s->Printf(" modtime = 0x%8.8x\n", header.modtime);
1259  s->Printf(" symoff = 0x%8.8x\n", header.symoff);
1260  s->Printf(" nsyms = 0x%8.8x\n", header.nsyms);
1261  s->Printf(" hdrsize = 0x%4.4x\n", header.hdrsize);
1262 }
1263 
1264 // DumpOptCOFFHeader
1265 //
1266 // Dump the optional COFF header to the specified output stream
1268  const coff_opt_header_t &header) {
1269  s->PutCString("Optional COFF Header\n");
1270  s->Printf(" magic = 0x%4.4x\n", header.magic);
1271  s->Printf(" major_linker_version = 0x%2.2x\n",
1272  header.major_linker_version);
1273  s->Printf(" minor_linker_version = 0x%2.2x\n",
1274  header.minor_linker_version);
1275  s->Printf(" code_size = 0x%8.8x\n", header.code_size);
1276  s->Printf(" data_size = 0x%8.8x\n", header.data_size);
1277  s->Printf(" bss_size = 0x%8.8x\n", header.bss_size);
1278  s->Printf(" entry = 0x%8.8x\n", header.entry);
1279  s->Printf(" code_offset = 0x%8.8x\n", header.code_offset);
1280  s->Printf(" data_offset = 0x%8.8x\n", header.data_offset);
1281  s->Printf(" image_base = 0x%16.16" PRIx64 "\n",
1282  header.image_base);
1283  s->Printf(" sect_alignment = 0x%8.8x\n", header.sect_alignment);
1284  s->Printf(" file_alignment = 0x%8.8x\n", header.file_alignment);
1285  s->Printf(" major_os_system_version = 0x%4.4x\n",
1286  header.major_os_system_version);
1287  s->Printf(" minor_os_system_version = 0x%4.4x\n",
1288  header.minor_os_system_version);
1289  s->Printf(" major_image_version = 0x%4.4x\n",
1290  header.major_image_version);
1291  s->Printf(" minor_image_version = 0x%4.4x\n",
1292  header.minor_image_version);
1293  s->Printf(" major_subsystem_version = 0x%4.4x\n",
1294  header.major_subsystem_version);
1295  s->Printf(" minor_subsystem_version = 0x%4.4x\n",
1296  header.minor_subsystem_version);
1297  s->Printf(" reserved1 = 0x%8.8x\n", header.reserved1);
1298  s->Printf(" image_size = 0x%8.8x\n", header.image_size);
1299  s->Printf(" header_size = 0x%8.8x\n", header.header_size);
1300  s->Printf(" checksum = 0x%8.8x\n", header.checksum);
1301  s->Printf(" subsystem = 0x%4.4x\n", header.subsystem);
1302  s->Printf(" dll_flags = 0x%4.4x\n", header.dll_flags);
1303  s->Printf(" stack_reserve_size = 0x%16.16" PRIx64 "\n",
1304  header.stack_reserve_size);
1305  s->Printf(" stack_commit_size = 0x%16.16" PRIx64 "\n",
1306  header.stack_commit_size);
1307  s->Printf(" heap_reserve_size = 0x%16.16" PRIx64 "\n",
1308  header.heap_reserve_size);
1309  s->Printf(" heap_commit_size = 0x%16.16" PRIx64 "\n",
1310  header.heap_commit_size);
1311  s->Printf(" loader_flags = 0x%8.8x\n", header.loader_flags);
1312  s->Printf(" num_data_dir_entries = 0x%8.8x\n",
1313  (uint32_t)header.data_dirs.size());
1314  uint32_t i;
1315  for (i = 0; i < header.data_dirs.size(); i++) {
1316  s->Printf(" data_dirs[%2u] vmaddr = 0x%8.8x, vmsize = 0x%8.8x\n", i,
1317  header.data_dirs[i].vmaddr, header.data_dirs[i].vmsize);
1318  }
1319 }
1320 // DumpSectionHeader
1321 //
1322 // Dump a single ELF section header to the specified output stream
1324  const section_header_t &sh) {
1326  s->Printf("%-16s 0x%8.8x 0x%8.8x 0x%8.8x 0x%8.8x 0x%8.8x 0x%8.8x 0x%4.4x "
1327  "0x%4.4x 0x%8.8x\n",
1328  name.c_str(), sh.vmaddr, sh.vmsize, sh.offset, sh.size, sh.reloff,
1329  sh.lineoff, sh.nreloc, sh.nline, sh.flags);
1330 }
1331 
1332 // DumpSectionHeaders
1333 //
1334 // Dump all of the ELF section header to the specified output stream
1336 
1337  s->PutCString("Section Headers\n");
1338  s->PutCString("IDX name vm addr vm size file off file "
1339  "size reloc off line off nreloc nline flags\n");
1340  s->PutCString("==== ---------------- ---------- ---------- ---------- "
1341  "---------- ---------- ---------- ------ ------ ----------\n");
1342 
1343  uint32_t idx = 0;
1344  SectionHeaderCollIter pos, end = m_sect_headers.end();
1345 
1346  for (pos = m_sect_headers.begin(); pos != end; ++pos, ++idx) {
1347  s->Printf("[%2u] ", idx);
1349  }
1350 }
1351 
1352 // DumpDependentModules
1353 //
1354 // Dump all of the dependent modules to the specified output stream
1356  auto num_modules = ParseDependentModules();
1357  if (num_modules > 0) {
1358  s->PutCString("Dependent Modules\n");
1359  for (unsigned i = 0; i < num_modules; ++i) {
1360  auto spec = m_deps_filespec->GetFileSpecAtIndex(i);
1361  s->Printf(" %s\n", spec.GetFilename().GetCString());
1362  }
1363  }
1364 }
1365 
1367  switch (m_coff_header_opt.subsystem) {
1368  case llvm::COFF::IMAGE_SUBSYSTEM_NATIVE:
1369  case llvm::COFF::IMAGE_SUBSYSTEM_WINDOWS_GUI:
1370  case llvm::COFF::IMAGE_SUBSYSTEM_WINDOWS_CUI:
1371  case llvm::COFF::IMAGE_SUBSYSTEM_NATIVE_WINDOWS:
1372  case llvm::COFF::IMAGE_SUBSYSTEM_WINDOWS_CE_GUI:
1373  case llvm::COFF::IMAGE_SUBSYSTEM_XBOX:
1374  case llvm::COFF::IMAGE_SUBSYSTEM_WINDOWS_BOOT_APPLICATION:
1375  return true;
1376  default:
1377  return false;
1378  }
1379 }
1380 
1382  uint16_t machine = m_coff_header.machine;
1383  switch (machine) {
1384  default:
1385  break;
1386  case llvm::COFF::IMAGE_FILE_MACHINE_AMD64:
1387  case llvm::COFF::IMAGE_FILE_MACHINE_I386:
1388  case llvm::COFF::IMAGE_FILE_MACHINE_POWERPC:
1389  case llvm::COFF::IMAGE_FILE_MACHINE_POWERPCFP:
1390  case llvm::COFF::IMAGE_FILE_MACHINE_ARM:
1391  case llvm::COFF::IMAGE_FILE_MACHINE_ARMNT:
1392  case llvm::COFF::IMAGE_FILE_MACHINE_THUMB:
1393  case llvm::COFF::IMAGE_FILE_MACHINE_ARM64:
1394  ArchSpec arch;
1396  IsWindowsSubsystem() ? llvm::Triple::Win32
1397  : llvm::Triple::UnknownOS);
1398  return arch;
1399  }
1400  return ArchSpec();
1401 }
1402 
1404  if (m_coff_header.machine != 0) {
1405  if ((m_coff_header.flags & llvm::COFF::IMAGE_FILE_DLL) == 0)
1406  return eTypeExecutable;
1407  else
1408  return eTypeSharedLibrary;
1409  }
1410  return eTypeExecutable;
1411 }
1412 
lldb_private::SectionLoadList::SetSectionLoadAddress
bool SetSectionLoadAddress(const lldb::SectionSP &section_sp, lldb::addr_t load_addr, bool warn_multiple=false)
Definition: SectionLoadList.cpp:64
lldb_private::UUID::CvRecordPdb70::Age
llvm::support::ulittle32_t Age
Definition: UUID.h:46
lldb_private::toString
const char * toString(AppleArm64ExceptionClass EC)
Definition: AppleArm64ExceptionClass.h:38
ObjectFilePECOFF::section_header::offset
uint32_t offset
Definition: ObjectFilePECOFF.h:233
ObjectFilePECOFF::coff_opt_header::checksum
uint32_t checksum
Definition: ObjectFilePECOFF.h:215
lldb_private::UUID
Definition: UUID.h:23
lldb::eSectionTypeDWARFDebugLoc
@ eSectionTypeDWARFDebugLoc
Definition: lldb-enumerations.h:676
ObjectFilePECOFF::coff_opt_header::stack_reserve_size
uint64_t stack_reserve_size
Definition: ObjectFilePECOFF.h:218
lldb_private::FileSpec::GetLastPathComponent
ConstString GetLastPathComponent() const
Definition: FileSpec.cpp:431
LLDB_SCOPED_TIMERF
#define LLDB_SCOPED_TIMERF(...)
Definition: Timer.h:86
ObjectFilePECOFF::NeedsEndianSwap
bool NeedsEndianSwap() const
Definition: ObjectFilePECOFF.cpp:514
ObjectFilePECOFF::dos_header::e_magic
uint16_t e_magic
Definition: ObjectFilePECOFF.h:156
ObjectFilePECOFF::dos_header::e_ip
uint16_t e_ip
Definition: ObjectFilePECOFF.h:166
ObjectFilePECOFF::data_directory::vmaddr
uint32_t vmaddr
Definition: ObjectFilePECOFF.h:188
ObjectFilePECOFF::~ObjectFilePECOFF
~ObjectFilePECOFF() override
lldb_private::ArchSpec
Definition: ArchSpec.h:32
lldb::eSectionTypeDebug
@ eSectionTypeDebug
Definition: lldb-enumerations.h:664
ObjectFilePECOFF::ReadImageData
lldb_private::DataExtractor ReadImageData(uint32_t offset, size_t size)
Definition: ObjectFilePECOFF.cpp:683
lldb_private::eArchTypeCOFF
@ eArchTypeCOFF
Definition: lldb-private-enumerations.h:65
lldb_private::Address::IsValid
bool IsValid() const
Check if the object state is valid.
Definition: Address.h:345
ObjectFilePECOFF::dos_header::e_oeminfo
uint16_t e_oeminfo
Definition: ObjectFilePECOFF.h:172
ObjectFilePECOFF::dos_header::e_oemid
uint16_t e_oemid
Definition: ObjectFilePECOFF.h:171
lldb::eSymbolTypeCode
@ eSymbolTypeCode
Definition: lldb-enumerations.h:622
lldb_private::SectionList::Dump
void Dump(llvm::raw_ostream &s, unsigned indent, Target *target, bool show_header, uint32_t depth) const
Definition: Section.cpp:632
lldb_private::ABI
Definition: ABI.h:27
ObjectFilePECOFF::GetDebugLink
llvm::Optional< lldb_private::FileSpec > GetDebugLink()
Return the contents of the .gnu_debuglink section, if the object file contains it.
Definition: ObjectFilePECOFF.cpp:1090
ObjectFilePECOFF::coff_opt_header::minor_os_system_version
uint16_t minor_os_system_version
Definition: ObjectFilePECOFF.h:207
lldb_private::Symbol::SetExternal
void SetExternal(bool b)
Definition: Symbol.h:182
ObjectFilePECOFF::GetDependentModules
uint32_t GetDependentModules(lldb_private::FileSpecList &files) override
Definition: ObjectFilePECOFF.cpp:1146
ObjectFilePECOFF::coff_header::modtime
uint32_t modtime
Definition: ObjectFilePECOFF.h:180
ModuleSpec.h
ObjectFilePECOFF::m_dos_header
dos_header_t m_dos_header
Definition: ObjectFilePECOFF.h:278
ObjectFilePECOFF::ParseCOFFOptionalHeader
bool ParseCOFFOptionalHeader(lldb::offset_t *offset_ptr)
Definition: ObjectFilePECOFF.cpp:600
GetDebugLinkContents
static bool GetDebugLinkContents(const llvm::object::COFFObjectFile &coff_obj, std::string &gnu_debuglink_file, uint32_t &gnu_debuglink_crc)
Definition: ObjectFilePECOFF.cpp:110
ObjectFilePECOFF::CreateSections
void CreateSections(lldb_private::SectionList &unified_section_list) override
Definition: ObjectFilePECOFF.cpp:1021
ObjectFilePECOFF::section_header::size
uint32_t size
Definition: ObjectFilePECOFF.h:232
lldb_private::Symbol
Definition: Symbol.h:20
ObjectFilePECOFF::coff_opt_header::subsystem
uint16_t subsystem
Definition: ObjectFilePECOFF.h:216
UUID.h
ObjectFilePECOFF::dos_header::e_maxalloc
uint16_t e_maxalloc
Definition: ObjectFilePECOFF.h:162
lldb::eSymbolTypeInvalid
@ eSymbolTypeInvalid
Definition: lldb-enumerations.h:620
ObjectFilePECOFF::GetPluginDescriptionStatic
static llvm::StringRef GetPluginDescriptionStatic()
Definition: ObjectFilePECOFF.cpp:201
ObjectFilePECOFF::section_header::lineoff
uint32_t lineoff
Definition: ObjectFilePECOFF.h:235
lldb_private::ObjectFile::eTypeExecutable
@ eTypeExecutable
A normal executable.
Definition: ObjectFile.h:71
OPT_HEADER_MAGIC_PE32
#define OPT_HEADER_MAGIC_PE32
Definition: ObjectFilePECOFF.cpp:44
lldb::eSectionTypeDWARFDebugAranges
@ eSectionTypeDWARFDebugAranges
Definition: lldb-enumerations.h:671
lldb_private::UUID::IsValid
bool IsValid() const
Definition: UUID.h:69
lldb_private::ObjectFile::m_process_wp
lldb::ProcessWP m_process_wp
Definition: ObjectFile.h:741
lldb_private::SectionList::GetSize
size_t GetSize() const
Definition: Section.h:74
lldb_private::ModuleSpecList
Definition: ModuleSpec.h:275
lldb_private::ModuleSpecList::Append
void Append(const ModuleSpec &spec)
Definition: ModuleSpec.h:308
ObjectFilePECOFF::GetUUID
lldb_private::UUID GetUUID() override
Gets the UUID for this object file.
Definition: ObjectFilePECOFF.cpp:1079
LLDB_LOGF
#define LLDB_LOGF(log,...)
Definition: Log.h:344
lldb::eSectionTypeDWARFDebugRanges
@ eSectionTypeDWARFDebugRanges
Definition: lldb-enumerations.h:681
ObjectFilePECOFF::section_header
Definition: ObjectFilePECOFF.h:228
ObjectFilePECOFF::dos_header::e_res
uint16_t e_res[4]
Definition: ObjectFilePECOFF.h:170
ObjectFilePECOFF::data_directory::vmsize
uint32_t vmsize
Definition: ObjectFilePECOFF.h:189
ObjectFilePECOFF::DumpSectionHeaders
void DumpSectionHeaders(lldb_private::Stream *s)
Definition: ObjectFilePECOFF.cpp:1335
lldb::eSectionTypeDWARFDebugFrame
@ eSectionTypeDWARFDebugFrame
Definition: lldb-enumerations.h:673
Module.h
lldb::eSectionTypeDWARFDebugLine
@ eSectionTypeDWARFDebugLine
Definition: lldb-enumerations.h:675
lldb_private::ObjectFile::m_symtab_up
std::unique_ptr< lldb_private::Symtab > m_symtab_up
Definition: ObjectFile.h:745
RVASymbolListCompareRVA
static bool RVASymbolListCompareRVA(const std::pair< uint32_t, uint32_t > &a, const std::pair< uint32_t, uint32_t > &b)
Definition: ObjectFilePECOFF.cpp:775
ObjectFilePECOFF::coff_opt_header::major_linker_version
uint8_t major_linker_version
Definition: ObjectFilePECOFF.h:194
lldb_private::ObjectFile::m_file
FileSpec m_file
Definition: ObjectFile.h:731
ObjectFilePECOFF::GetAddressByteSize
uint32_t GetAddressByteSize() const override
Gets the address size in bytes for the current object file.
Definition: ObjectFilePECOFF.cpp:502
lldb::eSymbolTypeData
@ eSymbolTypeData
Definition: lldb-enumerations.h:624
SectionLoadList.h
lldb_private::ConstString::AsCString
const char * AsCString(const char *value_if_empty=nullptr) const
Get the string value as a C string.
Definition: ConstString.h:192
lldb_private::Symbol::SetType
void SetType(lldb::SymbolType type)
Definition: Symbol.h:155
lldb_private::FileSpec::GetFilename
const ConstString & GetFilename() const
Filename string const get accessor.
Definition: FileSpec.h:239
lldb_private::SectionList
Definition: Section.h:34
lldb::offset_t
uint64_t offset_t
Definition: lldb-types.h:87
ObjectFilePECOFF::coff_opt_header::sect_alignment
uint32_t sect_alignment
Definition: ObjectFilePECOFF.h:204
ObjectFilePECOFF::coff_opt_header::code_size
uint32_t code_size
Definition: ObjectFilePECOFF.h:196
ObjectFilePECOFF::Terminate
static void Terminate()
Definition: ObjectFilePECOFF.cpp:197
lldb_private::Stream
Definition: Stream.h:28
lldb_private::ArchSpec::GetTriple
llvm::Triple & GetTriple()
Architecture triple accessor.
Definition: ArchSpec.h:454
lldb::addr_t
uint64_t addr_t
Definition: lldb-types.h:83
lldb_private::Symtab::SymbolAtIndex
Symbol * SymbolAtIndex(size_t idx)
Definition: Symtab.cpp:217
OptionValueDictionary.h
LLDB_INVALID_CPUTYPE
#define LLDB_INVALID_CPUTYPE
Definition: lldb-defines.h:95
lldb_private::ObjectFile::Type
Type
Definition: ObjectFile.h:66
ObjectFilePECOFF::coff_opt_header::heap_reserve_size
uint64_t heap_reserve_size
Definition: ObjectFilePECOFF.h:220
ObjectFilePECOFF::dos_header
Definition: ObjectFilePECOFF.h:155
lldb_private::Target
Definition: Target.h:469
ObjectFilePECOFF::IsExecutable
bool IsExecutable() const override
Tells whether this object file is capable of being the main executable for a process.
Definition: ObjectFilePECOFF.cpp:498
Section.h
lldb_private::eSortOrderNone
@ eSortOrderNone
Definition: lldb-private-enumerations.h:110
ObjectFilePECOFF::dos_header::e_cparhdr
uint16_t e_cparhdr
Definition: ObjectFilePECOFF.h:160
lldb_private::DataExtractor::SetData
lldb::offset_t SetData(const void *bytes, lldb::offset_t length, lldb::ByteOrder byte_order)
Set data with a buffer that is caller owned.
Definition: DataExtractor.cpp:223
ObjectFilePECOFF::Dump
void Dump(lldb_private::Stream *s) override
Dump a description of this object to a Stream.
Definition: ObjectFilePECOFF.cpp:1182
ObjectFilePECOFF::ObjectFilePECOFF
ObjectFilePECOFF(const lldb::ModuleSP &module_sp, lldb::DataBufferSP data_sp, lldb::offset_t data_offset, const lldb_private::FileSpec *file, lldb::offset_t file_offset, lldb::offset_t length)
Process.h
ObjectFilePECOFF::section_header::reloff
uint32_t reloff
Definition: ObjectFilePECOFF.h:234
ObjectFilePECOFF::coff_opt_header::image_size
uint32_t image_size
Definition: ObjectFilePECOFF.h:213
ObjectFilePECOFF::DumpDependentModules
void DumpDependentModules(lldb_private::Stream *s)
Definition: ObjectFilePECOFF.cpp:1355
ObjectFilePECOFF::coff_opt_header::minor_linker_version
uint8_t minor_linker_version
Definition: ObjectFilePECOFF.h:195
Target.h
lldb_private::ModuleSpec::GetUUID
UUID & GetUUID()
Definition: ModuleSpec.h:99
ObjectFilePECOFF::coff_opt_header::dll_flags
uint16_t dll_flags
Definition: ObjectFilePECOFF.h:217
lldb_private::Properties
Definition: UserSettingsController.h:33
lldb_private::DataExtractor::SetByteOrder
void SetByteOrder(lldb::ByteOrder byte_order)
Set the byte_order value.
Definition: DataExtractor.h:931
ObjectFilePECOFF::coff_opt_header::bss_size
uint32_t bss_size
Definition: ObjectFilePECOFF.h:198
lldb_private::SectionList::AddSection
size_t AddSection(const lldb::SectionSP &section_sp)
Definition: Section.cpp:469
GetCoffUUID
static UUID GetCoffUUID(llvm::object::COFFObjectFile &coff_obj)
Definition: ObjectFilePECOFF.cpp:140
lldb_private::FileSpec
Definition: FileSpec.h:55
ObjectFilePECOFF
Definition: ObjectFilePECOFF.h:17
error
static llvm::raw_ostream & error(Stream &strm)
Definition: CommandReturnObject.cpp:17
lldb_private::ObjectFile::GetSectionList
virtual SectionList * GetSectionList(bool update_module_section_list=true)
Gets the section list for the currently selected architecture (and object for archives).
Definition: ObjectFile.cpp:588
lldb_private::UUID::CvRecordPdb70::Uuid
struct lldb_private::UUID::CvRecordPdb70::@44 Uuid
ObjectFilePECOFF::m_sect_headers
SectionHeaderColl m_sect_headers
Definition: ObjectFilePECOFF.h:281
PECallFrameInfo.h
ObjectFilePECOFF::IsStripped
bool IsStripped() override
Detect if this object file has been stripped of local symbols.
Definition: ObjectFilePECOFF.cpp:945
lldb::eSectionTypeDWARFDebugAbbrev
@ eSectionTypeDWARFDebugAbbrev
Definition: lldb-enumerations.h:669
lldb_private::Stream::Indent
size_t Indent(llvm::StringRef s="")
Indent the current line in the stream.
Definition: Stream.cpp:130
ObjectFilePECOFF::coff_opt_header::data_dirs
std::vector< data_directory > data_dirs
Definition: ObjectFilePECOFF.h:225
lldb_private::DataExtractor
Definition: DataExtractor.h:48
lldb_private::ConstString::GetStringRef
llvm::StringRef GetStringRef() const
Get the string value as a llvm::StringRef.
Definition: ConstString.h:201
lldb_private::Symbol::SetID
void SetID(uint32_t uid)
Definition: Symbol.h:129
Log.h
ObjectFilePECOFF::dos_header::e_res2
uint16_t e_res2[10]
Definition: ObjectFilePECOFF.h:173
ObjectFilePECOFF::coff_opt_header::minor_image_version
uint16_t minor_image_version
Definition: ObjectFilePECOFF.h:209
ObjectFilePECOFF::coff_header
Definition: ObjectFilePECOFF.h:177
ObjectFilePECOFF::GetAddress
lldb_private::Address GetAddress(uint32_t rva)
Definition: ObjectFilePECOFF.cpp:671
lldb_private::ObjectFile::eStrataUser
@ eStrataUser
Definition: ObjectFile.h:90
ObjectFilePECOFF::coff_header::hdrsize
uint16_t hdrsize
Definition: ObjectFilePECOFF.h:183
lldb::eSectionTypeDWARFDebugStr
@ eSectionTypeDWARFDebugStr
Definition: lldb-enumerations.h:682
ObjectFilePECOFF::ParseDOSHeader
static bool ParseDOSHeader(lldb_private::DataExtractor &data, dos_header_t &dos_header)
Definition: ObjectFilePECOFF.cpp:522
ObjectFilePECOFF::coff_opt_header
Definition: ObjectFilePECOFF.h:192
ObjectFilePECOFF::CalculateStrata
ObjectFile::Strata CalculateStrata() override
The object file should be able to calculate the strata of the object file.
Definition: ObjectFilePECOFF.cpp:1413
lldb_private::ArchSpec::SetTriple
bool SetTriple(const llvm::Triple &triple)
Architecture triple setter.
Definition: ArchSpec.cpp:738
ObjectFilePECOFF::Initialize
static void Initialize()
Definition: ObjectFilePECOFF.cpp:179
ObjectFilePECOFF::m_coff_header
coff_header_t m_coff_header
Definition: ObjectFilePECOFF.h:279
ObjectFilePECOFF::AppendFromExportTable
rva_symbol_list_t AppendFromExportTable(lldb_private::SectionList *sect_list, lldb_private::Symtab &symtab)
Definition: ObjectFilePECOFF.cpp:849
ObjectFilePECOFF::coff_header::symoff
uint32_t symoff
Definition: ObjectFilePECOFF.h:181
ObjectFilePECOFF::GetFileAddress
lldb::addr_t GetFileAddress(uint32_t rva) const
Definition: ObjectFilePECOFF.cpp:679
lldb_private::DataExtractor::SetAddressByteSize
void SetAddressByteSize(uint32_t addr_size)
Set the address byte size.
Definition: DataExtractor.h:845
StreamString.h
ObjectFilePECOFF::dos_header::e_minalloc
uint16_t e_minalloc
Definition: ObjectFilePECOFF.h:161
lldb_private::Address::GetFileAddress
lldb::addr_t GetFileAddress() const
Get the file address.
Definition: Address.cpp:291
lldb_private::Symbol::GetAddressRef
Address & GetAddressRef()
Definition: Symbol.h:57
ObjectFilePECOFF::coff_opt_header::image_base
uint64_t image_base
Definition: ObjectFilePECOFF.h:203
ObjectFilePECOFF::dos_header::e_crlc
uint16_t e_crlc
Definition: ObjectFilePECOFF.h:159
ObjectFilePECOFF::CreateBinary
bool CreateBinary()
Definition: ObjectFilePECOFF.cpp:392
FileSpecList.h
lldb_private::ConstString
Definition: ConstString.h:39
IMAGE_NT_SIGNATURE
#define IMAGE_NT_SIGNATURE
Definition: ObjectFilePECOFF.cpp:43
ObjectFilePECOFF::coff_opt_header::major_subsystem_version
uint16_t major_subsystem_version
Definition: ObjectFilePECOFF.h:210
lldb::eSectionTypeDWARFDebugInfo
@ eSectionTypeDWARFDebugInfo
Definition: lldb-enumerations.h:674
lldb_private::DataExtractor::GetU8
uint8_t GetU8(lldb::offset_t *offset_ptr) const
Extract a uint8_t value from *offset_ptr.
Definition: DataExtractor.cpp:316
ObjectFilePECOFF::GetArchitecture
lldb_private::ArchSpec GetArchitecture() override
Get the ArchSpec for this object file.
Definition: ObjectFilePECOFF.cpp:1381
Timer.h
ObjectFilePECOFF::coff_opt_header::entry
uint32_t entry
Definition: ObjectFilePECOFF.h:199
ObjectFilePECOFF::AppendFromCOFFSymbolTable
void AppendFromCOFFSymbolTable(lldb_private::SectionList *sect_list, lldb_private::Symtab &symtab, const rva_symbol_list_t &sorted_exports)
Definition: ObjectFilePECOFF.cpp:780
ObjectFilePECOFF::dos_header::e_cp
uint16_t e_cp
Definition: ObjectFilePECOFF.h:158
ObjectFilePECOFF::dos_header::e_lfanew
uint32_t e_lfanew
Definition: ObjectFilePECOFF.h:174
ObjectFilePECOFF::GetPluginNameStatic
static llvm::StringRef GetPluginNameStatic()
Definition: ObjectFilePECOFF.h:62
ObjectFilePECOFF::ParseDependentModules
uint32_t ParseDependentModules()
Definition: ObjectFilePECOFF.cpp:1098
lldb::eSectionTypeDWARFDebugTypes
@ eSectionTypeDWARFDebugTypes
DWARF .debug_types section.
Definition: lldb-enumerations.h:701
lldb_private::SectionList::GetSectionAtIndex
lldb::SectionSP GetSectionAtIndex(size_t idx) const
Definition: Section.cpp:538
lldb::eSectionTypeZeroFill
@ eSectionTypeZeroFill
Definition: lldb-enumerations.h:665
ObjectFilePECOFF::dos_header::e_lfarlc
uint16_t e_lfarlc
Definition: ObjectFilePECOFF.h:168
ObjectFilePECOFF::m_entry_point_address
lldb_private::Address m_entry_point_address
Definition: ObjectFilePECOFF.h:283
ObjectFilePECOFF::coff_opt_header::code_offset
uint32_t code_offset
Definition: ObjectFilePECOFF.h:200
lldb::eSymbolTypeAdditional
@ eSymbolTypeAdditional
When symbols take more than one entry, the extra entries get this type.
Definition: lldb-enumerations.h:641
lldb_private::Debugger
Definition: Debugger.h:74
lldb_private::Stream::GetIndentLevel
unsigned GetIndentLevel() const
Get the current indentation level.
Definition: Stream.cpp:160
lldb_private::ObjectFile::eTypeSharedLibrary
@ eTypeSharedLibrary
A shared library that can be used during execution.
Definition: ObjectFile.h:79
OPT_HEADER_MAGIC_PE32_PLUS
#define OPT_HEADER_MAGIC_PE32_PLUS
Definition: ObjectFilePECOFF.cpp:45
ObjectFilePECOFF::ReadImageDataByRVA
lldb_private::DataExtractor ReadImageDataByRVA(uint32_t rva, size_t size)
Definition: ObjectFilePECOFF.cpp:706
string
string(SUBSTRING ${p} 10 -1 pStripped) if($
Definition: Plugins/CMakeLists.txt:40
ObjectFilePECOFF::m_coff_header_opt
coff_opt_header_t m_coff_header_opt
Definition: ObjectFilePECOFF.h:280
lldb_private::Address::GetSection
lldb::SectionSP GetSection() const
Get const accessor for the section.
Definition: Address.h:429
ObjectFilePECOFF::coff_opt_header::heap_commit_size
uint64_t heap_commit_size
Definition: ObjectFilePECOFF.h:221
lldb_private::Symbol::GetMangled
Mangled & GetMangled()
Definition: Symbol.h:131
ObjectFilePECOFF::m_uuid
lldb_private::UUID m_uuid
Definition: ObjectFilePECOFF.h:286
ObjectFilePECOFF::dos_header::e_csum
uint16_t e_csum
Definition: ObjectFilePECOFF.h:165
lldb::SymbolType
SymbolType
Symbol types.
Definition: lldb-enumerations.h:618
ObjectFilePECOFF::coff_header::flags
uint16_t flags
Definition: ObjectFilePECOFF.h:184
WindowsMiniDump.h
ObjectFilePECOFF::coff_opt_header::magic
uint16_t magic
Definition: ObjectFilePECOFF.h:193
OptionValueProperties.h
ObjectFilePECOFF::section_header::nline
uint16_t nline
Definition: ObjectFilePECOFF.h:237
lldb::eSectionTypeData
@ eSectionTypeData
Definition: lldb-enumerations.h:656
ObjectFile.h
ObjectFilePECOFF::section_header::flags
uint32_t flags
Definition: ObjectFilePECOFF.h:238
IMAGE_DOS_SIGNATURE
#define IMAGE_DOS_SIGNATURE
Definition: ObjectFilePECOFF.cpp:42
lldb_private::Section
Definition: Section.h:102
ObjectFilePECOFF::coff_opt_header::loader_flags
uint32_t loader_flags
Definition: ObjectFilePECOFF.h:222
ObjectFilePECOFF::coff_opt_header::reserved1
uint32_t reserved1
Definition: ObjectFilePECOFF.h:212
lldb::eSectionTypeOther
@ eSectionTypeOther
Definition: lldb-enumerations.h:703
lldb_private::Symtab::GetNumSymbols
size_t GetNumSymbols() const
Definition: Symtab.cpp:77
ObjectFilePECOFF::DebuggerInitialize
static void DebuggerInitialize(lldb_private::Debugger &debugger)
Definition: ObjectFilePECOFF.cpp:186
StreamFile.h
lldb::eSectionTypeCode
@ eSectionTypeCode
Definition: lldb-enumerations.h:654
lldb_private::Symtab::Reserve
void Reserve(size_t count)
Definition: Symtab.cpp:51
lldb_private::ArchSpec::SetArchitecture
bool SetArchitecture(ArchitectureType arch_type, uint32_t cpu, uint32_t sub, uint32_t os=0)
Change the architecture object type, CPU type and OS type.
Definition: ArchSpec.cpp:842
ObjectFilePECOFF::dos_header::e_ss
uint16_t e_ss
Definition: ObjectFilePECOFF.h:163
ObjectFilePECOFF::ParseCOFFHeader
static bool ParseCOFFHeader(lldb_private::DataExtractor &data, lldb::offset_t *offset_ptr, coff_header_t &coff_header)
Definition: ObjectFilePECOFF.cpp:581
lldb_private::Symtab::AddSymbol
uint32_t AddSymbol(const Symbol &symbol)
Definition: Symtab.cpp:64
lldb_private::ModuleSpec
Definition: ModuleSpec.h:27
ObjectFilePECOFF::DumpCOFFHeader
static void DumpCOFFHeader(lldb_private::Stream *s, const coff_header_t &header)
Definition: ObjectFilePECOFF.cpp:1254
ObjectFilePECOFF::dos_header::e_sp
uint16_t e_sp
Definition: ObjectFilePECOFF.h:164
ObjectFilePECOFF::DumpOptCOFFHeader
static void DumpOptCOFFHeader(lldb_private::Stream *s, const coff_opt_header_t &header)
Definition: ObjectFilePECOFF.cpp:1267
ObjectFilePECOFF::section_header_t
struct ObjectFilePECOFF::section_header section_header_t
lldb_private::Status
Definition: Status.h:44
lldb::eSectionTypeEHFrame
@ eSectionTypeEHFrame
Definition: lldb-enumerations.h:692
ObjectFilePECOFF::coff_header::nsyms
uint32_t nsyms
Definition: ObjectFilePECOFF.h:182
lldb_private::ArchSpec::GetArchitectureName
const char * GetArchitectureName() const
Returns a static string representing the current architecture.
Definition: ArchSpec.cpp:535
lldb::eSaveCoreFull
@ eSaveCoreFull
Definition: lldb-enumerations.h:1164
lldb_private::Symtab
Definition: Symtab.h:22
uint32_t
ObjectFilePECOFF::CreateInstance
static ObjectFile * CreateInstance(const lldb::ModuleSP &module_sp, lldb::DataBufferSP data_sp, lldb::offset_t data_offset, const lldb_private::FileSpec *file, lldb::offset_t offset, lldb::offset_t length)
Definition: ObjectFilePECOFF.cpp:206
ObjectFilePECOFF::ID
static char ID
Definition: ObjectFilePECOFF.h:92
ObjectFilePECOFF::SaveCore
static bool SaveCore(const lldb::ProcessSP &process_sp, const lldb_private::FileSpec &outfile, lldb::SaveCoreStyle &core_style, lldb_private::Status &error)
Definition: ObjectFilePECOFF.cpp:359
lldb::SectionType
SectionType
Definition: lldb-enumerations.h:652
lldb_private::FileSpec::GetDirectory
const ConstString & GetDirectory() const
Directory string const get accessor.
Definition: FileSpec.h:222
lldb_private::UUID::CvRecordPdb70
Definition: UUID.h:39
lldb_private::Address
Definition: Address.h:59
ObjectFilePECOFF::ParseSectionHeaders
bool ParseSectionHeaders(uint32_t offset)
Definition: ObjectFilePECOFF.cpp:717
lldb::eSectionTypeDWARFDebugPubTypes
@ eSectionTypeDWARFDebugPubTypes
Definition: lldb-enumerations.h:680
lldb::eSectionTypeDWARFDebugNames
@ eSectionTypeDWARFDebugNames
DWARF v5 .debug_names.
Definition: lldb-enumerations.h:702
lldb_private::DataExtractor::GetMaxU64
uint64_t GetMaxU64(lldb::offset_t *offset_ptr, size_t byte_size) const
Extract an unsigned integer of size byte_size from *offset_ptr.
Definition: DataExtractor.cpp:524
ObjectFilePECOFF::MagicBytesMatch
static bool MagicBytesMatch(lldb::DataBufferSP data_sp)
Definition: ObjectFilePECOFF.cpp:367
lldb_private::Stream::EOL
size_t EOL()
Output and End of Line character to the stream.
Definition: Stream.cpp:128
ObjectFilePECOFF::ParseSymtab
void ParseSymtab(lldb_private::Symtab &symtab) override
Parse the symbol table into the provides symbol table object.
Definition: ObjectFilePECOFF.cpp:769
lldb::eSectionTypeDWARFDebugPubNames
@ eSectionTypeDWARFDebugPubNames
Definition: lldb-enumerations.h:679
ObjectFilePECOFF::SetLoadAddress
bool SetLoadAddress(lldb_private::Target &target, lldb::addr_t value, bool value_is_offset) override
Sets the load address for an entire module, assuming a rigid slide of sections, if possible in the im...
Definition: ObjectFilePECOFF.cpp:465
lldb::eSectionTypeInvalid
@ eSectionTypeInvalid
Definition: lldb-enumerations.h:653
ObjectFilePECOFF::CreateMemoryInstance
static lldb_private::ObjectFile * CreateMemoryInstance(const lldb::ModuleSP &module_sp, lldb::WritableDataBufferSP data_sp, const lldb::ProcessSP &process_sp, lldb::addr_t header_addr)
Definition: ObjectFilePECOFF.cpp:239
ObjectFilePECOFF::m_image_base
lldb::addr_t m_image_base
Definition: ObjectFilePECOFF.h:282
lldb::SaveCoreStyle
SaveCoreStyle
Definition: lldb-enumerations.h:1162
ObjectFilePECOFF::coff_opt_header::data_size
uint32_t data_size
Definition: ObjectFilePECOFF.h:197
lldb_private::Address::ResolveAddressUsingFileSections
bool ResolveAddressUsingFileSections(lldb::addr_t addr, const SectionList *sections)
Resolve a file virtual address using a section list.
Definition: Address.cpp:248
ObjectFilePECOFF::GetModuleSpecifications
static size_t GetModuleSpecifications(const lldb_private::FileSpec &file, lldb::DataBufferSP &data_sp, lldb::offset_t data_offset, lldb::offset_t file_offset, lldb::offset_t length, lldb_private::ModuleSpecList &specs)
Definition: ObjectFilePECOFF.cpp:252
lldb::eSectionTypeDataCString
@ eSectionTypeDataCString
Inlined C string data.
Definition: lldb-enumerations.h:657
ObjectFilePECOFF::SectionHeaderCollIter
SectionHeaderColl::iterator SectionHeaderCollIter
Definition: ObjectFilePECOFF.h:266
ArchSpec.h
lldb_private::Stream::AsRawOstream
llvm::raw_ostream & AsRawOstream()
Returns a raw_ostream that forwards the data to this Stream object.
Definition: Stream.h:357
UINT32_MAX
#define UINT32_MAX
Definition: lldb-defines.h:19
lldb_private::ObjectFile::m_data
DataExtractor m_data
The data for this object file so things can be parsed lazily.
Definition: ObjectFile.h:740
ObjectFilePECOFF::coff_opt_header::header_size
uint32_t header_size
Definition: ObjectFilePECOFF.h:214
ObjectFilePECOFF::DumpSectionHeader
void DumpSectionHeader(lldb_private::Stream *s, const section_header_t &sh)
Definition: ObjectFilePECOFF.cpp:1323
ObjectFilePECOFF::CreateCallFrameInfo
std::unique_ptr< lldb_private::CallFrameInfo > CreateCallFrameInfo() override
Creates a plugin-specific call frame info.
Definition: ObjectFilePECOFF.cpp:929
lldb_private::ModuleChild::GetModule
lldb::ModuleSP GetModule() const
Get const accessor for the module pointer.
Definition: ModuleChild.cpp:24
uint16_t
lldb_private::DataExtractor::GetU32
uint32_t GetU32(lldb::offset_t *offset_ptr) const
Extract a uint32_t value from *offset_ptr.
Definition: DataExtractor.cpp:425
lldb_private::SaveMiniDump
bool SaveMiniDump(const lldb::ProcessSP &process_sp, const lldb_private::FileSpec &outfile, lldb_private::Status &error)
Definition: WindowsMiniDump.cpp:23
lldb_private::FileSpec::SetDirectory
void SetDirectory(ConstString directory)
Directory string set accessor.
Definition: FileSpec.cpp:332
ObjectFilePECOFF.h
PluginManager.h
lldb_private::Address::SetOffset
bool SetOffset(lldb::addr_t offset)
Set accessor for the offset.
Definition: Address.h:438
lldb_private::Target::GetSectionLoadList
SectionLoadList & GetSectionLoadList()
Definition: Target.h:1102
LLDB_INVALID_ADDRESS
#define LLDB_INVALID_ADDRESS
Definition: lldb-defines.h:74
lldb_private::ModuleSpec::GetArchitecture
ArchSpec & GetArchitecture()
Definition: ModuleSpec.h:89
ObjectFilePECOFF::MapSymbolType
static lldb::SymbolType MapSymbolType(uint16_t coff_symbol_type)
Definition: ObjectFilePECOFF.cpp:374
ObjectFilePECOFF::DumpDOSHeader
static void DumpDOSHeader(lldb_private::Stream *s, const dos_header_t &header)
Definition: ObjectFilePECOFF.cpp:1222
LLDB_LOG
#define LLDB_LOG(log,...)
The LLDB_LOG* macros defined below are the way to emit log messages.
Definition: Log.h:337
lldb_private::Stream::Printf
size_t Printf(const char *format,...) __attribute__((format(printf
Output printf formatted output to the stream.
Definition: Stream.cpp:107
lldb::user_id_t
uint64_t user_id_t
Definition: lldb-types.h:84
ObjectFilePECOFF::coff_opt_header::major_os_system_version
uint16_t major_os_system_version
Definition: ObjectFilePECOFF.h:206
ObjectFilePECOFF::section_header::vmsize
uint32_t vmsize
Definition: ObjectFilePECOFF.h:230
lldb_private
A class that represents a running process on the host machine.
Definition: SBCommandInterpreterRunOptions.h:16
lldb_private::DataExtractor::GetU16
uint16_t GetU16(lldb::offset_t *offset_ptr) const
Extract a uint16_t value from *offset_ptr.
Definition: DataExtractor.cpp:347
lldb_private::DataExtractor::GetCStr
const char * GetCStr(lldb::offset_t *offset_ptr) const
Extract a C string from *offset_ptr.
Definition: DataExtractor.cpp:784
Error
llvm::Error Error
Definition: UdtRecordCompleter.cpp:30
ObjectFilePECOFF::dos_header::e_cs
uint16_t e_cs
Definition: ObjectFilePECOFF.h:167
ObjectFilePECOFF::coff_opt_header::stack_commit_size
uint64_t stack_commit_size
Definition: ObjectFilePECOFF.h:219
ObjectFilePECOFF::GetBaseAddress
lldb_private::Address GetBaseAddress() override
Returns base address of this object file.
Definition: ObjectFilePECOFF.cpp:1174
ObjectFilePECOFF::dos_header::e_ovno
uint16_t e_ovno
Definition: ObjectFilePECOFF.h:169
FileSpec.h
lldb::eByteOrderBig
@ eByteOrderBig
Definition: lldb-enumerations.h:140
ObjectFilePECOFF::CalculateType
ObjectFile::Type CalculateType() override
The object file should be able to calculate its type by looking at its file header and possibly the s...
Definition: ObjectFilePECOFF.cpp:1403
lldb_private::OptionValueDictionary
Definition: OptionValueDictionary.h:19
ObjectFilePECOFF::coff_header::nsects
uint16_t nsects
Definition: ObjectFilePECOFF.h:179
lldb_private::Address::GetOffset
lldb::addr_t GetOffset() const
Get the section relative offset value.
Definition: Address.h:319
ObjectFilePECOFF::coff_opt_header::file_alignment
uint32_t file_alignment
Definition: ObjectFilePECOFF.h:205
ObjectFilePECOFF::GetSectionName
llvm::StringRef GetSectionName(const section_header_t &sect)
Definition: ObjectFilePECOFF.cpp:753
ObjectFilePECOFF::GetEntryPointAddress
lldb_private::Address GetEntryPointAddress() override
Returns the address of the Entry Point in this object file - if the object file doesn't have an entry...
Definition: ObjectFilePECOFF.cpp:1156
lldb_private::ModuleSpecList::GetSize
size_t GetSize() const
Definition: ModuleSpec.h:298
LLDB_PLUGIN_DEFINE
#define LLDB_PLUGIN_DEFINE(PluginName)
Definition: PluginManager.h:31
lldb_private::Log
Definition: Log.h:115
ObjectFilePECOFF::m_binary
std::unique_ptr< llvm::object::COFFObjectFile > m_binary
Definition: ObjectFilePECOFF.h:285
lldb_private::Stream::PutCString
size_t PutCString(llvm::StringRef cstr)
Output a C string to the stream.
Definition: Stream.cpp:63
lldb::eSectionTypeDWARFDebugMacInfo
@ eSectionTypeDWARFDebugMacInfo
Definition: lldb-enumerations.h:677
ObjectFilePECOFF::coff_opt_header::minor_subsystem_version
uint16_t minor_subsystem_version
Definition: ObjectFilePECOFF.h:211
lldb::eSymbolTypeAbsolute
@ eSymbolTypeAbsolute
Definition: lldb-enumerations.h:621
ObjectFilePECOFF::rva_symbol_list_t
std::vector< std::pair< uint32_t, uint32_t > > rva_symbol_list_t
Definition: ObjectFilePECOFF.h:271
lldb_private::GetLog
Log * GetLog(Cat mask)
Retrieve the Log object for the channel associated with the given log enum.
Definition: Log.h:309
lldb_private::FileSpec::GetPath
size_t GetPath(char *path, size_t max_path_length, bool denormalize=true) const
Extract the full path to the file.
Definition: FileSpec.cpp:364
lldb_private::Symbol::GetDisplayName
ConstString GetDisplayName() const
Definition: Symbol.cpp:121
ObjectFilePECOFF::coff_opt_header::major_image_version
uint16_t major_image_version
Definition: ObjectFilePECOFF.h:208
ObjectFilePECOFF::coff_header::machine
uint16_t machine
Definition: ObjectFilePECOFF.h:178
ObjectFilePECOFF::data_directory
Definition: ObjectFilePECOFF.h:187
lldb::eByteOrderLittle
@ eByteOrderLittle
Definition: lldb-enumerations.h:142
ObjectFilePECOFF::dos_header::e_cblp
uint16_t e_cblp
Definition: ObjectFilePECOFF.h:157
lldb_private::Symbol::GetType
lldb::SymbolType GetType() const
Definition: Symbol.h:153
lldb_private::ObjectFile::Strata
Strata
Definition: ObjectFile.h:87
ObjectFilePECOFF::coff_opt_header::data_offset
uint32_t data_offset
Definition: ObjectFilePECOFF.h:201
lldb_private::DataExtractor::ValidOffsetForDataOfSize
bool ValidOffsetForDataOfSize(lldb::offset_t offset, lldb::offset_t length) const
Test the availability of length bytes of data from offset.
Definition: DataExtractor.h:965
lldb
Definition: SBAddress.h:15
ObjectFilePECOFF::m_deps_filespec
llvm::Optional< lldb_private::FileSpecList > m_deps_filespec
Definition: ObjectFilePECOFF.h:284
LLDB_LOG_ERROR
#define LLDB_LOG_ERROR(log, error,...)
Definition: Log.h:360
lldb::eSectionTypeDWARFDebugLocLists
@ eSectionTypeDWARFDebugLocLists
DWARF v5 .debug_loclists.
Definition: lldb-enumerations.h:706
LLDBLog.h
lldb::eSectionTypeGoSymtab
@ eSectionTypeGoSymtab
Definition: lldb-enumerations.h:697
lldb_private::Symbol::SetDemangledNameIsSynthesized
void SetDemangledNameIsSynthesized(bool b)
Definition: Symbol.h:213
lldb_private::ObjectFile
Definition: ObjectFile.h:60
DataBufferHeap.h
lldb_private::SectionList::FindSectionByID
lldb::SectionSP FindSectionByID(lldb::user_id_t sect_id) const
Definition: Section.cpp:568
ObjectFilePECOFF::GetRVA
uint32_t GetRVA(const lldb_private::Address &addr) const
Definition: ObjectFilePECOFF.cpp:667
lldb_private::ObjectFile::m_sections_up
std::unique_ptr< lldb_private::SectionList > m_sections_up
Definition: ObjectFile.h:744
ObjectFilePECOFF::ParseHeader
bool ParseHeader() override
Attempts to parse the object header.
Definition: ObjectFilePECOFF.cpp:440
ObjectFilePECOFF::IsWindowsSubsystem
bool IsWindowsSubsystem()
Definition: ObjectFilePECOFF.cpp:1366
ObjectFilePECOFF::section_header::name
char name[8]
Definition: ObjectFilePECOFF.h:229
lldb::ByteOrder
ByteOrder
Byte ordering definitions.
Definition: lldb-enumerations.h:138
ObjectFilePECOFF::section_header::nreloc
uint16_t nreloc
Definition: ObjectFilePECOFF.h:236
ObjectFilePECOFF::section_header::vmaddr
uint32_t vmaddr
Definition: ObjectFilePECOFF.h:231
ObjectFilePECOFF::GetSectionType
static lldb::SectionType GetSectionType(llvm::StringRef sect_name, const section_header_t &sect)
Definition: ObjectFilePECOFF.cpp:950
ObjectFilePECOFF::GetByteOrder
lldb::ByteOrder GetByteOrder() const override
Gets whether endian swapping should occur when extracting data from this object file.
Definition: ObjectFilePECOFF.cpp:496