-
Notifications
You must be signed in to change notification settings - Fork 474
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Arm: add parallel instructions #1005
Open
serpilliere
wants to merge
1
commit into
cea-sec:master
Choose a base branch
from
serpilliere:arm_add_instr
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+720
−1
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
from builtins import str | ||
from builtins import object | ||
import sys | ||
import os | ||
|
||
from future.utils import viewitems | ||
|
||
from miasm.arch.arm.arch import mn_arm, base_expr, variable | ||
from miasm.core import parse_asm | ||
from miasm.expression.expression import * | ||
from miasm.core import asmblock | ||
from miasm.loader.strpatchwork import StrPatchwork | ||
from miasm.analysis.machine import Machine | ||
from miasm.jitter.csts import * | ||
|
||
reg_and_id = dict(mn_arm.regs.all_regs_ids_byname) | ||
|
||
class Asm_Test(object): | ||
run_addr = 0x0 | ||
|
||
def __init__(self, jitter_engine): | ||
self.myjit = Machine(self.arch_name).jitter(jitter_engine) | ||
self.myjit.init_stack() | ||
|
||
def test_init(self): | ||
pass | ||
|
||
def prepare(self): | ||
pass | ||
|
||
def __call__(self): | ||
self.prepare() | ||
self.asm() | ||
self.init_machine() | ||
self.test_init() | ||
self.run() | ||
self.check() | ||
|
||
def run(self): | ||
|
||
self.myjit.init_run(self.run_addr) | ||
self.myjit.continue_run() | ||
|
||
assert(self.myjit.pc == self.ret_addr) | ||
|
||
def asm(self): | ||
blocks, loc_db = parse_asm.parse_txt( | ||
mn_arm, self.arch_attrib, self.TXT, | ||
loc_db = self.myjit.ir_arch.loc_db | ||
) | ||
# fix shellcode addr | ||
loc_db.set_location_offset(loc_db.get_name_location("main"), 0x0) | ||
s = StrPatchwork() | ||
patches = asmblock.asm_resolve_final(mn_arm, blocks, loc_db) | ||
for offset, raw in viewitems(patches): | ||
s[offset] = raw | ||
|
||
s = bytes(s) | ||
self.assembly = s | ||
|
||
def check(self): | ||
raise NotImplementedError('abstract method') | ||
|
||
|
||
class Asm_Test(Asm_Test): | ||
arch_name = "arml" | ||
arch_attrib = "l" | ||
ret_addr = 0x1330 | ||
|
||
def init_machine(self): | ||
self.myjit.vm.add_memory_page(self.run_addr, PAGE_READ | PAGE_WRITE, self.assembly) | ||
self.myjit.push_uint32_t(self.ret_addr) | ||
self.myjit.add_breakpoint(self.ret_addr, lambda x:False) | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Double checking: is using
_sub
on purpose? (because it seems to be an addition)