Skip to content

Commit

Permalink
fix 'ELF load command address/offset not page-aligned'
Browse files Browse the repository at this point in the history
  • Loading branch information
DennyDai committed Dec 17, 2024
1 parent 277a0ac commit 43930f6
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -174,9 +174,9 @@ def _create_new_mapped_block(
[segment["p_align"] for segment in self.p.binfmt_tool._segments]
+ [0]
)
mem_addr = block.addr + (file_addr % max_seg_align)
mem_addr = block.addr + (file_addr - block.addr) % max_seg_align
else:
mem_addr = block.addr + (file_addr % 0x1000)
mem_addr = block.addr + (file_addr - block.addr) % 0x1000
block.addr = mem_addr + 0x10000
if file_addr and mem_addr:
self.add_block(
Expand Down
4 changes: 1 addition & 3 deletions src/patcherex2/patches/data_patches.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,7 @@ def apply(self, p: Patcherex) -> None:
if self.addr:
p.binfmt_tool.update_binary_content(self.addr, self.data)
elif self.name:
block = p.allocation_manager.allocate(
len(self.data), flag=MemoryFlag.RWX
) # FIXME: why RW not work?
block = p.allocation_manager.allocate(len(self.data), flag=MemoryFlag.RW)
p.symbols[self.name] = block.mem_addr
p.binfmt_tool.update_binary_content(block.file_addr, self.data)

Expand Down

0 comments on commit 43930f6

Please sign in to comment.