ObjectFileSP ObjectContainerUniversalMachO::GetObjectFile(const FileSpec *file) { uint32_t arch_idx = 0; ArchSpec arch; // If the module hasn't specified an architecture yet, set it to the default // architecture: ModuleSP module_sp(GetModule()); if (module_sp) { if (!module_sp->GetArchitecture().IsValid()) { arch = Target::GetDefaultArchitecture(); if (!arch.IsValid()) arch.SetTriple(LLDB_ARCH_DEFAULT); } else arch = module_sp->GetArchitecture(); ArchSpec curr_arch; // First, try to find an exact match for the Arch of the Target. for (arch_idx = 0; arch_idx < m_header.nfat_arch; ++arch_idx) { if (GetArchitectureAtIndex(arch_idx, curr_arch) && arch.IsExactMatch(curr_arch)) break; } // Failing an exact match, try to find a compatible Arch of the Target. if (arch_idx >= m_header.nfat_arch) { for (arch_idx = 0; arch_idx < m_header.nfat_arch; ++arch_idx) { if (GetArchitectureAtIndex(arch_idx, curr_arch) && arch.IsCompatibleMatch(curr_arch)) break; } } if (arch_idx < m_header.nfat_arch) { DataBufferSP data_sp; lldb::offset_t data_offset = 0; return ObjectFile::FindPlugin( module_sp, file, m_offset + m_fat_archs[arch_idx].offset, m_fat_archs[arch_idx].size, data_sp, data_offset); } } return ObjectFileSP(); }
//------------------------------------------------------------------ /// Lets a platform answer if it is compatible with a given /// architecture and the target triple contained within. //------------------------------------------------------------------ bool Platform::IsCompatibleArchitecture (const ArchSpec &arch, bool exact_arch_match, ArchSpec *compatible_arch_ptr) { // If the architecture is invalid, we must answer true... if (arch.IsValid()) { ArchSpec platform_arch; // Try for an exact architecture match first. if (exact_arch_match) { for (uint32_t arch_idx=0; GetSupportedArchitectureAtIndex (arch_idx, platform_arch); ++arch_idx) { if (arch.IsExactMatch(platform_arch)) { if (compatible_arch_ptr) *compatible_arch_ptr = platform_arch; return true; } } } else { for (uint32_t arch_idx=0; GetSupportedArchitectureAtIndex (arch_idx, platform_arch); ++arch_idx) { if (arch.IsCompatibleMatch(platform_arch)) { if (compatible_arch_ptr) *compatible_arch_ptr = platform_arch; return true; } } } } if (compatible_arch_ptr) compatible_arch_ptr->Clear(); return false; }
bool lldb_private::operator== (const ArchSpec& lhs, const ArchSpec& rhs) { return lhs.IsExactMatch (rhs); }