summaryrefslogtreecommitdiff
path: root/view/sharedcache/workflow
diff options
context:
space:
mode:
authorMark Rowe <mrowe@bdash.net.nz>2025-02-17 11:04:35 -0800
committerMason Reed <35282038+emesare@users.noreply.github.com>2025-04-07 22:39:32 -0400
commit73e7d21d029a1d3d1160cf6a7bc4a4faf41fe221 (patch)
tree8cd6a2a579c952349e0ea8eeeeac98d90108d2fa /view/sharedcache/workflow
parentf902f22843146fb04dddadc5765f6582e3096a18 (diff)
[SharedCache] Apply call overrides to objc_msgSendSuper / objc_msgSendSuper2
These are treated the same as `objc_msgSend` with the exception of their first argument being an `objc_super*` rather than `id`.
Diffstat (limited to 'view/sharedcache/workflow')
-rw-r--r--view/sharedcache/workflow/ObjCActivity.cpp29
1 files changed, 25 insertions, 4 deletions
diff --git a/view/sharedcache/workflow/ObjCActivity.cpp b/view/sharedcache/workflow/ObjCActivity.cpp
index 55a8a8fa..f620de85 100644
--- a/view/sharedcache/workflow/ObjCActivity.cpp
+++ b/view/sharedcache/workflow/ObjCActivity.cpp
@@ -57,11 +57,24 @@ void ObjCActivity::AdjustCallType(Ref<AnalysisContext> ctx)
if (insn.operation != LLIL_CALL_SSA)
return;
- // Filter out calls that aren't to `objc_msgSend`.
+ enum class MessageSendType {
+ Normal,
+ Super,
+ };
+
+ MessageSendType messageSendType = MessageSendType::Normal;
+ // Filter out calls that aren't to `objc_msgSend`, `objc_msgSendSuper`, or `objc_msgSendSuper2`.
auto callExpr = insn.GetDestExpr<LLIL_CALL_SSA>();
if (auto symbol = bv->GetSymbolByAddress(callExpr.GetValue().value))
- if (symbol->GetRawName() != "_objc_msgSend")
- return;
+ {
+ std::string_view symbolName = symbol->GetRawNameRef();
+ if (symbolName == "_objc_msgSend")
+ messageSendType = MessageSendType::Normal;
+ else if (symbolName == "_objc_msgSendSuper2" || symbolName == "_objc_msgSendSuper")
+ messageSendType = MessageSendType::Super;
+ else
+ return;
+ }
const auto params = insn.GetParameterExprs<LLIL_CALL_SSA>();
// The second parameter passed to the objc_msgSend call is the address of
@@ -98,7 +111,15 @@ void ObjCActivity::AdjustCallType(Ref<AnalysisContext> ctx)
std::vector<FunctionParameter> callTypeParams;
auto cc = bv->GetDefaultPlatform()->GetDefaultCallingConvention();
- callTypeParams.emplace_back("self", retType, true, Variable());
+ if (messageSendType == MessageSendType::Normal)
+ callTypeParams.emplace_back("self", retType, true, Variable());
+ else
+ {
+ auto superType = bv->GetTypeByName({ "objc_super" });
+ if (!superType)
+ superType = Type::PointerType(ssa->GetArchitecture(), Type::VoidType());
+ callTypeParams.emplace_back("super", Type::PointerType(ssa->GetArchitecture(), superType), true, Variable());
+ }
auto selType = bv->GetTypeByName({ "SEL" });
if (!selType)