Closed StarGazerM closed 2 years ago
It does not, though that's something that would be nice to add in the future. What sort of modifications are you looking to make?
I want to add something like:
.comm foo
to a binary, and used foo
in the asm code I want to insert.
Can I create some Symbol objects and ByteInterval objects then directly add them to module before register the insertion?
Yeah, that would be my recommendation. As long as the symbols are added to the module before begin_module
returns, the patches will be able to reference them.
Ah thx, another question what if I need some thing like:
call read@PLT
Do I need manually construct an plt code block?
Nope, that'll get generated during reassembly.
You might need to use get_or_insert_extern_symbol
to ensure that read
is present in the module's symbols.
okkk great thank you so much
Support for patches adding data has been added in gtirb-rewriting 0.24. It can't handle the .comm directive, but it can do things like this:
@patch_constraints(x86_syntax=X86Syntax.INTEL)
def assert_patch(insertion_context):
return """
lea rdi, [rip + .Lassertion]
lea rsi, [rip + .Lunknown]
xor rdx, rdx
lea rcx, [rip + .Lunknown]
call __assert_fail
ud2
.rodata
.Lassertion:
.string "something went wrong!"
.Lunknown:
.string "unknown"
"""
thx!
gtirb-rewriting gained support for rewriting data blocks in main today, using insert_at
, replace_at
, and delete_at
. It didn't add support for .comm
, but it's still on my radar as something I'd like to add in the future.
Hi: Does gtrirb-rewriting support modifying data other than
.text
section? If not, which part of GTIRB IR API maybe related to this?