static void copy_bootstrap(void *e, struct exec_info *boot_exec_info) { register vm_map_t user_map = current_task()->map; int err; printf("loading...\n"); if (err = exec_load(boot_read, read_exec, e, boot_exec_info)) panic("Cannot load user-bootstrap image: error code %d", err); #if MACH_KDB /* * Enter the bootstrap symbol table. */ #if 0 /*XXX*/ if (load_bootstrap_symbols) (void) X_db_sym_init( (char*) boot_start+lp->sym_offset, (char*) boot_start+lp->sym_offset+lp->sym_size, "bootstrap", (char *) user_map); #endif #if 0 /*XXX*/ if (load_fault_in_text) { vm_offset_t lenp = round_page(lp->text_start+lp->text_size) - trunc_page(lp->text_start); vm_offset_t i = 0; while (i < lenp) { vm_fault(user_map, text_page_start +i, load_protect_text ? VM_PROT_READ|VM_PROT_EXECUTE : VM_PROT_READ|VM_PROT_EXECUTE | VM_PROT_WRITE, 0,0,0); i = round_page (i+1); } } #endif #endif MACH_KDB }
/* * Loads a symbol table for an external file into the kernel debugger. * The symbol table data is an array of characters. It is assumed that * the caller and the kernel debugger agree on its format. */ kern_return_t host_load_symbol_table( host_t host, task_t task, char * name, pointer_t symtab, unsigned int symtab_count) { kern_return_t result; vm_offset_t symtab_start; vm_offset_t symtab_end; vm_map_t map; vm_map_copy_t symtab_copy_object; if (host == HOST_NULL) return (KERN_INVALID_ARGUMENT); /* * Copy the symbol table array into the kernel. * We make a copy of the copy object, and clear * the old one, so that returning error will not * deallocate the data twice. */ symtab_copy_object = (vm_map_copy_t) symtab; result = vm_map_copyout( kernel_map, &symtab_start, vm_map_copy_copy(symtab_copy_object)); if (result != KERN_SUCCESS) return (result); symtab_end = symtab_start + symtab_count; /* * Add the symbol table. * Do not keep a reference for the task map. XXX */ if (task == TASK_NULL) map = VM_MAP_NULL; else map = task->map; if (!X_db_sym_init((char *)symtab_start, (char *)symtab_end, name, (char *)map)) { /* * Not enough room for symbol table - failure. */ (void) vm_deallocate(kernel_map, symtab_start, symtab_count); return (KERN_FAILURE); } /* * Wire down the symbol table */ (void) vm_map_pageable(kernel_map, symtab_start, round_page(symtab_end), VM_PROT_READ|VM_PROT_WRITE); /* * Discard the original copy object */ vm_map_copy_discard(symtab_copy_object); return (KERN_SUCCESS); }