From 0b71a2d5de6b4ba38c598f18a39fe7b2c0ad273f Mon Sep 17 00:00:00 2001 From: christos Date: Sun, 30 Jan 2005 23:59:57 +0000 Subject: [PATCH] Don't try to map a 0 size bss. --- sys/compat/common/compat_exec.c | 11 ++++++----- sys/compat/linux/common/linux_exec_aout.c | 18 ++++++++++-------- sys/compat/m68k4k/m68k4k_exec.c | 11 ++++++----- sys/compat/pecoff/pecoff_exec.c | 11 ++++++----- sys/compat/sunos/sunos_exec_aout.c | 11 ++++++----- 5 files changed, 34 insertions(+), 28 deletions(-) diff --git a/sys/compat/common/compat_exec.c b/sys/compat/common/compat_exec.c index 90acc9c12b9f..0359443751cc 100644 --- a/sys/compat/common/compat_exec.c +++ b/sys/compat/common/compat_exec.c @@ -1,4 +1,4 @@ -/* $NetBSD: compat_exec.c,v 1.11 2003/11/19 15:48:21 christos Exp $ */ +/* $NetBSD: compat_exec.c,v 1.12 2005/01/30 23:59:57 christos Exp $ */ /* * Copyright (c) 1993, 1994 Christopher G. Demetriou @@ -31,7 +31,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: compat_exec.c,v 1.11 2003/11/19 15:48:21 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: compat_exec.c,v 1.12 2005/01/30 23:59:57 christos Exp $"); #include #include @@ -79,9 +79,10 @@ exec_aout_prep_oldzmagic(p, epp) VM_PROT_READ|VM_PROT_WRITE|VM_PROT_EXECUTE); /* set up command for bss segment */ - NEW_VMCMD(&epp->ep_vmcmds, vmcmd_map_zero, execp->a_bss, - epp->ep_daddr + execp->a_data, NULLVP, 0, - VM_PROT_READ|VM_PROT_WRITE|VM_PROT_EXECUTE); + if (execp->a_bss) + NEW_VMCMD(&epp->ep_vmcmds, vmcmd_map_zero, execp->a_bss, + epp->ep_daddr + execp->a_data, NULLVP, 0, + VM_PROT_READ|VM_PROT_WRITE|VM_PROT_EXECUTE); return (*epp->ep_esch->es_setup_stack)(p, epp); } diff --git a/sys/compat/linux/common/linux_exec_aout.c b/sys/compat/linux/common/linux_exec_aout.c index 6ba625da3998..72e9734b8dbb 100644 --- a/sys/compat/linux/common/linux_exec_aout.c +++ b/sys/compat/linux/common/linux_exec_aout.c @@ -1,4 +1,4 @@ -/* $NetBSD: linux_exec_aout.c,v 1.55 2003/08/08 18:57:06 christos Exp $ */ +/* $NetBSD: linux_exec_aout.c,v 1.56 2005/01/30 23:59:57 christos Exp $ */ /*- * Copyright (c) 1995, 1998 The NetBSD Foundation, Inc. @@ -41,7 +41,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: linux_exec_aout.c,v 1.55 2003/08/08 18:57:06 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: linux_exec_aout.c,v 1.56 2005/01/30 23:59:57 christos Exp $"); #include #include @@ -201,9 +201,10 @@ exec_linux_aout_prep_zmagic(p, epp) VM_PROT_READ|VM_PROT_WRITE|VM_PROT_EXECUTE); /* set up command for bss segment */ - NEW_VMCMD(&epp->ep_vmcmds, vmcmd_map_zero, execp->a_bss, - epp->ep_daddr + execp->a_data, NULLVP, 0, - VM_PROT_READ|VM_PROT_WRITE|VM_PROT_EXECUTE); + if (execp->a_bss) + NEW_VMCMD(&epp->ep_vmcmds, vmcmd_map_zero, execp->a_bss, + epp->ep_daddr + execp->a_data, NULLVP, 0, + VM_PROT_READ|VM_PROT_WRITE|VM_PROT_EXECUTE); return (*epp->ep_esch->es_setup_stack)(p, epp); } @@ -321,9 +322,10 @@ exec_linux_aout_prep_qmagic(p, epp) VM_PROT_READ|VM_PROT_WRITE|VM_PROT_EXECUTE); /* set up command for bss segment */ - NEW_VMCMD(&epp->ep_vmcmds, vmcmd_map_zero, execp->a_bss, - epp->ep_daddr + execp->a_data, NULLVP, 0, - VM_PROT_READ|VM_PROT_WRITE|VM_PROT_EXECUTE); + if (execp->a_bss) + NEW_VMCMD(&epp->ep_vmcmds, vmcmd_map_zero, execp->a_bss, + epp->ep_daddr + execp->a_data, NULLVP, 0, + VM_PROT_READ|VM_PROT_WRITE|VM_PROT_EXECUTE); return (*epp->ep_esch->es_setup_stack)(p, epp); } diff --git a/sys/compat/m68k4k/m68k4k_exec.c b/sys/compat/m68k4k/m68k4k_exec.c index 77a99590baf6..e37927e2561f 100644 --- a/sys/compat/m68k4k/m68k4k_exec.c +++ b/sys/compat/m68k4k/m68k4k_exec.c @@ -1,4 +1,4 @@ -/* $NetBSD: m68k4k_exec.c,v 1.14 2003/08/08 18:57:06 christos Exp $ */ +/* $NetBSD: m68k4k_exec.c,v 1.15 2005/01/30 23:59:58 christos Exp $ */ /* * Copyright (c) 1993, 1994 Christopher G. Demetriou @@ -41,7 +41,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: m68k4k_exec.c,v 1.14 2003/08/08 18:57:06 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: m68k4k_exec.c,v 1.15 2005/01/30 23:59:58 christos Exp $"); #if !defined(__m68k__) #error YOU GOTTA BE KIDDING! @@ -155,9 +155,10 @@ exec_m68k4k_prep_zmagic(p, epp) VM_PROT_READ|VM_PROT_WRITE|VM_PROT_EXECUTE); /* set up command for bss segment */ - NEW_VMCMD(&epp->ep_vmcmds, vmcmd_map_zero, execp->a_bss, - epp->ep_daddr + execp->a_data, NULLVP, 0, - VM_PROT_READ|VM_PROT_WRITE|VM_PROT_EXECUTE); + if (execp->a_bss) + NEW_VMCMD(&epp->ep_vmcmds, vmcmd_map_zero, execp->a_bss, + epp->ep_daddr + execp->a_data, NULLVP, 0, + VM_PROT_READ|VM_PROT_WRITE|VM_PROT_EXECUTE); return (*epp->ep_esch->es_setup_stack)(p, epp); } diff --git a/sys/compat/pecoff/pecoff_exec.c b/sys/compat/pecoff/pecoff_exec.c index ef97528c99bf..a8cc42e98059 100644 --- a/sys/compat/pecoff/pecoff_exec.c +++ b/sys/compat/pecoff/pecoff_exec.c @@ -1,4 +1,4 @@ -/* $NetBSD: pecoff_exec.c,v 1.25 2004/07/18 04:36:42 kent Exp $ */ +/* $NetBSD: pecoff_exec.c,v 1.26 2005/01/30 23:59:58 christos Exp $ */ /* * Copyright (c) 2000 Masaru OKI @@ -37,7 +37,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: pecoff_exec.c,v 1.25 2004/07/18 04:36:42 kent Exp $"); +__KERNEL_RCSID(0, "$NetBSD: pecoff_exec.c,v 1.26 2005/01/30 23:59:58 christos Exp $"); /*#define DEBUG_PECOFF*/ @@ -483,9 +483,10 @@ exec_pecoff_prep_zmagic(p, epp, fp, ap, peofs) /* set up command for bss segment */ baddr = sh[i].s_vaddr; bsize = sh[i].s_paddr; - NEW_VMCMD(&epp->ep_vmcmds, vmcmd_map_zero, - bsize, baddr, NULLVP, 0, - VM_PROT_READ|VM_PROT_WRITE|VM_PROT_EXECUTE); + if (bsize) + NEW_VMCMD(&epp->ep_vmcmds, vmcmd_map_zero, + bsize, baddr, NULLVP, 0, + VM_PROT_READ|VM_PROT_WRITE|VM_PROT_EXECUTE); epp->ep_daddr = min(epp->ep_daddr, baddr); bsize = baddr + bsize - epp->ep_daddr; epp->ep_dsize = max(epp->ep_dsize, bsize); diff --git a/sys/compat/sunos/sunos_exec_aout.c b/sys/compat/sunos/sunos_exec_aout.c index c13349d65a44..a34626e56802 100644 --- a/sys/compat/sunos/sunos_exec_aout.c +++ b/sys/compat/sunos/sunos_exec_aout.c @@ -1,4 +1,4 @@ -/* $NetBSD: sunos_exec_aout.c,v 1.11 2003/08/08 18:57:07 christos Exp $ */ +/* $NetBSD: sunos_exec_aout.c,v 1.12 2005/01/30 23:59:58 christos Exp $ */ /* * Copyright (c) 1993 Theo de Raadt @@ -28,7 +28,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: sunos_exec_aout.c,v 1.11 2003/08/08 18:57:07 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: sunos_exec_aout.c,v 1.12 2005/01/30 23:59:58 christos Exp $"); #include #include @@ -143,9 +143,10 @@ sunos_exec_aout_prep_zmagic(p, epp) VM_PROT_READ|VM_PROT_WRITE|VM_PROT_EXECUTE); /* set up command for bss segment */ - NEW_VMCMD(&epp->ep_vmcmds, vmcmd_map_zero, execp->a_bss, - epp->ep_daddr + execp->a_data, NULLVP, 0, - VM_PROT_READ|VM_PROT_WRITE|VM_PROT_EXECUTE); + if (execp->a_bss) + NEW_VMCMD(&epp->ep_vmcmds, vmcmd_map_zero, execp->a_bss, + epp->ep_daddr + execp->a_data, NULLVP, 0, + VM_PROT_READ|VM_PROT_WRITE|VM_PROT_EXECUTE); return (*epp->ep_esch->es_setup_stack)(p, epp); }