Skip to content

Commit 7919692

Browse files
committed
fix linker script and call main
1 parent c165bed commit 7919692

File tree

3 files changed

+74
-31
lines changed

3 files changed

+74
-31
lines changed

compiler/rustc_target/src/spec/targets/armv7a_vex_v5_linker_script.ld

Lines changed: 28 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -2,51 +2,53 @@ OUTPUT_FORMAT("elf32-littlearm")
22

33
ENTRY(_start)
44

5-
__cold_start = 0x03800000;
6-
__cold_length = 0x04800000;
7-
__cold_end = __cold_start + __cold_length;
5+
__user_ram_start = 0x03800000;
6+
__user_ram_length = 0x04800000;
7+
__user_ram_end = __user_ram_start + __user_ram_length;
88

99
MEMORY {
10-
COLD : ORIGIN = __cold_start, LENGTH = __cold_length
10+
USER_RAM : ORIGIN = __user_ram_start, LENGTH = __user_ram_length
1111
}
1212

1313
__stack_length = 0x400000;
14-
/*
15-
I'm not sure why subtracting anything is necessary, but it fixes memory permission errors.
16-
0x1000 is an arbitrary number that works.
17-
*/
18-
__heap_end = __cold_end - __stack_length - 0x1000;
14+
__heap_end = __user_ram_end - __stack_length - 64;
1915

2016
SECTIONS {
21-
.code_signature : {
17+
.code_signature __user_ram_start : {
2218
KEEP(*(.code_signature))
23-
. = __cold_start + 0x20;
24-
} > COLD
25-
.text : {
26-
KEEP(*(.text.boot))
19+
} > USER_RAM = 0
20+
21+
.text __user_ram_start + 0x20 : {
22+
*(.text.boot)
2723
*(.text .text.*)
28-
} > COLD
24+
} > USER_RAM
25+
2926
.rodata : {
30-
__rodata_start = .;
31-
*(.rodata1 .rodata1.*)
32-
__rodata_end = .;
33-
} > COLD
27+
*(.rodata .rodata.*)
28+
} > USER_RAM
29+
3430
.data : {
3531
*(.data .data.*)
36-
*(.data1 .data1.*)
37-
} > COLD
32+
} > USER_RAM
33+
3834
.bss : {
3935
__bss_start = .;
4036
*(.bss .bss.*)
4137
__bss_end = .;
42-
} > COLD
38+
} > USER_RAM
39+
4340
.heap (NOLOAD) : ALIGN(4) {
4441
__heap_start = .;
4542
. = __heap_end;
46-
} > COLD
43+
} > USER_RAM
44+
4745
.stack (NOLOAD) : ALIGN(8) {
48-
__stack_end = .;
46+
__stack_bottom = .;
4947
. += __stack_length;
50-
__stack_start = .;
51-
} > COLD
48+
__stack_top = .;
49+
} > USER_RAM
50+
51+
/DISCARD/ : {
52+
*(.ARM.exidx)
53+
}
5254
}

library/std/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ r-efi = { version = "4.5.0", features = ['rustc-dep-of-std'] }
9191
r-efi-alloc = { version = "1.0.0", features = ['rustc-dep-of-std'] }
9292

9393
[target.'cfg(target_os = "vexos")'.dependencies]
94-
vex-sdk = { version = "0.16.1", features = ['rustc-dep-of-std'] }
94+
vex-sdk = { version = "0.17.0", features = ['rustc-dep-of-std'] }
9595

9696
[features]
9797
backtrace = [

library/std/src/sys/pal/vexos/mod.rs

Lines changed: 45 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ pub mod os;
1515
pub mod pipe;
1616
#[path = "../unsupported/process.rs"]
1717
pub mod process;
18+
#[path = "../unsupported/stdio.rs"]
1819
pub mod stdio;
1920
#[path = "../unsupported/thread.rs"]
2021
pub mod thread;
@@ -23,17 +24,53 @@ pub mod thread_local_key;
2324
#[path = "../unsupported/time.rs"]
2425
pub mod time;
2526

26-
#[path = "../unsupported/common.rs"]
27-
#[deny(unsafe_op_in_unsafe_fn)]
28-
mod common;
29-
pub use common::*;
27+
use crate::arch::asm;
28+
29+
#[cfg(not(test))]
30+
#[no_mangle]
31+
#[link_section = ".text.boot"]
32+
pub unsafe extern "C" fn _start() -> ! {
33+
extern "C" {
34+
fn main() -> i32;
35+
}
36+
37+
asm!("ldr sp, =__stack_top", options(nostack));
38+
39+
main();
40+
41+
abort_internal()
42+
}
3043

3144
// This function is needed by the panic runtime. The symbol is named in
3245
// pre-link args for the target specification, so keep that in sync.
3346
#[cfg(not(test))]
3447
#[no_mangle]
3548
// NB. used by both libunwind and libpanic_abort
3649
pub extern "C" fn __rust_abort() -> ! {
50+
abort_internal()
51+
}
52+
53+
pub unsafe fn init(_argc: isize, _argv: *const *const u8, _sigpipe: u8) {}
54+
55+
pub unsafe fn cleanup() {}
56+
57+
pub fn unsupported<T>() -> crate::io::Result<T> {
58+
Err(unsupported_err())
59+
}
60+
61+
pub fn unsupported_err() -> crate::io::Error {
62+
crate::io::Error::UNSUPPORTED_PLATFORM
63+
}
64+
65+
pub fn is_interrupted(_code: i32) -> bool {
66+
false
67+
}
68+
69+
pub fn decode_error_kind(_code: i32) -> crate::io::ErrorKind {
70+
crate::io::ErrorKind::Uncategorized
71+
}
72+
73+
pub fn abort_internal() -> ! {
3774
unsafe {
3875
vex_sdk::vexSystemExitRequest();
3976
}
@@ -42,3 +79,7 @@ pub extern "C" fn __rust_abort() -> ! {
4279
crate::hint::spin_loop()
4380
}
4481
}
82+
83+
pub fn hashmap_random_keys() -> (u64, u64) {
84+
(1, 2)
85+
}

0 commit comments

Comments
 (0)