Skip to content

Commit

Permalink
Build vsock payload as ELF OBJ format and linux GCC calling convention
Browse files Browse the repository at this point in the history
…jyao1#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 <[email protected]>
  • Loading branch information
gaojiaqi7 committed Sep 10, 2021
1 parent 591eb4b commit d05057e
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 1 deletion.
1 change: 1 addition & 0 deletions .cargo/config.toml
Original file line number Diff line number Diff line change
@@ -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"
17 changes: 16 additions & 1 deletion rust-vsock-payload/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -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*
Expand Down
16 changes: 16 additions & 0 deletions rust-vsock-payload/target.json
Original file line number Diff line number Diff line change
@@ -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
}

0 comments on commit d05057e

Please sign in to comment.