//-------------------------------------------------------------------------- inline sel_t get_fixup_segdef_sel(ea_t ea) { fixup_data_t fd; if ( get_fixup(ea, &fd) ) return get_fixup_segdef_sel(&fd); return BADSEL; }
//-------------------------------------------------------------------------- inline ea_t get_fixup_extdef_ea(ea_t ea) { fixup_data_t fd; if ( get_fixup(ea, &fd) ) return get_fixup_extdef_ea(ea, &fd); return BADADDR; }
void load_binfile (const char *bin_filename) { s32 reloc, next, pos, code_end, len, i = 0; FILE *f; if ((f = fopen (bin_filename, "r")) == NULL) { fprintf (stderr, "Error opening 68k-binary '%s'\n", bin_filename); //SDL_Quit (); exit (-2); } fseek (f, 0, SEEK_END); len = ftell (f); fseek (f, 0, SEEK_SET); assert (len+LOAD_BASE < MEM_SIZE); fread (m68kram+LOAD_BASE, 1, len, f); fclose (f); buf_pos = LOAD_BASE + 2; code_end = LOAD_BASE + 0x1c + rdlong (buf_pos); i=0; reloc = get_fixup (0, code_end); while (reloc) { i++; pos = buf_pos; /* address to be modified */ buf_pos = reloc; next = rdlong (buf_pos); next += LOAD_BASE; wrlong (buf_pos, next); if (next > code_end) { fprintf (stderr, "Reloc 0x%x (0x%x) out of range..\n", next, reloc+LOAD_BASE); } buf_pos = pos; reloc = get_fixup (reloc, code_end); } fprintf (stderr, "%s: 0x%x bytes (code end 0x%x), %d fixups; loaded at 0x%x.\n", bin_filename, len, code_end, i, LOAD_BASE); }
static int gc_commit_wrapper(struct gccommit *gccommit) { int ret = 0; struct gccommit kgccommit; struct gcbuffer *head = NULL; struct gcbuffer *tail; struct gcbuffer *ubuffer; struct gcbuffer *kbuffer = NULL; struct gcfixup *ufixup; struct gcfixup *nfixup; struct gcfixup *kfixup = NULL; int tablesize; /* Get IOCTL parameters. */ if (copy_from_user(&kgccommit, gccommit, sizeof(struct gccommit))) { GCPRINT(NULL, 0, GC_MOD_PREFIX "failed to read data.\n", __func__, __LINE__); kgccommit.gcerror = GCERR_USER_READ; goto exit; } /* Make a copy of the user buffer structures. */ ubuffer = kgccommit.buffer; while (ubuffer != NULL) { /* Allocate a buffer structure. */ kgccommit.gcerror = get_buffer(&kbuffer); if (kgccommit.gcerror != GCERR_NONE) goto exit; /* Add to the list. */ if (head == NULL) head = kbuffer; else tail->next = kbuffer; tail = kbuffer; /* Reset user pointers in the kernel structure. */ kbuffer->fixuphead = NULL; kbuffer->next = NULL; /* Get the data from the user. */ if (copy_from_user(kbuffer, ubuffer, sizeof(struct gcbuffer))) { GCPRINT(NULL, 0, GC_MOD_PREFIX "failed to read data.\n", __func__, __LINE__); kgccommit.gcerror = GCERR_USER_READ; goto exit; } /* Get the next user buffer. */ ubuffer = kbuffer->next; kbuffer->next = NULL; /* Get fixups and reset them in the kernel copy. */ ufixup = kbuffer->fixuphead; kbuffer->fixuphead = NULL; /* Copy all fixups. */ while (ufixup != NULL) { /* Allocare a fixup structure. */ kgccommit.gcerror = get_fixup(&kfixup); if (kgccommit.gcerror != GCERR_NONE) goto exit; /* Add to the list. */ if (kbuffer->fixuphead == NULL) kbuffer->fixuphead = kfixup; else kbuffer->fixuptail->next = kfixup; kbuffer->fixuptail = kfixup; /* Get the data from the user. */ if (copy_from_user(kfixup, ufixup, offsetof(struct gcfixup, fixup))) { GCPRINT(NULL, 0, GC_MOD_PREFIX " failed to read data.\n", __func__, __LINE__); kgccommit.gcerror = GCERR_USER_READ; goto exit; } /* Get the next fixup. */ nfixup = kfixup->next; kfixup->next = NULL; /* Compute the size of the fixup table. */ tablesize = kfixup->count * sizeof(struct gcfixupentry); /* Get the fixup table. */ if (copy_from_user(kfixup->fixup, ufixup->fixup, tablesize)) { GCPRINT(NULL, 0, GC_MOD_PREFIX "failed to read data.\n", __func__, __LINE__); kgccommit.gcerror = GCERR_USER_READ; goto exit; } /* Advance to the next. */ ufixup = nfixup; } }