rustc++: Facilitating Advanced Analysis of Rust Code

Antonis Louka, Georgios Portokalidis, Elias Athanasopoulos

Research output: Chapter in Book/Report/Conference proceedingConference contributionpeer-review

Abstract

Rust is a popular programming language with strong memory-safety guarantees, achieved through its ownership and borrowing model. Rust allows a programmer to escape memory safety using explicitly marked unsafe code in order to facilitate integration with existing C/C++ code. Such safe code is not immune to typical memory errors. To avoid such bugs researchers try to provide both static and dynamic analysis tools and incorporate C/C++ hardening techniques for unsafe Rust. However, such analysis is not always trivial as Rust uses multiple intermediate representations (IR), and when lowering a higher level IR to a lower level IR, all information that marks a specific block of code as unsafe is lost. Since the two worlds of Rust, safe and unsafe, are built on different assumptions many analysis tools and techniques can benefit from knowing where the safe context changes to unsafe and vice-versa. In this work, we present a modified Rust compiler (rustc++) that extends the capabilities of the Mid-level Intermediate Representation (MIR) to enable serialization and metadata enhancements. Our framework introduces MIR++, an enhanced MIR representation that embeds metadata identifying safe and unsafe instructions, enabling fine-grained safety tracking throughout the compilation pipeline. Additionally, rustc++ enhances the LLVM-IR representation and produced binaries with metadata allowing LLVM passes and post-compilation analysis tools to distinguish between the safe and unsafe context. Lastly, rustc++ makes preliminary efforts in serializing Rusts MIR to a portable JSON format using the Serde serialization library. Our goal is to allow external tools to work on MIR and its in-memory metadata, without requiring the full compiler pipeline. Modifications of rustc++ maintain compatibility with the existing Rust ecosystem while offering a powerful foundation for future analysis tools.

Original languageEnglish
Title of host publicationProceedings of the 18th European Workshop on Systems Security, EuroSec 2025, Part of EuroSys 2025
Pages63-69
Number of pages7
ISBN (Electronic)9798400715631
DOIs
StatePublished - 2 Apr 2025
Event18th European Workshop on Systems Security, EuroSec 2025, co-located with the European Conference on Computer Systems, EuroSys 2025 - Rotterdam, Netherlands
Duration: 31 Mar 2025 → …

Publication series

NameProceedings of the 18th European Workshop on Systems Security, EuroSec 2025, Part of EuroSys 2025

Conference

Conference18th European Workshop on Systems Security, EuroSec 2025, co-located with the European Conference on Computer Systems, EuroSys 2025
Country/TerritoryNetherlands
CityRotterdam
Period31/03/25 → …

Keywords

  • Borrow Checker
  • MIR++
  • Memory Safety
  • Mixed Binaries
  • Rust
  • Rust Compiler Extensions

Fingerprint

Dive into the research topics of 'rustc++: Facilitating Advanced Analysis of Rust Code'. Together they form a unique fingerprint.

Cite this