feat: filter loop-head aligned entries via backward-branch targets#19
Draft
feat: filter loop-head aligned entries via backward-branch targets#19
Conversation
fbb975f to
4a89edc
Compare
With -O2, GCC aligns loop heads to 16-byte boundaries using NOP fill, producing the same ret+NOP+aligned pattern as a function separator. The aligned-entry detector fires on these, generating false positives. To filter them out, build a set of backward-branch targets from the already-computed call-site edges: any unconditional JMP/B where target < source is a loop back-edge, and its target is a loop head. Aligned-entry candidates that match a loop head are skipped. This post-filter adds no extra scan pass - it reuses the edges returned by DetectCallSites, which DetectFunctions already computes. Closes #18
4a89edc to
d1efbb2
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
With
-O2, GCC aligns loop heads to 16-byte boundaries using NOP fill, which produces the sameret + NOP + aligned addresspattern as a function separator. The aligned-entry detector fires on these, contributing false positives.This adds a post-filter to
DetectFunctions: before emitting aligned-entry candidates, build a set of backward-branch targets from the already-computed call-site edges. Any unconditional JMP/B wheretarget < sourceis a loop back-edge, and its target is a loop head - skip it.No extra scan pass is needed. The edges are already produced by
DetectCallSites, whichDetectFunctionscalls regardless.Tracks: #18