mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-27 01:04:03 +00:00
Remove start functions, use newlib instead of openlibm + ralloc
This commit is contained in:
parent
e7b006d3dd
commit
1eb6c44b1c
@ -27,12 +27,13 @@ pub fn opts() -> TargetOptions {
|
||||
// Always enable NX protection when it is available
|
||||
"-Wl,-z,noexecstack".to_string(),
|
||||
|
||||
// Do not link libc
|
||||
"-nostdlib".to_string(),
|
||||
|
||||
// Static link
|
||||
"-static".to_string()
|
||||
],
|
||||
late_link_args: vec![
|
||||
"-lc".to_string(),
|
||||
"-lm".to_string()
|
||||
],
|
||||
executables: true,
|
||||
relocation_model: "static".to_string(),
|
||||
disable_redzone: true,
|
||||
@ -40,8 +41,8 @@ pub fn opts() -> TargetOptions {
|
||||
target_family: Some("redox".to_string()),
|
||||
linker_is_gnu: true,
|
||||
no_default_libraries: true,
|
||||
lib_allocation_crate: "ralloc".to_string(),
|
||||
exe_allocation_crate: "ralloc".to_string(),
|
||||
lib_allocation_crate: "alloc_system".to_string(),
|
||||
exe_allocation_crate: "alloc_system".to_string(),
|
||||
has_elf_tls: true,
|
||||
panic_strategy: PanicStrategy::Abort,
|
||||
.. Default::default()
|
||||
|
@ -62,8 +62,6 @@ fn main() {
|
||||
println!("cargo:rustc-link-lib=magenta");
|
||||
println!("cargo:rustc-link-lib=mxio");
|
||||
println!("cargo:rustc-link-lib=launchpad"); // for std::process
|
||||
} else if target.contains("redox") {
|
||||
println!("cargo:rustc-link-lib=openlibm");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -299,7 +299,6 @@
|
||||
#![feature(unwind_attributes)]
|
||||
#![feature(vec_push_all)]
|
||||
#![feature(zero_one)]
|
||||
#![cfg_attr(target_os = "redox", feature(naked_functions))]
|
||||
#![cfg_attr(test, feature(update_panic_count))]
|
||||
|
||||
// Explicitly import the prelude. The compiler uses this same unstable attribute
|
||||
|
@ -25,10 +25,6 @@
|
||||
// Reexport some of our utilities which are expected by other crates.
|
||||
pub use panicking::{begin_panic, begin_panic_fmt, update_panic_count};
|
||||
|
||||
// Reexport the start module on platforms that provide it
|
||||
#[unstable(feature = "sys_rt", issue="0")]
|
||||
pub use sys::rt::*;
|
||||
|
||||
#[cfg(not(test))]
|
||||
#[lang = "start"]
|
||||
fn lang_start(main: *const u8, argc: isize, argv: *const *const u8) -> isize {
|
||||
|
@ -30,7 +30,6 @@ pub mod path;
|
||||
pub mod pipe;
|
||||
pub mod process;
|
||||
pub mod rand;
|
||||
pub mod rt;
|
||||
pub mod rwlock;
|
||||
pub mod stack_overflow;
|
||||
pub mod stdio;
|
||||
|
@ -1,130 +0,0 @@
|
||||
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
//! Defintion of functions like _start for the linker
|
||||
|
||||
use sys::syscall::exit;
|
||||
|
||||
#[unstable(feature = "sys_rt", issue = "0")]
|
||||
#[no_mangle]
|
||||
#[naked]
|
||||
#[cfg(target_arch = "x86")]
|
||||
pub unsafe fn _start() {
|
||||
asm!("push esp
|
||||
call _start_stack
|
||||
pop esp"
|
||||
:
|
||||
:
|
||||
: "memory"
|
||||
: "intel", "volatile");
|
||||
let _ = exit(0);
|
||||
}
|
||||
|
||||
#[unstable(feature = "sys_rt", issue = "0")]
|
||||
#[no_mangle]
|
||||
#[naked]
|
||||
#[cfg(target_arch = "x86_64")]
|
||||
pub unsafe fn _start() {
|
||||
asm!("mov rdi, rsp
|
||||
and rsp, 0xFFFFFFFFFFFFFFF0
|
||||
call _start_stack"
|
||||
:
|
||||
:
|
||||
: "memory"
|
||||
: "intel", "volatile");
|
||||
let _ = exit(0);
|
||||
}
|
||||
|
||||
#[unstable(feature = "sys_rt", issue = "0")]
|
||||
#[no_mangle]
|
||||
pub unsafe extern "C" fn _start_stack(stack: *const usize){
|
||||
extern "C" {
|
||||
fn main(argc: usize, argv: *const *const u8) -> usize;
|
||||
}
|
||||
|
||||
let argc = *stack as usize;
|
||||
let argv = stack.offset(1) as *const *const u8;
|
||||
let _ = exit(main(argc, argv));
|
||||
}
|
||||
|
||||
/// Memcpy
|
||||
///
|
||||
/// Copy N bytes of memory from one location to another.
|
||||
#[unstable(feature = "sys_rt", issue = "0")]
|
||||
#[no_mangle]
|
||||
pub unsafe extern fn memcpy(dest: *mut u8, src: *const u8,
|
||||
n: usize) -> *mut u8 {
|
||||
let mut i = 0;
|
||||
while i < n {
|
||||
*((dest as usize + i) as *mut u8) = *((src as usize + i) as *const u8);
|
||||
i += 1;
|
||||
}
|
||||
|
||||
dest
|
||||
}
|
||||
|
||||
/// Memmove
|
||||
///
|
||||
/// Copy N bytes of memory from src to dest. The memory areas may overlap.
|
||||
#[unstable(feature = "sys_rt", issue = "0")]
|
||||
#[no_mangle]
|
||||
pub unsafe extern fn memmove(dest: *mut u8, src: *const u8,
|
||||
n: usize) -> *mut u8 {
|
||||
if src < dest as *const u8 {
|
||||
let mut i = n;
|
||||
while i != 0 {
|
||||
i -= 1;
|
||||
*((dest as usize + i) as *mut u8) = *((src as usize + i) as *const u8);
|
||||
}
|
||||
} else {
|
||||
let mut i = 0;
|
||||
while i < n {
|
||||
*((dest as usize + i) as *mut u8) = *((src as usize + i) as *const u8);
|
||||
i += 1;
|
||||
}
|
||||
}
|
||||
|
||||
dest
|
||||
}
|
||||
|
||||
/// Memset
|
||||
///
|
||||
/// Fill a block of memory with a specified value.
|
||||
#[unstable(feature = "sys_rt", issue = "0")]
|
||||
#[no_mangle]
|
||||
pub unsafe extern fn memset(dest: *mut u8, c: i32, n: usize) -> *mut u8 {
|
||||
let mut i = 0;
|
||||
while i < n {
|
||||
*((dest as usize + i) as *mut u8) = c as u8;
|
||||
i += 1;
|
||||
}
|
||||
|
||||
dest
|
||||
}
|
||||
|
||||
/// Memcmp
|
||||
///
|
||||
/// Compare two blocks of memory.
|
||||
#[unstable(feature = "sys_rt", issue = "0")]
|
||||
#[no_mangle]
|
||||
pub unsafe extern fn memcmp(s1: *const u8, s2: *const u8, n: usize) -> i32 {
|
||||
let mut i = 0;
|
||||
|
||||
while i < n {
|
||||
let a = *((s1 as usize + i) as *const u8);
|
||||
let b = *((s2 as usize + i) as *const u8);
|
||||
if a != b {
|
||||
return a as i32 - b as i32
|
||||
}
|
||||
i += 1;
|
||||
}
|
||||
|
||||
0
|
||||
}
|
@ -50,7 +50,6 @@ pub mod path;
|
||||
pub mod pipe;
|
||||
pub mod process;
|
||||
pub mod rand;
|
||||
pub mod rt;
|
||||
pub mod rwlock;
|
||||
pub mod stack_overflow;
|
||||
pub mod thread;
|
||||
|
@ -1,11 +0,0 @@
|
||||
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
//! Stub for placing functions like _start for the linker
|
@ -36,7 +36,6 @@ pub mod path;
|
||||
pub mod pipe;
|
||||
pub mod process;
|
||||
pub mod rand;
|
||||
pub mod rt;
|
||||
pub mod rwlock;
|
||||
pub mod stack_overflow;
|
||||
pub mod thread;
|
||||
|
@ -1,11 +0,0 @@
|
||||
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
//! Stub for placing functions like _start for the linker
|
Loading…
Reference in New Issue
Block a user