Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ElfLoadAlignmentModifier #302

Merged
merged 8 commits into from
May 16, 2023
Merged

Conversation

whyitfor
Copy link
Contributor

@whyitfor whyitfor commented May 8, 2023

One sentence summary of this PR (This should go in the CHANGELOG!)
Add ElfLoadAlignmentModifier, which reclaims unused alignment bytes between PT_LOAD segments in ELFs as free space.

Please describe the changes in your request.
Add the ElfLoadAlignmentModifier, a free space creation technique that adds unused alignment bytes between PT_LOAD segments in ELF binaries to the segments, creating free space without increasing the ELF binary footprint.
The modifier's file has example usage with an experimental CLI interface:

% python3 ofrak/core/elf/load_alignment_modifier.py --file test_ofrak/components/assets/elf/hello_elf_exec -o hello_elf_exec_freed
[+] Free space found by ElfLoadAlignmentFreeSpaceModifier: Allocatable(free_space_ranges={<MemoryPermissions.R: 4>: [Range(0x400438, 0x401000), Range(0x402128, 0x402e10)], <MemoryPermissions.RX: 5>: [Range(0x4011cd, 0x402000)]})
[+] MemoryPermissions.R free space: 0x18b0 bytes
[+] MemoryPermissions.RX free space: 0xe33 bytes
[+] Output file written to hello_elf_exec_freed
It took 0.025 seconds to run the OFRAK script

@whyitfor whyitfor requested a review from EdwardLarson May 8, 2023 15:33
@whyitfor whyitfor force-pushed the feature/elf_load_alignment_modifier branch from 16c16d4 to e887bc6 Compare May 8, 2023 15:35
@whyitfor whyitfor merged commit c06d8e1 into master May 16, 2023
5 checks passed
@whyitfor whyitfor deleted the feature/elf_load_alignment_modifier branch June 30, 2023 14:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants