From 1bb00127874e414066fe91943aa938ae414eca2a Mon Sep 17 00:00:00 2001 From: Mark Rowe Date: Thu, 2 Apr 2026 09:51:00 -0700 Subject: [ObjC] Don't undefine / redefine symbols and types that already exist in the view This can cause functions to be reanalyzed unnecessarily when the view is loaded from a bndb. Fixes https://github.com/Vector35/binaryninja-api/issues/8051. --- objectivec/objc.cpp | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to 'objectivec/objc.cpp') diff --git a/objectivec/objc.cpp b/objectivec/objc.cpp index 2a9a9439..fb5187ee 100644 --- a/objectivec/objc.cpp +++ b/objectivec/objc.cpp @@ -412,10 +412,16 @@ void ObjCProcessor::DefineObjCSymbol( auto defineSymbol = [this](Ref symbol, const Confidence>& type) { uint64_t symbolAddress = symbol->GetAddress(); - // Armv7/Thumb: This will rewrite the symbol's address. - // e.g. We pass in 0xc001, it will rewrite it to 0xc000 and create the function w/ the "thumb2" arch. if (Ref existingSymbol = m_data->GetSymbolByAddress(symbolAddress)) + { + if (existingSymbol->IsAutoDefined() && existingSymbol->GetType() == symbol->GetType() && existingSymbol->GetRawNameRef() == symbol->GetRawNameRef()) + return; + m_data->UndefineAutoSymbol(existingSymbol); + } + + // Armv7/Thumb: This will rewrite the symbol's address. + // e.g. We pass in 0xc001, it will rewrite it to 0xc000 and create the function w/ the "thumb2" arch. Ref targetPlatform = m_data->GetDefaultPlatform()->GetAssociatedPlatformByAddress(symbolAddress); if (symbol->GetType() == FunctionSymbol) { @@ -1159,6 +1165,11 @@ void ObjCProcessor::GenerateClassTypes() { for (auto& [_, cls] : m_classes) { + QualifiedName classTypeName = cls.name; + std::string classTypeId = Type::GenerateAutoTypeId("objc", classTypeName); + if (m_data->GetTypeById(classTypeId)) + continue; + QualifiedName typeName; StructureBuilder classTypeBuilder; bool failedToDecodeType = false; @@ -1191,8 +1202,6 @@ void ObjCProcessor::GenerateClassTypes() if (failedToDecodeType) continue; auto classTypeStruct = classTypeBuilder.Finalize(); - QualifiedName classTypeName = cls.name; - std::string classTypeId = Type::GenerateAutoTypeId("objc", classTypeName); Ref classType = Type::StructureType(classTypeStruct); QualifiedName classQualName = m_data->DefineType(classTypeId, classTypeName, classType); cls.associatedName = classTypeName; -- cgit v1.3.1