Skip to content

Commit

Permalink
only copy patcherex section
Browse files Browse the repository at this point in the history
  • Loading branch information
DennyDai committed May 20, 2024
1 parent 5854fa9 commit 8fc1d29
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/patcherex2/components/compilers/compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,13 +95,13 @@ def compile(
os.path.join(td, "obj_linked.o"), main_opts={"base_addr": 0x0}
)

text_section = next(
patcherex2_section = next(
(s for s in ld.main_object.sections if s.name == ".patcherex2"), None
)
compiled_start = ld.all_objects[0].entry + base

compiled = ld.memory.load(
compiled_start,
text_section.memsize - compiled_start,
patcherex2_section.memsize - compiled_start,
)
return compiled
9 changes: 8 additions & 1 deletion src/patcherex2/components/compilers/llvm_recomp.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,14 @@ def compile(
ld = cle.Loader(
os.path.join(td, "obj_linked.o"), main_opts={"base_addr": 0x0}
)

patcherex2_section = next(
(s for s in ld.main_object.sections if s.name == ".patcherex2"), None
)
compiled_start = ld.all_objects[0].entry + base

compiled = ld.memory.load(
ld.all_objects[0].entry + base, ld.memory.max_addr
compiled_start,
patcherex2_section.memsize - compiled_start,
)
return compiled

0 comments on commit 8fc1d29

Please sign in to comment.