خلفيّة سياديّة م١: محرّك x86-64 (variable) + كاتب ELF64 ⇒ «خروج ٤٢» بلا clang/lld/as - #320
Merged
Merged
Conversation
…لا clang/lld/as أوّلُ كودٍ C++ فعليّ للخلفيّة الأصليّة (RFC rfcs #57): محرّكُ ترميز x86-64 عائلة variable (بادئة REX + ModRM + أوپكود + فوريّ) + كاتبُ ELF64 ساكن — header-only، لا يمسّ مكتبة المصرّف (أدنى مخاطرة بناء). المُضاف: • compiler/include/backend/native/x86_variable_encoder.h: محرّكٌ عامٌّ واحد يقرأ مواصفةَ ترميز (تُرآي encode في instructions.yaml) ويُخرج بايتات؛ المنطقُ الضيّق لعائلة x86 (REX 0100·WRXB، ModRM mod·reg·rm) مكتوبٌ مرّةً، والفرقُ بيانات (EncSpec). المجموعة الدنيا: mov r32,imm32 / mov r/m64,r64 / add r/m64,r64 / syscall / ret + فحص حدود المعاملات. • compiler/include/backend/native/elf64_writer.h: ثنائيّ ELF64 تنفيذيّ ساكن (رأس ٦٤ + PT_LOAD R+X + .text)، نقطة الدخول vbase+0x78، كتابة LE يدويّة (مستقلّة عن ترتيب بايتات المضيف). • compiler/tests/test_native_backend_m1.cpp: ١٠ اختبارات — ٧ ترميزات مُتحقَّقة بايتًا ببايت ضدّ مخرَج llvm-mc-18 (bf2a000000/b83c000000/0f05/4889d8/4801d8/4d89c8/c3) + تسلسل خروج ٤٢ + سلامة رأس ELF + كتابة الملفّ. ١٠/١٠ PASS. • scripts/native_backend/prove_m1_exit42.sh: برهانُ التشغيل الحيّ. • كتلة CMake معزولة (if EXISTS، بلا target_link_libraries) تحاكي test_docs_emitter. البرهان الحيّ: الثنائيّ الساكن نُفِّذ على Linux (WSL2 نواة ٦٫١٨) وخرج برمز ٤٢ — بلا clang ولا lld ولا as. معيار قبول م١+م٢ في rfcs #57 محقَّق (بايت-ببايت ضدّ llvm-mc + ELF يعمل). أميليا CLEAR (كلّ بت محسوب يدويًّا، ELF سليم، معزول، LE مستقلّ عن المضيف). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
الغرض
أوّلُ كودٍ C++ فعليّ للخلفيّة الأصليّة بلا LLVM (RFC rfcs #57، بعد م٠ #318 والهدف الثاني #319): محرّكُ ترميز x86-64 (عائلة variable) + كاتبُ ELF64 ساكن ⇒ ثنائيّ «خروج ٤٢» يعمل على Linux بلا clang ولا lld ولا as.
header-only ⇒ لا يمسّ مكتبةَ المصرّف (أدنى مخاطرة بناء).
المُضاف
compiler/include/backend/native/x86_variable_encoder.hencodeفيinstructions.yaml) ويُخرج بايتات؛ المنطق الضيّق (REX0100·WRXB+ ModRM) مرّةً، والفرق بيانات (EncSpec)compiler/include/backend/native/elf64_writer.hPT_LOADR+X +.text)، دخولvbase+0x78، كتابة LE يدويّة مستقلّة عن المضيفcompiler/tests/test_native_backend_m1.cppscripts/native_backend/prove_m1_exit42.shالبوّابة التفاضليّة (بايت-ببايت ضدّ llvm-mc)
٧ ترميزات مُتحقَّقة حرفيًّا ضدّ مخرَج
llvm-mc-18 --show-encoding:mov edi, 42bf2a000000mov eax, 60b83c000000syscall0f05mov rax, rbx4889d8add rax, rbx4801d8mov r8, r94d89c8retc3البرهان الحيّ 🎯
الثنائيّ ELF64 الساكن (تسلسل
mov edi,42; mov eax,60; syscall) نُفِّذ على Linux (WSL2، نواة ٦٫١٨) وخرج برمز ٤٢ — بلا أيّ أداةٍ أجنبيّة:التحقّق
target_link_libraries)، LE مستقلّ عن المضيف. أُضيف فحصُ حدودِ المعاملات (تحصينٌ لتوصيتها قبل قراءة YAML في م٣).if(EXISTS)لا تكسر البناء الرئيس؛ أثر الاختبارsad_m1_exit42في.gitignore.🤖 Generated with Claude Code