two issues with new register calling convention
@D0ntPanic đang làm issue này rồi.
Từ ngày 21/9/2026.
Đá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
- 64/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- cpp
- Lĩnh vực
- compilers, reverse-engineering
Hướng nghiên cứu
Start in arch/x86/arch_x86.cpp at the x86 register calling-convention implementation, especially IsStackAdjustedOnReturn and GetCallLayout, and compare the proposed layout with GetDefaultCallLayout. Verify callee cleanup and that an indirect result pointer occupies the slot after declared parameters: EAX with none, EDX after one, and the stack after EAX, EDX, and ECX are used.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
The x86 register calling convention added in the recent CC refactor needs two core fixes to be laid out
correctly: callee stack cleanup, and the hidden pointer for an indirectly returned result going in the argument slot following the declared parameters (EAX with no parameters, EDX after one, the stack once EAX/EDX/ECX
are taken). Without them, every Delphi prototype with a stack argument or a string/record/variant result has its arguments shifted.
Found this while working on a delphi plugin, it certainly produces better results but haven't validated it fully by hand:
diff --git a/arch/x86/arch_x86.cpp b/arch/x86/arch_x86.cpp
index 35d58a008..966f53c23 100644
--- a/arch/x86/arch_x86.cpp
+++ b/arch/x86/arch_x86.cpp
@@ -4913,11 +4913,56 @@ public:
return type && !type->IsFloat() && type->GetWidth() > 4;
}
+ bool IsStackAdjustedOnReturn() override
+ {
+ return true;
+ }
+
bool AreStackArgumentsPushedLeftToRight() override
{
return true;
}
+ /*! Delphi passes the hidden pointer for an indirectly returned result in the argument slot
+ *following* the declared parameters: EAX for a parameterless function, EDX after one
+ parameter, and the stack once EAX, EDX and ECX are taken. GetIndirectReturnValueLocation
+ cannot express that, because the slot depends on how many parameters precede it, so the
+ whole layout is computed here instead.
+ */
+ CallLayout GetCallLayout(BinaryView* view, const ReturnValue& returnValue, const vector<FunctionParameter>& params,
+ const std::optional<set<uint32_t>>& permittedRegs) override
+ {
+ CallLayout result = GetDefaultCallLayout(view, returnValue, params, permittedRegs);
+ if (!result.returnValue.has_value() || !result.returnValue->indirect)
+ return result;
+
+ // A caller that has pinned the return value to an explicit location keeps it.
+ // MarkNonDefaultParameterLocations clears defaultLocation and re-runs this until the
+ // layout agrees with the location it recorded, so moving a pinned location never
+ // terminates.
+ if (!returnValue.defaultLocation)
+ return result;
+
+ // Lay the call out a second time with the hidden pointer appended as an ordinary trailing
+ // parameter and nothing returned, then split that parameter back off as the return value.
+ vector<FunctionParameter> extended = params;
+ extended.push_back(FunctionParameter("", Type::PointerType(GetArchitecture(), Type::VoidType())));
+ CallLayout appended = GetDefaultCallLayout(view, ReturnValue(Type::VoidType()), extended, permittedRegs);
+ if (appended.parameters.size() != extended.size())
+ return result;
+
+ ValueLocation hidden = appended.parameters.back();
+ hidden.indirect = true;
+ hidden.returnedPointer = result.returnValue->returnedPointer;
+ appended.parameters.pop_back();
+
+ result.parameters = appended.parameters;
+ result.returnValue = hidden;
+ result.stackAdjustment = appended.stackAdjustment;
+ result.registerStackAdjustments = appended.registerStackAdjustments;
+ return result;
+ }
+
- 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
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 ·
-
Component: GLib
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
-
Mute ydb/tests/functional/dstool/test_canonical_requests.py.Test.test_group_take_snapshot in main Đang mởai_reviewed
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
ydb-platform/ydb#53974 · 3 bình luận ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
google/libultrahdr#485 ·