[ppc64] Incorrect decompilation as a result of incorrect instruction width
Maintainer antworten meist innerhalb von 2 Tagen
Dieses Issue hat noch niemand übernommen.
Bewertung
- Schwierigkeit
- 3/5
- Geschätzter Aufwand
- 1-2 Tage
- Anfängerfreundlichkeit
- 68/100
- Issue-Typ
- Bug
- Klarheit
- Klar beschrieben
- Aktivitätsstatus
- Aktiv
- Tech-Stack
- cpp
- Bereich
- compilers, reverse-engineering
Rechercherichtung
Start in arch/powerpc/il.cpp at the cmpw lifting code linked in the issue (around lines 766–772), then inspect how the comparison width is represented in the generated IL. Use the attached reproducer and compare its HLIL result with the expected 0xa. Done means the 32-bit comparison produces the correct condition and the decompilation selects 0xa.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
Version and Platform (required):
- Binary Ninja Version: 6.1.10926-dev Ultimate, 479fee2a
- OS: macos
- OS Version: 27.0.1
- CPU Architecture: arm64
Bug Description:
10010158 0 38600001 li r3, 0x1
1001015c 0 786307c6 sldi r3, r3, 0x20 {0x100000000} ; r3 = 0x0000_0001_0000_0000
10010160 0 38800001 li r4, 0x1 ; r4 = 1
10010164 0 7f832000 cmpw cr7, r3, r4 ; 32-bit signed compare of the low words
10010168 0 4fdcf382 cror cr7eq, cr7lt, cr7eq ; cr7.eq = cr7.lt | cr7.eq (i.e. "<=")
1001016c 0 38e0000a li r7, 0xa
10010170 0 39000014 li r8, 0x14
10010174 0 7c67479e isel r3, r7, r8, 0x1e {0x0} {0xa} {0x14} ; r3 = cr7.eq ? r7 : r8
10010178 0 4e800020 blr
This is incorrectly folded to the following by HLIL:
10010174 return 0x14
The expected result is 0xa, not 0x14.
Steps To Reproduce:
Open this binary ppc64_cmpw_cror.zip and let it analyze.
Additional Information:
I think this is due to cmpw being lifted to a 64-bit subtraction despite the operands only being 32-bits in size:
0 @ 10010158 0 (LLIL_SET_REG.q r3 = (LLIL_CONST.q 1))
1 @ 1001015c 0 (LLIL_SET_REG.q r3 = (LLIL_LSL.q (LLIL_REG.q r3) << (LLIL_CONST.q 0x20)))
2 @ 10010160 0 (LLIL_SET_REG.q r4 = (LLIL_CONST.q 1))
3 @ 10010164 0 (LLIL_SUB.q sub.q{cr7_signed}((LLIL_REG.d r3.d), (LLIL_REG.d r4.d)))
You can see that the lifter uses the address size for the size of the subtraction, despite the instruction being a 32-bit comparison:
https://github.com/Vector35/binaryninja-api/blob/dev/arch/powerpc/il.cpp#L766-L772
- Vorherrschende Sprache
- C++
- Sterne
- 1.3k
- Forks
- 304
- Ø Merge
- 2 T. 20 Std.
- Gemergte PRs (30 T.)
- 10
Entwicklungsumgebung
Dieses Projekt bietet weder Dev-Container noch Dockerfile noch Beitragsleitfaden – die Einrichtung liegt bei Ihnen. Beginnen Sie mit der README; die allgemeinen Schritte stehen in unserem Leitfaden für den ersten Beitrag.
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus Vector35/binaryninja-api
-
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 84/100
Vector35/binaryninja-api#8715 ·
Maintainer antworten meist innerhalb von 2 Tagen
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 78/100
Vector35/binaryninja-api#8714 ·
Maintainer antworten meist innerhalb von 2 Tagen
-
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 85/100
Vector35/binaryninja-api#8713 ·
Maintainer antworten meist innerhalb von 2 Tagen
-
Schwierigkeit 1/5 1-3 Stunden Anfängerfreundlichkeit 78/100
Vector35/binaryninja-api#8689 ·
Maintainer antworten meist innerhalb von 2 Tagen
-
Component: Python API
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 70/100
Vector35/binaryninja-api#8649 ·
Maintainer antworten meist innerhalb von 2 Tagen
Alle Issues in Vector35/binaryninja-api
Ähnliche Issues
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 80/100
ESPresense/ESPresense#2680 · 2 Kommentare ·
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 2/5 Unter einer Stunde Anfängerfreundlichkeit 75/100
stew675/llama-cpp-rdna-boosts#348 ·
Maintainer antworten meist innerhalb von 1 Tag
-
Documentation: Add comprehensive newcomer onboarding guide, project structure, and local usage to READMEEvtl. vergeben @Ash-Blanc hat das heute übernommen. Offenarea/other status/bot-triaged status/need-triage
Schwierigkeit 2/5 Ein halber Tag Anfängerfreundlichkeit 85/100
-
bug
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 85/100
Maintainer antworten meist innerhalb von 1 Tag
-
bug
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 72/100
Maintainer antworten meist innerhalb von 1 Tag