Skip to content

Commit 73e7d21

Browse files
bdashemesare
authored andcommitted
[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`.
1 parent f902f22 commit 73e7d21

File tree

1 file changed

+25
-4
lines changed

1 file changed

+25
-4
lines changed

view/sharedcache/workflow/ObjCActivity.cpp

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,24 @@ void ObjCActivity::AdjustCallType(Ref<AnalysisContext> ctx)
5757
if (insn.operation != LLIL_CALL_SSA)
5858
return;
5959

60-
// Filter out calls that aren't to `objc_msgSend`.
60+
enum class MessageSendType {
61+
Normal,
62+
Super,
63+
};
64+
65+
MessageSendType messageSendType = MessageSendType::Normal;
66+
// Filter out calls that aren't to `objc_msgSend`, `objc_msgSendSuper`, or `objc_msgSendSuper2`.
6167
auto callExpr = insn.GetDestExpr<LLIL_CALL_SSA>();
6268
if (auto symbol = bv->GetSymbolByAddress(callExpr.GetValue().value))
63-
if (symbol->GetRawName() != "_objc_msgSend")
64-
return;
69+
{
70+
std::string_view symbolName = symbol->GetRawNameRef();
71+
if (symbolName == "_objc_msgSend")
72+
messageSendType = MessageSendType::Normal;
73+
else if (symbolName == "_objc_msgSendSuper2" || symbolName == "_objc_msgSendSuper")
74+
messageSendType = MessageSendType::Super;
75+
else
76+
return;
77+
}
6578

6679
const auto params = insn.GetParameterExprs<LLIL_CALL_SSA>();
6780
// The second parameter passed to the objc_msgSend call is the address of
@@ -98,7 +111,15 @@ void ObjCActivity::AdjustCallType(Ref<AnalysisContext> ctx)
98111
std::vector<FunctionParameter> callTypeParams;
99112
auto cc = bv->GetDefaultPlatform()->GetDefaultCallingConvention();
100113

101-
callTypeParams.emplace_back("self", retType, true, Variable());
114+
if (messageSendType == MessageSendType::Normal)
115+
callTypeParams.emplace_back("self", retType, true, Variable());
116+
else
117+
{
118+
auto superType = bv->GetTypeByName({ "objc_super" });
119+
if (!superType)
120+
superType = Type::PointerType(ssa->GetArchitecture(), Type::VoidType());
121+
callTypeParams.emplace_back("super", Type::PointerType(ssa->GetArchitecture(), superType), true, Variable());
122+
}
102123

103124
auto selType = bv->GetTypeByName({ "SEL" });
104125
if (!selType)

0 commit comments

Comments
 (0)