I usually do "odx rom.bin > rom.odx" then use "vi" to examine the generated output, which looks like this:
0000ec10 2e0a 0020 2000 2020 2563 0a00 2020 0020 . %c 0000ec20 2025 630a 000a 4272 6f6f 6b74 7265 6520 %c Brooktree 0000ec30 4441 4320 2843 6f6c 6f72 204d 6170 2920 DAC (Color Map) 0000ec40 5465 7374 733a 2020 2827 7127 2066 6f72 Tests: ('q' forNote that odx always shows the bytes in file order, it does not byte swap the 16 bit values shown above. So if the file holds big endian words or longs, all is well. And for strings, as the above, we get the strings in proper order. But it the file holds little endian words or longs we will get them in little endian order and will probably want to use some other tool to swap bytes and display any large sections of these.
I should make one enhancement to odx. It currently always generates the dump addresses beginning at address 0. It is necessary (and sometimes error prone) to add the true base address to these when you want to relate them to the disassembly which does have proper addresses.
:let mapleader = "-" " special hooks for sun3/80 disassembly " hook for redoing disassembly nnoremapWe will talk about "vim_string" later. What this lets me do is to type the two character sequence -d (where d is for "disassemble) and it will run the external help program "redisv" (written in python) to use objdump to do the disassembly. This sounds ridiculously inefficient, but it only happens when you push a button and takes less than a second, so who cares.d :.!./redisv nnoremap s :.!./vim_string
fef567c: 4e75 rts fef567e: 0000 4e56 orib #86,%d0 fef5682: fffc .short 0xfffc fef5684: 2e87 movel %d7,%sp@I put the cursor on the second line (with orib), type -d, and I get this:
fef567c: 4e75 rts XXX fef567e: 0000 4e56 orib #86,%d0 fef5680: 4e56 fffc linkw %fp,#-4 XXX fef5682: fffc .short 0xfffc fef5684: 2e87 movel %d7,%sp@The original line is preserved for my study, but then a single line of disassembly at that address plus 2 is inserted. The XXX sandwich both the before and after. I then edit this to look like so:
fef567c: 4e75 rts fef5680: 4e56 fffc linkw %fp,#-4 fef5684: 2e87 movel %d7,%sp@
fef7f5c: 4879 0fef e738 pea 0xfefe738 fef7f62: 6100 1b76 bsrw 0xfef9adaYou are pretty sure the address in the "pea" is referencing a string. You know, either because you used the ctags thing to go there and look at it and recognize ascii hex values, or you know that the subroutine call following is printf or puts or some such.
So you put the cursor on the first line, type -s and you get:
fef7f5c: 4879 0fef e738 pea 0xfefe738 ; 0xfefe738 AMD Ethernet fef7f62: 6100 1b76 bsrw 0xfef9adaSometimes it comes back with a "Sorry" response which you just have to delete. This only gives you the first line of multiline strings and could benefit from further improvement, but it is a big step in the right direction.
When I use "odx" to dump the ROM binary, it is easy to identify large blocks of strings. I can determine their start and end addresses from the odx output, then use vim_string to dump the blocks, and then hand edit that into the disassembly file replacing the garbled disassembly.
Here is an example. The 3/60 dump shows strings from e738 to f480. Translating this to actual rom addresses, this is 0fef_e738 to 0fef_f480. Given these addresses, edit a line in vim_string.c like so:
batch ( 0x0fefe738, 0x0feff480 );Recompile, then invoke vim_string without arguments:
./xstrings 0fefe738: AMD Ethernet 0fefe745: w - Wr/Rd CSR1 Reg Test\n ++ 0fefe75d: l - Local Loopback Test\n ++ 0fefe775: x - External Loopback Test ..... .....I do this: ./xstrings > zzz and then copy zzz into rom.dis
Replacing garbled disassembly with strings does a great deal towards reducing the bulk (and useless noise) in the disassembly. There is some risk of including things like 32 bit constants in big blocks of disassembled data like this. So far this has not proven to be a problem. The linker seems to have put all the strings at the end of the ROM image (or most of them anyway). If this does happen, it can be sorted out later -- I always keep a copy of the naive disassembly available for cases like this.
Watch for big groups of "...." as xstrings prints a "." when it encounters a byte with no printable ascii to represent it.
Hexfix is a python program that cleans up certain issues with the objdump disassembly.
To run hexfix, I use this command "./hexfix rom.dis > zzz" I verify that the new file has the same number of lines as the original and use diff to examine the changes and make sure things aren't going crazy.
The sorts of changes it does are as follows. Sadly, objdump thinks it is sensible to display all kinds of things I would like to see as hex as binary. Sometimes I can see what I want from the opcodes themselves, but it is just easier and less error prone to let hexfix do the work. < fef0130: 0287 ffff 0000 andil #-65536,%d7 < fef0136: 0c87 7777 0000 cmpil #2004287488,%d7 --- > fef0130: 0287 ffff 0000 andil #0xffff0000,%d7 > fef0136: 0c87 7777 0000 cmpil #0x77770000,%d7
Tom's Computer Info / tom@mmto.org