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"
19 #include "lldb/Symbol/ObjectFile.h"
20 #include "lldb/Target/Process.h"
22 #include "lldb/Target/Target.h"
23 #include "lldb/Utility/ArchSpec.h"
25 #include "lldb/Utility/FileSpec.h"
26 #include "lldb/Utility/Log.h"
28 #include "lldb/Utility/Timer.h"
29 #include "lldb/Utility/UUID.h"
30 #include "llvm/BinaryFormat/COFF.h"
31 
32 #include "llvm/Object/COFFImportFile.h"
33 #include "llvm/Support/Error.h"
34 #include "llvm/Support/MemoryBuffer.h"
35 
36 #define IMAGE_DOS_SIGNATURE 0x5A4D // MZ
37 #define IMAGE_NT_SIGNATURE 0x00004550 // PE00
38 #define OPT_HEADER_MAGIC_PE32 0x010b
39 #define OPT_HEADER_MAGIC_PE32_PLUS 0x020b
40 
41 using namespace lldb;
42 using namespace lldb_private;
43 
45 
46 static UUID GetCoffUUID(llvm::object::COFFObjectFile &coff_obj) {
47  const llvm::codeview::DebugInfo *pdb_info = nullptr;
48  llvm::StringRef pdb_file;
49 
50  if (!coff_obj.getDebugPDBInfo(pdb_info, pdb_file) && pdb_info) {
51  if (pdb_info->PDB70.CVSignature == llvm::OMF::Signature::PDB70) {
53  memcpy(&info.Uuid, pdb_info->PDB70.Signature, sizeof(info.Uuid));
54  info.Age = pdb_info->PDB70.Age;
55  return UUID::fromCvRecord(info);
56  }
57  }
58 
59  return UUID();
60 }
61 
63 
65  PluginManager::RegisterPlugin(
66  GetPluginNameStatic(), GetPluginDescriptionStatic(), CreateInstance,
67  CreateMemoryInstance, GetModuleSpecifications, SaveCore);
68 }
69 
71  PluginManager::UnregisterPlugin(CreateInstance);
72 }
73 
75  return "Portable Executable and Common Object File Format object file reader "
76  "(32 and 64 bit)";
77 }
78 
79 ObjectFile *ObjectFilePECOFF::CreateInstance(const lldb::ModuleSP &module_sp,
80  DataBufferSP &data_sp,
81  lldb::offset_t data_offset,
82  const lldb_private::FileSpec *file_p,
83  lldb::offset_t file_offset,
84  lldb::offset_t length) {
85  FileSpec file = file_p ? *file_p : FileSpec();
86  if (!data_sp) {
87  data_sp = MapFileData(file, length, file_offset);
88  if (!data_sp)
89  return nullptr;
90  data_offset = 0;
91  }
92 
94  return nullptr;
95 
96  // Update the data to contain the entire file if it doesn't already
97  if (data_sp->GetByteSize() < length) {
98  data_sp = MapFileData(file, length, file_offset);
99  if (!data_sp)
100  return nullptr;
101  }
102 
103  auto objfile_up = std::make_unique<ObjectFilePECOFF>(
104  module_sp, data_sp, data_offset, file_p, file_offset, length);
105  if (!objfile_up || !objfile_up->ParseHeader())
106  return nullptr;
107 
108  // Cache coff binary.
109  if (!objfile_up->CreateBinary())
110  return nullptr;
111  return objfile_up.release();
112 }
113 
115  const lldb::ModuleSP &module_sp, lldb::DataBufferSP &data_sp,
116  const lldb::ProcessSP &process_sp, lldb::addr_t header_addr) {
117  if (!data_sp || !ObjectFilePECOFF::MagicBytesMatch(data_sp))
118  return nullptr;
119  auto objfile_up = std::make_unique<ObjectFilePECOFF>(
120  module_sp, data_sp, process_sp, header_addr);
121  if (objfile_up.get() && objfile_up->ParseHeader()) {
122  return objfile_up.release();
123  }
124  return nullptr;
125 }
126 
128  const lldb_private::FileSpec &file, lldb::DataBufferSP &data_sp,
129  lldb::offset_t data_offset, lldb::offset_t file_offset,
131  const size_t initial_count = specs.GetSize();
132  if (!data_sp || !ObjectFilePECOFF::MagicBytesMatch(data_sp))
133  return initial_count;
134 
136 
137  if (data_sp->GetByteSize() < length)
138  if (DataBufferSP full_sp = MapFileData(file, -1, file_offset))
139  data_sp = std::move(full_sp);
140  auto binary = llvm::object::createBinary(llvm::MemoryBufferRef(
141  toStringRef(data_sp->GetData()), file.GetFilename().GetStringRef()));
142 
143  if (!binary) {
144  LLDB_LOG_ERROR(log, binary.takeError(),
145  "Failed to create binary for file ({1}): {0}", file);
146  return initial_count;
147  }
148 
149  auto *COFFObj = llvm::dyn_cast<llvm::object::COFFObjectFile>(binary->get());
150  if (!COFFObj)
151  return initial_count;
152 
153  ModuleSpec module_spec(file);
154  ArchSpec &spec = module_spec.GetArchitecture();
155  lldb_private::UUID &uuid = module_spec.GetUUID();
156  if (!uuid.IsValid())
157  uuid = GetCoffUUID(*COFFObj);
158 
159  switch (COFFObj->getMachine()) {
160  case MachineAmd64:
161  spec.SetTriple("x86_64-pc-windows");
162  specs.Append(module_spec);
163  break;
164  case MachineX86:
165  spec.SetTriple("i386-pc-windows");
166  specs.Append(module_spec);
167  spec.SetTriple("i686-pc-windows");
168  specs.Append(module_spec);
169  break;
170  case MachineArmNt:
171  spec.SetTriple("armv7-pc-windows");
172  specs.Append(module_spec);
173  break;
174  case MachineArm64:
175  spec.SetTriple("aarch64-pc-windows");
176  specs.Append(module_spec);
177  break;
178  default:
179  break;
180  }
181 
182  return specs.GetSize() - initial_count;
183 }
184 
185 bool ObjectFilePECOFF::SaveCore(const lldb::ProcessSP &process_sp,
186  const lldb_private::FileSpec &outfile,
187  lldb::SaveCoreStyle &core_style,
189  core_style = eSaveCoreFull;
190  return SaveMiniDump(process_sp, outfile, error);
191 }
192 
193 bool ObjectFilePECOFF::MagicBytesMatch(DataBufferSP &data_sp) {
194  DataExtractor data(data_sp, eByteOrderLittle, 4);
195  lldb::offset_t offset = 0;
196  uint16_t magic = data.GetU16(&offset);
197  return magic == IMAGE_DOS_SIGNATURE;
198 }
199 
201  // TODO: We need to complete this mapping of COFF symbol types to LLDB ones.
202  // For now, here's a hack to make sure our function have types.
203  const auto complex_type =
204  coff_symbol_type >> llvm::COFF::SCT_COMPLEX_TYPE_SHIFT;
205  if (complex_type == llvm::COFF::IMAGE_SYM_DTYPE_FUNCTION) {
206  return lldb::eSymbolTypeCode;
207  }
209 }
210 
212  if (m_binary)
213  return true;
214 
216 
217  auto binary = llvm::object::createBinary(llvm::MemoryBufferRef(
218  toStringRef(m_data.GetData()), m_file.GetFilename().GetStringRef()));
219  if (!binary) {
220  LLDB_LOG_ERROR(log, binary.takeError(),
221  "Failed to create binary for file ({1}): {0}", m_file);
222  return false;
223  }
224 
225  // Make sure we only handle COFF format.
226  m_binary =
227  llvm::unique_dyn_cast<llvm::object::COFFObjectFile>(std::move(*binary));
228  if (!m_binary)
229  return false;
230 
231  LLDB_LOG(log, "this = {0}, module = {1} ({2}), file = {3}, binary = {4}",
232  this, GetModule().get(), GetModule()->GetSpecificationDescription(),
233  m_file.GetPath(), m_binary.get());
234  return true;
235 }
236 
237 ObjectFilePECOFF::ObjectFilePECOFF(const lldb::ModuleSP &module_sp,
238  DataBufferSP &data_sp,
239  lldb::offset_t data_offset,
240  const FileSpec *file,
241  lldb::offset_t file_offset,
242  lldb::offset_t length)
243  : ObjectFile(module_sp, file, file_offset, length, data_sp, data_offset),
244  m_dos_header(), m_coff_header(), m_sect_headers(),
245  m_entry_point_address(), m_deps_filespec() {
246  ::memset(&m_dos_header, 0, sizeof(m_dos_header));
247  ::memset(&m_coff_header, 0, sizeof(m_coff_header));
248 }
249 
250 ObjectFilePECOFF::ObjectFilePECOFF(const lldb::ModuleSP &module_sp,
251  DataBufferSP &header_data_sp,
252  const lldb::ProcessSP &process_sp,
253  addr_t header_addr)
254  : ObjectFile(module_sp, process_sp, header_addr, header_data_sp),
255  m_dos_header(), m_coff_header(), m_sect_headers(),
256  m_entry_point_address(), m_deps_filespec() {
257  ::memset(&m_dos_header, 0, sizeof(m_dos_header));
258  ::memset(&m_coff_header, 0, sizeof(m_coff_header));
259 }
260 
262 
264  ModuleSP module_sp(GetModule());
265  if (module_sp) {
266  std::lock_guard<std::recursive_mutex> guard(module_sp->GetMutex());
267  m_sect_headers.clear();
269  lldb::offset_t offset = 0;
270 
272  offset = m_dos_header.e_lfanew;
273  uint32_t pe_signature = m_data.GetU32(&offset);
274  if (pe_signature != IMAGE_NT_SIGNATURE)
275  return false;
276  if (ParseCOFFHeader(m_data, &offset, m_coff_header)) {
277  if (m_coff_header.hdrsize > 0)
278  ParseCOFFOptionalHeader(&offset);
279  ParseSectionHeaders(offset);
280  }
282  return true;
283  }
284  }
285  return false;
286 }
287 
289  bool value_is_offset) {
290  bool changed = false;
291  ModuleSP module_sp = GetModule();
292  if (module_sp) {
293  size_t num_loaded_sections = 0;
294  SectionList *section_list = GetSectionList();
295  if (section_list) {
296  if (!value_is_offset) {
297  value -= m_image_base;
298  }
299 
300  const size_t num_sections = section_list->GetSize();
301  size_t sect_idx = 0;
302 
303  for (sect_idx = 0; sect_idx < num_sections; ++sect_idx) {
304  // Iterate through the object file sections to find all of the sections
305  // that have SHF_ALLOC in their flag bits.
306  SectionSP section_sp(section_list->GetSectionAtIndex(sect_idx));
307  if (section_sp && !section_sp->IsThreadSpecific()) {
309  section_sp, section_sp->GetFileAddress() + value))
310  ++num_loaded_sections;
311  }
312  }
313  changed = num_loaded_sections > 0;
314  }
315  }
316  return changed;
317 }
318 
320 
322  return (m_coff_header.flags & llvm::COFF::IMAGE_FILE_DLL) == 0;
323 }
324 
327  return 8;
329  return 4;
330  return 4;
331 }
332 
333 // NeedsEndianSwap
334 //
335 // Return true if an endian swap needs to occur when extracting data from this
336 // file.
338 #if defined(__LITTLE_ENDIAN__)
339  return false;
340 #else
341  return true;
342 #endif
343 }
344 // ParseDOSHeader
347  bool success = false;
348  lldb::offset_t offset = 0;
349  success = data.ValidOffsetForDataOfSize(0, sizeof(dos_header));
350 
351  if (success) {
352  dos_header.e_magic = data.GetU16(&offset); // Magic number
354 
355  if (success) {
356  dos_header.e_cblp = data.GetU16(&offset); // Bytes on last page of file
357  dos_header.e_cp = data.GetU16(&offset); // Pages in file
358  dos_header.e_crlc = data.GetU16(&offset); // Relocations
360  data.GetU16(&offset); // Size of header in paragraphs
362  data.GetU16(&offset); // Minimum extra paragraphs needed
364  data.GetU16(&offset); // Maximum extra paragraphs needed
365  dos_header.e_ss = data.GetU16(&offset); // Initial (relative) SS value
366  dos_header.e_sp = data.GetU16(&offset); // Initial SP value
367  dos_header.e_csum = data.GetU16(&offset); // Checksum
368  dos_header.e_ip = data.GetU16(&offset); // Initial IP value
369  dos_header.e_cs = data.GetU16(&offset); // Initial (relative) CS value
371  data.GetU16(&offset); // File address of relocation table
372  dos_header.e_ovno = data.GetU16(&offset); // Overlay number
373 
374  dos_header.e_res[0] = data.GetU16(&offset); // Reserved words
375  dos_header.e_res[1] = data.GetU16(&offset); // Reserved words
376  dos_header.e_res[2] = data.GetU16(&offset); // Reserved words
377  dos_header.e_res[3] = data.GetU16(&offset); // Reserved words
378 
380  data.GetU16(&offset); // OEM identifier (for e_oeminfo)
382  data.GetU16(&offset); // OEM information; e_oemid specific
383  dos_header.e_res2[0] = data.GetU16(&offset); // Reserved words
384  dos_header.e_res2[1] = data.GetU16(&offset); // Reserved words
385  dos_header.e_res2[2] = data.GetU16(&offset); // Reserved words
386  dos_header.e_res2[3] = data.GetU16(&offset); // Reserved words
387  dos_header.e_res2[4] = data.GetU16(&offset); // Reserved words
388  dos_header.e_res2[5] = data.GetU16(&offset); // Reserved words
389  dos_header.e_res2[6] = data.GetU16(&offset); // Reserved words
390  dos_header.e_res2[7] = data.GetU16(&offset); // Reserved words
391  dos_header.e_res2[8] = data.GetU16(&offset); // Reserved words
392  dos_header.e_res2[9] = data.GetU16(&offset); // Reserved words
393 
395  data.GetU32(&offset); // File address of new exe header
396  }
397  }
398  if (!success)
399  memset(&dos_header, 0, sizeof(dos_header));
400  return success;
401 }
402 
403 // ParserCOFFHeader
405  lldb::offset_t *offset_ptr,
407  bool success =
408  data.ValidOffsetForDataOfSize(*offset_ptr, sizeof(coff_header));
409  if (success) {
410  coff_header.machine = data.GetU16(offset_ptr);
411  coff_header.nsects = data.GetU16(offset_ptr);
412  coff_header.modtime = data.GetU32(offset_ptr);
413  coff_header.symoff = data.GetU32(offset_ptr);
414  coff_header.nsyms = data.GetU32(offset_ptr);
415  coff_header.hdrsize = data.GetU16(offset_ptr);
416  coff_header.flags = data.GetU16(offset_ptr);
417  }
418  if (!success)
419  memset(&coff_header, 0, sizeof(coff_header));
420  return success;
421 }
422 
424  bool success = false;
425  const lldb::offset_t end_offset = *offset_ptr + m_coff_header.hdrsize;
426  if (*offset_ptr < end_offset) {
427  success = true;
428  m_coff_header_opt.magic = m_data.GetU16(offset_ptr);
433  m_coff_header_opt.bss_size = m_data.GetU32(offset_ptr);
434  m_coff_header_opt.entry = m_data.GetU32(offset_ptr);
436 
437  const uint32_t addr_byte_size = GetAddressByteSize();
438 
439  if (*offset_ptr < end_offset) {
441  // PE32 only
443  } else
445 
446  if (*offset_ptr < end_offset) {
448  m_data.GetMaxU64(offset_ptr, addr_byte_size);
460  m_coff_header_opt.checksum = m_data.GetU32(offset_ptr);
464  m_data.GetMaxU64(offset_ptr, addr_byte_size);
466  m_data.GetMaxU64(offset_ptr, addr_byte_size);
468  m_data.GetMaxU64(offset_ptr, addr_byte_size);
470  m_data.GetMaxU64(offset_ptr, addr_byte_size);
472  uint32_t num_data_dir_entries = m_data.GetU32(offset_ptr);
474  m_coff_header_opt.data_dirs.resize(num_data_dir_entries);
475  uint32_t i;
476  for (i = 0; i < num_data_dir_entries; i++) {
477  m_coff_header_opt.data_dirs[i].vmaddr = m_data.GetU32(offset_ptr);
478  m_coff_header_opt.data_dirs[i].vmsize = m_data.GetU32(offset_ptr);
479  }
480 
482  }
483  }
484  }
485  // Make sure we are on track for section data which follows
486  *offset_ptr = end_offset;
487  return success;
488 }
489 
491  return addr.GetFileAddress() - m_image_base;
492 }
493 
495  SectionList *sect_list = GetSectionList();
496  if (!sect_list)
497  return Address(GetFileAddress(rva));
498 
499  return Address(GetFileAddress(rva), sect_list);
500 }
501 
503  return m_image_base + rva;
504 }
505 
507  if (!size)
508  return {};
509 
510  if (m_data.ValidOffsetForDataOfSize(offset, size))
511  return DataExtractor(m_data, offset, size);
512 
513  ProcessSP process_sp(m_process_wp.lock());
514  DataExtractor data;
515  if (process_sp) {
516  auto data_up = std::make_unique<DataBufferHeap>(size, 0);
517  Status readmem_error;
518  size_t bytes_read =
519  process_sp->ReadMemory(m_image_base + offset, data_up->GetBytes(),
520  data_up->GetByteSize(), readmem_error);
521  if (bytes_read == size) {
522  DataBufferSP buffer_sp(data_up.release());
523  data.SetData(buffer_sp, 0, buffer_sp->GetByteSize());
524  }
525  }
526  return data;
527 }
528 
530  Address addr = GetAddress(rva);
531  SectionSP sect = addr.GetSection();
532  if (!sect)
533  return {};
534  rva = sect->GetFileOffset() + addr.GetOffset();
535 
536  return ReadImageData(rva, size);
537 }
538 
539 // ParseSectionHeaders
541  uint32_t section_header_data_offset) {
542  const uint32_t nsects = m_coff_header.nsects;
543  m_sect_headers.clear();
544 
545  if (nsects > 0) {
546  const size_t section_header_byte_size = nsects * sizeof(section_header_t);
547  DataExtractor section_header_data =
548  ReadImageData(section_header_data_offset, section_header_byte_size);
549 
550  lldb::offset_t offset = 0;
551  if (section_header_data.ValidOffsetForDataOfSize(
552  offset, section_header_byte_size)) {
553  m_sect_headers.resize(nsects);
554 
555  for (uint32_t idx = 0; idx < nsects; ++idx) {
556  const void *name_data = section_header_data.GetData(&offset, 8);
557  if (name_data) {
558  memcpy(m_sect_headers[idx].name, name_data, 8);
559  m_sect_headers[idx].vmsize = section_header_data.GetU32(&offset);
560  m_sect_headers[idx].vmaddr = section_header_data.GetU32(&offset);
561  m_sect_headers[idx].size = section_header_data.GetU32(&offset);
562  m_sect_headers[idx].offset = section_header_data.GetU32(&offset);
563  m_sect_headers[idx].reloff = section_header_data.GetU32(&offset);
564  m_sect_headers[idx].lineoff = section_header_data.GetU32(&offset);
565  m_sect_headers[idx].nreloc = section_header_data.GetU16(&offset);
566  m_sect_headers[idx].nline = section_header_data.GetU16(&offset);
567  m_sect_headers[idx].flags = section_header_data.GetU32(&offset);
568  }
569  }
570  }
571  }
572 
573  return !m_sect_headers.empty();
574 }
575 
577  llvm::StringRef hdr_name(sect.name, llvm::array_lengthof(sect.name));
578  hdr_name = hdr_name.split('\0').first;
579  if (hdr_name.consume_front("/")) {
580  lldb::offset_t stroff;
581  if (!to_integer(hdr_name, stroff, 10))
582  return "";
583  lldb::offset_t string_file_offset =
584  m_coff_header.symoff + (m_coff_header.nsyms * 18) + stroff;
585  if (const char *name = m_data.GetCStr(&string_file_offset))
586  return name;
587  return "";
588  }
589  return hdr_name;
590 }
591 
592 // GetNListSymtab
594  ModuleSP module_sp(GetModule());
595  if (module_sp) {
596  std::lock_guard<std::recursive_mutex> guard(module_sp->GetMutex());
597  if (m_symtab_up == nullptr) {
598  SectionList *sect_list = GetSectionList();
599  m_symtab_up = std::make_unique<Symtab>(this);
600  std::lock_guard<std::recursive_mutex> guard(m_symtab_up->GetMutex());
601 
602  const uint32_t num_syms = m_coff_header.nsyms;
603 
604  if (m_file && num_syms > 0 && m_coff_header.symoff > 0) {
605  const uint32_t symbol_size = 18;
606  const size_t symbol_data_size = num_syms * symbol_size;
607  // Include the 4-byte string table size at the end of the symbols
608  DataExtractor symtab_data =
609  ReadImageData(m_coff_header.symoff, symbol_data_size + 4);
610  lldb::offset_t offset = symbol_data_size;
611  const uint32_t strtab_size = symtab_data.GetU32(&offset);
612  if (strtab_size > 0) {
613  DataExtractor strtab_data = ReadImageData(
614  m_coff_header.symoff + symbol_data_size, strtab_size);
615 
616  offset = 0;
617  std::string symbol_name;
618  Symbol *symbols = m_symtab_up->Resize(num_syms);
619  for (uint32_t i = 0; i < num_syms; ++i) {
620  coff_symbol_t symbol;
621  const uint32_t symbol_offset = offset;
622  const char *symbol_name_cstr = nullptr;
623  // If the first 4 bytes of the symbol string are zero, then they
624  // are followed by a 4-byte string table offset. Else these
625  // 8 bytes contain the symbol name
626  if (symtab_data.GetU32(&offset) == 0) {
627  // Long string that doesn't fit into the symbol table name, so
628  // now we must read the 4 byte string table offset
629  uint32_t strtab_offset = symtab_data.GetU32(&offset);
630  symbol_name_cstr = strtab_data.PeekCStr(strtab_offset);
631  symbol_name.assign(symbol_name_cstr);
632  } else {
633  // Short string that fits into the symbol table name which is 8
634  // bytes
635  offset += sizeof(symbol.name) - 4; // Skip remaining
636  symbol_name_cstr = symtab_data.PeekCStr(symbol_offset);
637  if (symbol_name_cstr == nullptr)
638  break;
639  symbol_name.assign(symbol_name_cstr, sizeof(symbol.name));
640  }
641  symbol.value = symtab_data.GetU32(&offset);
642  symbol.sect = symtab_data.GetU16(&offset);
643  symbol.type = symtab_data.GetU16(&offset);
644  symbol.storage = symtab_data.GetU8(&offset);
645  symbol.naux = symtab_data.GetU8(&offset);
646  symbols[i].GetMangled().SetValue(ConstString(symbol_name.c_str()));
647  if ((int16_t)symbol.sect >= 1) {
648  Address symbol_addr(sect_list->FindSectionByID(symbol.sect),
649  symbol.value);
650  symbols[i].GetAddressRef() = symbol_addr;
651  symbols[i].SetType(MapSymbolType(symbol.type));
652  }
653 
654  if (symbol.naux > 0) {
655  i += symbol.naux;
656  offset += symbol.naux * symbol_size;
657  }
658  }
659  }
660  }
661 
662  // Read export header
666  export_directory_entry export_table;
667  uint32_t data_start =
669 
670  DataExtractor symtab_data = ReadImageDataByRVA(
671  data_start, m_coff_header_opt.data_dirs[0].vmsize);
672  lldb::offset_t offset = 0;
673 
674  // Read export_table header
675  export_table.characteristics = symtab_data.GetU32(&offset);
676  export_table.time_date_stamp = symtab_data.GetU32(&offset);
677  export_table.major_version = symtab_data.GetU16(&offset);
678  export_table.minor_version = symtab_data.GetU16(&offset);
679  export_table.name = symtab_data.GetU32(&offset);
680  export_table.base = symtab_data.GetU32(&offset);
681  export_table.number_of_functions = symtab_data.GetU32(&offset);
682  export_table.number_of_names = symtab_data.GetU32(&offset);
683  export_table.address_of_functions = symtab_data.GetU32(&offset);
684  export_table.address_of_names = symtab_data.GetU32(&offset);
685  export_table.address_of_name_ordinals = symtab_data.GetU32(&offset);
686 
687  bool has_ordinal = export_table.address_of_name_ordinals != 0;
688 
689  lldb::offset_t name_offset = export_table.address_of_names - data_start;
690  lldb::offset_t name_ordinal_offset =
691  export_table.address_of_name_ordinals - data_start;
692 
693  Symbol *symbols = m_symtab_up->Resize(export_table.number_of_names);
694 
695  std::string symbol_name;
696 
697  // Read each export table entry
698  for (size_t i = 0; i < export_table.number_of_names; ++i) {
699  uint32_t name_ordinal =
700  has_ordinal ? symtab_data.GetU16(&name_ordinal_offset) : i;
701  uint32_t name_address = symtab_data.GetU32(&name_offset);
702 
703  const char *symbol_name_cstr =
704  symtab_data.PeekCStr(name_address - data_start);
705  symbol_name.assign(symbol_name_cstr);
706 
707  lldb::offset_t function_offset = export_table.address_of_functions -
708  data_start +
709  sizeof(uint32_t) * name_ordinal;
710  uint32_t function_rva = symtab_data.GetU32(&function_offset);
711 
712  Address symbol_addr(m_coff_header_opt.image_base + function_rva,
713  sect_list);
714  symbols[i].GetMangled().SetValue(ConstString(symbol_name.c_str()));
715  symbols[i].GetAddressRef() = symbol_addr;
716  symbols[i].SetType(lldb::eSymbolTypeCode);
717  symbols[i].SetDebug(true);
718  }
719  }
720  m_symtab_up->CalculateSymbolSizes();
721  }
722  }
723  return m_symtab_up.get();
724 }
725 
726 std::unique_ptr<CallFrameInfo> ObjectFilePECOFF::CreateCallFrameInfo() {
728  return {};
729 
730  data_directory data_dir_exception =
732  if (!data_dir_exception.vmaddr)
733  return {};
734 
735  if (m_coff_header.machine != llvm::COFF::IMAGE_FILE_MACHINE_AMD64)
736  return {};
737 
738  return std::make_unique<PECallFrameInfo>(*this, data_dir_exception.vmaddr,
739  data_dir_exception.vmsize);
740 }
741 
743  // TODO: determine this for COFF
744  return false;
745 }
746 
748  const section_header_t &sect) {
749  ConstString const_sect_name(sect_name);
750  static ConstString g_code_sect_name(".code");
751  static ConstString g_CODE_sect_name("CODE");
752  static ConstString g_data_sect_name(".data");
753  static ConstString g_DATA_sect_name("DATA");
754  static ConstString g_bss_sect_name(".bss");
755  static ConstString g_BSS_sect_name("BSS");
756 
757  if (sect.flags & llvm::COFF::IMAGE_SCN_CNT_CODE &&
758  ((const_sect_name == g_code_sect_name) ||
759  (const_sect_name == g_CODE_sect_name))) {
760  return eSectionTypeCode;
761  }
762  if (sect.flags & llvm::COFF::IMAGE_SCN_CNT_INITIALIZED_DATA &&
763  ((const_sect_name == g_data_sect_name) ||
764  (const_sect_name == g_DATA_sect_name))) {
765  if (sect.size == 0 && sect.offset == 0)
766  return eSectionTypeZeroFill;
767  else
768  return eSectionTypeData;
769  }
770  if (sect.flags & llvm::COFF::IMAGE_SCN_CNT_UNINITIALIZED_DATA &&
771  ((const_sect_name == g_bss_sect_name) ||
772  (const_sect_name == g_BSS_sect_name))) {
773  if (sect.size == 0)
774  return eSectionTypeZeroFill;
775  else
776  return eSectionTypeData;
777  }
778 
779  SectionType section_type =
780  llvm::StringSwitch<SectionType>(sect_name)
781  .Case(".debug", eSectionTypeDebug)
782  .Case(".stabstr", eSectionTypeDataCString)
783  .Case(".reloc", eSectionTypeOther)
784  .Case(".debug_abbrev", eSectionTypeDWARFDebugAbbrev)
785  .Case(".debug_aranges", eSectionTypeDWARFDebugAranges)
786  .Case(".debug_frame", eSectionTypeDWARFDebugFrame)
787  .Case(".debug_info", eSectionTypeDWARFDebugInfo)
788  .Case(".debug_line", eSectionTypeDWARFDebugLine)
789  .Case(".debug_loc", eSectionTypeDWARFDebugLoc)
790  .Case(".debug_loclists", eSectionTypeDWARFDebugLocLists)
791  .Case(".debug_macinfo", eSectionTypeDWARFDebugMacInfo)
792  .Case(".debug_names", eSectionTypeDWARFDebugNames)
793  .Case(".debug_pubnames", eSectionTypeDWARFDebugPubNames)
794  .Case(".debug_pubtypes", eSectionTypeDWARFDebugPubTypes)
795  .Case(".debug_ranges", eSectionTypeDWARFDebugRanges)
796  .Case(".debug_str", eSectionTypeDWARFDebugStr)
797  .Case(".debug_types", eSectionTypeDWARFDebugTypes)
798  // .eh_frame can be truncated to 8 chars.
799  .Cases(".eh_frame", ".eh_fram", eSectionTypeEHFrame)
800  .Case(".gosymtab", eSectionTypeGoSymtab)
801  .Default(eSectionTypeInvalid);
802  if (section_type != eSectionTypeInvalid)
803  return section_type;
804 
805  if (sect.flags & llvm::COFF::IMAGE_SCN_CNT_CODE)
806  return eSectionTypeCode;
807  if (sect.flags & llvm::COFF::IMAGE_SCN_CNT_INITIALIZED_DATA)
808  return eSectionTypeData;
809  if (sect.flags & llvm::COFF::IMAGE_SCN_CNT_UNINITIALIZED_DATA) {
810  if (sect.size == 0)
811  return eSectionTypeZeroFill;
812  else
813  return eSectionTypeData;
814  }
815  return eSectionTypeOther;
816 }
817 
818 void ObjectFilePECOFF::CreateSections(SectionList &unified_section_list) {
819  if (m_sections_up)
820  return;
821  m_sections_up = std::make_unique<SectionList>();
822  ModuleSP module_sp(GetModule());
823  if (module_sp) {
824  std::lock_guard<std::recursive_mutex> guard(module_sp->GetMutex());
825 
826  SectionSP header_sp = std::make_shared<Section>(
827  module_sp, this, ~user_id_t(0), ConstString("PECOFF header"),
830  /*file_offset*/ 0, m_coff_header_opt.header_size,
832  /*flags*/ 0);
833  header_sp->SetPermissions(ePermissionsReadable);
834  m_sections_up->AddSection(header_sp);
835  unified_section_list.AddSection(header_sp);
836 
837  const uint32_t nsects = m_sect_headers.size();
838  ModuleSP module_sp(GetModule());
839  for (uint32_t idx = 0; idx < nsects; ++idx) {
840  llvm::StringRef sect_name = GetSectionName(m_sect_headers[idx]);
841  ConstString const_sect_name(sect_name);
842  SectionType section_type = GetSectionType(sect_name, m_sect_headers[idx]);
843 
844  SectionSP section_sp(new Section(
845  module_sp, // Module to which this section belongs
846  this, // Object file to which this section belongs
847  idx + 1, // Section ID is the 1 based section index.
848  const_sect_name, // Name of this section
849  section_type,
851  m_sect_headers[idx].vmaddr, // File VM address == addresses as
852  // they are found in the object file
853  m_sect_headers[idx].vmsize, // VM size in bytes of this section
854  m_sect_headers[idx]
855  .offset, // Offset to the data for this section in the file
856  m_sect_headers[idx]
857  .size, // Size in bytes of this section as found in the file
858  m_coff_header_opt.sect_alignment, // Section alignment
859  m_sect_headers[idx].flags)); // Flags for this section
860 
861  uint32_t permissions = 0;
862  if (m_sect_headers[idx].flags & llvm::COFF::IMAGE_SCN_MEM_EXECUTE)
863  permissions |= ePermissionsExecutable;
864  if (m_sect_headers[idx].flags & llvm::COFF::IMAGE_SCN_MEM_READ)
865  permissions |= ePermissionsReadable;
866  if (m_sect_headers[idx].flags & llvm::COFF::IMAGE_SCN_MEM_WRITE)
867  permissions |= ePermissionsWritable;
868  section_sp->SetPermissions(permissions);
869 
870  m_sections_up->AddSection(section_sp);
871  unified_section_list.AddSection(section_sp);
872  }
873  }
874 }
875 
877  if (m_uuid.IsValid())
878  return m_uuid;
879 
880  if (!CreateBinary())
881  return UUID();
882 
884  return m_uuid;
885 }
886 
888  ModuleSP module_sp(GetModule());
889  if (!module_sp)
890  return 0;
891 
892  std::lock_guard<std::recursive_mutex> guard(module_sp->GetMutex());
893  if (m_deps_filespec)
894  return m_deps_filespec->GetSize();
895 
896  // Cache coff binary if it is not done yet.
897  if (!CreateBinary())
898  return 0;
899 
901  LLDB_LOG(log, "this = {0}, module = {1} ({2}), file = {3}, binary = {4}",
902  this, GetModule().get(), GetModule()->GetSpecificationDescription(),
903  m_file.GetPath(), m_binary.get());
904 
905  m_deps_filespec = FileSpecList();
906 
907  for (const auto &entry : m_binary->import_directories()) {
908  llvm::StringRef dll_name;
909  // Report a bogus entry.
910  if (llvm::Error e = entry.getName(dll_name)) {
911  LLDB_LOGF(log,
912  "ObjectFilePECOFF::ParseDependentModules() - failed to get "
913  "import directory entry name: %s",
914  llvm::toString(std::move(e)).c_str());
915  continue;
916  }
917 
918  // At this moment we only have the base name of the DLL. The full path can
919  // only be seen after the dynamic loading. Our best guess is Try to get it
920  // with the help of the object file's directory.
921  llvm::SmallString<128> dll_fullpath;
922  FileSpec dll_specs(dll_name);
924 
925  if (!llvm::sys::fs::real_path(dll_specs.GetPath(), dll_fullpath))
926  m_deps_filespec->EmplaceBack(dll_fullpath);
927  else {
928  // Known DLLs or DLL not found in the object file directory.
929  m_deps_filespec->EmplaceBack(dll_name);
930  }
931  }
932  return m_deps_filespec->GetSize();
933 }
934 
936  auto num_modules = ParseDependentModules();
937  auto original_size = files.GetSize();
938 
939  for (unsigned i = 0; i < num_modules; ++i)
940  files.AppendIfUnique(m_deps_filespec->GetFileSpecAtIndex(i));
941 
942  return files.GetSize() - original_size;
943 }
944 
947  return m_entry_point_address;
948 
949  if (!ParseHeader() || !IsExecutable())
950  return m_entry_point_address;
951 
952  SectionList *section_list = GetSectionList();
954 
955  if (!section_list)
956  m_entry_point_address.SetOffset(file_addr);
957  else
959  section_list);
960  return m_entry_point_address;
961 }
962 
964  return Address(GetSectionList()->GetSectionAtIndex(0), 0);
965 }
966 
967 // Dump
968 //
969 // Dump the specifics of the runtime file container (such as any headers
970 // segments, sections, etc).
972  ModuleSP module_sp(GetModule());
973  if (module_sp) {
974  std::lock_guard<std::recursive_mutex> guard(module_sp->GetMutex());
975  s->Printf("%p: ", static_cast<void *>(this));
976  s->Indent();
977  s->PutCString("ObjectFilePECOFF");
978 
979  ArchSpec header_arch = GetArchitecture();
980 
981  *s << ", file = '" << m_file
982  << "', arch = " << header_arch.GetArchitectureName() << "\n";
983 
984  SectionList *sections = GetSectionList();
985  if (sections)
986  sections->Dump(s->AsRawOstream(), s->GetIndentLevel(), nullptr, true,
987  UINT32_MAX);
988 
989  if (m_symtab_up)
990  m_symtab_up->Dump(s, nullptr, eSortOrderNone);
991 
992  if (m_dos_header.e_magic)
994  if (m_coff_header.machine) {
998  }
999  s->EOL();
1000  DumpSectionHeaders(s);
1001  s->EOL();
1002 
1004  s->EOL();
1005  }
1006 }
1007 
1008 // DumpDOSHeader
1009 //
1010 // Dump the MS-DOS header to the specified output stream
1012  s->PutCString("MSDOS Header\n");
1013  s->Printf(" e_magic = 0x%4.4x\n", header.e_magic);
1014  s->Printf(" e_cblp = 0x%4.4x\n", header.e_cblp);
1015  s->Printf(" e_cp = 0x%4.4x\n", header.e_cp);
1016  s->Printf(" e_crlc = 0x%4.4x\n", header.e_crlc);
1017  s->Printf(" e_cparhdr = 0x%4.4x\n", header.e_cparhdr);
1018  s->Printf(" e_minalloc = 0x%4.4x\n", header.e_minalloc);
1019  s->Printf(" e_maxalloc = 0x%4.4x\n", header.e_maxalloc);
1020  s->Printf(" e_ss = 0x%4.4x\n", header.e_ss);
1021  s->Printf(" e_sp = 0x%4.4x\n", header.e_sp);
1022  s->Printf(" e_csum = 0x%4.4x\n", header.e_csum);
1023  s->Printf(" e_ip = 0x%4.4x\n", header.e_ip);
1024  s->Printf(" e_cs = 0x%4.4x\n", header.e_cs);
1025  s->Printf(" e_lfarlc = 0x%4.4x\n", header.e_lfarlc);
1026  s->Printf(" e_ovno = 0x%4.4x\n", header.e_ovno);
1027  s->Printf(" e_res[4] = { 0x%4.4x, 0x%4.4x, 0x%4.4x, 0x%4.4x }\n",
1028  header.e_res[0], header.e_res[1], header.e_res[2], header.e_res[3]);
1029  s->Printf(" e_oemid = 0x%4.4x\n", header.e_oemid);
1030  s->Printf(" e_oeminfo = 0x%4.4x\n", header.e_oeminfo);
1031  s->Printf(" e_res2[10] = { 0x%4.4x, 0x%4.4x, 0x%4.4x, 0x%4.4x, 0x%4.4x, "
1032  "0x%4.4x, 0x%4.4x, 0x%4.4x, 0x%4.4x, 0x%4.4x }\n",
1033  header.e_res2[0], header.e_res2[1], header.e_res2[2],
1034  header.e_res2[3], header.e_res2[4], header.e_res2[5],
1035  header.e_res2[6], header.e_res2[7], header.e_res2[8],
1036  header.e_res2[9]);
1037  s->Printf(" e_lfanew = 0x%8.8x\n", header.e_lfanew);
1038 }
1039 
1040 // DumpCOFFHeader
1041 //
1042 // Dump the COFF header to the specified output stream
1044  s->PutCString("COFF Header\n");
1045  s->Printf(" machine = 0x%4.4x\n", header.machine);
1046  s->Printf(" nsects = 0x%4.4x\n", header.nsects);
1047  s->Printf(" modtime = 0x%8.8x\n", header.modtime);
1048  s->Printf(" symoff = 0x%8.8x\n", header.symoff);
1049  s->Printf(" nsyms = 0x%8.8x\n", header.nsyms);
1050  s->Printf(" hdrsize = 0x%4.4x\n", header.hdrsize);
1051 }
1052 
1053 // DumpOptCOFFHeader
1054 //
1055 // Dump the optional COFF header to the specified output stream
1057  const coff_opt_header_t &header) {
1058  s->PutCString("Optional COFF Header\n");
1059  s->Printf(" magic = 0x%4.4x\n", header.magic);
1060  s->Printf(" major_linker_version = 0x%2.2x\n",
1061  header.major_linker_version);
1062  s->Printf(" minor_linker_version = 0x%2.2x\n",
1063  header.minor_linker_version);
1064  s->Printf(" code_size = 0x%8.8x\n", header.code_size);
1065  s->Printf(" data_size = 0x%8.8x\n", header.data_size);
1066  s->Printf(" bss_size = 0x%8.8x\n", header.bss_size);
1067  s->Printf(" entry = 0x%8.8x\n", header.entry);
1068  s->Printf(" code_offset = 0x%8.8x\n", header.code_offset);
1069  s->Printf(" data_offset = 0x%8.8x\n", header.data_offset);
1070  s->Printf(" image_base = 0x%16.16" PRIx64 "\n",
1071  header.image_base);
1072  s->Printf(" sect_alignment = 0x%8.8x\n", header.sect_alignment);
1073  s->Printf(" file_alignment = 0x%8.8x\n", header.file_alignment);
1074  s->Printf(" major_os_system_version = 0x%4.4x\n",
1075  header.major_os_system_version);
1076  s->Printf(" minor_os_system_version = 0x%4.4x\n",
1077  header.minor_os_system_version);
1078  s->Printf(" major_image_version = 0x%4.4x\n",
1079  header.major_image_version);
1080  s->Printf(" minor_image_version = 0x%4.4x\n",
1081  header.minor_image_version);
1082  s->Printf(" major_subsystem_version = 0x%4.4x\n",
1083  header.major_subsystem_version);
1084  s->Printf(" minor_subsystem_version = 0x%4.4x\n",
1085  header.minor_subsystem_version);
1086  s->Printf(" reserved1 = 0x%8.8x\n", header.reserved1);
1087  s->Printf(" image_size = 0x%8.8x\n", header.image_size);
1088  s->Printf(" header_size = 0x%8.8x\n", header.header_size);
1089  s->Printf(" checksum = 0x%8.8x\n", header.checksum);
1090  s->Printf(" subsystem = 0x%4.4x\n", header.subsystem);
1091  s->Printf(" dll_flags = 0x%4.4x\n", header.dll_flags);
1092  s->Printf(" stack_reserve_size = 0x%16.16" PRIx64 "\n",
1093  header.stack_reserve_size);
1094  s->Printf(" stack_commit_size = 0x%16.16" PRIx64 "\n",
1095  header.stack_commit_size);
1096  s->Printf(" heap_reserve_size = 0x%16.16" PRIx64 "\n",
1097  header.heap_reserve_size);
1098  s->Printf(" heap_commit_size = 0x%16.16" PRIx64 "\n",
1099  header.heap_commit_size);
1100  s->Printf(" loader_flags = 0x%8.8x\n", header.loader_flags);
1101  s->Printf(" num_data_dir_entries = 0x%8.8x\n",
1102  (uint32_t)header.data_dirs.size());
1103  uint32_t i;
1104  for (i = 0; i < header.data_dirs.size(); i++) {
1105  s->Printf(" data_dirs[%2u] vmaddr = 0x%8.8x, vmsize = 0x%8.8x\n", i,
1106  header.data_dirs[i].vmaddr, header.data_dirs[i].vmsize);
1107  }
1108 }
1109 // DumpSectionHeader
1110 //
1111 // Dump a single ELF section header to the specified output stream
1113  const section_header_t &sh) {
1115  s->Printf("%-16s 0x%8.8x 0x%8.8x 0x%8.8x 0x%8.8x 0x%8.8x 0x%8.8x 0x%4.4x "
1116  "0x%4.4x 0x%8.8x\n",
1117  name.c_str(), sh.vmaddr, sh.vmsize, sh.offset, sh.size, sh.reloff,
1118  sh.lineoff, sh.nreloc, sh.nline, sh.flags);
1119 }
1120 
1121 // DumpSectionHeaders
1122 //
1123 // Dump all of the ELF section header to the specified output stream
1125 
1126  s->PutCString("Section Headers\n");
1127  s->PutCString("IDX name vm addr vm size file off file "
1128  "size reloc off line off nreloc nline flags\n");
1129  s->PutCString("==== ---------------- ---------- ---------- ---------- "
1130  "---------- ---------- ---------- ------ ------ ----------\n");
1131 
1132  uint32_t idx = 0;
1133  SectionHeaderCollIter pos, end = m_sect_headers.end();
1134 
1135  for (pos = m_sect_headers.begin(); pos != end; ++pos, ++idx) {
1136  s->Printf("[%2u] ", idx);
1138  }
1139 }
1140 
1141 // DumpDependentModules
1142 //
1143 // Dump all of the dependent modules to the specified output stream
1145  auto num_modules = ParseDependentModules();
1146  if (num_modules > 0) {
1147  s->PutCString("Dependent Modules\n");
1148  for (unsigned i = 0; i < num_modules; ++i) {
1149  auto spec = m_deps_filespec->GetFileSpecAtIndex(i);
1150  s->Printf(" %s\n", spec.GetFilename().GetCString());
1151  }
1152  }
1153 }
1154 
1156  switch (m_coff_header_opt.subsystem) {
1157  case llvm::COFF::IMAGE_SUBSYSTEM_NATIVE:
1158  case llvm::COFF::IMAGE_SUBSYSTEM_WINDOWS_GUI:
1159  case llvm::COFF::IMAGE_SUBSYSTEM_WINDOWS_CUI:
1160  case llvm::COFF::IMAGE_SUBSYSTEM_NATIVE_WINDOWS:
1161  case llvm::COFF::IMAGE_SUBSYSTEM_WINDOWS_CE_GUI:
1162  case llvm::COFF::IMAGE_SUBSYSTEM_XBOX:
1163  case llvm::COFF::IMAGE_SUBSYSTEM_WINDOWS_BOOT_APPLICATION:
1164  return true;
1165  default:
1166  return false;
1167  }
1168 }
1169 
1171  uint16_t machine = m_coff_header.machine;
1172  switch (machine) {
1173  default:
1174  break;
1175  case llvm::COFF::IMAGE_FILE_MACHINE_AMD64:
1176  case llvm::COFF::IMAGE_FILE_MACHINE_I386:
1177  case llvm::COFF::IMAGE_FILE_MACHINE_POWERPC:
1178  case llvm::COFF::IMAGE_FILE_MACHINE_POWERPCFP:
1179  case llvm::COFF::IMAGE_FILE_MACHINE_ARM:
1180  case llvm::COFF::IMAGE_FILE_MACHINE_ARMNT:
1181  case llvm::COFF::IMAGE_FILE_MACHINE_THUMB:
1182  case llvm::COFF::IMAGE_FILE_MACHINE_ARM64:
1183  ArchSpec arch;
1185  IsWindowsSubsystem() ? llvm::Triple::Win32
1186  : llvm::Triple::UnknownOS);
1187  return arch;
1188  }
1189  return ArchSpec();
1190 }
1191 
1193  if (m_coff_header.machine != 0) {
1194  if ((m_coff_header.flags & llvm::COFF::IMAGE_FILE_DLL) == 0)
1195  return eTypeExecutable;
1196  else
1197  return eTypeSharedLibrary;
1198  }
1199  return eTypeExecutable;
1200 }
1201 
lldb_private::SectionLoadList::SetSectionLoadAddress
bool SetSectionLoadAddress(const lldb::SectionSP &section_sp, lldb::addr_t load_addr, bool warn_multiple=false)
Definition: SectionLoadList.cpp:63
lldb_private::UUID::CvRecordPdb70::Age
llvm::support::ulittle32_t Age
Definition: UUID.h:36
lldb_private::toString
const char * toString(AppleArm64ExceptionClass EC)
Definition: AppleArm64ExceptionClass.h:38
ObjectFilePECOFF::section_header::offset
uint32_t offset
Definition: ObjectFilePECOFF.h:233
lldb_private::Symbol::SetDebug
void SetDebug(bool b)
Definition: Symbol.h:168
ObjectFilePECOFF::coff_symbol::sect
uint16_t sect
Definition: ObjectFilePECOFF.h:244
ObjectFilePECOFF::MagicBytesMatch
static bool MagicBytesMatch(lldb::DataBufferSP &data_sp)
Definition: ObjectFilePECOFF.cpp:193
ObjectFilePECOFF::coff_opt_header::checksum
uint32_t checksum
Definition: ObjectFilePECOFF.h:209
lldb_private::UUID
Definition: UUID.h:23
lldb::eSectionTypeDWARFDebugLoc
@ eSectionTypeDWARFDebugLoc
Definition: lldb-enumerations.h:670
ObjectFilePECOFF::coff_opt_header::stack_reserve_size
uint64_t stack_reserve_size
Definition: ObjectFilePECOFF.h:212
llvm
Definition: Debugger.h:49
ObjectFilePECOFF::NeedsEndianSwap
bool NeedsEndianSwap() const
Definition: ObjectFilePECOFF.cpp:337
ObjectFilePECOFF::dos_header::e_magic
uint16_t e_magic
Definition: ObjectFilePECOFF.h:150
ObjectFilePECOFF::dos_header::e_ip
uint16_t e_ip
Definition: ObjectFilePECOFF.h:160
ObjectFilePECOFF::data_directory::vmaddr
uint32_t vmaddr
Definition: ObjectFilePECOFF.h:182
ObjectFilePECOFF::~ObjectFilePECOFF
~ObjectFilePECOFF() override
lldb_private::ArchSpec
Definition: ArchSpec.h:33
lldb::eSectionTypeDebug
@ eSectionTypeDebug
Definition: lldb-enumerations.h:658
ObjectFilePECOFF::ReadImageData
lldb_private::DataExtractor ReadImageData(uint32_t offset, size_t size)
Definition: ObjectFilePECOFF.cpp:506
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:336
ObjectFilePECOFF::dos_header::e_oeminfo
uint16_t e_oeminfo
Definition: ObjectFilePECOFF.h:166
ObjectFilePECOFF::dos_header::e_oemid
uint16_t e_oemid
Definition: ObjectFilePECOFF.h:165
lldb::eSymbolTypeCode
@ eSymbolTypeCode
Definition: lldb-enumerations.h:616
lldb_private::SectionList::Dump
void Dump(llvm::raw_ostream &s, unsigned indent, Target *target, bool show_header, uint32_t depth) const
Definition: Section.cpp:570
ObjectFilePECOFF::coff_opt_header::minor_os_system_version
uint16_t minor_os_system_version
Definition: ObjectFilePECOFF.h:201
lldb_private::UUID::CvRecordPdb70::Uuid
struct lldb_private::UUID::CvRecordPdb70::@45 Uuid
ObjectFilePECOFF::GetDependentModules
uint32_t GetDependentModules(lldb_private::FileSpecList &files) override
Definition: ObjectFilePECOFF.cpp:935
ObjectFilePECOFF::coff_header::modtime
uint32_t modtime
Definition: ObjectFilePECOFF.h:174
ModuleSpec.h
ObjectFilePECOFF::m_dos_header
dos_header_t m_dos_header
Definition: ObjectFilePECOFF.h:295
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)
ObjectFilePECOFF::ParseCOFFOptionalHeader
bool ParseCOFFOptionalHeader(lldb::offset_t *offset_ptr)
Definition: ObjectFilePECOFF.cpp:423
ObjectFilePECOFF::CreateSections
void CreateSections(lldb_private::SectionList &unified_section_list) override
Definition: ObjectFilePECOFF.cpp:818
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:210
UUID.h
ObjectFilePECOFF::dos_header::e_maxalloc
uint16_t e_maxalloc
Definition: ObjectFilePECOFF.h:156
lldb::eSymbolTypeInvalid
@ eSymbolTypeInvalid
Definition: lldb-enumerations.h:614
ObjectFilePECOFF::GetPluginDescriptionStatic
static llvm::StringRef GetPluginDescriptionStatic()
Definition: ObjectFilePECOFF.cpp:74
ObjectFilePECOFF::section_header::lineoff
uint32_t lineoff
Definition: ObjectFilePECOFF.h:235
lldb_private::ObjectFile::eTypeExecutable
@ eTypeExecutable
A normal executable.
Definition: ObjectFile.h:69
ObjectFilePECOFF::export_directory_entry::minor_version
uint16_t minor_version
Definition: ObjectFilePECOFF.h:254
OPT_HEADER_MAGIC_PE32
#define OPT_HEADER_MAGIC_PE32
Definition: ObjectFilePECOFF.cpp:38
lldb::eSectionTypeDWARFDebugAranges
@ eSectionTypeDWARFDebugAranges
Definition: lldb-enumerations.h:665
lldb_private::UUID::IsValid
bool IsValid() const
Definition: UUID.h:79
lldb_private::ObjectFile::m_process_wp
lldb::ProcessWP m_process_wp
Definition: ObjectFile.h:707
lldb_private::SectionList::GetSize
size_t GetSize() const
Definition: Section.h:74
lldb_private::ModuleSpecList
Definition: ModuleSpec.h:280
lldb_private::ModuleSpecList::Append
void Append(const ModuleSpec &spec)
Definition: ModuleSpec.h:313
ObjectFilePECOFF::GetUUID
lldb_private::UUID GetUUID() override
Gets the UUID for this object file.
Definition: ObjectFilePECOFF.cpp:876
LLDB_LOGF
#define LLDB_LOGF(log,...)
Definition: Log.h:249
lldb::eSectionTypeDWARFDebugRanges
@ eSectionTypeDWARFDebugRanges
Definition: lldb-enumerations.h:675
ObjectFilePECOFF::section_header
Definition: ObjectFilePECOFF.h:228
ObjectFilePECOFF::dos_header::e_res
uint16_t e_res[4]
Definition: ObjectFilePECOFF.h:164
ObjectFilePECOFF::data_directory::vmsize
uint32_t vmsize
Definition: ObjectFilePECOFF.h:183
ObjectFilePECOFF::DumpSectionHeaders
void DumpSectionHeaders(lldb_private::Stream *s)
Definition: ObjectFilePECOFF.cpp:1124
lldb::eSectionTypeDWARFDebugFrame
@ eSectionTypeDWARFDebugFrame
Definition: lldb-enumerations.h:667
Module.h
lldb::eSectionTypeDWARFDebugLine
@ eSectionTypeDWARFDebugLine
Definition: lldb-enumerations.h:669
lldb_private::ObjectFile::m_symtab_up
std::unique_ptr< lldb_private::Symtab > m_symtab_up
Definition: ObjectFile.h:710
ObjectFilePECOFF::export_directory_entry::time_date_stamp
uint32_t time_date_stamp
Definition: ObjectFilePECOFF.h:252
ObjectFilePECOFF::coff_opt_header::major_linker_version
uint8_t major_linker_version
Definition: ObjectFilePECOFF.h:188
lldb_private::ObjectFile::m_file
FileSpec m_file
Definition: ObjectFile.h:697
ObjectFilePECOFF::coff_symbol::name
char name[8]
Definition: ObjectFilePECOFF.h:242
ObjectFilePECOFF::GetAddressByteSize
uint32_t GetAddressByteSize() const override
Gets the address size in bytes for the current object file.
Definition: ObjectFilePECOFF.cpp:325
SectionLoadList.h
lldb_private::Symbol::SetType
void SetType(lldb::SymbolType type)
Definition: Symbol.h:145
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:198
ObjectFilePECOFF::coff_opt_header::code_size
uint32_t code_size
Definition: ObjectFilePECOFF.h:190
ObjectFilePECOFF::Terminate
static void Terminate()
Definition: ObjectFilePECOFF.cpp:70
ObjectFilePECOFF::export_directory_entry::address_of_name_ordinals
uint32_t address_of_name_ordinals
Definition: ObjectFilePECOFF.h:261
lldb_private::Stream
Definition: Stream.h:28
lldb::addr_t
uint64_t addr_t
Definition: lldb-types.h:83
LLDB_INVALID_CPUTYPE
#define LLDB_INVALID_CPUTYPE
Definition: lldb-defines.h:106
lldb_private::ObjectFile::Type
Type
Definition: ObjectFile.h:64
ObjectFilePECOFF::coff_opt_header::heap_reserve_size
uint64_t heap_reserve_size
Definition: ObjectFilePECOFF.h:214
ObjectFilePECOFF::dos_header
Definition: ObjectFilePECOFF.h:149
lldb_private::Target
Definition: Target.h:451
ObjectFilePECOFF::IsExecutable
bool IsExecutable() const override
Tells whether this object file is capable of being the main executable for a process.
Definition: ObjectFilePECOFF.cpp:321
Section.h
lldb_private::eSortOrderNone
@ eSortOrderNone
Definition: lldb-private-enumerations.h:110
ObjectFilePECOFF::dos_header::e_cparhdr
uint16_t e_cparhdr
Definition: ObjectFilePECOFF.h:154
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:225
ObjectFilePECOFF::export_directory_entry::address_of_functions
uint32_t address_of_functions
Definition: ObjectFilePECOFF.h:259
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:79
ObjectFilePECOFF::Dump
void Dump(lldb_private::Stream *s) override
Dump a description of this object to a Stream.
Definition: ObjectFilePECOFF.cpp:971
ObjectFilePECOFF::GetSymtab
lldb_private::Symtab * GetSymtab() override
Gets the symbol table for the currently selected architecture (and object for archives).
Definition: ObjectFilePECOFF.cpp:593
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:207
ObjectFilePECOFF::DumpDependentModules
void DumpDependentModules(lldb_private::Stream *s)
Definition: ObjectFilePECOFF.cpp:1144
lldb_private::DataExtractor::PeekCStr
const char * PeekCStr(lldb::offset_t offset) const
Peek at a C string at offset.
Definition: DataExtractor.cpp:834
ObjectFilePECOFF::coff_data_dir_exception_table
@ coff_data_dir_exception_table
Definition: ObjectFilePECOFF.h:225
ObjectFilePECOFF::coff_opt_header::minor_linker_version
uint8_t minor_linker_version
Definition: ObjectFilePECOFF.h:189
Target.h
lldb_private::ModuleSpec::GetUUID
UUID & GetUUID()
Definition: ModuleSpec.h:104
ObjectFilePECOFF::coff_opt_header::dll_flags
uint16_t dll_flags
Definition: ObjectFilePECOFF.h:211
ObjectFilePECOFF::coff_symbol::storage
uint8_t storage
Definition: ObjectFilePECOFF.h:246
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:192
lldb_private::SectionList::AddSection
size_t AddSection(const lldb::SectionSP &section_sp)
Definition: Section.cpp:407
GetCoffUUID
static UUID GetCoffUUID(llvm::object::COFFObjectFile &coff_obj)
Definition: ObjectFilePECOFF.cpp:46
lldb_private::FileSpec
Definition: FileSpec.h:56
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:583
ObjectFilePECOFF::m_sect_headers
SectionHeaderColl m_sect_headers
Definition: ObjectFilePECOFF.h:298
PECallFrameInfo.h
ObjectFilePECOFF::IsStripped
bool IsStripped() override
Detect if this object file has been stripped of local symbols.
Definition: ObjectFilePECOFF.cpp:742
lldb_private::ConstString::SetString
void SetString(const llvm::StringRef &s)
Definition: ConstString.cpp:306
lldb::eSectionTypeDWARFDebugAbbrev
@ eSectionTypeDWARFDebugAbbrev
Definition: lldb-enumerations.h:663
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:219
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:202
Log.h
ObjectFilePECOFF::dos_header::e_res2
uint16_t e_res2[10]
Definition: ObjectFilePECOFF.h:167
ObjectFilePECOFF::coff_opt_header::minor_image_version
uint16_t minor_image_version
Definition: ObjectFilePECOFF.h:203
ObjectFilePECOFF::export_directory_entry::base
uint32_t base
Definition: ObjectFilePECOFF.h:256
ObjectFilePECOFF::coff_header
Definition: ObjectFilePECOFF.h:171
ObjectFilePECOFF::GetAddress
lldb_private::Address GetAddress(uint32_t rva)
Definition: ObjectFilePECOFF.cpp:494
lldb_private::ObjectFile::eStrataUser
@ eStrataUser
Definition: ObjectFile.h:88
ObjectFilePECOFF::coff_header::hdrsize
uint16_t hdrsize
Definition: ObjectFilePECOFF.h:177
lldb::eSectionTypeDWARFDebugStr
@ eSectionTypeDWARFDebugStr
Definition: lldb-enumerations.h:676
ObjectFilePECOFF::ParseDOSHeader
static bool ParseDOSHeader(lldb_private::DataExtractor &data, dos_header_t &dos_header)
Definition: ObjectFilePECOFF.cpp:345
ObjectFilePECOFF::coff_opt_header
Definition: ObjectFilePECOFF.h:186
ObjectFilePECOFF::CalculateStrata
ObjectFile::Strata CalculateStrata() override
The object file should be able to calculate the strata of the object file.
Definition: ObjectFilePECOFF.cpp:1202
lldb_private::ArchSpec::SetTriple
bool SetTriple(const llvm::Triple &triple)
Architecture triple setter.
Definition: ArchSpec.cpp:739
ObjectFilePECOFF::Initialize
static void Initialize()
Definition: ObjectFilePECOFF.cpp:64
ObjectFilePECOFF::m_coff_header
coff_header_t m_coff_header
Definition: ObjectFilePECOFF.h:296
ObjectFilePECOFF::export_directory_entry::number_of_names
uint32_t number_of_names
Definition: ObjectFilePECOFF.h:258
ObjectFilePECOFF::export_directory_entry::number_of_functions
uint32_t number_of_functions
Definition: ObjectFilePECOFF.h:257
ObjectFilePECOFF::coff_header::symoff
uint32_t symoff
Definition: ObjectFilePECOFF.h:175
ObjectFilePECOFF::GetFileAddress
lldb::addr_t GetFileAddress(uint32_t rva) const
Definition: ObjectFilePECOFF.cpp:502
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:155
lldb_private::Address::GetFileAddress
lldb::addr_t GetFileAddress() const
Get the file address.
Definition: Address.cpp:290
lldb_private::Symbol::GetAddressRef
Address & GetAddressRef()
Definition: Symbol.h:57
ObjectFilePECOFF::export_directory_entry
Definition: ObjectFilePECOFF.h:250
ObjectFilePECOFF::coff_data_dir_export_table
@ coff_data_dir_export_table
Definition: ObjectFilePECOFF.h:223
ObjectFilePECOFF::coff_opt_header::image_base
uint64_t image_base
Definition: ObjectFilePECOFF.h:197
ObjectFilePECOFF::dos_header::e_crlc
uint16_t e_crlc
Definition: ObjectFilePECOFF.h:153
ObjectFilePECOFF::CreateBinary
bool CreateBinary()
Definition: ObjectFilePECOFF.cpp:211
FileSpecList.h
lldb_private::ConstString
Definition: ConstString.h:40
IMAGE_NT_SIGNATURE
#define IMAGE_NT_SIGNATURE
Definition: ObjectFilePECOFF.cpp:37
ObjectFilePECOFF::coff_opt_header::major_subsystem_version
uint16_t major_subsystem_version
Definition: ObjectFilePECOFF.h:204
lldb::eSectionTypeDWARFDebugInfo
@ eSectionTypeDWARFDebugInfo
Definition: lldb-enumerations.h:668
lldb_private::DataExtractor::GetU8
uint8_t GetU8(lldb::offset_t *offset_ptr) const
Extract a uint8_t value from *offset_ptr.
Definition: DataExtractor.cpp:318
ObjectFilePECOFF::GetArchitecture
lldb_private::ArchSpec GetArchitecture() override
Get the ArchSpec for this object file.
Definition: ObjectFilePECOFF.cpp:1170
Timer.h
ObjectFilePECOFF::coff_opt_header::entry
uint32_t entry
Definition: ObjectFilePECOFF.h:193
ObjectFilePECOFF::dos_header::e_cp
uint16_t e_cp
Definition: ObjectFilePECOFF.h:152
ObjectFilePECOFF::dos_header::e_lfanew
uint32_t e_lfanew
Definition: ObjectFilePECOFF.h:168
lldb_private::GetLogIfAllCategoriesSet
Log * GetLogIfAllCategoriesSet(uint32_t mask)
Definition: Logging.cpp:58
ObjectFilePECOFF::ParseDependentModules
uint32_t ParseDependentModules()
Definition: ObjectFilePECOFF.cpp:887
lldb::eSectionTypeDWARFDebugTypes
@ eSectionTypeDWARFDebugTypes
DWARF .debug_types section.
Definition: lldb-enumerations.h:695
lldb_private::SectionList::GetSectionAtIndex
lldb::SectionSP GetSectionAtIndex(size_t idx) const
Definition: Section.cpp:476
lldb::eSectionTypeZeroFill
@ eSectionTypeZeroFill
Definition: lldb-enumerations.h:659
ObjectFilePECOFF::dos_header::e_lfarlc
uint16_t e_lfarlc
Definition: ObjectFilePECOFF.h:162
ObjectFilePECOFF::m_entry_point_address
lldb_private::Address m_entry_point_address
Definition: ObjectFilePECOFF.h:300
ObjectFilePECOFF::coff_opt_header::code_offset
uint32_t code_offset
Definition: ObjectFilePECOFF.h:194
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:77
OPT_HEADER_MAGIC_PE32_PLUS
#define OPT_HEADER_MAGIC_PE32_PLUS
Definition: ObjectFilePECOFF.cpp:39
ObjectFilePECOFF::ReadImageDataByRVA
lldb_private::DataExtractor ReadImageDataByRVA(uint32_t rva, size_t size)
Definition: ObjectFilePECOFF.cpp:529
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:297
lldb_private::Address::GetSection
lldb::SectionSP GetSection() const
Get const accessor for the section.
Definition: Address.h:420
ObjectFilePECOFF::coff_opt_header::heap_commit_size
uint64_t heap_commit_size
Definition: ObjectFilePECOFF.h:215
ObjectFilePECOFF::coff_symbol
Definition: ObjectFilePECOFF.h:241
ObjectFilePECOFF::CreateMemoryInstance
static lldb_private::ObjectFile * CreateMemoryInstance(const lldb::ModuleSP &module_sp, lldb::DataBufferSP &data_sp, const lldb::ProcessSP &process_sp, lldb::addr_t header_addr)
Definition: ObjectFilePECOFF.cpp:114
lldb_private::Symbol::GetMangled
Mangled & GetMangled()
Definition: Symbol.h:121
ObjectFilePECOFF::m_uuid
lldb_private::UUID m_uuid
Definition: ObjectFilePECOFF.h:303
ObjectFilePECOFF::dos_header::e_csum
uint16_t e_csum
Definition: ObjectFilePECOFF.h:159
lldb::SymbolType
SymbolType
Symbol types.
Definition: lldb-enumerations.h:612
ObjectFilePECOFF::coff_header::flags
uint16_t flags
Definition: ObjectFilePECOFF.h:178
WindowsMiniDump.h
ObjectFilePECOFF::coff_opt_header::magic
uint16_t magic
Definition: ObjectFilePECOFF.h:187
ObjectFilePECOFF::section_header::nline
uint16_t nline
Definition: ObjectFilePECOFF.h:237
ObjectFilePECOFF::export_directory_entry::major_version
uint16_t major_version
Definition: ObjectFilePECOFF.h:253
lldb::eSectionTypeData
@ eSectionTypeData
Definition: lldb-enumerations.h:650
ObjectFile.h
ObjectFilePECOFF::section_header::flags
uint32_t flags
Definition: ObjectFilePECOFF.h:238
IMAGE_DOS_SIGNATURE
#define IMAGE_DOS_SIGNATURE
Definition: ObjectFilePECOFF.cpp:36
lldb_private::Section
Definition: Section.h:96
ObjectFilePECOFF::coff_opt_header::loader_flags
uint32_t loader_flags
Definition: ObjectFilePECOFF.h:216
ObjectFilePECOFF::coff_opt_header::reserved1
uint32_t reserved1
Definition: ObjectFilePECOFF.h:206
lldb::eSectionTypeOther
@ eSectionTypeOther
Definition: lldb-enumerations.h:697
StreamFile.h
lldb::eSectionTypeCode
@ eSectionTypeCode
Definition: lldb-enumerations.h:648
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:843
ObjectFilePECOFF::dos_header::e_ss
uint16_t e_ss
Definition: ObjectFilePECOFF.h:157
ObjectFilePECOFF::ParseCOFFHeader
static bool ParseCOFFHeader(lldb_private::DataExtractor &data, lldb::offset_t *offset_ptr, coff_header_t &coff_header)
Definition: ObjectFilePECOFF.cpp:404
lldb_private::ModuleSpec
Definition: ModuleSpec.h:26
ObjectFilePECOFF::DumpCOFFHeader
static void DumpCOFFHeader(lldb_private::Stream *s, const coff_header_t &header)
Definition: ObjectFilePECOFF.cpp:1043
ObjectFilePECOFF::coff_symbol::naux
uint8_t naux
Definition: ObjectFilePECOFF.h:247
ObjectFilePECOFF::dos_header::e_sp
uint16_t e_sp
Definition: ObjectFilePECOFF.h:158
ObjectFilePECOFF::DumpOptCOFFHeader
static void DumpOptCOFFHeader(lldb_private::Stream *s, const coff_opt_header_t &header)
Definition: ObjectFilePECOFF.cpp:1056
ObjectFilePECOFF::section_header_t
struct ObjectFilePECOFF::section_header section_header_t
lldb_private::Status
Definition: Status.h:44
ObjectFilePECOFF::export_directory_entry::address_of_names
uint32_t address_of_names
Definition: ObjectFilePECOFF.h:260
LIBLLDB_LOG_OBJECT
#define LIBLLDB_LOG_OBJECT
Definition: Logging.h:25
lldb::eSectionTypeEHFrame
@ eSectionTypeEHFrame
Definition: lldb-enumerations.h:686
ObjectFilePECOFF::coff_header::nsyms
uint32_t nsyms
Definition: ObjectFilePECOFF.h:176
lldb_private::ArchSpec::GetArchitectureName
const char * GetArchitectureName() const
Returns a static string representing the current architecture.
Definition: ArchSpec.cpp:538
lldb::eSaveCoreFull
@ eSaveCoreFull
Definition: lldb-enumerations.h:1138
lldb_private::Symtab
Definition: Symtab.h:22
ObjectFilePECOFF::export_directory_entry::characteristics
uint32_t characteristics
Definition: ObjectFilePECOFF.h:251
uint32_t
ObjectFilePECOFF::ID
static char ID
Definition: ObjectFilePECOFF.h:90
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:185
lldb::SectionType
SectionType
Definition: lldb-enumerations.h:646
lldb_private::UUID::CvRecordPdb70
Definition: UUID.h:29
lldb_private::Address
Definition: Address.h:59
ObjectFilePECOFF::ParseSectionHeaders
bool ParseSectionHeaders(uint32_t offset)
Definition: ObjectFilePECOFF.cpp:540
lldb::eSectionTypeDWARFDebugPubTypes
@ eSectionTypeDWARFDebugPubTypes
Definition: lldb-enumerations.h:674
lldb::eSectionTypeDWARFDebugNames
@ eSectionTypeDWARFDebugNames
DWARF v5 .debug_names.
Definition: lldb-enumerations.h:696
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:526
lldb_private::Stream::EOL
size_t EOL()
Output and End of Line character to the stream.
Definition: Stream.cpp:128
lldb::eSectionTypeDWARFDebugPubNames
@ eSectionTypeDWARFDebugPubNames
Definition: lldb-enumerations.h:673
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:288
lldb::eSectionTypeInvalid
@ eSectionTypeInvalid
Definition: lldb-enumerations.h:647
ObjectFilePECOFF::m_image_base
lldb::addr_t m_image_base
Definition: ObjectFilePECOFF.h:299
lldb::SaveCoreStyle
SaveCoreStyle
Definition: lldb-enumerations.h:1136
ObjectFilePECOFF::coff_opt_header::data_size
uint32_t data_size
Definition: ObjectFilePECOFF.h:191
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:247
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:127
lldb::eSectionTypeDataCString
@ eSectionTypeDataCString
Inlined C string data.
Definition: lldb-enumerations.h:651
ObjectFilePECOFF::SectionHeaderCollIter
SectionHeaderColl::iterator SectionHeaderCollIter
Definition: ObjectFilePECOFF.h:289
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:31
lldb_private::ObjectFile::m_data
DataExtractor m_data
The data for this object file so things can be parsed lazily.
Definition: ObjectFile.h:706
ObjectFilePECOFF::coff_opt_header::header_size
uint32_t header_size
Definition: ObjectFilePECOFF.h:208
ObjectFilePECOFF::DumpSectionHeader
void DumpSectionHeader(lldb_private::Stream *s, const section_header_t &sh)
Definition: ObjectFilePECOFF.cpp:1112
ObjectFilePECOFF::CreateCallFrameInfo
std::unique_ptr< lldb_private::CallFrameInfo > CreateCallFrameInfo() override
Creates a plugin-specific call frame info.
Definition: ObjectFilePECOFF.cpp:726
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:427
lldb_private::SaveMiniDump
bool SaveMiniDump(const lldb::ProcessSP &process_sp, const lldb_private::FileSpec &outfile, lldb_private::Status &error)
Definition: WindowsMiniDump.cpp:23
ObjectFilePECOFF.h
PluginManager.h
lldb_private::Address::SetOffset
bool SetOffset(lldb::addr_t offset)
Set accessor for the offset.
Definition: Address.h:429
lldb_private::Target::GetSectionLoadList
SectionLoadList & GetSectionLoadList()
Definition: Target.h:1040
lldb_private::ConstString::GetCString
const char * GetCString() const
Get the string value as a C string.
Definition: ConstString.h:216
lldb_private::ModuleSpec::GetArchitecture
ArchSpec & GetArchitecture()
Definition: ModuleSpec.h:94
ObjectFilePECOFF::MapSymbolType
static lldb::SymbolType MapSymbolType(uint16_t coff_symbol_type)
Definition: ObjectFilePECOFF.cpp:200
ObjectFilePECOFF::DumpDOSHeader
static void DumpDOSHeader(lldb_private::Stream *s, const dos_header_t &header)
Definition: ObjectFilePECOFF.cpp:1011
LLDB_LOG
#define LLDB_LOG(log,...)
The LLDB_LOG* macros defined below are the way to emit log messages.
Definition: Log.h:242
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:200
ObjectFilePECOFF::section_header::vmsize
uint32_t vmsize
Definition: ObjectFilePECOFF.h:230
ObjectFilePECOFF::export_directory_entry::name
uint32_t name
Definition: ObjectFilePECOFF.h:255
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:349
lldb_private::DataExtractor::GetCStr
const char * GetCStr(lldb::offset_t *offset_ptr) const
Extract a C string from *offset_ptr.
Definition: DataExtractor.cpp:786
Error
llvm::Error Error
Definition: UdtRecordCompleter.cpp:29
ObjectFilePECOFF::coff_symbol::value
uint32_t value
Definition: ObjectFilePECOFF.h:243
ObjectFilePECOFF::dos_header::e_cs
uint16_t e_cs
Definition: ObjectFilePECOFF.h:161
ObjectFilePECOFF::coff_opt_header::stack_commit_size
uint64_t stack_commit_size
Definition: ObjectFilePECOFF.h:213
ObjectFilePECOFF::GetBaseAddress
lldb_private::Address GetBaseAddress() override
Returns base address of this object file.
Definition: ObjectFilePECOFF.cpp:963
ObjectFilePECOFF::dos_header::e_ovno
uint16_t e_ovno
Definition: ObjectFilePECOFF.h:163
FileSpec.h
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:1192
lldb_private::FileSpec::GetDirectory
ConstString & GetDirectory()
Directory string get accessor.
Definition: FileSpec.cpp:335
ObjectFilePECOFF::coff_header::nsects
uint16_t nsects
Definition: ObjectFilePECOFF.h:173
lldb_private::Address::GetOffset
lldb::addr_t GetOffset() const
Get the section relative offset value.
Definition: Address.h:310
ObjectFilePECOFF::coff_opt_header::file_alignment
uint32_t file_alignment
Definition: ObjectFilePECOFF.h:199
ObjectFilePECOFF::GetSectionName
llvm::StringRef GetSectionName(const section_header_t &sect)
Definition: ObjectFilePECOFF.cpp:576
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:945
lldb_private::ModuleSpecList::GetSize
size_t GetSize() const
Definition: ModuleSpec.h:303
LLDB_PLUGIN_DEFINE
#define LLDB_PLUGIN_DEFINE(PluginName)
Definition: PluginManager.h:31
lldb_private::Log
Definition: Log.h:49
ObjectFilePECOFF::m_binary
std::unique_ptr< llvm::object::COFFObjectFile > m_binary
Definition: ObjectFilePECOFF.h:302
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:671
ObjectFilePECOFF::coff_opt_header::minor_subsystem_version
uint16_t minor_subsystem_version
Definition: ObjectFilePECOFF.h:205
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:348
ObjectFilePECOFF::coff_opt_header::major_image_version
uint16_t major_image_version
Definition: ObjectFilePECOFF.h:202
ObjectFilePECOFF::coff_header::machine
uint16_t machine
Definition: ObjectFilePECOFF.h:172
ObjectFilePECOFF::data_directory
Definition: ObjectFilePECOFF.h:181
lldb::eByteOrderLittle
@ eByteOrderLittle
Definition: lldb-enumerations.h:142
ObjectFilePECOFF::dos_header::e_cblp
uint16_t e_cblp
Definition: ObjectFilePECOFF.h:151
lldb_private::ObjectFile::Strata
Strata
Definition: ObjectFile.h:85
ObjectFilePECOFF::coff_opt_header::data_offset
uint32_t data_offset
Definition: ObjectFilePECOFF.h:195
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:301
LLDB_LOG_ERROR
#define LLDB_LOG_ERROR(log, error,...)
Definition: Log.h:265
lldb_private::FileSpec::GetFilename
ConstString & GetFilename()
Filename string get accessor.
Definition: FileSpec.cpp:341
lldb::eSectionTypeDWARFDebugLocLists
@ eSectionTypeDWARFDebugLocLists
DWARF v5 .debug_loclists.
Definition: lldb-enumerations.h:700
lldb::eSectionTypeGoSymtab
@ eSectionTypeGoSymtab
Definition: lldb-enumerations.h:691
lldb_private::ObjectFile
Definition: ObjectFile.h:58
DataBufferHeap.h
lldb_private::SectionList::FindSectionByID
lldb::SectionSP FindSectionByID(lldb::user_id_t sect_id) const
Definition: Section.cpp:506
ObjectFilePECOFF::GetRVA
uint32_t GetRVA(const lldb_private::Address &addr) const
Definition: ObjectFilePECOFF.cpp:490
lldb_private::ObjectFile::m_sections_up
std::unique_ptr< lldb_private::SectionList > m_sections_up
Definition: ObjectFile.h:709
ObjectFilePECOFF::ParseHeader
bool ParseHeader() override
Attempts to parse the object header.
Definition: ObjectFilePECOFF.cpp:263
ObjectFilePECOFF::coff_symbol::type
uint16_t type
Definition: ObjectFilePECOFF.h:245
ObjectFilePECOFF::IsWindowsSubsystem
bool IsWindowsSubsystem()
Definition: ObjectFilePECOFF.cpp:1155
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:747
ObjectFilePECOFF::GetByteOrder
lldb::ByteOrder GetByteOrder() const override
Gets whether endian swapping should occur when extracting data from this object file.
Definition: ObjectFilePECOFF.cpp:319