summaryrefslogtreecommitdiff
path: root/view/sharedcache/core/SharedCacheController.cpp
diff options
context:
space:
mode:
authorMason Reed <mason@vector35.com>2025-04-04 23:57:13 -0400
committerMason Reed <mason@vector35.com>2025-04-06 20:00:37 -0400
commit4f22a944d77f784b53ee3a37d9f1966ede1c98a4 (patch)
tree4eaaa0dab98760b1a9ebc12bd15cfb9a7e1be6ea /view/sharedcache/core/SharedCacheController.cpp
parent2e855275732aed00486ca100f4151f4074d9949e (diff)
[SharedCache] Prevent all functions from being queued up for reanalysis when adding new images and regions
Within the user section creation we will assume that because a non-default section was added, we should mark all functions for reanalysis. From initial testing this isn't an extreme slowdown, but with the addition of more images the number of queued up functions becomes much greater, even if those are unmarked immediately and processing of those functions isn't slow it is unneeded and might lead to other non-obvious slowdowns. To be clear, we do not need to queue up functions from already analyzed images to be analyzed again, there is no benefit, our workflow handles cross images calls already, so those places will already be queued up, and if they aren't, that is the issue to solve, not this.
Diffstat (limited to 'view/sharedcache/core/SharedCacheController.cpp')
-rw-r--r--view/sharedcache/core/SharedCacheController.cpp15
1 files changed, 15 insertions, 0 deletions
diff --git a/view/sharedcache/core/SharedCacheController.cpp b/view/sharedcache/core/SharedCacheController.cpp
index 678f4b59..13afb476 100644
--- a/view/sharedcache/core/SharedCacheController.cpp
+++ b/view/sharedcache/core/SharedCacheController.cpp
@@ -159,7 +159,15 @@ bool SharedCacheController::ApplyRegion(BinaryView& view, const CacheRegion& reg
// If we are not associated with an image we can create a section here to set the semantics.
// This is important for stub regions, as they will deref non image data that we want to retrieve the value of.
if (region.type != CacheRegionType::Image)
+ {
+ // Adding a user section will mark all functions for updates unless we disable this.
+ // Because images are known separate compilation units, we have a real reason to make sure we don't mark all previously
+ // analyzed functions as updated.
+ auto prevDisabledState = view.GetFunctionAnalysisUpdateDisabled();
+ view.SetFunctionAnalysisUpdateDisabled(true);
view.AddUserSection(memoryRegionName, region.start, region.size, region.SectionSemanticsForRegion());
+ view.SetFunctionAnalysisUpdateDisabled(prevDisabledState);
+ }
m_loadedRegions.insert(region.start);
@@ -198,7 +206,14 @@ bool SharedCacheController::ApplyImage(BinaryView& view, const CacheImage& image
{
// Header information is applied to the view here, such as sections.
auto machoProcessor = SharedCacheMachOProcessor(&view, m_cache.GetVirtualMemory());
+
+ // Adding a user section will mark all functions for updates unless we disable this.
+ // Because images are known separate compilation units, we have a real reason to make sure we don't mark all previously
+ // analyzed functions as updated.
+ auto prevDisabledState = view.GetFunctionAnalysisUpdateDisabled();
+ view.SetFunctionAnalysisUpdateDisabled(true);
machoProcessor.ApplyHeader(*image.header);
+ view.SetFunctionAnalysisUpdateDisabled(prevDisabledState);
// TODO: Passing in an image name here is weird considering this is shared with the MACHO view.
// TODO: We should abstract out the "image" into an objc image type that represents what is required, which ig is the name?