-
Notifications
You must be signed in to change notification settings - Fork 470
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1474 from DimitriPapadopoulos/codespell
Fix typos found by codespell
- Loading branch information
Showing
13 changed files
with
135 additions
and
135 deletions.
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 was deleted.
Oops, something went wrong.
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,113 @@ | ||
from miasm.analysis.data_flow import State | ||
from miasm.expression.expression import * | ||
|
||
""" | ||
Test memory interferences | ||
A memory interference may appear when two ExprMem objects relate to the same area of memory: editing one may impact the other. | ||
""" | ||
|
||
a32 = ExprId('a', 32) | ||
b32 = ExprId('b', 32) | ||
|
||
a64 = ExprId('a', 64) | ||
b64 = ExprId('b', 64) | ||
|
||
mem_a32_32 = ExprMem(a32, 32) | ||
mem_b32_32 = ExprMem(b32, 32) | ||
|
||
mem_a64_32 = ExprMem(a64, 32) | ||
|
||
mem_a32_m1_8 = ExprMem(a32 + ExprInt(-1, 32), 8) | ||
mem_a32_p0_8 = ExprMem(a32, 8) | ||
mem_a32_p1_8 = ExprMem(a32 + ExprInt(1, 32), 8) | ||
mem_a32_p2_8 = ExprMem(a32 + ExprInt(2, 32), 8) | ||
mem_a32_p3_8 = ExprMem(a32 + ExprInt(3, 32), 8) | ||
mem_a32_p4_8 = ExprMem(a32 + ExprInt(4, 32), 8) | ||
|
||
|
||
mem_a32_m4_32 = ExprMem(a32 + ExprInt(-4, 32), 32) | ||
mem_a32_m3_32 = ExprMem(a32 + ExprInt(-3, 32), 32) | ||
mem_a32_m2_32 = ExprMem(a32 + ExprInt(-2, 32), 32) | ||
mem_a32_m1_32 = ExprMem(a32 + ExprInt(-1, 32), 32) | ||
mem_a32_p0_32 = ExprMem(a32, 32) | ||
mem_a32_p1_32 = ExprMem(a32 + ExprInt(1, 32), 32) | ||
mem_a32_p2_32 = ExprMem(a32 + ExprInt(2, 32), 32) | ||
mem_a32_p3_32 = ExprMem(a32 + ExprInt(3, 32), 32) | ||
mem_a32_p4_32 = ExprMem(a32 + ExprInt(4, 32), 32) | ||
|
||
|
||
mem_a64_m4_32 = ExprMem(a64 + ExprInt(-4, 64), 32) | ||
mem_a64_m3_32 = ExprMem(a64 + ExprInt(-3, 64), 32) | ||
mem_a64_m2_32 = ExprMem(a64 + ExprInt(-2, 64), 32) | ||
mem_a64_m1_32 = ExprMem(a64 + ExprInt(-1, 64), 32) | ||
mem_a64_p0_32 = ExprMem(a64, 32) | ||
mem_a64_p1_32 = ExprMem(a64 + ExprInt(1, 64), 32) | ||
mem_a64_p2_32 = ExprMem(a64 + ExprInt(2, 64), 32) | ||
mem_a64_p3_32 = ExprMem(a64 + ExprInt(3, 64), 32) | ||
mem_a64_p4_32 = ExprMem(a64 + ExprInt(4, 64), 32) | ||
|
||
|
||
state = State() | ||
|
||
|
||
assert state.may_interfere(set([mem_a32_32]), mem_b32_32) == True | ||
assert state.may_interfere(set([mem_b32_32]), mem_a32_32) == True | ||
|
||
# Test 8 bit accesses | ||
assert state.may_interfere(set([mem_a32_m1_8]), mem_a32_32) == False | ||
assert state.may_interfere(set([mem_a32_p0_8]), mem_a32_32) == True | ||
assert state.may_interfere(set([mem_a32_p1_8]), mem_a32_32) == True | ||
assert state.may_interfere(set([mem_a32_p2_8]), mem_a32_32) == True | ||
assert state.may_interfere(set([mem_a32_p3_8]), mem_a32_32) == True | ||
assert state.may_interfere(set([mem_a32_p4_8]), mem_a32_32) == False | ||
|
||
assert state.may_interfere(set([mem_a32_32]), mem_a32_m1_8) == False | ||
assert state.may_interfere(set([mem_a32_32]), mem_a32_p0_8) == True | ||
assert state.may_interfere(set([mem_a32_32]), mem_a32_p1_8) == True | ||
assert state.may_interfere(set([mem_a32_32]), mem_a32_p2_8) == True | ||
assert state.may_interfere(set([mem_a32_32]), mem_a32_p3_8) == True | ||
assert state.may_interfere(set([mem_a32_32]), mem_a32_p4_8) == False | ||
|
||
|
||
# Test 32 bit accesses | ||
assert state.may_interfere(set([mem_a32_m4_32]), mem_a32_32) == False | ||
assert state.may_interfere(set([mem_a32_m3_32]), mem_a32_32) == True | ||
assert state.may_interfere(set([mem_a32_m2_32]), mem_a32_32) == True | ||
assert state.may_interfere(set([mem_a32_m1_32]), mem_a32_32) == True | ||
assert state.may_interfere(set([mem_a32_p0_32]), mem_a32_32) == True | ||
assert state.may_interfere(set([mem_a32_p1_32]), mem_a32_32) == True | ||
assert state.may_interfere(set([mem_a32_p2_32]), mem_a32_32) == True | ||
assert state.may_interfere(set([mem_a32_p3_32]), mem_a32_32) == True | ||
assert state.may_interfere(set([mem_a32_p4_32]), mem_a32_32) == False | ||
|
||
assert state.may_interfere(set([mem_a32_32]), mem_a32_m4_32) == False | ||
assert state.may_interfere(set([mem_a32_32]), mem_a32_m3_32) == True | ||
assert state.may_interfere(set([mem_a32_32]), mem_a32_m2_32) == True | ||
assert state.may_interfere(set([mem_a32_32]), mem_a32_m1_32) == True | ||
assert state.may_interfere(set([mem_a32_32]), mem_a32_p0_32) == True | ||
assert state.may_interfere(set([mem_a32_32]), mem_a32_p1_32) == True | ||
assert state.may_interfere(set([mem_a32_32]), mem_a32_p2_32) == True | ||
assert state.may_interfere(set([mem_a32_32]), mem_a32_p3_32) == True | ||
assert state.may_interfere(set([mem_a32_32]), mem_a32_p4_32) == False | ||
|
||
# Test 32 bit accesses with 64 bit memory address | ||
assert state.may_interfere(set([mem_a64_m4_32]), mem_a64_32) == False | ||
assert state.may_interfere(set([mem_a64_m3_32]), mem_a64_32) == True | ||
assert state.may_interfere(set([mem_a64_m2_32]), mem_a64_32) == True | ||
assert state.may_interfere(set([mem_a64_m1_32]), mem_a64_32) == True | ||
assert state.may_interfere(set([mem_a64_p0_32]), mem_a64_32) == True | ||
assert state.may_interfere(set([mem_a64_p1_32]), mem_a64_32) == True | ||
assert state.may_interfere(set([mem_a64_p2_32]), mem_a64_32) == True | ||
assert state.may_interfere(set([mem_a64_p3_32]), mem_a64_32) == True | ||
assert state.may_interfere(set([mem_a64_p4_32]), mem_a64_32) == False | ||
|
||
assert state.may_interfere(set([mem_a64_32]), mem_a64_m4_32) == False | ||
assert state.may_interfere(set([mem_a64_32]), mem_a64_m3_32) == True | ||
assert state.may_interfere(set([mem_a64_32]), mem_a64_m2_32) == True | ||
assert state.may_interfere(set([mem_a64_32]), mem_a64_m1_32) == True | ||
assert state.may_interfere(set([mem_a64_32]), mem_a64_p0_32) == True | ||
assert state.may_interfere(set([mem_a64_32]), mem_a64_p1_32) == True | ||
assert state.may_interfere(set([mem_a64_32]), mem_a64_p2_32) == True | ||
assert state.may_interfere(set([mem_a64_32]), mem_a64_p3_32) == True | ||
assert state.may_interfere(set([mem_a64_32]), mem_a64_p4_32) == False |
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
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
Oops, something went wrong.