-
Notifications
You must be signed in to change notification settings - Fork 174
Provide terminal disasm command #1842
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
The AVRDUDE terminal @johndoe31415 Johannes, please have a look at the copyright, reference and acknowledgement of your work and let me know whether you want changes, eg, a different email address (or none for that matter). @MCUdude, your little test example should now be formatted as below. Not sure it can be made cripser. @mcuee, @MCUdude Here some tips for testing: Clone this PR and copy an arbitrary .hex file of yours for any MCU you can think of into the directory of the PR. If you have the .elf file of when you created it, then copy that as well. Then call this bash script The part name must be the full name in lower case. You may need to modify the avr-cc line for modern parts (as they need a service pack argument), but disassembly should still be OK,. |
|
Test using picoboot. Build with the default Makefile. |
|
Maybe the above error is due to some bash compatibility thingy between MSYS2 bash and Linux bash. |
|
The disasm feature itself seems to work fine. Original source code in assembly. |
|
@mcuee Anyway it's the last three lines of the
I am sure you can write your own, but it's the disassemble, compile, compare cycle that proves the disassembly correct. |
|
Msys2 shell under Windows is indeed a bit strange. The following bash script works.
Run log: |
|
Using the urclock example from the first post. |
|
@SpenceKonde I know you've been using inline assembly in some of your Arduino cores. Would you like to give this PR a try?
|
|
@ndim I would like to install the bash script elf2tag in the same bin directory as avrdude; it should be installed/uninstalled the same way avrdude is. Which changes do CMakeLists.txt and Makefile.am need to undergo so this happens? Thanks! |
|
This looks really cool, as I spend a lot of time staring at dissassebled AVR code, and what you get out of gcc itself, we all know the result is pretty lousy.... Only question I have is why does it even make sense as part of avrdude instead of a separate tool? (My dream form of a dissembler tool is something I could drag and drop the input file as .elf or .hex onto, and have it create a .asm or .S or something with the asm. But I guess as long as it;s commandlinable I can get that easy enough no matter what) |
@SpenceKonde
AVRDUDE knows 300+ parts, how big flash is, where sram sits, where the io region is, whether or not it has a 0x20 offset, the register names, the MCU architecture (and by implication, which opcodes a part has), ... So the whole infrastructure for a disassembler that knows its shit is already there. That's the USP of this approach: the disassembly is part-specific. When you use And AVRDUDE already has an interactive terminal that gives you access to an interactive disassembly session for free. So, for me, there is no better infrastructure than AVRDUDE to code a disassembler that sucks less (and, yes, they all suck). |
@stefanrueger I see a problem here: The build system files you mention are Adding something to the top level On the Automake side, if we had a top-level |
|
I was just about to reply when @stefanrueger provided his excellent answer. Basically what he said. The fact that Avrdude has a @SpenceKonde Avrdude has recently gotten lots of new and powerful features since the 6.3 version you're probably the most familiar with. And @stefanrueger has implemented incredible features we could just dream of a few years ago. There is a lot to be excited about here!
|
|
@ndim Thanks for looking into this! I'd be vvv happy to move I have a related question. It occurred to me that the |
Here is what appears to work. You can add that to your branch yourself.
This is very much unrelated, so I have put this into a separate issue: #1847 |
The new terminal command
disasmdisassembles the selected memory section. It knows about the register file of the part, so you get these symbols for free. You can also provide an ASCII tag file (and generate one viatools/elf2tagfrom an.elffile).A big shoutout to @johndoe31415 whose 17 year old
avrdisasprovides the base for this PR. It is well written, relatively easy to port, and it was relatively easy to add 8 opcodes that had cropped up in the meantime and to add some 20 or so unallocated opcodes that are known to behave in a certain way (the famous0xffffthat behaves likesbrs r31, 7). Option-dshows the unallocated opcodes asu/, so, eg,u/sbrs r31, 7. Option-D(the default) switches back to only disassembling the opcodes that the architecture of the part knows.Here an example: use the files in urclock_cs8_ad.zip
Anyway, have fun.