arXivDaily arXiv每日学术速递 周一至周五更新
感恩节,周五至周末无更新,大家顺遂。周一再来吧
arXiv 2604.04527cs.SEcs.AIcs.PL
收藏

ENCRUST:在活体支架上进行封装替换和代理细化以实现安全的C到Rust翻译

ENCRUST: Encapsulated Substitution and Agentic Refinement on a Live Scaffold for Safe C-to-Rust Translation

Korea University(高丽大学);University of Houston(休斯顿大学);State University of New York Korea(纽约州立大学韩国分校)

Hohyun Sim, Hyeonjoong Cho, Ali Shokri, Zhoulai Fu, Binoy Ravindran

AI总结:

ENCRUST通过封装替换和代理细化方法,解决C到Rust翻译中的类型不匹配和不安全构造问题,通过ABI保持封装模式和整体代码库验证,实现安全且可编译的转换。

摘要:

我们提出了ENCRUST:在活体支架上进行封装替换和代理细化以实现安全的C到Rust翻译,一种两阶段流程用于将现实中的C项目安全地转换为Rust。现有方法要么产生无内存安全保证的不安全输出,要么孤立地翻译函数,无法检测跨单元类型不匹配或处理需要整个程序推理的不安全构造。此外,函数级LLM流程在类型签名变化时需要协调调用者更新,而项目级系统在现实依赖复杂性下往往无法生成可编译的输出。ENCRUST通过通过保持应用程序二进制接口(ABI)的封装模式解耦边界适应与函数逻辑,并通过整合代码库验证每个中间状态来解决这些限制。第一阶段(封装替换)使用保持ABI的封装器将每个函数拆分为两个部分:一个调用者透明的封装器保留原始原始指针签名,以及一个由LLM目标的安全内部函数,具有干净、作用域限制的提示。这使每个函数的类型变化可以独立进行,失败时自动回滚,而无需协调调用者更新。一个确定性、类型指导的封装器消除过程随后在成功翻译后删除封装器。第二阶段(代理细化)解决超出函数范围的不安全构造,包括静态突变全局、跳过封装对和失败的翻译,使用在基线感知验证门下操作整个代码库的LLM代理。我们评估了ENCRUST在7个GNU Coreutils程序和8个Laertes基准测试库上的表现,显示在所有15个程序中显著减少不安全构造,同时保持完整的测试向量正确性。

英文摘要:

We present Encapsulated Substitution and Agentic Refinement on a Live Scaffold for Safe C-to-Rust Translation, a two-phase pipeline for translating real-world C projects to safe Rust. Existing approaches either produce unsafe output without memory-safety guarantees or translate functions in isolation, failing to detect cross-unit type mismatches or handle unsafe constructs requiring whole-program reasoning. Furthermore, function-level LLM pipelines require coordinated caller updates when type signatures change, while project-scale systems often fail to produce compilable output under real-world dependency complexity. Encrust addresses these limitations by decoupling boundary adaptation from function logic via an Application Binary Interface (ABI)-preserving wrapper pattern and validating each intermediate state against the integrated codebase. Phase 1 (Encapsulated Substitution) translates each function using an ABI-preserving wrapper that splits it into two components: a caller-transparent shim retaining the original raw-pointer signature, and a safe inner function targeted by the LLM with a clean, scope-limited prompt. This enables independent per-function type changes with automatic rollback on failure, without coordinated caller updates. A deterministic, type-directed wrapper elimination pass then removes wrappers after successful translation. Phase 2 (Agentic Refinement) resolves unsafe constructs beyond per-function scope, including static mut globals, skipped wrapper pairs, and failed translations, using an LLM agent operating on the whole codebase under a baseline-aware verification gate. We evaluate Encrust on 7 GNU Coreutils programs and 8 libraries from the Laertes benchmark, showing substantial unsafe-construct reduction across all 15 programs while maintaining full test-vector correctness.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑