summaryrefslogtreecommitdiff
path: root/view
diff options
context:
space:
mode:
authorkat <kat@vector35.com>2024-06-14 19:46:39 -0400
committerkat <kat@vector35.com>2024-06-16 10:43:46 -0400
commit42fe51aecc09d2d57bfacfa4504e4a1bb0e04281 (patch)
treeb6ea10ebb9af4d20edb99156f01b308323d53b37 /view
parent51c0684340555c3a2f85461224f327402a546287 (diff)
[Objective-C] Mark __objc_ivar as const, define names for class/super refs
Diffstat (limited to 'view')
-rw-r--r--view/macho/objc.cpp30
1 files changed, 29 insertions, 1 deletions
diff --git a/view/macho/objc.cpp b/view/macho/objc.cpp
index 3daaf61e..b2e82fd7 100644
--- a/view/macho/objc.cpp
+++ b/view/macho/objc.cpp
@@ -967,7 +967,15 @@ void ObjCProcessor::PostProcessObjCSections(BinaryReader* reader)
auto type = Type::PointerType(ptrSize, Type::NamedType(m_data, m_typeNames.cls));
for (view_ptr_t i = start; i < end; i += ptrSize)
{
- m_data->DefineDataVariable(i, type);
+ reader->Seek(i);
+ auto clsLoc = ReadPointerAccountingForRelocations(reader);
+ if (const auto& it = m_classes.find(clsLoc); it != m_classes.end())
+ {
+ auto& cls = it->second;
+ std::string name = cls.name;
+ if (!name.empty())
+ DefineObjCSymbol(DataSymbol, type, "clsRef_" + name, i, true);
+ }
}
}
if (auto superRefs = m_data->GetSectionByName("__objc_superrefs"))
@@ -977,6 +985,26 @@ void ObjCProcessor::PostProcessObjCSections(BinaryReader* reader)
auto type = Type::PointerType(ptrSize, Type::NamedType(m_data, m_typeNames.cls));
for (view_ptr_t i = start; i < end; i += ptrSize)
{
+ reader->Seek(i);
+ auto clsLoc = ReadPointerAccountingForRelocations(reader);
+ if (const auto& it = m_classes.find(clsLoc); it != m_classes.end())
+ {
+ auto& cls = it->second;
+ std::string name = cls.name;
+ if (!name.empty())
+ DefineObjCSymbol(DataSymbol, type, "superRef_" + name, i, true);
+ }
+ }
+ }
+ if (auto ivars = m_data->GetSectionByName("__objc_ivar"))
+ {
+ auto start = ivars->GetStart();
+ auto end = ivars->GetEnd();
+ auto ivarSectionEntryTypeBuilder = new TypeBuilder(Type::IntegerType(8, false));
+ ivarSectionEntryTypeBuilder->SetConst(true);
+ auto type = ivarSectionEntryTypeBuilder->Finalize();
+ for (view_ptr_t i = start; i < end; i += ptrSize)
+ {
m_data->DefineDataVariable(i, type);
}
}