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/MemoryBuffer.h"
40#include "llvm/TargetParser/Host.h"
43#define IMAGE_DOS_SIGNATURE 0x5A4D
44#define IMAGE_NT_SIGNATURE 0x00004550
45#define OPT_HEADER_MAGIC_PE32 0x010b
46#define OPT_HEADER_MAGIC_PE32_PLUS 0x020b
57 llvm::Triple::UnknownEnvironment,
59 "Use default target (if it is Windows) or MSVC",
69 "MinGW / Itanium ABI",
73#define LLDB_PROPERTIES_objectfilepecoff
74#include "ObjectFilePECOFFProperties.inc"
77#define LLDB_PROPERTIES_objectfilepecoff
78#include "ObjectFilePECOFFPropertiesEnum.inc"
83 static llvm::StringRef GetSettingName() {
88 m_collection_sp = std::make_shared<OptionValueProperties>(GetSettingName());
89 m_collection_sp->Initialize(g_objectfilepecoff_properties_def);
92 llvm::Triple::EnvironmentType ABI()
const {
93 return GetPropertyAtIndexAs<llvm::Triple::EnvironmentType>(
94 ePropertyABI, llvm::Triple::UnknownEnvironment);
97 OptionValueDictionary *ModuleABIMap()
const {
98 return m_collection_sp->GetPropertyAtIndexAsOptionValueDictionary(
99 ePropertyModuleABIMap);
106 static PluginProperties g_settings;
111 std::string &gnu_debuglink_file,
112 uint32_t &gnu_debuglink_crc) {
113 static constexpr llvm::StringLiteral g_sect_name_gnu_debuglink(
115 for (
const auto §ion : coff_obj.sections()) {
116 auto name = section.getName();
118 llvm::consumeError(name.takeError());
121 if (*name == g_sect_name_gnu_debuglink) {
122 auto content = section.getContents();
124 llvm::consumeError(content.takeError());
128 content->data(), content->size(),
131 gnu_debuglink_file = data.
GetCStr(&gnu_debuglink_offset);
133 gnu_debuglink_offset = llvm::alignTo(gnu_debuglink_offset, 4);
134 data.
GetU32(&gnu_debuglink_offset, &gnu_debuglink_crc, 1);
142 const llvm::codeview::DebugInfo *pdb_info =
nullptr;
143 llvm::StringRef pdb_file;
147 if (!coff_obj.getDebugPDBInfo(pdb_info, pdb_file) && pdb_info) {
148 if (pdb_info->PDB70.CVSignature == llvm::OMF::Signature::PDB70) {
150 memcpy(&info.
Uuid, pdb_info->PDB70.Signature,
sizeof(info.
Uuid));
151 info.
Age = pdb_info->PDB70.Age;
156 std::string gnu_debuglink_file;
157 uint32_t gnu_debuglink_crc;
166 auto raw_data = coff_obj.getData();
168 "Calculating module crc32 %s with size %" PRIu64
" KiB",
171 gnu_debuglink_crc = llvm::crc32(0, llvm::arrayRefFromStringRef(raw_data));
174 llvm::support::ulittle32_t data(gnu_debuglink_crc);
175 return UUID(&data,
sizeof(data));
189 debugger, PluginProperties::GetSettingName())) {
190 const bool is_global_setting =
true;
193 "Properties for the PE/COFF object-file plug-in.", is_global_setting);
202 return "Portable Executable and Common Object File Format object file reader "
211 if (!extractor_sp || !extractor_sp->HasData()) {
216 extractor_sp = std::make_shared<DataExtractor>(data_sp);
223 if (extractor_sp->GetByteSize() < length) {
227 extractor_sp = std::make_shared<DataExtractor>(data_sp);
230 auto objfile_up = std::make_unique<ObjectFilePECOFF>(
231 module_sp, extractor_sp, data_offset, file_p, file_offset, length);
232 if (!objfile_up || !objfile_up->ParseHeader())
236 if (!objfile_up->CreateBinary())
238 return objfile_up.release();
250 auto objfile_up = std::make_unique<ObjectFilePECOFF>(
251 module_sp, data_sp, process_sp, header_addr);
252 if (objfile_up.get() && objfile_up->ParseHeader()) {
253 return objfile_up.release();
261 if (!extractor_sp || !extractor_sp->HasData() ||
267 if (extractor_sp->GetByteSize() < length)
269 extractor_sp->SetData(std::move(full_sp));
270 auto binary = llvm::object::createBinary(llvm::MemoryBufferRef(
271 toStringRef(extractor_sp->GetSharedDataBuffer()->GetData()),
276 "Failed to create binary for file ({1}): {0}", file);
280 auto *COFFObj = llvm::dyn_cast<llvm::object::COFFObjectFile>(binary->get());
290 static llvm::Triple::EnvironmentType default_env = [] {
291 auto def_target = llvm::Triple(
292 llvm::Triple::normalize(llvm::sys::getDefaultTargetTriple()));
293 if (def_target.getOS() == llvm::Triple::Win32 &&
294 def_target.getEnvironment() != llvm::Triple::UnknownEnvironment)
295 return def_target.getEnvironment();
296 return llvm::Triple::MSVC;
302 if (map->GetNumValues() > 0) {
305 module_env_option = map->GetValueForKey(name);
306 if (!module_env_option) {
308 auto name_lower = name.lower();
309 module_env_option = map->GetValueForKey(llvm::StringRef(name_lower));
311 if (!module_env_option) {
313 auto name_stripped = name;
314 if (name_stripped.consume_back_insensitive(
".debug")) {
315 module_env_option = map->GetValueForKey(name_stripped);
316 if (!module_env_option) {
319 auto name_lower = name_stripped.lower();
320 module_env_option = map->GetValueForKey(llvm::StringRef(name_lower));
325 llvm::Triple::EnvironmentType env;
326 if (module_env_option)
328 module_env_option->GetValueAs<llvm::Triple::EnvironmentType>().value_or(
329 static_cast<llvm::Triple::EnvironmentType
>(0));
333 if (env == llvm::Triple::UnknownEnvironment)
337 switch (COFFObj->getMachine()) {
341 specs.
Append(module_spec);
346 specs.
Append(module_spec);
351 specs.
Append(module_spec);
357 specs.
Append(module_spec);
377 uint16_t magic = extractor_sp->GetU16(&offset);
384 const auto complex_type =
385 coff_symbol_type >> llvm::COFF::SCT_COMPLEX_TYPE_SHIFT;
386 if (complex_type == llvm::COFF::IMAGE_SYM_DTYPE_FUNCTION) {
389 const auto base_type = coff_symbol_type & 0xff;
390 if (base_type == llvm::COFF::IMAGE_SYM_TYPE_NULL &&
391 complex_type == llvm::COFF::IMAGE_SYM_DTYPE_NULL) {
405 auto binary = llvm::object::createBinary(llvm::MemoryBufferRef(
409 "Failed to create binary for file ({1}): {0}",
m_file);
415 llvm::unique_dyn_cast<llvm::object::COFFObjectFile>(std::move(*binary));
419 LLDB_LOG(log,
"this = {0}, module = {1} ({2}), file = {3}, binary = {4}",
431 :
ObjectFile(module_sp, file, file_offset, length, extractor_sp,
441 :
ObjectFile(module_sp, process_sp, header_addr,
452 std::lock_guard<std::recursive_mutex> guard(module_sp->GetMutex());
459 uint32_t pe_signature =
m_data_nsp->GetU32(&offset);
475 bool value_is_offset) {
476 bool changed =
false;
479 size_t num_loaded_sections = 0;
482 if (!value_is_offset) {
486 const size_t num_sections = section_list->
GetSize();
489 for (sect_idx = 0; sect_idx < num_sections; ++sect_idx) {
493 if (section_sp && !section_sp->IsThreadSpecific()) {
495 section_sp, section_sp->GetFileAddress() + value))
496 ++num_loaded_sections;
499 changed = num_loaded_sections > 0;
508 return (
m_coff_header.flags & llvm::COFF::IMAGE_FILE_DLL) == 0;
524#if defined(__LITTLE_ENDIAN__)
533 bool success =
false;
610 bool success =
false;
612 if (*offset_ptr < end_offset) {
625 if (*offset_ptr < end_offset) {
632 if (*offset_ptr < end_offset) {
634 m_data_nsp->GetMaxU64(offset_ptr, addr_byte_size);
654 m_data_nsp->GetMaxU64(offset_ptr, addr_byte_size);
656 m_data_nsp->GetMaxU64(offset_ptr, addr_byte_size);
658 m_data_nsp->GetMaxU64(offset_ptr, addr_byte_size);
660 m_data_nsp->GetMaxU64(offset_ptr, addr_byte_size);
662 uint32_t num_data_dir_entries =
m_data_nsp->GetU32(offset_ptr);
666 for (i = 0; i < num_data_dir_entries; i++) {
678 *offset_ptr = end_offset;
702 if (
m_data_nsp->ValidOffsetForDataOfSize(offset, size))
708 auto data_up = std::make_unique<DataBufferHeap>(size, 0);
711 process_sp->ReadMemory(
m_image_base + offset, data_up->GetBytes(),
712 data_up->GetByteSize(), readmem_error);
713 if (bytes_read == size) {
715 data.
SetData(buffer_sp, 0, buffer_sp->GetByteSize());
726 rva = sect->GetFileOffset() + addr.
GetOffset();
733 uint32_t section_header_data_offset) {
740 ReadImageData(section_header_data_offset, section_header_byte_size);
743 if (section_header_data.ValidOffsetForDataOfSize(
744 offset, section_header_byte_size)) {
747 for (uint32_t idx = 0; idx < nsects; ++idx) {
748 const void *name_data = section_header_data.GetData(&offset, 8);
756 m_sect_headers[idx].lineoff = section_header_data.GetU32(&offset);
769 llvm::StringRef hdr_name(sect.
name, std::size(sect.
name));
770 hdr_name = hdr_name.split(
'\0').first;
771 if (hdr_name.consume_front(
"/")) {
773 if (!to_integer(hdr_name, stroff, 10))
777 if (
const char *name =
m_data_nsp->GetCStr(&string_file_offset))
791 const std::pair<uint32_t, uint32_t> &b) {
792 return a.first < b.first;
798 const uint32_t num_syms =
m_binary->getNumberOfSymbols();
802 if (
m_binary->getSymbolTableEntrySize() !=
803 sizeof(llvm::object::coff_symbol16))
808 for (
const auto &sym_ref :
m_binary->symbols()) {
809 const auto coff_sym_ref =
m_binary->getCOFFSymbol(sym_ref);
810 auto name_or_error = sym_ref.getName();
811 if (!name_or_error) {
813 "ObjectFilePECOFF::AppendFromCOFFSymbolTable - failed to "
814 "get symbol table entry name: {0}");
817 const llvm::StringRef sym_name = *name_or_error;
820 int16_t section_number =
821 static_cast<int16_t
>(coff_sym_ref.getSectionNumber());
822 if (section_number >= 1) {
825 const auto symbol_type =
MapSymbolType(coff_sym_ref.getType());
831 const auto &first_match = std::lower_bound(
832 sorted_exports.begin(), sorted_exports.end(),
834 for (
auto it = first_match;
835 it != sorted_exports.end() && it->first == symbol_rva; ++it) {
838 exported->
SetType(symbol_type);
854 }
else if (section_number == llvm::COFF::IMAGE_SYM_ABSOLUTE) {
865 const auto *export_table =
m_binary->getExportTable();
868 const uint32_t num_syms = export_table->AddressTableEntries;
876 for (
const auto &entry :
m_binary->export_directories()) {
877 llvm::StringRef sym_name;
878 if (
auto err = entry.getSymbolName(sym_name)) {
880 "ObjectFilePECOFF::AppendFromExportTable - failed to get "
881 "export table entry name: {0}");
889 llvm::cantFail(entry.getOrdinal(ordinal));
890 symbol.
SetID(ordinal);
893 llvm::cantFail(entry.isForwarder(is_forwarder));
897 llvm::StringRef forwarder_name;
898 if (
auto err = entry.getForwardTo(forwarder_name)) {
900 "ObjectFilePECOFF::AppendFromExportTable - failed to "
901 "get forwarder name of forwarder export '{1}': {0}",
906 " (forwarded to ", forwarder_name,
912 uint32_t function_rva;
913 if (
auto err = entry.getExportRVA(function_rva)) {
915 "ObjectFilePECOFF::AppendFromExportTable - failed to get "
916 "address of export entry '{1}': {0}",
921 if (function_rva == 0 && sym_name.empty())
931 if (section_sp->GetPermissions() & ePermissionsExecutable)
935 export_list.push_back(std::make_pair(function_rva, idx));
947 if (!data_dir_exception.
vmaddr)
950 if (
m_coff_header.machine != llvm::COFF::IMAGE_FILE_MACHINE_AMD64)
953 return std::make_unique<PECallFrameInfo>(*
this, data_dir_exception.
vmaddr,
954 data_dir_exception.
vmsize);
964 static constexpr llvm::StringLiteral g_code_sect_name(
".code");
965 static constexpr llvm::StringLiteral g_CODE_sect_name(
"CODE");
966 static constexpr llvm::StringLiteral g_data_sect_name(
".data");
967 static constexpr llvm::StringLiteral g_DATA_sect_name(
"DATA");
968 static constexpr llvm::StringLiteral g_bss_sect_name(
".bss");
969 static constexpr llvm::StringLiteral g_BSS_sect_name(
"BSS");
971 if (sect.
flags & llvm::COFF::IMAGE_SCN_CNT_CODE &&
972 ((sect_name == g_code_sect_name) || (sect_name == g_CODE_sect_name))) {
975 if (sect.
flags & llvm::COFF::IMAGE_SCN_CNT_INITIALIZED_DATA &&
976 ((sect_name == g_data_sect_name) || (sect_name == g_DATA_sect_name))) {
982 if (sect.
flags & llvm::COFF::IMAGE_SCN_CNT_UNINITIALIZED_DATA &&
983 ((sect_name == g_bss_sect_name) || (sect_name == g_BSS_sect_name))) {
990 if (sect_name.consume_front(
".debug_"))
994 llvm::StringSwitch<SectionType>(sect_name)
999 .Cases({
".lldbsummaries",
".lldbsum"},
1001 .Cases({
".lldbformatters",
".lldbfor"},
1009 return section_type;
1011 if (sect.
flags & llvm::COFF::IMAGE_SCN_CNT_CODE)
1013 if (sect.
flags & llvm::COFF::IMAGE_SCN_CNT_INITIALIZED_DATA)
1015 if (sect.
flags & llvm::COFF::IMAGE_SCN_CNT_UNINITIALIZED_DATA) {
1040 std::lock_guard<std::recursive_mutex> guard(module_sp->GetMutex());
1042 SectionSP header_sp = std::make_shared<Section>(
1049 header_sp->SetPermissions(ePermissionsReadable);
1054 for (uint32_t idx = 0; idx < nsects; ++idx) {
1059 SectionSP section_sp = std::make_shared<Section>(
1076 uint32_t permissions = 0;
1077 if (
m_sect_headers[idx].flags & llvm::COFF::IMAGE_SCN_MEM_EXECUTE)
1078 permissions |= ePermissionsExecutable;
1080 permissions |= ePermissionsReadable;
1082 permissions |= ePermissionsWritable;
1083 section_sp->SetPermissions(permissions);
1103 std::string gnu_debuglink_file;
1104 uint32_t gnu_debuglink_crc;
1106 return FileSpec(gnu_debuglink_file);
1107 return std::nullopt;
1111 llvm::StringRef pdb_file;
1112 const llvm::codeview::DebugInfo *pdb_info =
nullptr;
1113 if (llvm::Error Err =
m_binary->getDebugPDBInfo(pdb_info, pdb_file)) {
1116 llvm::StringRef file =
m_binary->getFileName();
1118 log, std::move(Err),
1119 "Failed to read Codeview record for PDB debug info file ({1}): {0}",
1121 return std::nullopt;
1123 if (pdb_file.empty()) {
1125 return std::nullopt;
1128 FileSpec::Style::native));
1136 std::lock_guard<std::recursive_mutex> guard(module_sp->GetMutex());
1145 LLDB_LOG(log,
"this = {0}, module = {1} ({2}), file = {3}, binary = {4}",
1151 for (
const auto &entry :
m_binary->import_directories()) {
1152 llvm::StringRef dll_name;
1154 if (llvm::Error e = entry.getName(dll_name)) {
1156 "ObjectFilePECOFF::ParseDependentModules() - failed to get "
1157 "import directory entry name: %s",
1158 llvm::toString(std::move(e)).c_str());
1165 llvm::SmallString<128> dll_fullpath;
1169 if (!llvm::sys::fs::real_path(dll_specs.
GetPath(), dll_fullpath))
1181 auto original_size = files.
GetSize();
1183 for (
unsigned i = 0; i < num_modules; ++i)
1186 return files.
GetSize() - original_size;
1218 std::lock_guard<std::recursive_mutex> guard(module_sp->GetMutex());
1219 s->
Printf(
"%p: ",
static_cast<void *
>(
this));
1225 *s <<
", file = '" <<
m_file
1271 s->
Printf(
" e_res[4] = { 0x%4.4x, 0x%4.4x, 0x%4.4x, 0x%4.4x }\n",
1275 s->
Printf(
" e_res2[10] = { 0x%4.4x, 0x%4.4x, 0x%4.4x, 0x%4.4x, 0x%4.4x, "
1276 "0x%4.4x, 0x%4.4x, 0x%4.4x, 0x%4.4x, 0x%4.4x }\n",
1304 s->
Printf(
" major_linker_version = 0x%2.2x\n",
1306 s->
Printf(
" minor_linker_version = 0x%2.2x\n",
1314 s->
Printf(
" image_base = 0x%16.16" PRIx64
"\n",
1318 s->
Printf(
" major_os_system_version = 0x%4.4x\n",
1320 s->
Printf(
" minor_os_system_version = 0x%4.4x\n",
1322 s->
Printf(
" major_image_version = 0x%4.4x\n",
1324 s->
Printf(
" minor_image_version = 0x%4.4x\n",
1326 s->
Printf(
" major_subsystem_version = 0x%4.4x\n",
1328 s->
Printf(
" minor_subsystem_version = 0x%4.4x\n",
1336 s->
Printf(
" stack_reserve_size = 0x%16.16" PRIx64
"\n",
1338 s->
Printf(
" stack_commit_size = 0x%16.16" PRIx64
"\n",
1340 s->
Printf(
" heap_reserve_size = 0x%16.16" PRIx64
"\n",
1342 s->
Printf(
" heap_commit_size = 0x%16.16" PRIx64
"\n",
1345 s->
Printf(
" num_data_dir_entries = 0x%8.8x\n",
1348 for (i = 0; i < header.
data_dirs.size(); i++) {
1349 s->
Printf(
" data_dirs[%2u] vmaddr = 0x%8.8x, vmsize = 0x%8.8x\n", i,
1359 s->
Printf(
"%-16s 0x%8.8x 0x%8.8x 0x%8.8x 0x%8.8x 0x%8.8x 0x%8.8x 0x%4.4x "
1360 "0x%4.4x 0x%8.8x\n",
1371 s->
PutCString(
"IDX name vm addr vm size file off file "
1372 "size reloc off line off nreloc nline flags\n");
1373 s->
PutCString(
"==== ---------------- ---------- ---------- ---------- "
1374 "---------- ---------- ---------- ------ ------ ----------\n");
1380 s->
Printf(
"[%2u] ", idx);
1390 if (num_modules > 0) {
1392 for (
unsigned i = 0; i < num_modules; ++i) {
1394 s->
Format(
" {0}\n", spec.GetFilename());
1401 case llvm::COFF::IMAGE_SUBSYSTEM_NATIVE:
1402 case llvm::COFF::IMAGE_SUBSYSTEM_WINDOWS_GUI:
1403 case llvm::COFF::IMAGE_SUBSYSTEM_WINDOWS_CUI:
1404 case llvm::COFF::IMAGE_SUBSYSTEM_NATIVE_WINDOWS:
1405 case llvm::COFF::IMAGE_SUBSYSTEM_WINDOWS_CE_GUI:
1406 case llvm::COFF::IMAGE_SUBSYSTEM_XBOX:
1407 case llvm::COFF::IMAGE_SUBSYSTEM_WINDOWS_BOOT_APPLICATION:
1419 case llvm::COFF::IMAGE_FILE_MACHINE_AMD64:
1420 case llvm::COFF::IMAGE_FILE_MACHINE_I386:
1421 case llvm::COFF::IMAGE_FILE_MACHINE_POWERPC:
1422 case llvm::COFF::IMAGE_FILE_MACHINE_POWERPCFP:
1423 case llvm::COFF::IMAGE_FILE_MACHINE_ARM:
1424 case llvm::COFF::IMAGE_FILE_MACHINE_ARMNT:
1425 case llvm::COFF::IMAGE_FILE_MACHINE_THUMB:
1426 case llvm::COFF::IMAGE_FILE_MACHINE_ARM64:
1430 : llvm::Triple::UnknownOS);
1438 if ((
m_coff_header.flags & llvm::COFF::IMAGE_FILE_DLL) == 0)
static llvm::raw_ostream & error(Stream &strm)
static PluginProperties & GetGlobalPluginProperties()
#define LLDB_LOG(log,...)
The LLDB_LOG* macros defined below are the way to emit log messages.
#define LLDB_LOGF(log,...)
#define LLDB_LOG_ERROR(log, error,...)
static PluginProperties & GetGlobalPluginProperties()
#define OPT_HEADER_MAGIC_PE32
#define OPT_HEADER_MAGIC_PE32_PLUS
static bool RVASymbolListCompareRVA(const std::pair< uint32_t, uint32_t > &a, const std::pair< uint32_t, uint32_t > &b)
#define IMAGE_NT_SIGNATURE
static UUID GetCoffUUID(llvm::object::COFFObjectFile &coff_obj)
static bool GetDebugLinkContents(const llvm::object::COFFObjectFile &coff_obj, std::string &gnu_debuglink_file, uint32_t &gnu_debuglink_crc)
#define IMAGE_DOS_SIGNATURE
#define LLDB_PLUGIN_DEFINE(PluginName)
#define LLDB_SCOPED_TIMERF(...)
ObjectFile::Strata CalculateStrata() override
The object file should be able to calculate the strata of the object file.
bool IsExecutable() const override
Tells whether this object file is capable of being the main executable for a process.
void DumpSectionHeaders(lldb_private::Stream *s)
std::unique_ptr< llvm::object::COFFObjectFile > m_binary
dos_header_t m_dos_header
lldb_private::DataExtractor ReadImageDataByRVA(uint32_t rva, size_t size)
llvm::StringRef GetSectionName(const section_header_t §)
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...
std::optional< lldb_private::FileSpecList > m_deps_filespec
~ObjectFilePECOFF() override
static bool ParseDOSHeader(lldb_private::DataExtractor &data, dos_header_t &dos_header)
uint32_t GetDependentModules(lldb_private::FileSpecList &files) override
Extract the dependent modules from an object file.
lldb_private::Address GetBaseAddress() override
Returns base address of this object file.
bool IsWindowsSubsystem()
static lldb_private::ModuleSpecList GetModuleSpecifications(const lldb_private::FileSpec &file, lldb::DataExtractorSP &extractor_sp, lldb::offset_t file_offset, lldb::offset_t length)
lldb::addr_t m_image_base
void DumpSectionHeader(lldb_private::Stream *s, const section_header_t &sh)
std::unique_ptr< lldb_private::CallFrameInfo > CreateCallFrameInfo() override
Creates a plugin-specific call frame info.
size_t GetSectionDataSize(lldb_private::Section *section) override
static void DebuggerInitialize(lldb_private::Debugger &debugger)
ObjectFile::Type CalculateType() override
The object file should be able to calculate its type by looking at its file header and possibly the s...
lldb_private::ArchSpec GetArchitecture() override
Get the ArchSpec for this object file.
static void DumpCOFFHeader(lldb_private::Stream *s, const coff_header_t &header)
bool ParseHeader() override
Attempts to parse the object header.
struct ObjectFilePECOFF::section_header section_header_t
void DumpDependentModules(lldb_private::Stream *s)
static bool MagicBytesMatch(lldb::DataExtractorSP extractor_sp)
lldb_private::UUID m_uuid
lldb_private::UUID GetUUID() override
Gets the UUID for this object file.
std::vector< std::pair< uint32_t, uint32_t > > rva_symbol_list_t
static llvm::StringRef GetPluginNameStatic()
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...
SectionHeaderColl::iterator SectionHeaderCollIter
SectionHeaderColl m_sect_headers
static lldb_private::ObjectFile * CreateMemoryInstance(const lldb::ModuleSP &module_sp, lldb::WritableDataBufferSP data_sp, const lldb::ProcessSP &process_sp, lldb::addr_t header_addr)
static llvm::StringRef GetPluginDescriptionStatic()
coff_opt_header_t m_coff_header_opt
static bool SaveCore(const lldb::ProcessSP &process_sp, lldb_private::SaveCoreOptions &options, lldb_private::Status &error)
bool ParseCOFFOptionalHeader(lldb::offset_t *offset_ptr)
bool IsStripped() override
Detect if this object file has been stripped of local symbols.
uint32_t ParseDependentModules()
struct ObjectFilePECOFF::coff_header coff_header_t
bool NeedsEndianSwap() const
static ObjectFile * CreateInstance(const lldb::ModuleSP &module_sp, lldb::DataExtractorSP extractor_sp, lldb::offset_t data_offset, const lldb_private::FileSpec *file, lldb::offset_t offset, lldb::offset_t length)
lldb::addr_t GetFileAddress(uint32_t rva) const
struct ObjectFilePECOFF::coff_opt_header coff_opt_header_t
void ParseSymtab(lldb_private::Symtab &symtab) override
Parse the symbol table into the provides symbol table object.
void CreateSections(lldb_private::SectionList &unified_section_list) override
void Dump(lldb_private::Stream *s) override
Dump a description of this object to a Stream.
rva_symbol_list_t AppendFromExportTable(lldb_private::SectionList *sect_list, lldb_private::Symtab &symtab)
coff_header_t m_coff_header
lldb_private::Address GetAddress(uint32_t rva)
ObjectFilePECOFF(const lldb::ModuleSP &module_sp, lldb::DataExtractorSP extractor_sp, lldb::offset_t data_offset, const lldb_private::FileSpec *file, lldb::offset_t file_offset, lldb::offset_t length)
lldb::ByteOrder GetByteOrder() const override
Gets whether endian swapping should occur when extracting data from this object file.
lldb_private::DataExtractor ReadImageData(uint32_t offset, size_t size)
void AppendFromCOFFSymbolTable(lldb_private::SectionList *sect_list, lldb_private::Symtab &symtab, const rva_symbol_list_t &sorted_exports)
std::optional< lldb_private::FileSpec > GetDebugLink()
Return the contents of the .gnu_debuglink section, if the object file contains it.
bool ParseSectionHeaders(uint32_t offset)
static lldb::SymbolType MapSymbolType(uint16_t coff_symbol_type)
uint32_t GetRVA(const lldb_private::Address &addr) const
uint32_t GetAddressByteSize() const override
Gets the address size in bytes for the current object file.
static void DumpOptCOFFHeader(lldb_private::Stream *s, const coff_opt_header_t &header)
static lldb::SectionType GetSectionType(llvm::StringRef sect_name, const section_header_t §)
static bool ParseCOFFHeader(lldb_private::DataExtractor &data, lldb::offset_t *offset_ptr, coff_header_t &coff_header)
std::optional< lldb_private::FileSpec > GetPDBPath()
struct ObjectFilePECOFF::dos_header dos_header_t
lldb_private::Address m_entry_point_address
static void DumpDOSHeader(lldb_private::Stream *s, const dos_header_t &header)
A section + offset based address class.
lldb::SectionSP GetSection() const
Get const accessor for the section.
lldb::addr_t GetFileAddress() const
Get the file address.
lldb::addr_t GetOffset() const
Get the section relative offset value.
An architecture specification class.
llvm::Triple & GetTriple()
Architecture triple accessor.
bool SetTriple(const llvm::Triple &triple)
Architecture triple setter.
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.
const char * GetArchitectureName() const
Returns a static string representing the current architecture.
A uniqued constant string class.
llvm::StringRef GetStringRef() const
Get the string value as a llvm::StringRef.
A class to manage flag bits.
size_t GetSize() const
Get the number of files in the file list.
bool AppendIfUnique(const FileSpec &file)
Append a FileSpec object if unique.
static std::optional< Style > GuessPathStyle(llvm::StringRef absolute_path)
Attempt to guess path style for a given path string.
llvm::StringRef GetFilename() const
Filename string const get accessor.
size_t GetPath(char *path, size_t max_path_length, bool denormalize=true) const
Extract the full path to the file.
void SetDirectory(llvm::StringRef directory)
Directory string set accessor.
void SetDemangledName(ConstString name)
void SetValue(ConstString name)
Set the string value in this object.
lldb::ModuleSP GetModule() const
Get const accessor for the module pointer.
void Append(const ModuleSpec &spec)
ArchSpec & GetArchitecture()
std::unique_ptr< lldb_private::SectionList > m_sections_up
static lldb::DataBufferSP MapFileData(const FileSpec &file, uint64_t Size, uint64_t Offset)
std::unique_ptr< lldb_private::Symtab > m_symtab_up
static lldb::SectionType GetDWARFSectionTypeFromName(llvm::StringRef name)
Parses the section type from a section name for DWARF sections.
DataExtractorNSP m_data_nsp
The data for this object file so things can be parsed lazily.
@ eTypeExecutable
A normal executable.
@ eTypeSharedLibrary
A shared library that can be used during execution.
virtual SectionList * GetSectionList(bool update_module_section_list=true)
Gets the section list for the currently selected architecture (and object for archives).
ObjectFile(const lldb::ModuleSP &module_sp, const FileSpec *file_spec_ptr, lldb::offset_t file_offset, lldb::offset_t length, lldb::DataExtractorSP extractor_sp, lldb::offset_t data_offset)
Construct with a parent module, offset, and header data.
lldb::ProcessWP m_process_wp
static lldb::OptionValuePropertiesSP GetSettingForObjectFilePlugin(Debugger &debugger, llvm::StringRef setting_name)
static bool CreateSettingForObjectFilePlugin(Debugger &debugger, const lldb::OptionValuePropertiesSP &properties_sp, llvm::StringRef description, bool is_global_property)
static bool RegisterPlugin(llvm::StringRef name, llvm::StringRef description, ABICreateInstance create_callback)
static bool UnregisterPlugin(ABICreateInstance create_callback)
const std::optional< lldb_private::FileSpec > GetOutputFile() const
lldb::SectionSP FindSectionByID(lldb::user_id_t sect_id) const
size_t AddSection(const lldb::SectionSP §ion_sp)
void Dump(llvm::raw_ostream &s, unsigned indent, Target *target, bool show_header, uint32_t depth) const
lldb::SectionSP GetSectionAtIndex(size_t idx) const
lldb::addr_t GetByteSize() const
lldb::offset_t GetFileSize() const
A stream class that can stream formatted output to a file.
void Format(const char *format, Args &&... args)
Forwards the arguments to llvm::formatv and writes to the stream.
llvm::raw_ostream & AsRawOstream()
Returns a raw_ostream that forwards the data to this Stream object.
size_t Indent(llvm::StringRef s="")
Indent the current line in the stream.
size_t Printf(const char *format,...) __attribute__((format(printf
Output printf formatted output to the stream.
size_t PutCString(llvm::StringRef cstr)
Output a C string to the stream.
size_t EOL()
Output and End of Line character to the stream.
unsigned GetIndentLevel() const
Get the current indentation level.
void SetType(lldb::SymbolType type)
Address & GetAddressRef()
lldb::SymbolType GetType() const
void SetDemangledNameIsSynthesized(bool b)
ConstString GetDisplayName() const
Symbol * SymbolAtIndex(size_t idx)
uint32_t AddSymbol(const Symbol &symbol)
size_t GetNumSymbols() const
void Reserve(size_t count)
bool SetSectionLoadAddress(const lldb::SectionSP §ion, lldb::addr_t load_addr, bool warn_multiple=false)
Represents UUID's of various sizes.
#define LLDB_INVALID_CPUTYPE
#define LLDB_INVALID_ADDRESS
A class that represents a running process on the host machine.
Log * GetLog(Cat mask)
Retrieve the Log object for the channel associated with the given log enum.
bool SaveMiniDump(const lldb::ProcessSP &process_sp, SaveCoreOptions &core_options, lldb_private::Status &error)
std::shared_ptr< lldb_private::Process > ProcessSP
@ eSymbolTypeAdditional
When symbols take more than one entry, the extra entries get this type.
ByteOrder
Byte ordering definitions.
std::shared_ptr< lldb_private::DataBuffer > DataBufferSP
std::shared_ptr< lldb_private::Section > SectionSP
std::shared_ptr< lldb_private::WritableDataBuffer > WritableDataBufferSP
@ eSectionTypeLLDBFormatters
@ eSectionTypeLLDBTypeSummaries
@ eSectionTypeSwiftModules
@ eSectionTypeDataCString
Inlined C string data.
std::shared_ptr< lldb_private::DataExtractor > DataExtractorSP
std::shared_ptr< lldb_private::Module > ModuleSP
std::shared_ptr< lldb_private::OptionValue > OptionValueSP
struct lldb_private::UUID::CvRecordPdb70::@270014123013057306020052025020177330273131255133 Uuid
llvm::support::ulittle32_t Age