Skip to content

Instantly share code, notes, and snippets.

@arielb1
Created November 23, 2014 16:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save arielb1/669b56620a797d41d81b to your computer and use it in GitHub Desktop.
Save arielb1/669b56620a797d41d81b to your computer and use it in GitHub Desktop.
Rust with only libcore
$ rustc -C no-stack-check source.rs --crate-type=staticlib # kernel also wants -C no-redzone -C code-model=kernel
$ gcc libsource.a
$ ldd ./a.out # no rust libs here
linux-vdso.so.1 => (0x00007fffb5343000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f59ef69b000)
/lib64/ld-linux-x86-64.so.2 (0x00007f59efaa4000)
$ ./a.out; echo $?
42
#![no_std]
#![feature(lang_items)]
extern crate core;
#[no_mangle] pub fn main() -> uint { 42 }
#[lang = "stack_exhausted"] extern fn stack_exhausted() { loop {} }
#[lang = "eh_personality"] extern fn eh_personality() { loop {} }
#[lang = "panic_fmt"] fn panic_fmt() -> ! { loop {} }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment