summaryrefslogtreecommitdiff
path: root/objectivec
diff options
context:
space:
mode:
authorMark Rowe <mark@vector35.com>2026-04-02 09:51:00 -0700
committerMark Rowe <mark@vector35.com>2026-04-08 11:07:41 -0700
commit1bb00127874e414066fe91943aa938ae414eca2a (patch)
tree5b5025ba8a6d0813794c2d6ce6050516075aa4ac /objectivec
parent5aa33821483c0ef72030342a70b36eec5dfb5387 (diff)
[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.
Diffstat (limited to 'objectivec')
-rw-r--r--objectivec/objc.cpp17
1 files changed, 13 insertions, 4 deletions
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> symbol, const Confidence<Ref<Type>>& 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<Symbol> 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<Platform> 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<Type> classType = Type::StructureType(classTypeStruct);
QualifiedName classQualName = m_data->DefineType(classTypeId, classTypeName, classType);
cls.associatedName = classTypeName;