-
Notifications
You must be signed in to change notification settings - Fork 4
Open
Description
Is there a way to define data in one patch that can be used in another patch?
I've tried to do like so:
context.register_insert(
SingleBlockScope(module.entry_point, BlockPosition.ENTRY),
Patch.from_function(lambda _:'''
nop
.data
__variable: .quad 0
''', Constraints(x86_syntax=X86Syntax.INTEL))
)
context.register_insert_function(
'inserted_function_that_uses_var',
Patch.from_function(lambda _: '''
mov rdi, [rip + __variable]
''', Constraints(x86_syntax=X86Syntax.INTEL))
)
This causes this error:
gtirb_rewriting.driver.main(AddAFLPass)
File "/usr/local/lib/python3.9/dist-packages/gtirb_rewriting/driver.py", line 350, in main
_driver_core([entrypoint], False, argv)
File "/usr/local/lib/python3.9/dist-packages/gtirb_rewriting/driver.py", line 316, in _driver_core
pass_man.run(ir)
File "/usr/local/lib/python3.9/dist-packages/gtirb_rewriting/passes.py", line 116, in run
context.apply()
File "/usr/local/lib/python3.9/dist-packages/gtirb_rewriting/rewriting.py", line 1039, in apply
self._apply_function_insertion(
File "/usr/local/lib/python3.9/dist-packages/gtirb_rewriting/rewriting.py", line 732, in _apply_function_insertion
assembler_result = self._invoke_patch(
File "/usr/local/lib/python3.9/dist-packages/gtirb_rewriting/rewriting.py", line 404, in _invoke_patch
assembler.assemble(asm, patch.constraints.x86_syntax)
File "/usr/local/lib/python3.9/dist-packages/gtirb_rewriting/assembler/assembler.py", line 333, in assemble
assembler.assemble(_Streamer(self._state), asm)
File "/usr/local/lib/python3.9/dist-packages/gtirb_rewriting/assembler/assembler.py", line 122, in impl
return func(self, *args, **kwargs)
File "/usr/local/lib/python3.9/dist-packages/gtirb_rewriting/assembler/assembler.py", line 998, in emit_instruction
] = self._fixup_to_symbolic_operand(
File "/usr/local/lib/python3.9/dist-packages/gtirb_rewriting/assembler/assembler.py", line 1584, in _fixup_to_symbolic_operand
return self._mcexpr_to_symbolic_operand(expr, is_branch, loc)
File "/usr/local/lib/python3.9/dist-packages/gtirb_rewriting/assembler/assembler.py", line 1552, in _mcexpr_to_symbolic_operand
sym = self._resolve_symbol_ref(expr)
File "/usr/local/lib/python3.9/dist-packages/gtirb_rewriting/assembler/assembler.py", line 1447, in _resolve_symbol_ref
return self._resolve_symbol(expr.symbol, expr.location)
File "/usr/local/lib/python3.9/dist-packages/gtirb_rewriting/assembler/assembler.py", line 1432, in _resolve_symbol
raise UndefSymbolError._make(
gtirb_rewriting.assembler.assembler.UndefSymbolError: __variable is an undefined symbol reference
I've also tried to add the data in a seperate pass before it gets used but this also doesn't seem to work.
Thanks
Metadata
Metadata
Assignees
Labels
No labels