From 1387ff8aed1164813a45b33be0dbc8f1f559817d Mon Sep 17 00:00:00 2001 From: Jiaqi Gao Date: Sat, 11 Sep 2021 02:44:05 +0800 Subject: [PATCH] Build vsock payload as ELF OBJ format and linux GCC calling convention #26 By specifying build target to rust-vsock-payload/target.json, payload can be built as ELF format and linux GCC x86-64 calling convention. 'Cargo elfbuild..' can be use directly, the usage has been document to rust-vsock-payload/readme.md Signed-off-by: Jiaqi Gao --- .cargo/config.toml | 1 + rust-vsock-payload/readme.md | 17 ++++++++++++++++- rust-vsock-payload/target.json | 16 ++++++++++++++++ 3 files changed, 33 insertions(+), 1 deletion(-) create mode 100644 rust-vsock-payload/target.json diff --git a/.cargo/config.toml b/.cargo/config.toml index 09ac59a..bab7276 100644 --- a/.cargo/config.toml +++ b/.cargo/config.toml @@ -1,3 +1,4 @@ [alias] mbuild = "build --target x86_64-unknown-uefi -Zbuild-std=core,alloc -Zbuild-std-features=compiler-builtins-mem" +elfbuild = "xbuild --target rust-vsock-payload/target.json" diff --git a/rust-vsock-payload/readme.md b/rust-vsock-payload/readme.md index 23f363f..02f4220 100644 --- a/rust-vsock-payload/readme.md +++ b/rust-vsock-payload/readme.md @@ -11,12 +11,27 @@ export RESET_VECTOR_BIN=$BASE_DIR/target/x86_64-unknown-uefi/release/ResetVector export RUST_IPL_BIN=$BASE_DIR/target/x86_64-unknown-uefi/release/rust_ipl.efi export RUST_PAYLOAD_BIN=$BASE_DIR/target/x86_64-unknown-uefi/release/rust-vsock-payload.efi export RUST_FIRMWARE_BIN=$BASE_DIR/target/x86_64-unknown-uefi/release/final_vsock.bin +``` + +To build default PE format OBJ and link with a static C library: +```bash cargo mbuild -p rust-vsock-payload --release -cargo run -p rust-firmware-tool -- $RESET_VECTOR_BIN $RUST_IPL_BIN $RUST_PAYLOAD_BIN $RUST_FIRMWARE_BIN +``` + +To build ELF format OBJ and link with a static C library: +```bash +cargo elfbuild -p rust-vsock-payload --release ``` +Then: + +```bash +cargo run -p rust-firmware-tool -- $RESET_VECTOR_BIN $RUST_IPL_BIN $RUST_PAYLOAD_BIN $RUST_FIRMWARE_BIN +``` + + ## How to Run Qemu version is *QEMU emulator version 5.2.0* diff --git a/rust-vsock-payload/target.json b/rust-vsock-payload/target.json new file mode 100644 index 0000000..cea8193 --- /dev/null +++ b/rust-vsock-payload/target.json @@ -0,0 +1,16 @@ +{ + "llvm-target": "x86_64-unknown-none", + "data-layout": "e-m:e-i64:64-f80:128-n8:16:32:64-S128", + "arch": "x86_64", + "target-endian": "little", + "target-pointer-width": "64", + "target-c-int-width": "32", + "os": "none", + "executables": true, + "linker": "rust-lld", + "linker-flavor": "ld.lld", + "panic-strategy": "abort", + "disable-redzone": true, + "features": "-mmx,-sse,+soft-float", + "position-independent-executables": true +}