Ejemplo n.º 1
0
	object *translate_data(const object *obj)
	{
		if(obj < *data_finger)
			return fixup_data((object *)obj);
		else
			return (object *)obj;
	}
Ejemplo n.º 2
0
/* This function also initializes the data and code heaps */
void factor_vm::load_image(vm_parameters* p) {
  FILE* file = open_image(p);
  if (file == NULL) {
    std::cout << "Cannot open image file: " << p->image_path << std::endl;
    char *msg = threadsafe_strerror(errno);
    std::cout << "strerror:2: " << msg << std::endl;
    free(msg);
    exit(1);
  }
  image_header h;
  if (raw_fread(&h, sizeof(image_header), 1, file) != 1)
    fatal_error("Cannot read image header", 0);

  if (h.magic != image_magic)
    fatal_error("Bad image: magic number check failed", h.magic);

  if (h.version != image_version)
    fatal_error("Bad image: version number check failed", h.version);

  load_data_heap(file, &h, p);
  load_code_heap(file, &h, p);

  raw_fclose(file);

  /* Certain special objects in the image are known to the runtime */
  memcpy(special_objects, h.special_objects, sizeof(special_objects));

  cell data_offset = data->tenured->start - h.data_relocation_base;
  cell code_offset = code->allocator->start - h.code_relocation_base;

  fixup_data(data_offset, code_offset);
  fixup_code(data_offset, code_offset);

  /* Store image path name */
  special_objects[OBJ_IMAGE] = allot_alien(false_object, (cell)p->image_path);
}
Ejemplo n.º 3
0
/* This function also initializes the data and code heaps */
void factor_vm::load_image(vm_parameters *p)
{
	FILE *file = OPEN_READ(p->image_path);
	if(file == NULL)
	{
		std::cout << "Cannot open image file: " << p->image_path << std::endl;
		std::cout << strerror(errno) << std::endl;
		exit(1);
	}

	image_header h;
	if(safe_fread(&h,sizeof(image_header),1,file) != 1)
		fatal_error("Cannot read image header",0);

	if(h.magic != image_magic)
		fatal_error("Bad image: magic number check failed",h.magic);

	if(h.version != image_version)
		fatal_error("Bad image: version number check failed",h.version);
	
	load_data_heap(file,&h,p);
	load_code_heap(file,&h,p);

	safe_fclose(file);

	init_objects(&h);

	cell data_offset = data->tenured->start - h.data_relocation_base;
	cell code_offset = code->seg->start - h.code_relocation_base;

	fixup_data(data_offset,code_offset);
	fixup_code(data_offset,code_offset);

	/* Store image path name */
	special_objects[OBJ_IMAGE] = allot_alien(false_object,(cell)p->image_path);
}
Ejemplo n.º 4
0
 object* translate_data(const object* obj) { return fixup_data((object*)obj); }