Skip to content

Diff: select match with highest similarity - #6741

Merged
notxvilka merged 4 commits into
rizinorg:devfrom
PremadeS:match-max-similarity-diff
Sep 16, 2026
Merged

notxvilka merged 4 commits into
rizinorg:devfrom
PremadeS:match-max-similarity-diff

Conversation

@PremadeS

@PremadeS PremadeS commented Sep 14, 2026

Copy link
Copy Markdown
Contributor

Your checklist for this pull request

  • I've read the guidelines for contributing to this repository.
  • I made sure to follow the project's coding style.
  • I've documented every RZ_API function and struct this PR changes.
  • I've added tests that prove my changes are effective (required for changes to RZ_API).
  • I've updated the Rizin book with the relevant information (if needed).
  • I've used AI tools to generate fully or partially these code changes and I'm sure the changes are not copyrighted by somebody else.

Detailed description

When diffing two files where the fileB has multiple candidate functions that can be matched against a function in fileA, select the one with the highest similarity instead of one that appears last.

related to: rizinorg/cutter#3625
requires: rizinorg/rizin-testbins#312

Output before:

┌────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
│ name0                    │ size0 │      addr0 │ type     │ similarity │      addr1 │ size1 │ name1                         │
│────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────│
│ sym.imp.printf           │     6 │ 0x00001030 │ COMPLETE │ 1.000000   │ 0x00001030 │     6 │ sym.imp.printf                │
│ sym.imp.__cxa_finalize   │     6 │ 0x00001040 │ COMPLETE │ 1.000000   │ 0x00001040 │     6 │ sym.imp.__cxa_finalize        │
│ sym.deregister_tm_clones │    34 │ 0x00001080 │ COMPLETE │ 1.000000   │ 0x00001080 │    34 │ sym.deregister_tm_clones      │
│ sym.process_data         │    84 │ 0x00001139 │ PARTIAL  │ 0.500000   │ 0x00001190 │    50 │ sym.candidate_low_similarity  │
│                          │     0 │ ---------- │ UNLIKE   │ 0.000000   │ 0x00001139 │    87 │ sym.candidate_high_similarity │
└────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘

Output after:

┌────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
│ name0                    │ size0 │      addr0 │ type     │ similarity │      addr1 │ size1 │ name1                         │
│────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────│
│ sym.imp.printf           │     6 │ 0x00001030 │ COMPLETE │ 1.000000   │ 0x00001030 │     6 │ sym.imp.printf                │
│ sym.imp.__cxa_finalize   │     6 │ 0x00001040 │ COMPLETE │ 1.000000   │ 0x00001040 │     6 │ sym.imp.__cxa_finalize        │
│ sym.deregister_tm_clones │    34 │ 0x00001080 │ COMPLETE │ 1.000000   │ 0x00001080 │    34 │ sym.deregister_tm_clones      │
│ sym.process_data         │    84 │ 0x00001139 │ PARTIAL  │ 0.965517   │ 0x00001139 │    87 │ sym.candidate_high_similarity │
│                          │     0 │ ---------- │ UNLIKE   │ 0.000000   │ 0x00001190 │    50 │ sym.candidate_low_similarity  │
└────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘

Test plan

Run new test-case

rz-test test/db/tools/rz_diff

...

Closing issues

...

@codecov

codecov Bot commented Sep 15, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 50.32%. Comparing base (e9157ca) to head (722fc34).
⚠️ Report is 1 commits behind head on dev.

Additional details and impacted files
Files with missing lines Coverage Δ
librz/arch/similarity.c 55.58% <100.00%> (ø)

... and 15 files with indirect coverage changes


Continue to review full report in Codecov by Harness.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update e9157ca...722fc34. Read the comment docs.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@notxvilka
notxvilka merged commit d58f4c0 into rizinorg:dev Sep 16, 2026
52 of 53 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants