Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unable to verify that produced executable is an ARM binary with `cargo readobj`: no such subcommand

I am learning embedded Rust. I've setup the environment and am now following the Build It instructions.

When I verify that the produced executable is an ARM binary by running the command

cargo readobj --target thumbv7em-none-eabihf --bin led-roulette -- -file-headers

It generates an error:

error: no such subcommand: readobj

I've also tried the command

cargo readelf -h target/thumbv7em-none-eabihf/debug/led-roulette 

It generates the error:

error: no such subcommand: readelf
like image 572
Muhammad Umer Avatar asked Sep 10 '19 19:09

Muhammad Umer


3 Answers

Before running these commands, you have to install the tools as described in chapter 3.

If you did that already, then make sure you are in the src/05-led-roulette directory.

like image 63
Abdur Rehman Siddiqui Avatar answered Nov 11 '22 15:11

Abdur Rehman Siddiqui


The cargo package that we install by default doesn't provide the readobj subcommand, so you need to add this subcommand explicitly:

cargo install cargo-binutils --vers 0.1.4
like image 5
Jawwad Turabi Avatar answered Nov 11 '22 15:11

Jawwad Turabi


Most answers here suggest installing version 0.1.4 of cargo-binutils to fix this problem. Although this works, the recommended way is installing the latest stable version, and just after that install llvm-tools-preview to supply all the missing commands:

$ cargo install cargo-binutils
$ rustup component add llvm-tools-preview

This is documented in the cargo-binutils crate.

like image 3
doragasu Avatar answered Nov 11 '22 16:11

doragasu