diff options
author | Barry Wardell <rockbox@barrywardell.net> | 2007-08-01 22:25:18 +0000 |
---|---|---|
committer | Barry Wardell <rockbox@barrywardell.net> | 2007-08-01 22:25:18 +0000 |
commit | a049fa7c82cf155314c7e141f72ac8f8a7cf92fb (patch) | |
tree | 306d49928188c90646674e60a0f8dfa7175558ac | |
parent | 0b08f41ae9671b1387cce7278857f17ec77b801f (diff) | |
download | rockbox-a049fa7c82cf155314c7e141f72ac8f8a7cf92fb.tar.gz 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
-rw-r--r-- | utils/disassembler/arm/main.c | 16 |
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 */ | |||
11 | 11 | ||
12 | extern void dis_asm(ULONG off, ULONG val, char *stg); | 12 | extern void dis_asm(ULONG off, ULONG val, char *stg); |
13 | 13 | ||
14 | int static inline le2int(unsigned char* buf) | ||
15 | { | ||
16 | int32_t res = (buf[3] << 24) | (buf[2] << 16) | (buf[1] << 8) | buf[0]; | ||
17 | |||
18 | return res; | ||
19 | } | ||
20 | |||
14 | int main(int argc, char **argv) | 21 | int main(int argc, char **argv) |
15 | { | 22 | { |
16 | FILE *in, *out; | 23 | FILE *in, *out; |
17 | char *ptr, stg[256]; | 24 | char *ptr, stg[256]; |
25 | unsigned char buf[4]; | ||
18 | ULONG pos, sz, val, loop; | 26 | ULONG pos, sz, val, loop; |
19 | int offset, offset1; | 27 | int offset, offset1; |
20 | USHORT regid; | 28 | USHORT regid; |
@@ -46,7 +54,9 @@ int main(int argc, char **argv) | |||
46 | memset(stg, 0, 40); | 54 | memset(stg, 0, 40); |
47 | /* read next code dword */ | 55 | /* read next code dword */ |
48 | fseek(in, pos, SEEK_SET); | 56 | fseek(in, pos, SEEK_SET); |
49 | fread(&val, 4, 1, in); | 57 | fread(buf, 1, 4, in); |
58 | |||
59 | val = le2int(buf); | ||
50 | 60 | ||
51 | /* check for data tag set: if 1 byte out of 4 is marked => assume data */ | 61 | /* check for data tag set: if 1 byte out of 4 is marked => assume data */ |
52 | if((isdata[pos>>5] & (0xf << (pos & 31))) || (val & 0xffff0000) == 0) | 62 | if((isdata[pos>>5] & (0xf << (pos & 31))) || (val & 0xffff0000) == 0) |
@@ -101,7 +111,9 @@ int main(int argc, char **argv) | |||
101 | 111 | ||
102 | /* add const data to disassembler string */ | 112 | /* add const data to disassembler string */ |
103 | fseek(in, pos+offset+8, SEEK_SET); | 113 | fseek(in, pos+offset+8, SEEK_SET); |
104 | fread(&offset, 4, 1, in); | 114 | fread(&buf, 1, 4, in); |
115 | offset = le2int(buf); | ||
116 | |||
105 | sprintf(stg+strlen(stg), " <- 0x%x", offset); | 117 | sprintf(stg+strlen(stg), " <- 0x%x", offset); |
106 | } | 118 | } |
107 | } | 119 | } |