diff --git a/user/Makefile b/user/Makefile index eabb4b2750804fb9372589f1aec977504919ea82..5e0f87c39060e50ddde9c0585887e2f1ecdec53e 100644 --- a/user/Makefile +++ b/user/Makefile @@ -1,5 +1,5 @@ TARGET := riscv64gc-unknown-none-elf -MODE := debug +MODE := release APP_DIR := src/bin TARGET_DIR := target/$(TARGET)/$(MODE) APPS := $(wildcard $(APP_DIR)/*.rs) @@ -10,7 +10,7 @@ OBJDUMP := rust-objdump --arch-name=riscv64 OBJCOPY := rust-objcopy --binary-architecture=riscv64 elf: $(APPS) - @python3 build.py + @cargo build --release binary: elf $(foreach elf, $(ELFS), $(OBJCOPY) $(elf) --strip-all -O binary $(patsubst $(TARGET_DIR)/%, $(TARGET_DIR)/%.bin, $(elf));) diff --git a/user/build.py b/user/build.py deleted file mode 100644 index 1a220881568856a37da3371ed4a6d51cee4a6693..0000000000000000000000000000000000000000 --- a/user/build.py +++ /dev/null @@ -1,25 +0,0 @@ -import os - -base_address = 0x80100000 -step = 0x20000 -linker = 'src/linker.ld' - -app_id = 0 -apps = os.listdir('src/bin') -apps.sort() -for app in apps: - app = app[:app.find('.')] - lines = [] - lines_before = [] - with open(linker, 'r') as f: - for line in f.readlines(): - lines_before.append(line) - line = line.replace(hex(base_address), hex(base_address+step*app_id)) - lines.append(line) - with open(linker, 'w+') as f: - f.writelines(lines) - os.system('cargo build --bin %s' % app) - print('[build.py] application %s start with address %s' %(app, hex(base_address+step*app_id))) - with open(linker, 'w+') as f: - f.writelines(lines_before) - app_id = app_id + 1 diff --git a/user/src/lib.rs b/user/src/lib.rs index fdcb6d56deb60482aab4fa6c65e1f5ea7b612c5a..c072ef498056ebf08bb900c9ba9cea9a1b2500ba 100644 --- a/user/src/lib.rs +++ b/user/src/lib.rs @@ -11,7 +11,6 @@ mod lang_items; #[no_mangle] #[link_section = ".text.entry"] pub extern "C" fn _start() -> ! { - clear_bss(); syscall::sys_exit(main()); panic!("unreachable after sys_exit!"); } @@ -22,14 +21,5 @@ fn main() -> i32 { panic!("Cannot find main!"); } -fn clear_bss() { - extern "C" { - fn start_bss(); - fn end_bss(); - } - (start_bss as usize..end_bss as usize).for_each(|addr| { - unsafe { (addr as *mut u8).write_volatile(0); } - }); -} pub use syscall::*; \ No newline at end of file diff --git a/user/src/linker.ld b/user/src/linker.ld index 1c64a19b2ed1d6ab00831e6798e69813646a75a5..db314ce32eda682d110416b309537397e6014fa9 100644 --- a/user/src/linker.ld +++ b/user/src/linker.ld @@ -2,7 +2,7 @@ OUTPUT_ARCH(riscv) ENTRY(_start) -BASE_ADDRESS = 0x80100000; +BASE_ADDRESS = 0x0; SECTIONS { @@ -18,9 +18,7 @@ SECTIONS *(.data .data.*) } .bss : { - start_bss = .; *(.bss .bss.*) - end_bss = .; } /DISCARD/ : { *(.eh_frame)