rust-embedded / cargo-binutils

Cargo subcommands to invoke the LLVM tools shipped with the Rust toolchain
Apache License 2.0
499 stars 45 forks source link

"'test_app.exe': no such file or directory" dumping thumbv7em from instructions in the book #32

Closed thejpster closed 6 years ago

thejpster commented 6 years ago
user@host $ cat Cargo.toml
[package]
authors = ["user@host.com"]
edition = "2018"
name = "test_app"
version = "0.1.0"

[dependencies]
cortex-m = "0.5.7"
cortex-m-rt = "0.6.3"
cortex-m-semihosting = "0.3.1"
panic-halt = "0.2.0"

# Uncomment for the panic example.
panic-semihosting = "*"

# Uncomment for the allocator example.
# alloc-cortex-m = "0.3.5"

# Uncomment for the device example.
# [dependencies.stm32f30x]
# features = ["rt"]
# version = "0.7.1"

# this lets you use `cargo fix`!
[[bin]]
name = "test_app"
test = false
bench = false

[profile.release]
codegen-units = 1 # better optimizations
debug = true # symbols are nice and they don't increase the size on Flash
lto = true # better optimizations
user@host ~/Documents/rust_training/blank_app $ cargo +beta objdump --bin test_app -- -disassemble -no-show-raw-insn -print-imm-hex
    Finished dev [unoptimized + debuginfo] target(s) in 0.08s
C:\Users\jgp\.rustup\toolchains\beta-x86_64-pc-windows-msvc\lib\rustlib\x86_64-pc-windows-msvc\bin\llvm-objdump.exe: 'test_app.exe': no such file or directory

Is this a bug, or have I missed a step? If so, could we make it more obvious what's gone wrong?

Platform: Windows 10 Rust: rustc 1.30.0-beta.9 (a18eb4852 2018-09-30)

Phaiax commented 6 years ago

I have the same problem. The problem is that the binutils add the .exe suffix to the application binary name, which is not present windows for ELF binaries. As a workaroud you can leave out --bin test_app and add target/your-target-triple/debug/test_app after the two -- .

https://github.com/rust-embedded/cargo-binutils/blob/master/src/lib.rs#L165

If anyone would give me a hint where the information if the file is named .exe is, I can write a patch.

GregWoods commented 4 years ago

i am having the same issue on v 0.1.7 of cargo-binutils

coredump commented 4 years ago

This problem is back, apparently. Getting it on v 0.1.7, @japaric

In the meantime,

> cargo readobj  target/$TRIPLE/debug/app -- -file-headers

will work