Skip to content

Minimal program w/o std, libc creates binary that seg faults #16089

Closed
@mikedilger

Description

@mikedilger

I'm trying to create a program without std and without libc. Based on this page: http://doc.rust-lang.org/guide-unsafe.html (and elsewhere). I still cannot get a minimal program to work. It compiles, but the binary segmentation faults (on x86_64 linux).

Compiled with: rustc --crate-type=bin -C link-args="-nostdlib" -C relocation-model=static start.rs

Program is:

#![feature(lang_items)]
#![no_std]

extern crate core;
extern crate rlibc;

#[lang = "stack_exhausted"]
extern fn stack_exhausted() {}

#[lang = "eh_personality" ]
extern fn eh_personality() {}

#[lang = "begin_unwind" ]
unsafe extern fn begin_unwind(args: &core::fmt::Arguments,
                       file: &str,
                       line: uint) -> ! {
    loop {}
}

#[start]
fn main(argc: int, argv: *const *const u8) -> int
{
    0
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions