Skip to content

Commit

Permalink
include .rodata in function patches
Browse files Browse the repository at this point in the history
  • Loading branch information
DennyDai committed Feb 12, 2024
1 parent a11245c commit 2fa42a7
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
7 changes: 6 additions & 1 deletion src/patcherex2/components/compilers/compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,12 @@ def compile(self, code, base=0, symbols=None, extra_compiler_flags=None, **kwarg
_symbols.update(self.p.binary_analyzer.get_all_symbols())
_symbols.update(symbols)
linker_script = (
"SECTIONS { .text : SUBALIGN(0) { . = " + hex(base) + "; *(.text) "
"SECTIONS { .text : SUBALIGN(0) { . = "
+ hex(base)
# TODO: shouldn't put .rodata in .text, but otherwise switch case jump table won't work
# Note that even we don't include .rodata here, cle might still include it if there is
# no gap between .text and .rodata
+ "; *(.text) *(.rodata) "
)
for name, addr in _symbols.items():
linker_script += name + " = " + hex(addr) + ";"
Expand Down
4 changes: 3 additions & 1 deletion src/patcherex2/components/compilers/llvm_recomp.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,9 @@ def compile(
_symbols.update(self.p.binary_analyzer.get_all_symbols())
_symbols.update(symbols)
linker_script = (
"SECTIONS { .text : SUBALIGN(0) { . = " + hex(base) + "; *(.text) "
"SECTIONS { .text : SUBALIGN(0) { . = "
+ hex(base)
+ "; *(.text) *(.rodata) "
)
for name, addr in _symbols.items():
linker_script += name + " = " + hex(addr) + ";"
Expand Down

0 comments on commit 2fa42a7

Please sign in to comment.