Skip to content

Commit 4f22a94

Browse files
committed
[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.
1 parent 2e85527 commit 4f22a94

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

view/sharedcache/core/SharedCacheController.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,15 @@ bool SharedCacheController::ApplyRegion(BinaryView& view, const CacheRegion& reg
159159
// If we are not associated with an image we can create a section here to set the semantics.
160160
// This is important for stub regions, as they will deref non image data that we want to retrieve the value of.
161161
if (region.type != CacheRegionType::Image)
162+
{
163+
// Adding a user section will mark all functions for updates unless we disable this.
164+
// Because images are known separate compilation units, we have a real reason to make sure we don't mark all previously
165+
// analyzed functions as updated.
166+
auto prevDisabledState = view.GetFunctionAnalysisUpdateDisabled();
167+
view.SetFunctionAnalysisUpdateDisabled(true);
162168
view.AddUserSection(memoryRegionName, region.start, region.size, region.SectionSemanticsForRegion());
169+
view.SetFunctionAnalysisUpdateDisabled(prevDisabledState);
170+
}
163171

164172
m_loadedRegions.insert(region.start);
165173

@@ -198,7 +206,14 @@ bool SharedCacheController::ApplyImage(BinaryView& view, const CacheImage& image
198206
{
199207
// Header information is applied to the view here, such as sections.
200208
auto machoProcessor = SharedCacheMachOProcessor(&view, m_cache.GetVirtualMemory());
209+
210+
// Adding a user section will mark all functions for updates unless we disable this.
211+
// Because images are known separate compilation units, we have a real reason to make sure we don't mark all previously
212+
// analyzed functions as updated.
213+
auto prevDisabledState = view.GetFunctionAnalysisUpdateDisabled();
214+
view.SetFunctionAnalysisUpdateDisabled(true);
201215
machoProcessor.ApplyHeader(*image.header);
216+
view.SetFunctionAnalysisUpdateDisabled(prevDisabledState);
202217

203218
// TODO: Passing in an image name here is weird considering this is shared with the MACHO view.
204219
// TODO: We should abstract out the "image" into an objc image type that represents what is required, which ig is the name?

0 commit comments

Comments
 (0)