如何将 .hex 文件反编译为 Arduino 的 C++?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/16706110/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How do I decompile a .hex file into C++ for Arduino?
提问by Matt Cashatt
I have a hex file that is to be flashed onto an Atmelchip running on an Arduino device.
我有一个 hex 文件,该文件要刷入运行在 Arduino 设备上的Atmel芯片上。
There are certain aspects of this file that I would like to modify before putting it onto my Arduino, but I don't have the source C++; just the hex file.
在把这个文件放到我的 Arduino 之前,我想修改这个文件的某些方面,但我没有源 C++;只是十六进制文件。
Is there any efficient way to take a .hex file and reassemble the C code? If so, how?
有没有有效的方法来获取 .hex 文件并重新组装 C 代码?如果是这样,如何?
回答by cdplayer
This may not have been available at the time the other answers was given. It coverts the .hex back to assembler. You might need to know the architecture of the original AVR it was intended for. Works well for me for code that I wrote and compiled. I tested with AVR-25 for Tiny 85. Hope it helps. Would be nice to have an offline version of same thing! http://www.onlinedisassembler.com/An alternative commercial option is IDA from https://www.hex-rays.com/
在给出其他答案时,这可能不可用。它将 .hex 转换回汇编程序。您可能需要了解它适用于的原始 AVR 的架构。对于我编写和编译的代码,对我来说效果很好。我用 AVR-25 测试了 Tiny 85。希望它有所帮助。如果有相同内容的离线版本就好了! http://www.onlinedisassembler.com/另一种商业选择是来自https://www.hex-rays.com/ 的IDA
回答by John b
I would look at the output of avr-objdump(gulp):
我会看看avr-objdump(gulp)的输出:
avr-objdump -j .sec1 -d -m avr5 foo.hex
You will have to change the words following the "-m" to your architecture. Even when/if this works it will give you the Assembly code, which might not look anything you have ever written. The variable names will different, and the handy Arduino functions will look like messy Assembly junk. I hope there is a better way, sorry.
您必须将“-m”后面的单词更改为您的架构。即使/如果这有效,它也会为您提供汇编代码,它可能看起来不像您曾经编写过的任何东西。变量名称会有所不同,方便的 Arduino 函数看起来就像是杂乱无章的汇编垃圾。我希望有更好的方法,抱歉。
See also AVR GCC forum - Using avr-objdump to disassemble hex code.