forked from jbevain/cecil
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix RVA field alignment (jbevain#60)
This ensures that section starts are aligned by adjusting the previous Range's length to ensure the computed start of a new Range meets the alignment requirements. It was done this way rather than just computing an aligned start for the new Range, because the TextMap assumes that the Ranges are contiguous - see for example GetNextRVA. GetNextRVA was used to compute the Code RVA, before adding that segment to the TextMap. This meant that the alignment (only added later) wasn't taken into account when writing out the code, but then later the TextMap was modified to include the alignment. This is fixed by first inserting an aligned zero-length Code segment before writing the code, then inserting it again once the length is known. Removing the Code alignment altogether would work too, but the alignment constants are kept in there, because it looks like they were added intentionally, even though the reason is unknown. Note that before this change, the start of the Code segment (at least on x64) was not 16-byte aligned in the first place, so this change will actually move the beginning of the Code segment.
- Loading branch information
Showing
5 changed files
with
46 additions
and
5 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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