Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

Very oldschool x86 signed division by 2 using `sar`+`adc` lifts into something unhelpful

Đang mở
#8,457 2 bình luận 0 reaction 0 người được giao Xem trên GitHub

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:

  1. 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

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. 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.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của Vector35/binaryninja-api

Tất cả issue của Vector35/binaryninja-api

Issue tương tự

Thêm issue về C++

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.