Changeset View
Changeset View
Standalone View
Standalone View
source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
Show First 20 Lines • Show All 122 Lines • ▼ Show 20 Lines | if (ObjectFilePECOFF::MagicBytesMatch(data_sp)) { | ||||
coff_header_t coff_header; | coff_header_t coff_header; | ||||
if (ParseDOSHeader(data, dos_header)) { | if (ParseDOSHeader(data, dos_header)) { | ||||
lldb::offset_t offset = dos_header.e_lfanew; | lldb::offset_t offset = dos_header.e_lfanew; | ||||
uint32_t pe_signature = data.GetU32(&offset); | uint32_t pe_signature = data.GetU32(&offset); | ||||
if (pe_signature != IMAGE_NT_SIGNATURE) | if (pe_signature != IMAGE_NT_SIGNATURE) | ||||
return false; | return false; | ||||
if (ParseCOFFHeader(data, &offset, coff_header)) { | if (ParseCOFFHeader(data, &offset, coff_header)) { | ||||
ArchSpec spec; | ModuleSpec module_spec(file); | ||||
ArchSpec &spec = module_spec.GetArchitecture(); | |||||
lldb_private::UUID &uuid = module_spec.GetUUID(); | |||||
if (!uuid.IsValid()) { | |||||
if (auto Result = llvm::sys::fs::md5_contents(file.GetPath())) | |||||
uuid = | |||||
UUID::fromOptionalData(llvm::ArrayRef<uint8_t>(Result->Bytes)); | |||||
} | |||||
if (coff_header.machine == MachineAmd64) { | if (coff_header.machine == MachineAmd64) { | ||||
spec.SetTriple("x86_64-pc-windows"); | spec.SetTriple("x86_64-pc-windows"); | ||||
specs.Append(ModuleSpec(file, spec)); | specs.Append(module_spec); | ||||
} else if (coff_header.machine == MachineX86) { | } else if (coff_header.machine == MachineX86) { | ||||
spec.SetTriple("i386-pc-windows"); | spec.SetTriple("i386-pc-windows"); | ||||
specs.Append(ModuleSpec(file, spec)); | specs.Append(module_spec); | ||||
spec.SetTriple("i686-pc-windows"); | spec.SetTriple("i686-pc-windows"); | ||||
specs.Append(ModuleSpec(file, spec)); | specs.Append(module_spec); | ||||
} else if (coff_header.machine == MachineArmNt) { | } else if (coff_header.machine == MachineArmNt) { | ||||
spec.SetTriple("arm-pc-windows"); | spec.SetTriple("arm-pc-windows"); | ||||
specs.Append(ModuleSpec(file, spec)); | specs.Append(module_spec); | ||||
} | } | ||||
} | } | ||||
} | } | ||||
} | } | ||||
return specs.GetSize() - initial_count; | return specs.GetSize() - initial_count; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 682 Lines • ▼ Show 20 Lines | for (uint32_t idx = 0; idx < nsects; ++idx) { | ||||
m_coff_header_opt.sect_alignment, // Section alignment | m_coff_header_opt.sect_alignment, // Section alignment | ||||
m_sect_headers[idx].flags)); // Flags for this section | m_sect_headers[idx].flags)); // Flags for this section | ||||
image_sp->GetChildren().AddSection(std::move(section_sp)); | image_sp->GetChildren().AddSection(std::move(section_sp)); | ||||
} | } | ||||
} | } | ||||
} | } | ||||
UUID ObjectFilePECOFF::GetUUID() { return UUID(); } | UUID ObjectFilePECOFF::GetUUID() { | ||||
if (m_uuid.IsValid()) | |||||
return m_uuid; | |||||
// Use the object content's MD5 as UUID | |||||
auto Result = llvm::sys::fs::md5_contents(GetFileSpec().GetPath()); | |||||
if (!Result) | |||||
return UUID(); | |||||
m_uuid = UUID::fromOptionalData(llvm::ArrayRef<uint8_t>(Result->Bytes)); | |||||
return m_uuid; | |||||
} | |||||
uint32_t ObjectFilePECOFF::ParseDependentModules() { | uint32_t ObjectFilePECOFF::ParseDependentModules() { | ||||
ModuleSP module_sp(GetModule()); | ModuleSP module_sp(GetModule()); | ||||
if (!module_sp) | if (!module_sp) | ||||
return 0; | return 0; | ||||
std::lock_guard<std::recursive_mutex> guard(module_sp->GetMutex()); | std::lock_guard<std::recursive_mutex> guard(module_sp->GetMutex()); | ||||
if (m_deps_filespec) | if (m_deps_filespec) | ||||
▲ Show 20 Lines • Show All 338 Lines • Show Last 20 Lines |