Some more fixes for SMD and m68k

This commit is contained in:
pancake 2015-10-29 14:16:30 +01:00
parent 97233ecbae
commit f03a2a80c8
2 changed files with 24 additions and 8 deletions

View File

@ -102,12 +102,16 @@ static int analop(RAnal *a, RAnalOp *op, ut64 addr, const ut8 *buf, int len) {
case M68K_INS_BGT:
case M68K_INS_BLE:
op->type = R_ANAL_OP_TYPE_CJMP;
op->jump = IMM(0) - 0x100; // XXX wtf capstone bug
op->fail = addr + 2;
break;
case M68K_INS_BRA:
op->type = R_ANAL_OP_TYPE_JMP;
break;
case M68K_INS_BSR:
op->type = R_ANAL_OP_TYPE_CALL;
op->jump = IMM(0) - 0x100; // XXX wtf capstone bug
op->fail = addr + 2;
break;
case M68K_INS_BCHG:
case M68K_INS_BCLR:

View File

@ -130,7 +130,7 @@ static RBinInfo* info(RBinFile *arch) {
return ret;
}
static void addsym(RList *ret, ut64 addr, const char *name) {
static void addsym(RList *ret, const char *name, ut64 addr) {
RBinSymbol *ptr = R_NEW0 (RBinSymbol);
if (!ptr) return;
strncpy (ptr->name, name, R_BIN_SIZEOF_STRINGS);
@ -157,10 +157,10 @@ static RList* symbols(RBinFile *arch) {
{
// TODO: store all this stuff in SDB
SMD_Header * hdr = (SMD_Header*)(arch->buf->buf + 0x100);
addsym(ret, hdr->RomStart, "rom_start");
addsym(ret, hdr->RomEnd, "rom_end");
addsym(ret, hdr->RamStart, "ram_start");
addsym(ret, hdr->RamEnd, "ram_start");
addsym(ret, "rom_start", hdr->RomStart);
addsym(ret, "rom_end", hdr->RomEnd);
addsym(ret, "ram_start", hdr->RamStart);
addsym(ret, "ram_end", hdr->RamEnd);
showstr ("Copyright", hdr->CopyRights, 32);
showstr ("DomesticName", hdr->DomesticName, 48);
showstr ("OverseasName", hdr->OverseasName, 48);
@ -241,7 +241,7 @@ static RList* symbols(RBinFile *arch) {
}
if (!name) continue;
if (!vtable[i]) continue;
addsym(ret, vtable[i], name);
addsym(ret, name, vtable[i]);
}
return ret;
}
@ -266,18 +266,30 @@ static RList* sections(RBinFile *arch) {
ptr->size = ptr->vsize = sizeof (SMD_Header);
ptr->srwx = R_BIN_SCN_MAP;
r_list_append (ret, ptr);
if (!(ptr = R_NEW0 (RBinSection)))
return ret;
strcpy (ptr->name, "text");
ptr->paddr = ptr->vaddr = 0x100 + sizeof (SMD_Header);
{
SMD_Header * hdr = (SMD_Header*)(arch->buf->buf + 0x100);
ut64 baddr = hdr->RamStart;
ptr->vaddr += baddr;
}
ptr->size = ptr->vsize = arch->buf->length - ptr->paddr;
ptr->srwx = R_BIN_SCN_MAP;
r_list_append (ret, ptr);
return ret;
}
static RList* entries(RBinFile *arch) { //Should be 3 offsets pointed by NMI, RESET, IRQ after mapping && default = 1st CHR
RList *ret;
ut32 *vtable = (ut32*)arch->buf->buf;
RBinAddr *ptr = NULL;
if (!(ret = r_list_new ()))
return NULL;
if (!(ptr = R_NEW0 (RBinAddr)))
return ret;
ptr->paddr = ptr->vaddr = vtable[1];
ptr->paddr = ptr->vaddr = 0x100 + sizeof (SMD_Header); //vtable[1];
r_list_append (ret, ptr);
return ret;
}