25 |
* SUCH DAMAGE. |
* SUCH DAMAGE. |
26 |
* |
* |
27 |
* |
* |
28 |
* $Id: file.c,v 1.132 2006/07/09 05:51:28 debug Exp $ |
* $Id: file.c,v 1.134 2006/08/12 11:43:12 debug Exp $ |
29 |
* |
* |
30 |
* This file contains functions which load executable images into (emulated) |
* This file contains functions which load executable images into (emulated) |
31 |
* memory. File formats recognized so far are: |
* memory. File formats recognized so far are: |
1163 |
char *filename, uint64_t *entrypointp) |
char *filename, uint64_t *entrypointp) |
1164 |
{ |
{ |
1165 |
FILE *f; |
FILE *f; |
1166 |
int len; |
int len, sign3264; |
1167 |
unsigned char buf[16384]; |
unsigned char buf[16384]; |
1168 |
uint64_t entry, loadaddr, vaddr, skip = 0; |
uint64_t entry, loadaddr, vaddr, skip = 0; |
1169 |
char *p, *p2; |
char *p, *p2; |
1170 |
|
|
1171 |
|
/* Special case for 32-bit MIPS: */ |
1172 |
|
sign3264 = 0; |
1173 |
|
if (m->arch == ARCH_MIPS && m->cpus[0]->is_32bit) |
1174 |
|
sign3264 = 1; |
1175 |
|
|
1176 |
p = strchr(filename, ':'); |
p = strchr(filename, ':'); |
1177 |
if (p == NULL) { |
if (p == NULL) { |
1178 |
fprintf(stderr, "\n"); |
fprintf(stderr, "\n"); |
1196 |
} else |
} else |
1197 |
p = p2; |
p = p2; |
1198 |
|
|
1199 |
|
if (sign3264) { |
1200 |
|
loadaddr = (int64_t)(int32_t)loadaddr; |
1201 |
|
entry = (int64_t)(int32_t)entry; |
1202 |
|
vaddr = (int64_t)(int32_t)vaddr; |
1203 |
|
skip = (int64_t)(int32_t)skip; |
1204 |
|
} |
1205 |
|
|
1206 |
f = fopen(strrchr(filename, ':')+1, "r"); |
f = fopen(strrchr(filename, ':')+1, "r"); |
1207 |
if (f == NULL) { |
if (f == NULL) { |
1208 |
perror(p); |
perror(p); |
1495 |
debug("%08"PRIx32"\n", (uint32_t) eentry); |
debug("%08"PRIx32"\n", (uint32_t) eentry); |
1496 |
|
|
1497 |
/* |
/* |
1498 |
* SH64: 32-bit instruction encoding? TODO |
* SH64: 32-bit instruction encoding? |
1499 |
*/ |
*/ |
1500 |
if (arch == ARCH_SH && (eentry & 1)) { |
if (arch == ARCH_SH && (eentry & 1)) { |
1501 |
debug("SH64: 32-bit instruction encoding\n"); |
debug("SH64: 32-bit instruction encoding\n"); |
1502 |
m->cpus[0]->cd.sh.compact = 0; |
m->cpus[0]->cd.sh.compact = 0; |
1503 |
m->cpus[0]->cd.sh.bits = 64; |
m->cpus[0]->cd.sh.cpu_type.bits = 64; |
1504 |
} |
} |
1505 |
|
|
1506 |
/* Read the program headers: */ |
/* Read the program headers: */ |