From 79ef475f51d21d83dcc5a6e3e5b6b40cac616cc7 Mon Sep 17 00:00:00 2001 From: Mark Rowe Date: Wed, 7 May 2025 22:56:09 -0700 Subject: [ObjC] Retrieve category's class name when class is an external symbol This also updates the symbol names that are generated when the name cannot be found to include the address in hex rather than decimal so it's easier to navigate to. --- objectivec/objc.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'objectivec/objc.cpp') diff --git a/objectivec/objc.cpp b/objectivec/objc.cpp index 9bdd61c3..acfdbe53 100644 --- a/objectivec/objc.cpp +++ b/objectivec/objc.cpp @@ -583,7 +583,8 @@ void ObjCProcessor::LoadCategories(ObjCReader* reader, Ref
classPtrSect } else if (const auto symbol = GetSymbol(cat.cls)) { - if (symbol->GetType() == ImportedDataSymbol || symbol->GetType() == ImportAddressSymbol || symbol->GetType() == DataSymbol) + if (symbol->GetType() == ImportedDataSymbol || symbol->GetType() == ImportAddressSymbol + || symbol->GetType() == DataSymbol || symbol->GetType() == ExternalSymbol) { // Symbols named `_OBJC_CLASS_$_` are references to external classes. // Symbols named `cls_` are classes defined in a loaded image other than @@ -601,7 +602,7 @@ void ObjCProcessor::LoadCategories(ObjCReader* reader, Ref
classPtrSect m_logger->LogInfo( "[SharedCache.ObjC] Using base address as stand-in classname for category at 0x%llx", catLocation); - categoryBaseClassName = std::to_string(catLocation); + categoryBaseClassName = fmt::format("{:x}", catLocation); } try { @@ -613,7 +614,7 @@ void ObjCProcessor::LoadCategories(ObjCReader* reader, Ref
classPtrSect m_logger->LogWarn( "Failed to read category name for category at 0x%llx. Using base address as stand-in category name", catLocation); - categoryAdditionsName = std::to_string(catLocation); + categoryAdditionsName = fmt::format("{:x}", catLocation); } category.name = categoryBaseClassName + " (" + categoryAdditionsName + ")"; DefineObjCSymbol(BNSymbolType::DataSymbol, ptrType, "categoryPtr_" + category.name, i, true); @@ -699,7 +700,7 @@ void ObjCProcessor::LoadProtocols(ObjCReader* reader, Ref
listSection) m_logger->LogError( "Failed to read protocol name for protocol at 0x%llx. Using base address as stand-in protocol name", protocolLocation); - protocolName = std::to_string(protocolLocation); + protocolName = fmt::format("{:x}", protocolLocation); } Protocol protocolClass; -- cgit v1.3.1