summaryrefslogtreecommitdiffstats
path: root/utils/disassembler
diff options
context:
space:
mode:
authorBarry Wardell <rockbox@barrywardell.net>2007-08-01 22:25:18 +0000
committerBarry Wardell <rockbox@barrywardell.net>2007-08-01 22:25:18 +0000
commita049fa7c82cf155314c7e141f72ac8f8a7cf92fb (patch)
tree306d49928188c90646674e60a0f8dfa7175558ac /utils/disassembler
parent0b08f41ae9671b1387cce7278857f17ec77b801f (diff)
downloadrockbox-a049fa7c82cf155314c7e141f72ac8f8a7cf92fb.tar.gz
rockbox-a049fa7c82cf155314c7e141f72ac8f8a7cf92fb.tar.bz2
rockbox-a049fa7c82cf155314c7e141f72ac8f8a7cf92fb.zip
FS#7182: Fix endianness bugs in ARM disassembler which made it report wrong addresses on PPC.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@14130 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'utils/disassembler')
-rw-r--r--utils/disassembler/arm/main.c16
1 files changed, 14 insertions, 2 deletions
diff --git a/utils/disassembler/arm/main.c b/utils/disassembler/arm/main.c
index 812f80779f..0edc633785 100644
--- a/utils/disassembler/arm/main.c
+++ b/utils/disassembler/arm/main.c
@@ -11,10 +11,18 @@ ULONG isdata[1000000]; /* each bit defines one byte as: code=0, data=1 */
extern void dis_asm(ULONG off, ULONG val, char *stg);
+int static inline le2int(unsigned char* buf)
+{
+ int32_t res = (buf[3] << 24) | (buf[2] << 16) | (buf[1] << 8) | buf[0];
+
+ return res;
+}
+
int main(int argc, char **argv)
{
FILE *in, *out;
char *ptr, stg[256];
+ unsigned char buf[4];
ULONG pos, sz, val, loop;
int offset, offset1;
USHORT regid;
@@ -46,7 +54,9 @@ int main(int argc, char **argv)
memset(stg, 0, 40);
/* read next code dword */
fseek(in, pos, SEEK_SET);
- fread(&val, 4, 1, in);
+ fread(buf, 1, 4, in);
+
+ val = le2int(buf);
/* check for data tag set: if 1 byte out of 4 is marked => assume data */
if((isdata[pos>>5] & (0xf << (pos & 31))) || (val & 0xffff0000) == 0)
@@ -101,7 +111,9 @@ int main(int argc, char **argv)
/* add const data to disassembler string */
fseek(in, pos+offset+8, SEEK_SET);
- fread(&offset, 4, 1, in);
+ fread(&buf, 1, 4, in);
+ offset = le2int(buf);
+
sprintf(stg+strlen(stg), " <- 0x%x", offset);
}
}