Skip to content

feat: filter loop-head aligned entries via backward-branch targets#19

Draft
maxgio92 wants to merge 1 commit intomainfrom
feat/loop-head-filter
Draft

feat: filter loop-head aligned entries via backward-branch targets#19
maxgio92 wants to merge 1 commit intomainfrom
feat/loop-head-filter

Conversation

@maxgio92
Copy link
Owner

@maxgio92 maxgio92 commented Mar 3, 2026

With -O2, GCC aligns loop heads to 16-byte boundaries using NOP fill, which produces the same ret + NOP + aligned address pattern 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 where target < source is 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, which DetectFunctions calls regardless.

Tracks: #18

@maxgio92 maxgio92 force-pushed the feat/loop-head-filter branch from fbb975f to 4a89edc Compare March 3, 2026 14:55
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
@maxgio92 maxgio92 force-pushed the feat/loop-head-filter branch from 4a89edc to d1efbb2 Compare March 6, 2026 10:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant