cpu_rec_rs icon indicating copy to clipboard operation
cpu_rec_rs copied to clipboard

embed default corpus

Open evanrichter opened this issue 2 years ago • 5 comments
trafficstars

hey thanks for this tool, it came in handy identifying 8051 firmware today!

when in doubt, it's always 8051 ;)

anyway, I hit a small snag when trying to just cargo install --git https://github.com/trou/cpu_rec_rs and go (because the corpus wasn't on my local disk). Not too big of a deal, but a self-contained binary would be more convenient than keeping a copy of the corpus files around.

This obviously bloats the binary size. I chose postcard to encode the corpus, which is relatively compact, but the corpus still weighs in around 40MB.

So then I compressed it with lz4 and landed around 32MB for the executable (apple m1 mach-o binary).

In my opinion that's a good tradeoff, what do you think?

evanrichter avatar Jun 30 '23 06:06 evanrichter

Hello. Thank you for your PR. I'd be happy to merge it if there's a way to embed the corpus when using "cargo install". Unfortunately I could not find a simple way to do that. Do you have any idea on how to do this?

trou avatar Jul 01 '23 07:07 trou

That's precisely what this PR does! You can verify with something like

cd /tmp # no corpus here
cargo install --force --git https://github.com/evanrichter/cpu_rec_rs
ls -lah ~/.cargo/bin/cpu_rec_rs # verify binary size is ~32 MB

evanrichter avatar Jul 01 '23 13:07 evanrichter

Sorry, I forgot "only" in embed the corpus only when using "cargo install".

trou avatar Jul 01 '23 15:07 trou

We could make it conditional on release vs. debug, but I don't know a way to change behavior of cargo install more precisely

evanrichter avatar Jul 01 '23 18:07 evanrichter

rebased to fix conflicts

evanrichter avatar Jul 03 '23 21:07 evanrichter