summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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 */
11 11
12extern void dis_asm(ULONG off, ULONG val, char *stg); 12extern void dis_asm(ULONG off, ULONG val, char *stg);
13 13
14int 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
14int main(int argc, char **argv) 21int 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 }