librz/core/canalysis.c: Fix data xref analysis#6612
Open
MrQuantum1915 wants to merge 2 commits into
Open
Conversation
a13e3bb to
92e8970
Compare
MrQuantum1915
commented
Jul 8, 2026
Comment on lines
+4209
to
+4222
| ut64 next_sec_start = UT64_MAX; | ||
|
|
||
| RzBinSection *s; | ||
| void **iter; | ||
| rz_pvector_foreach (bo->sections, iter) { | ||
| s = *iter; | ||
| if (s->is_segment) { | ||
| continue; | ||
| } | ||
| ut64 vaddr = rz_bin_object_addr_with_base(bo, s->vaddr); | ||
| if (vaddr > target && vaddr < next_sec_start) { | ||
| next_sec_start = vaddr; | ||
| } | ||
| } |
Contributor
Author
There was a problem hiding this comment.
wondering if we should create api fxn for rz_bin_get_next_section or not
Member
|
Can you give some context why this is needed please? |
Contributor
Author
i discussed this in mattermost rizin dev channel |
Member
|
Sorry, just saw the message. |
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.
Your checklist for this pull request
RZ_APIfunction and struct this PR changes.RZ_API).Detailed description
while processing for marking xrefs as data
classify target using
xref_ref_kindfor data section too, previously it was only classified if target was in exec segment. Which caused false positive when the target was in non-exec section. Happens when the immediate value is small and it points in data section.restrict data block from bleeding into other sections. Currently it correctly caps data block at next "detected" function (or next data) but when the function is not detected yet (like in stripped bins) and the area onwards from data ref is empty, the data block bleeds into other sections specifically executable section. This should never happen.
while experimenting on my fix i also noticed that this fails when the target is in a section gap (for any reason :D) and it fallback to caping on map_end.
so we need to iterate over sections if any , to cap upper at next section.
fallback to map end (when target is in last section before unmapped region)
Relevant PRs:
1st bug : #6506
2nd bug : #6307
...
Test plan
before:
after:
...
Closing issues
...