define dekkodex $r0=$r1=0x3000x $r2=$arg0j *0xff865008x/16x 0x3000end
(gdb) x/8x 0x30000x3000: 0x00000000 0x00000000 0x00000000 0x000000000x3010: 0x00000000 0x00000000 0x00000000 0x00000000
(gdb) dekkode 640x3000: 0x000000000x40: 0x00000000Breakpoint 1, 0xff8650c8 in _binary_ixus860is_dump_start ()0x3000: 0x00ffffa0 0xffa0ffff 0xffff00ff 0x00ffffa00x3010: 0xffa0ffff 0xffff00ff 0x00ffffa0 0xffa0ffff0x3020: 0xffff00ff 0x00ffffa0 0xffa0ffff 0xffff00ff0x3030: 0x00ffffa0 0xffa0ffff 0xffff00ff 0x00ffffa0
(gdb)0x3000: 0x00ffffa00x40: 0x00000000Breakpoint 1, 0xff8650c8 in _binary_ixus860is_dump_start ()0x3000: 0x0a005f5f 0xff5f0000 0x00ffff5f 0xff0000a00x3010: 0x005f0000 0x00ff0a00 0x0a005f5f 0xff5f00000x3020: 0x00ffff5f 0xff0000a0 0x005f0000 0x00ff0a000x3030: 0x0a005f5f 0xff5f0000 0x00ffff5f 0xff0000a0another:(gdb)0x3000: 0x0a005f5f0x40: 0x00000000Breakpoint 1, 0xff8650c8 in _binary_ixus860is_dump_start ()0x3000: 0xf5a0a0a0 0xf5a0ff00 0xa000005f 0x00ff005f0x3010: 0xffa000ff 0xfff5f5ff 0xf5a0a0a0 0xf5a0ff000x3020: 0xa000005f 0x00ff005f 0xffa000ff 0xfff5f5ff0x3030: 0xf5a0a0a0 0xf5a0ff00 0xa000005f 0x00ff005fand another:(gdb)0x3000: 0xf5a0a0a00x40: 0x00000000Breakpoint 1, 0xff8650c8 in _binary_ixus860is_dump_start ()0x3000: 0x0a5f5fa0 0x0a5f5f0a 0xa0ffffa0 0x0affffa00x3010: 0x00a00a00 0x000a0a00 0x0a5f5fa0 0x0a5f5f0a0x3020: 0xa0ffffa0 0x0affffa0 0x00a00a00 0x000a0a000x3030: 0x0a5f5fa0 0x0a5f5f0a 0xa0ffffa0 0x0affffa0Hey, it's free, so take another trip:(gdb)0x3000: 0x0a5f5fa00x40: 0x00000000Breakpoint 1, 0xff8650c8 in _binary_ixus860is_dump_start ()0x3000: 0x0aa0a0aa 0xf5ffa0f5 0x5f00ff5f 0x0a0000aa0x3010: 0xffaaf5ff 0xfff50aff 0x0aa0a0aa 0xf5ffa0f50x3020: 0x5f00ff5f 0x0a0000aa 0xffaaf5ff 0xfff50aff0x3030: 0x0aa0a0aa 0xf5ffa0f5 0x5f00ff5f 0x0a0000aa(gdb)0x3000: 0x0aa0a0aa0x40: 0x00000000Breakpoint 1, 0xff8650c8 in _binary_ixus860is_dump_start ()0x3000: 0xaa5f0055 0xf5005f0a 0xa0000055 0xf5ffffaa0x3010: 0x00550a00 0x00f5aa00 0xaa5f0055 0xf5005f0a0x3020: 0xa0000055 0xf5ffffaa 0x00550a00 0x00f5aa000x3030: 0xaa5f0055 0xf5005f0a 0xa0000055 0xf5ffffaa(gdb)0x3000: 0xaa5f00550x40: 0x00000000Breakpoint 1, 0xff8650c8 in _binary_ixus860is_dump_start ()0x3000: 0x55ffffaa 0x55ffa00a 0xaaffff55 0x0a00ff550x3010: 0xffaa0aff 0xff5555ff 0x55ffffaa 0x55ffa00a0x3020: 0xaaffff55 0x0a00ff55 0xffaa0aff 0xff5555ff0x3030: 0x55ffffaa 0x55ffa00a 0xaaffff55 0x0a00ff55(gdb)0x3000: 0x55ffffaa0x40: 0x00000000Breakpoint 1, 0xff8650c8 in _binary_ixus860is_dump_start ()0x3000: 0xaa0000aa 0xaa0000aa 0xaa0000aa 0xaa0000aa0x3010: 0x00aaaa00 0x00aaaa00 0xaa0000aa 0xaa0000aa0x3020: 0xaa0000aa 0xaa0000aa 0x00aaaa00 0x00aaaa000x3030: 0xaa0000aa 0xaa0000aa 0xaa0000aa 0xaa0000aa(gdb)0x3000: 0xaa0000aa0x40: 0x00000000Breakpoint 1, 0xff8650c8 in _binary_ixus860is_dump_start ()0x3000: 0xaaffff0a 0x55a0ff55 0x55ff0055 0xaaffff0a0x3010: 0xff0a55ff 0xff55aaff 0xaaffff0a 0x55a0ff550x3020: 0x55ff0055 0xaaffff0a 0xff0a55ff 0xff55aaff0x3030: 0xaaffff0a 0x55a0ff55 0x55ff0055 0xaaffff0a(gdb)0x3000: 0xaaffff0a0x40: 0x00000000Breakpoint 1, 0xff8650c8 in _binary_ixus860is_dump_start ()0x3000: 0xa0005ff5 0x555f00aa 0xaafffff5 0x5500000a0x3010: 0x00f5aa00 0x0055a000 0xa0005ff5 0x555f00aa0x3020: 0xaafffff5 0x5500000a 0x00f5aa00 0x0055a0000x3030: 0xa0005ff5 0x555f00aa 0xaafffff5 0x5500000a(gdb)0x3000: 0xa0005ff50x40: 0x00000000Breakpoint 1, 0xff8650c8 in _binary_ixus860is_dump_start ()0x3000: 0x5fa0a00a 0x5fa0ffaa 0x0a0000f5 0xaaff00f50x3010: 0xff0aaaff 0xff5f5fff 0x5fa0a00a 0x5fa0ffaa0x3020: 0x0a0000f5 0xaaff00f5 0xff0aaaff 0xff5f5fff0x3030: 0x5fa0a00a 0x5fa0ffaa 0x0a0000f5 0xaaff00f5(gdb)0x3000: 0x5fa0a00a0x40: 0x00000000Breakpoint 1, 0xff8650c8 in _binary_ixus860is_dump_start ()0x3000: 0xa05f5f0a 0xa05f5fa0 0x0affff0a 0xa0ffff0a0x3010: 0x000aa000 0x00a0a000 0xa05f5f0a 0xa05f5fa00x3020: 0x0affff0a 0xa0ffff0a 0x000aa000 0x00a0a0000x3030: 0xa05f5f0a 0xa05f5fa0 0x0affff0a 0xa0ffff0a(gdb)0x3000: 0xa05f5f0a0x40: 0x00000000Breakpoint 1, 0xff8650c8 in _binary_ixus860is_dump_start ()0x3000: 0xa0a0a000 0x5fffa05f 0xf500fff5 0xa00000000x3010: 0xff005fff 0xff5fa0ff 0xa0a0a000 0x5fffa05f0x3020: 0xf500fff5 0xa0000000 0xff005fff 0xff5fa0ff0x3030: 0xa0a0a000 0x5fffa05f 0xf500fff5 0xa0000000(gdb)0x3000: 0xa0a0a0000x40: 0x00000000Breakpoint 1, 0xff8650c8 in _binary_ixus860is_dump_start ()0x3000: 0x005f00ff 0x5f005fa0 0x0a0000ff 0x5fffff000x3010: 0x00ffa000 0x005f0000 0x005f00ff 0x5f005fa00x3020: 0x0a0000ff 0x5fffff00 0x00ffa000 0x005f00000x3030: 0x005f00ff 0x5f005fa0 0x0a0000ff 0x5fffff00(gdb)0x3000: 0x005f00ff0x40: 0x00000000Breakpoint 1, 0xff8650c8 in _binary_ixus860is_dump_start ()0x3000: 0xffffff00 0xffffa0a0 0x00ffffff 0xa000ffff0x3010: 0xff00a0ff 0xffffffff 0xffffff00 0xffffa0a00x3020: 0x00ffffff 0xa000ffff 0xff00a0ff 0xffffffff0x3030: 0xffffff00 0xffffa0a0 0x00ffffff 0xa000ffff(gdb)0x3000: 0xffffff000x40: 0x00000000Breakpoint 1, 0xff8650c8 in _binary_ixus860is_dump_start ()0x3000: 0x00000000 0x00000000 0x00000000 0x000000000x3010: 0x00000000 0x00000000 0x00000000 0x000000000x3020: 0x00000000 0x00000000 0x00000000 0x000000000x3030: 0x00000000 0x00000000 0x00000000 0x00000000
(gdb) restore led/diskboot.bin binary 0x3000Restoring binary file led/diskboot.bin into memory (0x3000 to 0x3088)(gdb) dekkode 0x100repeat 15 times(gdb) dump memory outfile.bin 0x3000-1 0x3000+0x19000
(gdb) dekkode 0x100
#!/bin/sh### addstrings.sh### Add strings and values to a firmware dump dissassemblyif [ -z "$1" ]; then echo "usage:" echo "cat dump.dis | ./addstrings.sh dump.strings dump.dis > dump.diss" exit 0fiSTRINGSFILE=$1DISFILE=$2# empty separator list for read, otherwise it removes whitespacesIFS=""while [ "$eof_found" != "1" ]; do read -n 1024 row eof_found=$? # process rows which have an ldr assembler command and something that looks like <_binary_dump_bin_start+0x178> ldr=`echo "$row" | grep ldr | grep "start+" | wc -l | tr -c -d 0-9` if [ "$ldr" = "1" ]; then # remove that <...start+0x...> thing: from line end: row=`echo $row | cut -d '<' -f 1 ` # extract string pointer: pntraddr=`echo $row | cut -d ';' -f 2 | tr -c -d '0-9a-f\n'` echo -n $row # print the value in hex as it may be an interesting RAM address if there is no # string or the string is not a real string but just something the filter passed thru. value=`grep "$pntraddr:" $DISFILE | cut -f 2 | tr -c -d 0-9a-f` echo -n "VALUE:<"$value">" # search the strings file for a match at our address (if we have an address): if [ "$value" != "" ]; then gout=`grep $value $STRINGSFILE` rv=$? if [ "$rv" == "0" ]; then # string found string=`echo $gout|cut -d ' ' -f 2-` echo -n " STRING:<"$string">" fi fi # line feed echo else # pass thru other rows echo "$row" fidone
The bad news is that this quick hack turned out to be extremely slow, seems to take like a day to process a single disassembly on my computer ... so if someone finds this useful, please make better one. Processing small parts is obviously fast enough.
I also have this "slowness". I found out, it only happens sometimes when gdb is in tui mode.Switch to cmd mode (ctrl-x a) and it runs fine!
#!/bin/sh### This script disassembles all firmwared dumps in it's reach using### arm-elf-objdump and arm-elf-objcopy. You need chr's renumber.pl from###### [url=http://chdk.wikia.com/wiki/Gpl_renumber.pl]Gpl renumber.pl - CHDK Wiki[/url] ###### and you will want to read ###### [url=http://chdk.wikia.com/wiki/GPL_Tools]GPL Tools - CHDK Wiki[/url].###### Run the script in trunk/platform with firmware dumps in their### respective subdirecories, named PRIMARY.BIN or primary.bin.### uncomment and set path to your arm-elf binaries here if ### they are not in your path:#export PATH=/usr/local/arm-elf/bin:$PATH### path to renumber.plRENUMBER_PATH=.disassemble (){ echo -n "disassembling $fwdump: strings..." strings -t x $fwdump | $RENUMBER_PATH/renumber.pl 0x$ROMBASEADDR > $p/primary.strings# echo -n hexdump...# hexdump -C $fwdump |$RENUMBER_PATH/renumber.pl 0x$ROMBASEADDR > $p/primary.hex echo -n objcopy... arm-elf-objcopy --change-addresses=0x$ROMBASEADDR -I binary -O elf32-littlearm -B arm $fwdump $p/primary.elf arm-elf-objcopy --set-section-flags .data=code $p/primary.elf echo -n objdump...# arm-elf-objdump -x dump.elf arm-elf-objdump -d $p/primary.elf > $p/primary.dis echo done.}# loop thru all sub-platformsfor p in */sub/*; do fwdump="" # if makefile.inc exists and is readable if [ -r $p/makefile.inc ]; then # get ROMBASEADDR from makefile.inc ROMBASEADDR=`grep ROMBASEADDR $p/makefile.inc | cut -f 2 -d '=' | tr -c -d 0-9a-fA-F` echo -n "$p: ROMBASEADDR=$ROMBASEADDR, " # if a non-zero firmware dump exists: if [ -s $p/PRIMARY.BIN ]; then fwdump=$p/PRIMARY.BIN elif [ -s $p/primary.bin ]; then fwdump=$p/primary.bin fi if [ "$fwdump" == "" ]; then echo no non-zero PRIMARY.BIN or primary.bin found. elif [ -r $fwdump ]; then disassemble else echo $fwdump found but unreadable. fi fidone
ff936a40: e59f12e8 ldr r1, [pc, #744] ; ff936d30: (0xff81d88c)ff936a44: e28f0fba add r0, pc, #744 ; ff936d34: (0x63727473) "strcpy"ff936a48: ebfccc5a bl ff869bb8 <_binary_dump_bin_start+0x59bb8>ff936a4c: e59f12e8 ldr r1, [pc, #744] ; ff936d3c: (0xff81d8e8)ff936a50: e28f0fba add r0, pc, #744 ; ff936d40: (0x6c727473) "strlen"ff936a54: ebfccc57 bl ff869bb8 <_binary_dump_bin_start+0x59bb8>ff936a58: e59f12e8 ldr r1, [pc, #744] ; ff936d48: (0xff81d8a4)ff936a5c: e28f0fba add r0, pc, #744 ; ff936d4c: (0x63727473) "strcmp"ff936a60: ebfccc54 bl ff869bb8 <_binary_dump_bin_start+0x59bb8>
ffea4f64: 50415353 subpl r5, r1, r3, asr r3ffea4f68: 453a3a49 ldrmi r3, [sl, #-2633]!ffea4f6c: 7265746e rsbvc r7, r5, #1845493760 ; 0x6e000000ffea4f70: 6f436f54 svcvs 0x00436f54ffea4f74: 6e65706d cdpvs 0, 6, cr7, cr5, cr13, {3}ffea4f78: 69746173 ldmdbvs r4!, {r0, r1, r4, r5, r6, r8, sp, lr}^ffea4f7c: 56456e6f strbpl r6, [r5], -pc, ror #28ffea4f80: 00000046 andeq r0, r0, r6, asr #32ffea4f84: e59f1050 ldr r1, [pc, #80] ; ffea4fdc VALUE:<ffea4f64> STRING:<SSAPI::EnterToCompensationEVF>ffea4f88: e3a00020 mov r0, #32 ; 0x20
"SSAPI::EnterToCompensationEVF":ffea4f64: 50415353 subpl r5, r1, r3, asr r3ffea4f68: 453a3a49 ldrmi r3, [sl, #-2633]!ffea4f6c: 7265746e rsbvc r7, r5, #1845493760 ; 0x6e000000ffea4f70: 6f436f54 svcvs 0x00436f54ffea4f74: 6e65706d cdpvs 0, 6, cr7, cr5, cr13, {3}ffea4f78: 69746173 ldmdbvs r4!, {r0, r1, r4, r5, r6, r8, sp, lr}^ffea4f7c: 56456e6f strbpl r6, [r5], -pc, ror #28ffea4f80: 00000046 andeq r0, r0, r6, asr #32ffea4f84: e59f1050 ldr r1, [pc, #80] ; ffea4fdc: (0xffea4f64) ffea4f88: e3a00020 mov r0, #32 ; 0x20
Cool, I was hoping someone would make a speedier thing But is it working as intended? I can't find any strings after ldr or add instructions, just as comments before the strings themselves (a570is 1.00e):
ff936a5c: e28f0fba add r0, pc, #744 ; ff936d4c: (0x63727473) "strcmp"
ffea4f84: e59f1050 ldr r1, [pc, #80] ; ffea4fdc VALUE:<ffea4f64> STRING:<SSAPI::EnterToCompensationEVF>
Started by Daniel Moore Feature Requests
Started by Hardware_Hacker General Discussion and Assistance