Very oldschool x86 signed division by 2 using `sar`+`adc` lifts into something unhelpful
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 55/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Khá rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- cpp
- Lĩnh vực
- reverse-engineering
Hướng nghiên cứu
Start with the attached binjabaddiv.zip and inspect the function at 0x40107c in Binary Ninja; compare the lifted SAR/ADC flags and conditional path with signed division by two. Done means this pattern decompiles without an unimplemented carry flag and expresses the intended signed result.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Version and Platform (required):
- Binary Ninja Version: 5.3.9757 Personal (a99f2380)
- OS: macOS
- OS Version: 26.6.1
- CPU Architecture: ARM64
Bug Description:
I have a target that has been compiled using Borland C++, either version 4.5 or 5.x (from the late 90s). In this compiler, the following code:
int bad_div2(int x) { return x / 2; }
…which computes a signed division by 2, ends up compiling into the following assembly:
sar eax,1
jns short @3
adc eax,0
@3:
After loading this into Binary Ninja, it decompiles into a rather unhelpful:
0040107c int32_t sub_40107c(int32_t arg1)
0040107c {
0040107c int32_t result = arg1 >> 1;
🚫🚫00401082 bool c = /* bool c = unimplemented {sar eax, 0x1} */;
00401082
00401084 if (arg1 >> 1 >= 0)
0040108a return result;
0040108a
00401086 return result + 0;
0040107c }
Steps To Reproduce:
Please provide all steps required to reproduce the behavior:
- I am attaching a fully-linked EXE which includes this function at address 0x40107c. (Running the EXE doesn't do anything, it's only useful for looking at the function.)
Expected Behavior:
It'd be really nice if this pattern could be recognized and simplified.
Screenshots/Video Recording:
N/A
Binary:
binjabaddiv.zip
Additional Information:
N/A
- Ngôn ngữ chính
- C++
- Star
- 1.3k
- Fork
- 298
- Merge trung bình
- 4 ngày 13 giờ
- Pull request đã merge (30 ngày)
- 20
Hướng dẫn đóng góp
Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của Vector35/binaryninja-api
-
Độ khó 1/5 1-3 giờ Mức phù hợp với người mới 88/100
Vector35/binaryninja-api#8540 ·
-
normalize time logs from WARP Đang mở
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 88/100
Vector35/binaryninja-api#8446 ·
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 88/100
Vector35/binaryninja-api#8444 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
Vector35/binaryninja-api#8441 · 3 bình luận ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
Vector35/binaryninja-api#8404 ·
Tất cả issue của Vector35/binaryninja-api
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
-
good first issue
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
ros2/message_filters#338 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
subsurface/subsurface#4984 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
flutter-webrtc/flutter-webrtc#2206 ·
-
litertlm-android AAR ships no consumer ProGuard rules → "mid == null" SIGABRT in minified apps Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
google-ai-edge/LiteRT-LM#3739 ·