From aa408cfdeaa3cd0c4319598223a4548b18731290 Mon Sep 17 00:00:00 2001 From: Mark Rowe Date: Sun, 24 Nov 2024 22:28:04 -0800 Subject: [SharedCache] Fix handling of relative selectors in macOS shared caches Find the relative selector base address in the Objective-C optimization data pointed to by the shared cache header, rather than via `__objc_scoffs`. This is only present on iOS, and not for every iOS version that encodes selectors via direct offsets. This also includes some related improvements: 1. Direct selectors get their own pointer type so they're rendered correctly in the view. 2. Method lists encoded as lists of lists are now handled. 3. The `dyld_cache_header` type added to the view is truncated to the length in the loaded cache. This ensures it is applied to the view. 4. A couple of methods that process method IMPs and selectors are updated to check whether the address is valid before attempting to process them. They would otherwise fail by throwing an exception if they proceed, but checking for validity is quicker and makes exception breakpoints usable. --- view/sharedcache/workflow/SharedCacheWorkflow.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'view/sharedcache/workflow/SharedCacheWorkflow.cpp') diff --git a/view/sharedcache/workflow/SharedCacheWorkflow.cpp b/view/sharedcache/workflow/SharedCacheWorkflow.cpp index 61832e93..fa34e2f5 100644 --- a/view/sharedcache/workflow/SharedCacheWorkflow.cpp +++ b/view/sharedcache/workflow/SharedCacheWorkflow.cpp @@ -468,7 +468,7 @@ void fixObjCCallTypes(Ref ctx) const auto selectorRegister = params[0].GetParameterExprs()[1].GetSourceSSARegister(); rawSelector = ssa->GetSSARegisterValue(selectorRegister).value; } - if (rawSelector == 0) + if (!rawSelector || !bv->IsValidOffset(rawSelector)) return; // -- Do callsite override -- cgit v1.3.1