Skip to content
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

Unify jmp and br behaviour #69

Closed
wants to merge 2 commits into from
Closed

Unify jmp and br behaviour #69

wants to merge 2 commits into from

Conversation

Gert-JanG
Copy link
Contributor

@Gert-JanG Gert-JanG commented May 23, 2024

Example

init_state.inspect.b('exit', when=angr.BP_BEFORE, action=check_jump)

def check_jump(state):
    addr = state.regs.ip

For jmp, jz, ... instructions 'addr' will contain the value of ip BEFORE THE JMP instruction as they only execute self.jump(...) (https://github.com/angr/angr-platforms/blob/master/angr_platforms/msp430/instrs_msp430.py#L933)

For a branch instruction https://github.com/angr/angr-platforms/blob/master/angr_platforms/msp430/instrs_msp430.py#L660-L661, a value (src) will be returned, which will trigger an immediate commit (https://github.com/angr/pyvex/blob/master/pyvex/lifting/util/instr_helper.py#L132-L134).

In the example above, the br instruction will thus immediately commit the result to the ip, so the 'addr' will contain the ip AFTER THE BR instruction (so 'addr' will contain the ip after the br)

When 
init_state.inspect.b('exit', when=angr.BP_BEFORE, action=check_jump)

def check_jump(state):
    addr = state.regs.ip

For jmp, jz, ... type instructions 'addr' will contain the value of ip before execution of the jmp instruction as they only execute self.jump(...) (https://github.com/angr/angr-platforms/blob/master/angr_platforms/msp430/instrs_msp430.py#L933)

For a branch instruction https://github.com/angr/angr-platforms/blob/master/angr_platforms/msp430/instrs_msp430.py#L660-L661 also the src will be returned which will trigger an immediate commit (https://github.com/angr/pyvex/blob/master/pyvex/lifting/util/instr_helper.py#L132-L134). 

In the example above the br instruction will thus immediately affect the 'addr' as it will contain the ip where the br already occurred (so 'addr' will contain the ip after the br)
Fix Lint issue?
@Gert-JanG Gert-JanG closed this by deleting the head repository Jun 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant