Created
April 4, 2015 18:32
-
-
Save tilpner/edc993a81ed8b0433087 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#![no_std] | |
#![feature(no_std, libc, lang_items, start)] | |
#![no_main] | |
//! ```sh | |
//! # compile | |
//! rustc -C opt-level=3 -C no-stack-check standalone.rs | |
//! # strip | |
//! strip -sR .comment -R .gnu.hash -R .gnu.version -R .note.ABI-tag -R .note.gnu.build-id standalone | |
//! # check size | |
//! ls -lh standalone | |
//! # output: -rwxr-xr-x 1 till till 4.5K Apr 4 20:30 standalone* | |
//! ``` | |
extern crate libc; | |
use libc::funcs::c95::stdio::puts; | |
const HELLO: &'static [u8] = b"Hello World!\x00"; | |
#[no_mangle] | |
pub extern fn main(_argc: isize, _argv: *const *const u8) -> isize { | |
unsafe { puts(&HELLO[0] as *const u8 as *const i8); } | |
0 | |
} | |
#[lang = "stack_exhausted"] extern fn stack_exhausted() {} | |
#[lang = "eh_personality"] extern fn eh_personality() {} | |
#[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