rem: dprintf("unhandled pheader type 0x%x\n", pheaders[i].p_type);
add: dprintf("unhandled pheader type 0x%lx\n", pheaders[i].p_type);
context: elf_load_kspace(const char *path, const char *sym_prepend){	struct Elf32_Ehdr *eheader;	struct Elf32_Phdr *pheaders;	struct elf_image_info *image;	void *vnode = NULL;	int fd;	int err;	int i;	ssize_t len;	PRINT(("elf_load_kspace: entry path '%s'\n", path));	fd = sys_open(path, 0);	if (fd < 0)		return fd;	err = vfs_get_vnode_from_fd(fd, true, &vnode);	if (err < 0)		goto error0;	// XXX awful hack to keep someone else from trying to load this image	// probably not a bad thing, shouldn't be too many races	mutex_lock(&image_load_lock);	// make sure it's not loaded already. Search by vnode	image = find_image_by_vnode(vnode);	if (image) {		atomic_add(&image->ref_count, 1);		//err = ERR_NOT_ALLOWED;		goto done;	}	eheader = (struct Elf32_Ehdr *)kmalloc(sizeof(*eheader));	if (!eheader) {		err = ENOMEM;		goto error;	}	len = sys_read(fd, 0, eheader, sizeof(*eheader));	if (len < 0) {		err = len;		goto error1;	}	if (len != sizeof(*eheader)) {		// short read		err = ERR_INVALID_BINARY;		goto error1;	}	err = verify_eheader(eheader);	if (err < 0)		goto error1;	image = create_image_struct();	if (!image) {		err = ENOMEM;		goto error1;	}	image->vnode = vnode;	image->eheader = eheader;	image->name = kstrdup(path);	pheaders = (struct Elf32_Phdr *)kmalloc(eheader->e_phnum * eheader->e_phentsize);	if (pheaders == NULL) {		dprintf("error allocating space for program headers\n");		err = ENOMEM;		goto error2;	}	PRINT(("reading in program headers at 0x%x, len 0x%x\n", eheader->e_phoff, eheader->e_phnum * eheader->e_phentsize));	len = sys_read(fd, eheader->e_phoff, pheaders, eheader->e_phnum * eheader->e_phentsize);	if (len < 0) {		err = len;		PRINT(("error reading in program headers\n"));		goto error3;	}	if (len != eheader->e_phnum * eheader->e_phentsize) {		PRINT(("short read while reading in program headers\n"));		err = -1;		goto error3;	}	for (i = 0; i < eheader->e_phnum; i++) {		char region_name[64];		bool ro_segment_handled = false;		bool rw_segment_handled = false;		int image_region;		int lock;		PRINT(("looking at program header %d\n", i));		switch (pheaders[i].p_type) {			case PT_LOAD:				break;			case PT_DYNAMIC:				image->dynamic_ptr = pheaders[i].p_vaddr;				continue;			default:				dprintf("unhandled pheader type 0x%x\n", pheaders[i].p_type);				continue;		}		// we're here, so it must be a PT_LOAD segment		if ((pheaders[i].p_flags & (PF_R | PF_W | PF_X)) == (PF_R | PF_W)) {			// this is the writable segment			if(rw_segment_handled) {				// we've already created this segment				continue;			}			rw_segment_handled = true;			image_region = 1;			lock = LOCK_RW|LOCK_KERNEL;			sprintf(region_name, "%s_rw", path);		} else if ((pheaders[i].p_flags & (PF_R | PF_W | PF_X)) == (PF_R | PF_X)) {			// this is the non-writable segment			if(ro_segment_handled) {				// we've already created this segment				continue;			}			ro_segment_handled = true;			image_region = 0;//			lock = LOCK_RO|LOCK_KERNEL;			lock = LOCK_RW|LOCK_KERNEL;			sprintf(region_name, "%s_ro", path);		} else {			dprintf("weird program header flags 0x%x\n", pheaders[i].p_flags);			continue;		}		image->regions[image_region].size = ROUNDUP(pheaders[i].p_memsz + (pheaders[i].p_vaddr % PAGE_SIZE), PAGE_SIZE);		image->regions[image_region].id = vm_create_anonymous_region(vm_get_kernel_aspace_id(), region_name,			(void **)&image->regions[image_region].start, REGION_ADDR_ANY_ADDRESS,			image->regions[image_region].size, REGION_WIRING_WIRED, lock);		if (image->regions[image_region].id < 0) {			dprintf("error allocating region!\n");			err = ERR_INVALID_BINARY;			goto error3;		}		image->regions[image_region].delta = image->regions[image_region].start - ROUNDOWN(pheaders[i].p_vaddr, PAGE_SIZE);		PRINT(("elf_load_kspace: created a region at %p\n", (void *)image->regions[image_region].start));		len = sys_read(fd, pheaders[i].p_offset,			(void *)(image->regions[image_region].start + (pheaders[i].p_vaddr % PAGE_SIZE)),			pheaders[i].p_filesz);		if (len < 0) {			err = len;			dprintf("error reading in seg %d\n", i);			goto error4;		}	}	if (image->regions[1].start != 0		&& image->regions[0].delta != image->regions[1].delta) {		dprintf("could not load binary, fix the region problem!\n");		dump_image_info(image);		err = ENOMEM;		goto error4;	}	// modify the dynamic ptr by the delta of the regions	image->dynamic_ptr += image->regions[0].delta;	err = elf_parse_dynamic_section(image);	if (err < 0)		goto error4;	err = elf_relocate(image, sym_prepend);	if (err < 0)		goto error4;	err = 0;	kfree(pheaders);	sys_close(fd);	insert_image_in_list(image);done:	mutex_unlock(&image_load_lock);		return image->id;error4:	if (image->regions[1].id >= 0)		vm_delete_region(vm_get_kernel_aspace_id(), image->regions[1].id);	if (image->regions[0].id >= 0)		vm_delete_region(vm_get_kernel_aspace_id(), image->regions[0].id);error3:	kfree(image);error2:	kfree(pheaders);error1:	kfree(eheader);error:	mutex_unlock(&image_load_lock);error0:	if (vnode)		vfs_put_vnode_ptr(vnode);	sys_close(fd);	return err;}