IL TestBit operation result isn't known even when testing a constant
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 35/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Stale
- Domain
- compilers, reverse-engineering
Research direction
Reproduce the report by comparing func.llil.instructions and func.mlil.instructions for the test_bit and equivalent and conditions shown. Then inspect the MLIL constant-folding path for test_bit; the work is done when the constant test is folded to a known conditional result like the equivalent and expression.
Written by the indexing model from the issue text.
Description
even though mlil should know the result of testing a single bit of a constant, it doesn't
>>> pprint.pprint(list(func.llil.instructions))
[<il: x20 = 0x3210>,
<il: x20 = x20 | 0x76540000>,
<il: x20 = x20 | 0xba9800000000>,
<il: x20 = x20 | 0x7edc000000000000>,
<il: x0 = x20 << 5>,
<il: if (test_bit(x20, 0x20)) then 6 else 8>,
<il: x0 = x0 | 0xffffffe000000000>,
<il: goto 10 @ 0x14>,
<il: x0 = x0 & 0x1fffffffff>,
<il: goto 10 @ 0x14>,
<il: <return> jump(x30)>]
>>> pprint.pprint(list(func.mlil.instructions))
[<il: if ( test_bit(0x7edcba9876543210, 0x20)) then 1 else 3>,
<il: x0 = -0x113579be00>,
<il: goto 5 @ 0x14>,
<il: x0 = 0xeca864200>,
<il: goto 5 @ 0x14>,
<il: return x0>]
doing the same thing with an and operation allows mlil to know the result of the conditional
>>> pprint.pprint(list(func.llil.instructions))
[<il: x20 = 0x3210>,
<il: x20 = x20 | 0x76540000>,
<il: x20 = x20 | 0xba9800000000>,
<il: x20 = x20 | 0x7edc000000000000>,
<il: x0 = (x20 & 0xffffffff) << 5>,
<il: if (x20 & 0x80000000 == 0) then 6 else 8>,
<il: x0 = x0 & 0x1fffffffff>,
<il: goto 10 @ 0x14>,
<il: x0 = x0 | 0xffffffe000000000>,
<il: goto 10 @ 0x14>,
<il: <return> jump(x30)>]
>>> pprint.pprint(list(func.mlil.instructions))
[<il: if (true) then 1 else 3>,
<il: x0 = 0xeca864200>,
<il: goto 5 @ 0x14>,
<il: x0 = -0x113579be00>,
<il: goto 5 @ 0x14>,
<il: return x0>]
- Dominant language
- C++
- Stars
- 1.3k
- Forks
- 298
- Avg merge
- 5d 5h
- Merged PRs (30d)
- 19
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from Vector35/binaryninja-api
-
Difficulty 1/5 1-3 hours Newbie friendliness 88/100
Vector35/binaryninja-api#8540 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
Vector35/binaryninja-api#8516 ·
-
Difficulty 1/5 Under an hour Newbie friendliness 92/100
Vector35/binaryninja-api#8503 ·
-
Difficulty 1/5 Under an hour Newbie friendliness 88/100
Vector35/binaryninja-api#8446 ·
-
Difficulty 1/5 Under an hour Newbie friendliness 88/100
Vector35/binaryninja-api#8444 ·
All issues in Vector35/binaryninja-api
Similar issues
-
Website Doc Typo Open
Difficulty 1/5 Under an hour Newbie friendliness 92/100
-
Difficulty 1/5 1-3 hours Newbie friendliness 92/100
autowarefoundation/autoware_universe#13413 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
-
automated-analysis bug memory-safety
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100