Refactor data relocation diffing to improve accuracy and fix bugs #157
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.
This rewrites how data relocation diffs are performed to be less hacky and more accurate.
The way it was originally implemented in #154 was to first perform a diff on the raw bytes of each side as normal, then diff the relocations, and then attempt to modify the diff of bytes after the fact to slice the diffs up and keep track of changed relocations in there.
This appeared to work when the bytes containing the relocations were unchanged and the same length on both sides.
But when the bytes themselves also changed (e.g. because dtk detected bytes that look like a pointer as being a relocation) it becomes practically impossible to modify the diff of bytes in a way that makes sense, which would result in the GUI code displaying the data as incorrectly shifted around, and scrolling to the bottom of the section would result in an index out of bounds error in some cases.
Furthermore, even when the bytes were the same, there were some other edge cases where the relocations could be displayed at the wrong offsets within the section.
The new way it's implemented in this PR simplifies how objdiff-core keeps track of relocation diffs: it now has a second list of diffs specifically for relocations, and the original list of diffs of bytes is reverted to how it worked in objdiff 2.6.0, without relocation data in it.
Instead, the GUI code now looks at both the list of byte diffs and the list of relocation diffs and merges them together per-row, and then displays each byte within a diff with its own color so that the bytes that contain a relocation can be colored differently from other bytes in the same diff.
The diffs no longer seem to get shifted around or cause errors.
I also made the hover tooltip show the source address of data relocations so that it's easier to tell exactly where they originate from (because multiple relocs can appear on one line, and the address objdiff shows in the left gutter isn't accurate anyway).