Skip to content

Commit

Permalink
Check if the file is the same on SymbolComparisonInfo to figure out i…
Browse files Browse the repository at this point in the history
…f it should do an offset diff or an absolute
  • Loading branch information
AngheloAlf committed Jul 19, 2024
1 parent b02f250 commit f72cd6a
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 6 deletions.
9 changes: 7 additions & 2 deletions src/mapfile_parser/mapfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,14 @@ def diff(self) -> int|None:
buildAddress = self.buildAddress
expectedAddress = self.expectedAddress

# If both symbols are present in the same file then we do a diff
# between their offsets into their respectives file.
# This is done as a way to avoid too much noise in case an earlier file
# did shift.
if self.buildFile is not None and self.expectedFile is not None:
buildAddress = buildAddress - self.buildFile.vram
expectedAddress = expectedAddress - self.expectedFile.vram
if self.buildFile.filepath == self.expectedFile.filepath:
buildAddress -= self.buildFile.vram
expectedAddress -= self.expectedFile.vram

return buildAddress - expectedAddress

Expand Down
14 changes: 10 additions & 4 deletions src/rs/symbol_comparison_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,17 @@ impl SymbolComparisonInfo {
let mut build_address = self.build_address;
let mut expected_address = self.expected_address;

// If both symbols are present in the same file then we do a diff
// between their offsets into their respectives file.
// This is done as a way to avoid too much noise in case an earlier file
// did shift.
if let Some(build_file) = &self.build_file {
build_address -= build_file.vram;
}
if let Some(expected_file) = &self.expected_file {
expected_address -= expected_file.vram;
if let Some(expected_file) = &self.expected_file {
if build_file.filepath == expected_file.filepath {
build_address -= build_file.vram;
expected_address -= expected_file.vram;
}
}
}

Some(build_address as i64 - expected_address as i64)
Expand Down

0 comments on commit f72cd6a

Please sign in to comment.