Commit 9db3f7a3 authored by John Hodge's avatar John Hodge
Browse files

Usermode - Semi-working xargo build (using custom xargo)

parent fdf1dfb2
......@@ -90,10 +90,10 @@ LOADER_DEPS := $(patsubst %,$(LIBDIR)lib%.rlib,$(call fn_getdeps,loader/bin/src/
# loader: Requires an assembly stub
# > Linking is done in two steps so that --gc-sections works
#$(BINDIR)loader: loader/bin/link.ld $(OBJDIR)loader/bin/start.ao $(OBJDIR)loader/bin/src/main.o
$(BINDIR)loader: loader/bin/link.ld $(OBJDIR)loader/bin/start.ao $(OBJDIR)loader/bin/src/main.o $(LOADER_DEPS)
$(BINDIR)loader: loader/bin/link.ld $(OBJDIR)loader/bin/start.ao $(OBJDIR)loader/bin/src/main.o $(OBJDIR)rustrt0.o $(LOADER_DEPS)
@mkdir -p $(dir [email protected])
@echo [LD] [email protected]
$V$(LD) -r --gc-sections --undefined image_header --entry start -o $(OBJDIR)loader.o $(OBJDIR)loader/bin/start.ao $(OBJDIR)loader/bin/src/main.o $(LOADER_DEPS)
$V$(LD) -r --gc-sections --undefined image_header --entry start -o $(OBJDIR)loader.o $(OBJDIR)rustrt0.o $(OBJDIR)loader/bin/start.ao $(OBJDIR)loader/bin/src/main.o $(LOADER_DEPS)
$V$(LD) -o $(OBJDIR)loader.elf -T loader/bin/link.ld $(OBJDIR)loader.o -Map $(OBJDIR)loader_map.txt
$V$(OBJCOPY) $(OBJDIR)loader.elf -O binary [email protected]
$V$(OBJDUMP) -CS $(OBJDIR)loader.elf > $(OBJDIR)loader.dsm
......@@ -102,12 +102,15 @@ $(OBJDIR)loader/bin/src/main.o: $(LOADER_DEPS)
# $(XARGO) build $(XARGO_FLAGS) --manifest-path loader/Cargo.toml
.PHONY: xargo
xargo: $(LIBDIR)libloader_dyn.so $(OBJDIR)loader/bin/start.ao # Referenced by link-$(TARGET).ld
$(XARGO) build $(XARGO_FLAGS) --manifest-path libstd/Cargo.toml
xargo: $(OBJDIR)rustrt0.o $(LIBDIR)libloader_dyn.so $(LIBDIR)libloader_start.a # Referenced by link-$(TARGET).ld
#$(XARGO) build $(XARGO_FLAGS) --manifest-path libstd/Cargo.toml
$(XARGO) build $(XARGO_FLAGS) --manifest-path loader/bin/Cargo.toml
cp target/$(XARGO_TARGET)/$(XARGO_PROFILE)/libstd.rlib ../.prefix/xargo/lib/rustlib/$(XARGO_TARGET)/lib/
#cp target/$(XARGO_TARGET)/$(XARGO_PROFILE)/libstd.rlib ../.prefix/xargo/lib/rustlib/$(XARGO_TARGET)/lib/
$(XARGO) build $(XARGO_FLAGS)
$(LIBDIR)libloader_start.a: $(OBJDIR)loader/bin/start.ao
@mkdir -p $(dir [email protected])
$V$(AR) rcu [email protected] $<
# Low-level loader dummy dynamic library
# - Used to tell ld that `loader`'s exported symbols actually exist
$(LIBDIR)libloader_dyn.so: loader/bin/lib.S $(makefile_deps)
......
[xargo]
track-sysroot = true
[xargo.stage1]
disable-staged-api = true
[dependencies.alloc]
stage = 0
[dependencies.std]
stage = 1
path = "libstd"
......@@ -6,5 +6,5 @@ version = "0.0.1"
path = "lib.rs"
[dependencies]
std = { path = "../libstd" }
#std = { path = "../libstd" }
syscalls = { path = "../libsyscalls" }
......@@ -3,6 +3,6 @@ name = "byteorder"
version = "0.0.1"
[dependencies]
std = { path = "../libstd" }
#std = { path = "../libstd" }
......@@ -6,5 +6,4 @@ version = "0.0.1"
path = "lib.rs"
[dependencies]
std = { path = "../libstd" }
#std = { path = "../libstd" }
......@@ -11,4 +11,4 @@ macros = { path = "../libmacros" }
async = { path = "../libasync" }
byteorder = { path = "../libbyteorder" }
std = { path = "../libstd" }
#std = { path = "../libstd" }
ENTRY(start)
SEARCH_DIR( .ojs/amd64/libs )
/*SEARCH_DIR( .objs/amd64/libs )*/
SEARCH_DIR( .output/amd64/libs )
STARTUP( .objs/amd64/rustrt0.o )
PHDRS {
......
......@@ -2,12 +2,14 @@
name = "loader-binary"
version = "0.0.0"
[lib]
path = "src/main.rs"
#[bin]
#path = "src/main.rs"
[dependencies]
loader = { path = "../lib" }
syscalls = { path = "../../libsyscalls" }
byteorder = { path = "../../libbyteorder" }
macros = { path = "../../libmacros" }
cmdline_words_parser = { path = "../../../externals/crates.io/cmdline_words_parser" }
# Part of sysroot
#syscalls = { path = "../../libsyscalls" }
......@@ -3,7 +3,7 @@
//
// This program is both the initial entrypoint for the userland, and the default dynamic linker.
#![feature(const_fn)]
#![crate_type="lib"]
//#![crate_type="lib"]
#![no_main]
use cmdline_words_parser::StrExt as CmdlineStrExt;
......
......@@ -57,6 +57,7 @@ ENTRY(start)
.loop:
jmp .loop
/*
// RDI = Address
// RSI = Value
// RDX = Count
......@@ -93,6 +94,7 @@ ENTRY(memcmp)
ret
ENTRY(_Unwind_Resume)
jmp .
*/
#elif defined(ARCH_armv7)
# define DEFPTR .long
......
......@@ -6,7 +6,7 @@
.extern main
.extern register_arguments
.globl start
.weak start
start:
call *start_ra(%rip)
mov $0, %rdi
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment