Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/kern Remove the 'prot' argument from elf_load_psection()...



details:   https://anonhg.NetBSD.org/src/rev/ce026e0a99a8
branches:  trunk
changeset: 327750:ce026e0a99a8
user:      maxv <maxv%NetBSD.org@localhost>
date:      Sun Mar 16 07:57:25 2014 +0000

description:
Remove the 'prot' argument from elf_load_psection(). It is not used
outside, and can be declared locally. Clearer.

ok christos@

diffstat:

 sys/kern/exec_elf.c |  27 +++++++++++++--------------
 1 files changed, 13 insertions(+), 14 deletions(-)

diffs (108 lines):

diff -r afbf971cd423 -r ce026e0a99a8 sys/kern/exec_elf.c
--- a/sys/kern/exec_elf.c       Sun Mar 16 06:51:43 2014 +0000
+++ b/sys/kern/exec_elf.c       Sun Mar 16 07:57:25 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: exec_elf.c,v 1.63 2014/03/06 09:30:37 matt Exp $       */
+/*     $NetBSD: exec_elf.c,v 1.64 2014/03/16 07:57:25 maxv Exp $       */
 
 /*-
  * Copyright (c) 1994, 2000, 2005 The NetBSD Foundation, Inc.
@@ -57,7 +57,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(1, "$NetBSD: exec_elf.c,v 1.63 2014/03/06 09:30:37 matt Exp $");
+__KERNEL_RCSID(1, "$NetBSD: exec_elf.c,v 1.64 2014/03/16 07:57:25 maxv Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_pax.h"
@@ -103,7 +103,7 @@
     struct exec_vmcmd_set *, u_long *, Elf_Addr *);
 static void
 elf_load_psection(struct exec_vmcmd_set *, struct vnode *, const Elf_Phdr *,
-    Elf_Addr *, u_long *, int *, int);
+    Elf_Addr *, u_long *, int);
 
 int    netbsd_elf_signature(struct lwp *, struct exec_package *, Elf_Ehdr *);
 int    netbsd_elf_probe(struct lwp *, struct exec_package *, void *, char *,
@@ -317,10 +317,11 @@
  */
 static void
 elf_load_psection(struct exec_vmcmd_set *vcset, struct vnode *vp,
-    const Elf_Phdr *ph, Elf_Addr *addr, u_long *size, int *prot, int flags)
+    const Elf_Phdr *ph, Elf_Addr *addr, u_long *size, int flags)
 {
        u_long msize, psize, rm, rf;
        long diff, offset;
+       int vmprot = 0;
 
        /*
         * If the user specified an address, then we load there.
@@ -342,9 +343,9 @@
        } else
                diff = 0;
 
-       *prot |= (ph->p_flags & PF_R) ? VM_PROT_READ : 0;
-       *prot |= (ph->p_flags & PF_W) ? VM_PROT_WRITE : 0;
-       *prot |= (ph->p_flags & PF_X) ? VM_PROT_EXECUTE : 0;
+       vmprot |= (ph->p_flags & PF_R) ? VM_PROT_READ : 0;
+       vmprot |= (ph->p_flags & PF_W) ? VM_PROT_WRITE : 0;
+       vmprot |= (ph->p_flags & PF_X) ? VM_PROT_EXECUTE : 0;
 
        /*
         * Adjust everything so it all starts on a page boundary.
@@ -372,12 +373,12 @@
        if (psize > 0) {
                NEW_VMCMD2(vcset, ph->p_align < PAGE_SIZE ?
                    vmcmd_map_readvn : vmcmd_map_pagedvn, psize, *addr, vp,
-                   offset, *prot, flags);
+                   offset, vmprot, flags);
                flags &= VMCMD_RELATIVE;
        }
        if (psize < *size) {
                NEW_VMCMD2(vcset, vmcmd_map_readvn, *size - psize,
-                   *addr + psize, vp, offset + psize, *prot, flags);
+                   *addr + psize, vp, offset + psize, vmprot, flags);
        }
 
        /*
@@ -389,7 +390,7 @@
 
        if (rm != rf) {
                NEW_VMCMD2(vcset, vmcmd_map_zero, rm - rf, rf, NULLVP,
-                   0, *prot, flags & VMCMD_RELATIVE);
+                   0, vmprot, flags & VMCMD_RELATIVE);
                *size = msize;
        }
 }
@@ -556,7 +557,6 @@
                switch (ph[i].p_type) {
                case PT_LOAD: {
                        u_long size;
-                       int prot = 0;
                        int flags;
 
                        if (base_ph == NULL) {
@@ -596,7 +596,7 @@
                        }
                        last_ph = &ph[i];
                        elf_load_psection(vcset, vp, &ph[i], &addr,
-                           &size, &prot, flags);
+                           &size, flags);
                        /*
                         * If entry is within this psection then this
                         * must contain the .text section.  *entryoff is
@@ -749,12 +749,11 @@
        for (i = 0; i < eh->e_phnum; i++) {
                Elf_Addr addr = ELFDEFNNAME(NO_ADDR);
                u_long size = 0;
-               int prot = 0;
 
                switch (ph[i].p_type) {
                case PT_LOAD:
                        elf_load_psection(&epp->ep_vmcmds, epp->ep_vp,
-                           &ph[i], &addr, &size, &prot, VMCMD_FIXED);
+                           &ph[i], &addr, &size, VMCMD_FIXED);
 
                        /*
                         * Consider this as text segment, if it is executable.



Home | Main Index | Thread Index | Old Index