Skip to content

Commit

Permalink
Test
Browse files Browse the repository at this point in the history
  • Loading branch information
clabby committed Nov 11, 2023
1 parent f44984b commit 77f5804
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 10 deletions.
7 changes: 5 additions & 2 deletions crates/mipsevm/src/mips/instrumented.rs
Original file line number Diff line number Diff line change
Expand Up @@ -240,11 +240,14 @@ mod test {
let mut ins =
InstrumentedState::new(state, StaticOracle::new(b"hello world".to_vec()), out, err);

for i in 0..400_000 {
for i in 0..50_000_000 {
if ins.state.exited {
break;
}
dbg!(i);
dbg!(format!(
"i: {} | pc: {} | next_pc: {}",
i, ins.state.pc, ins.state.next_pc
));
ins.step(false).unwrap();
}

Expand Down
12 changes: 6 additions & 6 deletions crates/mipsevm/src/patch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,12 @@ pub fn load_elf(raw: &[u8]) -> Result<State> {
);
}
} else {
anyhow::bail!(
"Program segment {} has different file size ({}) than mem size ({}): filling for non PT_LOAD segments is not supported",
i,
header.p_filesz,
header.p_memsz
);
// anyhow::bail!(
// "Program segment {} has different file size ({}) than mem size ({}): filling for non PT_LOAD segments is not supported",
// i,
// header.p_filesz,
// header.p_memsz
// );
}
}

Expand Down
4 changes: 2 additions & 2 deletions example/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ dump: $(patsubst %/go.mod,bin/%.dump,$(wildcard */go.mod))
.PHONY: ex-rs
ex-rs:
cd hello-rs && \
RUSTFLAGS='-C link-arg=-no-pie -C target-feature=+mips32,+crt-static,-mips32r2,-fpxx,-nooddspreg' cross build --release --target mips-unknown-linux-musl && \
cp ../../target/mips-unknown-linux-musl/release/hello-rs ../bin/hello-rs.elf
RUSTFLAGS='-C link-arg=-no-pie' cross build --release --target ../mips-unknown-linux-gnu.json -Z build-std -Z build-std-features="" -vv && \
cp ../../target/mips-unknown-linux-gnu/release/hello-rs ../bin/hello-rs.elf

bin:
mkdir bin
Expand Down
Binary file modified example/bin/hello-rs.elf
Binary file not shown.
6 changes: 6 additions & 0 deletions example/hello-rs/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,9 @@ authors.workspace = true

[dependencies]
# no deps

[profile.dev]
panic = "abort"

[profile.release]
panic = "abort"
29 changes: 29 additions & 0 deletions example/mips-unknown-linux-gnu.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"arch": "mips",
"cpu": "mips32r2",
"crt-objects-fallback": "false",
"crt-static-respected": true,
"data-layout": "E-m:m-p:32:32-i8:8:32-i16:16:32-i64:64-n32-S64",
"dynamic-linking": true,
"env": "gnu",
"features": "+mips32r2,+fpxx,+nooddspreg",
"has-rpath": true,
"has-thread-local": true,
"linker-flavor": "gnu-cc",
"llvm-target": "mips-unknown-linux-gnu",
"max-atomic-width": 32,
"os": "linux",
"position-independent-executables": true,
"relro-level": "full",
"supported-split-debuginfo": [
"packed",
"unpacked",
"off"
],
"target-endian": "big",
"target-family": [
"unix"
],
"target-mcount": "_mcount",
"target-pointer-width": "32"
}

0 comments on commit 77f5804

Please sign in to comment.