From f0332ec9239f65649f0967d47a3731466cea04a0 Mon Sep 17 00:00:00 2001 From: manu Date: Thu, 5 Dec 2002 22:48:53 +0000 Subject: [PATCH] In load_shared_file, do zero-fill uninitialized data segments that explicitely request to be zero filled. --- sys/compat/darwin/darwin_mman.c | 9 ++++++--- sys/compat/mach/mach_vm.h | 5 ++++- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/sys/compat/darwin/darwin_mman.c b/sys/compat/darwin/darwin_mman.c index ccf2d9110061..a7361d5824c4 100644 --- a/sys/compat/darwin/darwin_mman.c +++ b/sys/compat/darwin/darwin_mman.c @@ -1,4 +1,4 @@ -/* $NetBSD: darwin_mman.c,v 1.2 2002/11/17 16:51:13 manu Exp $ */ +/* $NetBSD: darwin_mman.c,v 1.3 2002/12/05 22:48:54 manu Exp $ */ /*- * Copyright (c) 2002 The NetBSD Foundation, Inc. @@ -104,7 +104,7 @@ darwin_sys_load_shared_file(p, v, retval) if ((error = copyin(SCARG(uap, flags), &flags, sizeof(base))) != 0) return error; - DPRINTF(("mach_sys_load_shared_file: filename = %p ", + DPRINTF(("darwin_sys_load_shared_file: filename = %p ", SCARG(uap, filename))); DPRINTF(("addr = %p len = 0x%08lx base = %p ", SCARG(uap, addr), SCARG(uap, len), SCARG(uap, base))); @@ -201,7 +201,10 @@ darwin_sys_load_shared_file(p, v, retval) evc.ev_len = mapp[i].size; evc.ev_prot = mapp[i].protection & VM_PROT_ALL; evc.ev_flags = 0; - evc.ev_proc = vmcmd_map_readvn; + if (mapp[i].protection & MACH_VM_PROT_ZF) + evc.ev_proc = vmcmd_map_zero; + else + evc.ev_proc = vmcmd_map_readvn; evc.ev_offset = mapp[i].file_offset; evc.ev_vp = vp; diff --git a/sys/compat/mach/mach_vm.h b/sys/compat/mach/mach_vm.h index 38cd7121acc0..08309e3296c8 100644 --- a/sys/compat/mach/mach_vm.h +++ b/sys/compat/mach/mach_vm.h @@ -1,4 +1,4 @@ -/* $NetBSD: mach_vm.h,v 1.6 2002/12/04 22:55:11 manu Exp $ */ +/* $NetBSD: mach_vm.h,v 1.7 2002/12/05 22:48:53 manu Exp $ */ /*- * Copyright (c) 2002 The NetBSD Foundation, Inc. @@ -52,6 +52,9 @@ #define MACH_SF_PREV_LOADED 1 #define MACH_SYSTEM_REGION_BACKED 2 +#define MACH_VM_PROT_COW 0x8 +#define MACH_VM_PROT_ZF 0x10 + typedef struct mach_sf_mapping { mach_vm_offset_t mapping_offset; mach_vm_size_t size;