- if (shared_regions) {
- vm_offset_t vmaddr;
- shared_region_mapping_t shared_region;
- struct shared_region_task_mappings map_info;
- shared_region_mapping_t next;
-
-RedoLookup:
- vm_get_shared_region(task, &shared_region);
- map_info.self = (vm_offset_t)shared_region;
- shared_region_mapping_info(shared_region,
- &(map_info.text_region),
- &(map_info.text_size),
- &(map_info.data_region),
- &(map_info.data_size),
- &(map_info.region_mappings),
- &(map_info.client_base),
- &(map_info.alternate_base),
- &(map_info.alternate_next),
- &(map_info.fs_base),
- &(map_info.system),
- &(map_info.flags), &next);
-
- if((map_info.flags & SHARED_REGION_FULL) ||
- (map_info.flags & SHARED_REGION_STALE)) {
- shared_region_mapping_t system_region;
- system_region = lookup_default_shared_region(
- map_info.fs_base, map_info.system);
- if((map_info.self != (vm_offset_t)system_region) &&
- (map_info.flags & SHARED_REGION_SYSTEM)) {
- if(system_region == NULL) {
- shared_file_boot_time_init(
- map_info.fs_base, map_info.system);
- } else {
- vm_set_shared_region(task, system_region);
- }
- shared_region_mapping_dealloc(
- (shared_region_mapping_t)map_info.self);
- goto RedoLookup;
- } else if (map_info.flags & SHARED_REGION_SYSTEM) {
- shared_region_mapping_dealloc(system_region);
- shared_file_boot_time_init(
- map_info.fs_base, map_info.system);
- shared_region_mapping_dealloc(
- (shared_region_mapping_t)map_info.self);
- } else {
- shared_region_mapping_dealloc(system_region);
- }
- }
-
- if (dylink_test) {
- p->p_flag |= P_NOSHLIB; /* no shlibs in use */
- vmaddr = map_info.client_base;
- if(clean_regions) {
- vm_map(map, &vmaddr, map_info.text_size,
- 0, SHARED_LIB_ALIAS|VM_FLAGS_FIXED,
- map_info.text_region, 0, FALSE,
- VM_PROT_READ, VM_PROT_READ, VM_INHERIT_SHARE);
- } else {
- vm_map(map, &vmaddr, map_info.text_size, 0,
- (VM_MEMORY_SHARED_PMAP << 24)
- | SHARED_LIB_ALIAS | VM_FLAGS_FIXED,
- map_info.text_region, 0, FALSE,
- VM_PROT_READ, VM_PROT_READ, VM_INHERIT_SHARE);
- }
- vmaddr = map_info.client_base + map_info.text_size;
- vm_map(map, &vmaddr, map_info.data_size,
- 0, SHARED_LIB_ALIAS | VM_FLAGS_FIXED,
- map_info.data_region, 0, TRUE,
- VM_PROT_READ, VM_PROT_READ, VM_INHERIT_SHARE);
-
- while (next) {
- /* this should be fleshed out for the general case */
- /* but this is not necessary for now. Indeed we */
- /* are handling the com page inside of the */
- /* shared_region mapping create calls for now for */
- /* simplicities sake. If more general support is */
- /* needed the code to manipulate the shared range */
- /* chain can be pulled out and moved to the callers*/
- shared_region_mapping_info(next,
- &(map_info.text_region),
- &(map_info.text_size),
- &(map_info.data_region),
- &(map_info.data_size),
- &(map_info.region_mappings),
- &(map_info.client_base),
- &(map_info.alternate_base),
- &(map_info.alternate_next),
- &(map_info.fs_base),
- &(map_info.system),
- &(map_info.flags), &next);
-
- vmaddr = map_info.client_base;
- vm_map(map, &vmaddr, map_info.text_size,
- 0, SHARED_LIB_ALIAS | VM_FLAGS_FIXED,
- map_info.text_region, 0, FALSE,
- VM_PROT_READ, VM_PROT_READ, VM_INHERIT_SHARE);
- }
- }
- }