Skip to content

Commit d18b770

Browse files
committed
[Objective-C] Nonlazy Category Support, improve category variable naming
1 parent b055631 commit d18b770

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

view/macho/objc.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -559,7 +559,6 @@ void ObjCProcessor::LoadCategories(BinaryReader* reader, Ref<Section> classPtrSe
559559
category_t cat;
560560

561561
reader->Seek(i);
562-
m_data->DefineDataVariable(i, ptrType);
563562
auto catLocation = ReadPointerAccountingForRelocations(reader);
564563
reader->Seek(catLocation);
565564

@@ -577,7 +576,6 @@ void ObjCProcessor::LoadCategories(BinaryReader* reader, Ref<Section> classPtrSe
577576
m_logger->LogError("Failed to read category pointed to by 0x%llx", i);
578577
continue;
579578
}
580-
m_data->DefineDataVariable(catLocation, catType);
581579

582580
std::string categoryAdditionsName;
583581
std::string categoryBaseClassName;
@@ -616,6 +614,8 @@ void ObjCProcessor::LoadCategories(BinaryReader* reader, Ref<Section> classPtrSe
616614
categoryAdditionsName = std::to_string(catLocation);
617615
}
618616
category.name = categoryBaseClassName + " (" + categoryAdditionsName + ")";
617+
DefineObjCSymbol(BNSymbolType::DataSymbol, ptrType, "categoryPtr_" + category.name, i, true);
618+
DefineObjCSymbol(BNSymbolType::DataSymbol, catType, "category_" + category.name, catLocation, true);
619619

620620
if (cat.instanceMethods)
621621
{
@@ -1426,6 +1426,8 @@ void ObjCProcessor::ProcessObjCData()
14261426

14271427
if (auto catList = m_data->GetSectionByName("__objc_catlist")) // Do this after loading class type data.
14281428
LoadCategories(&reader, catList);
1429+
if (auto nonLazyCatList = m_data->GetSectionByName("__objc_nlcatlist")) // Do this after loading class type data.
1430+
LoadCategories(&reader, nonLazyCatList);
14291431
for (auto& [_, cat] : m_categories)
14301432
ApplyMethodTypes(cat);
14311433

0 commit comments

Comments
 (0)