Thu Oct 7 02:14:02 2010 UTC ()
when we use a fake data section, make sure that the start is page-aligned.


(chs)
diff -r1.26 -r1.27 src/sys/kern/exec_elf.c

cvs diff -r1.26 -r1.27 src/sys/kern/exec_elf.c (expand / switch to unified diff)

--- src/sys/kern/exec_elf.c 2010/09/11 20:49:28 1.26
+++ src/sys/kern/exec_elf.c 2010/10/07 02:14:02 1.27
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: exec_elf.c,v 1.26 2010/09/11 20:49:28 chs Exp $ */ 1/* $NetBSD: exec_elf.c,v 1.27 2010/10/07 02:14:02 chs Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 1994, 2000, 2005 The NetBSD Foundation, Inc. 4 * Copyright (c) 1994, 2000, 2005 The NetBSD Foundation, Inc.
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * This code is derived from software contributed to The NetBSD Foundation 7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Christos Zoulas. 8 * by Christos Zoulas.
9 * 9 *
10 * Redistribution and use in source and binary forms, with or without 10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions 11 * modification, are permitted provided that the following conditions
12 * are met: 12 * are met:
13 * 1. Redistributions of source code must retain the above copyright 13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer. 14 * notice, this list of conditions and the following disclaimer.
@@ -47,27 +47,27 @@ @@ -47,27 +47,27 @@
47 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 47 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
48 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 48 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
49 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 49 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
50 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 50 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
51 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 51 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
52 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 52 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
53 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 53 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
54 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 54 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
55 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 55 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
56 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 56 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
57 */ 57 */
58 58
59#include <sys/cdefs.h> 59#include <sys/cdefs.h>
60__KERNEL_RCSID(1, "$NetBSD: exec_elf.c,v 1.26 2010/09/11 20:49:28 chs Exp $"); 60__KERNEL_RCSID(1, "$NetBSD: exec_elf.c,v 1.27 2010/10/07 02:14:02 chs Exp $");
61 61
62#ifdef _KERNEL_OPT 62#ifdef _KERNEL_OPT
63#include "opt_pax.h" 63#include "opt_pax.h"
64#endif /* _KERNEL_OPT */ 64#endif /* _KERNEL_OPT */
65 65
66#include <sys/param.h> 66#include <sys/param.h>
67#include <sys/proc.h> 67#include <sys/proc.h>
68#include <sys/malloc.h> 68#include <sys/malloc.h>
69#include <sys/kmem.h> 69#include <sys/kmem.h>
70#include <sys/namei.h> 70#include <sys/namei.h>
71#include <sys/vnode.h> 71#include <sys/vnode.h>
72#include <sys/exec.h> 72#include <sys/exec.h>
73#include <sys/exec_elf.h> 73#include <sys/exec_elf.h>
@@ -771,27 +771,27 @@ exec_elf_makecmds(struct lwp *l, struct  @@ -771,27 +771,27 @@ exec_elf_makecmds(struct lwp *l, struct
771 default: 771 default:
772 /* 772 /*
773 * Not fatal; we don't need to understand everything. 773 * Not fatal; we don't need to understand everything.
774 */ 774 */
775 break; 775 break;
776 } 776 }
777 } 777 }
778 if (interp || (epp->ep_flags & EXEC_FORCEAUX) != 0) { 778 if (interp || (epp->ep_flags & EXEC_FORCEAUX) != 0) {
779 ap = malloc(sizeof(struct elf_args), M_TEMP, M_WAITOK); 779 ap = malloc(sizeof(struct elf_args), M_TEMP, M_WAITOK);
780 ap->arg_interp = (vaddr_t)NULL; 780 ap->arg_interp = (vaddr_t)NULL;
781 } 781 }
782 782
783 if (epp->ep_daddr == ELFDEFNNAME(NO_ADDR)) { 783 if (epp->ep_daddr == ELFDEFNNAME(NO_ADDR)) {
784 epp->ep_daddr = end_text; 784 epp->ep_daddr = round_page(end_text);
785 epp->ep_dsize = 0; 785 epp->ep_dsize = 0;
786 } 786 }
787 787
788 /* 788 /*
789 * Check if we found a dynamically linked binary and arrange to load 789 * Check if we found a dynamically linked binary and arrange to load
790 * its interpreter 790 * its interpreter
791 */ 791 */
792 if (interp) { 792 if (interp) {
793 int j = epp->ep_vmcmds.evs_used; 793 int j = epp->ep_vmcmds.evs_used;
794 u_long interp_offset; 794 u_long interp_offset;
795 795
796 if ((error = elf_load_file(l, epp, interp, 796 if ((error = elf_load_file(l, epp, interp,
797 &epp->ep_vmcmds, &interp_offset, ap, &pos)) != 0) { 797 &epp->ep_vmcmds, &interp_offset, ap, &pos)) != 0) {