BACKEND·중요도 6·2026. 06. 12.·GeekNews

Rust에서 main 이전에도 실행되는 코드가 있다

── KO ──────────────────

Rust 바이너리는 main 함수 실행 전에 여러 초기화 단계를 수행한다.

Rust 프로그램은 fn main() 함수가 실행되기 전에 런타임 초기화 단계를 거칩니다. 이 과정에서 패닉 처리, 언와인딩, 프로그램 인자 변환 등의 작업이 이루어집니다. 운영체제 로더가 C 및 Rust 런타임 초기화 함수를 실행하는 방식으로 제어가 넘어가는 구조입니다.


── EN ──────────────────

Rust binaries perform several initialization steps before the main function executes.

Rust binaries go through a runtime initialization phase before the execution of the main function. During this phase, tasks such as panic handling, unwinding, and argument conversion are performed. Control is passed from the operating system loader to the initialization functions of both the C and Rust runtimes.

원문 보기 →목록으로