summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Bushnell <thomas@gnu.org>1999-07-11 05:27:17 +0000
committerThomas Bushnell <thomas@gnu.org>1999-07-11 05:27:17 +0000
commit601c2121002d89a651d94038483f0aae82ebb924 (patch)
tree12d17347585074f25d70dedcba9855e7ccd98ca0
parent1fbf419e91c882f1098677bcd191ef792a2fa43e (diff)
1999-07-06 Thomas Bushnell, BSG <tb@mit.edu>
* exec.c (load_section): Use mmap instead of vm_allocate when allocating in mach_task_self (). (servercopy): Likewise. (do_exec): Likewise. * hashexec.c (check_hashbang): Likewise.
-rw-r--r--exec/ChangeLog8
-rw-r--r--exec/exec.c35
-rw-r--r--exec/hashexec.c14
3 files changed, 35 insertions, 22 deletions
diff --git a/exec/ChangeLog b/exec/ChangeLog
index 9bfbb274..d3c4c03e 100644
--- a/exec/ChangeLog
+++ b/exec/ChangeLog
@@ -18,6 +18,14 @@
* priv.h: Add #include <sys/mman.h> for munmap decl.
+1999-07-06 Thomas Bushnell, BSG <tb@mit.edu>
+
+ * exec.c (load_section): Use mmap instead of vm_allocate when
+ allocating in mach_task_self ().
+ (servercopy): Likewise.
+ (do_exec): Likewise.
+ * hashexec.c (check_hashbang): Likewise.
+
1999-07-03 Thomas Bushnell, BSG <tb@mit.edu>
* core.c (core_dump_task): Use munmap instead of vm_deallocate,
diff --git a/exec/exec.c b/exec/exec.c
index 6cfb8a70..d70083a3 100644
--- a/exec/exec.c
+++ b/exec/exec.c
@@ -224,8 +224,10 @@ load_section (void *section, struct execdata *u)
if (! u->error && off != 0)
{
vm_address_t page = 0;
- u->error = vm_allocate (mach_task_self (),
- &page, vm_page_size, 1);
+ page = (vm_address_t) mmap (0, vm_page_size,
+ PROT_READ|PROT_WRITE, MAP_ANON,
+ 0, 0);
+ u->error = (page == -1) ? errno : 0;
if (! u->error)
{
memcpy ((void *) page,
@@ -268,8 +270,8 @@ load_section (void *section, struct execdata *u)
it into the task. */
void *buf;
const vm_size_t size = filesz - (mapstart - addr);
- u->error = vm_allocate (mach_task_self (),
- (vm_address_t *) &buf, size, 1);
+ buf = mmap (0, size, PROT_READ|PROT_WRITE, MAP_ANON, 0, 0);
+ u->error = (buf == (caddr_t) -1) ? errno : 0;
if (! u->error)
{
if (fseek (&u->stream,
@@ -318,8 +320,11 @@ load_section (void *section, struct execdata *u)
&overlap_page, vm_page_size, 0);
size = vm_page_size;
if (!u->error)
- u->error = vm_allocate (mach_task_self (),
- &ourpage, vm_page_size, 1);
+ {
+ ourpage = (vm_address_t) mmap (0, vm_page_size,
+ PROT_READ|PROT_WRITE,
+ MAP_ANON, 0, 0);
+ u->error = (ourpage == -1) ? errno : 0;
}
if (u->error)
{
@@ -1141,10 +1146,9 @@ servercopy (void **arg, mach_msg_type_number_t argsize, boolean_t argcopy)
/* ARG came in-line, so we must copy it. */
error_t error;
void *copy;
- error = vm_allocate (mach_task_self (),
- (vm_address_t *) &copy, argsize, 1);
- if (error)
- return error;
+ copy = mmap (0, argsize, PROT_READ|PROT_WRITE, MAP_ANON, 0, 0);
+ if (copy == (void *) -1)
+ return errno;
bcopy (*arg, copy, argsize);
*arg = copy;
}
@@ -1388,10 +1392,8 @@ do_exec (file_t file,
round_page (INIT_INT_MAX * sizeof (int))))
{
/* Allocate a new vector that is big enough. */
- vm_allocate (mach_task_self (),
- (vm_address_t *) &boot->intarray,
- INIT_INT_MAX * sizeof (int),
- 1);
+ boot->intarray = mmap (0, INIT_INT_MAX * sizeof (int),
+ PROT_READ|PROT_WRITE, MAP_ANON, 0, 0);
memcpy (boot->intarray, intarray, nints * sizeof (int));
intarray_dealloc = !intarray_copy;
}
@@ -1415,9 +1417,8 @@ do_exec (file_t file,
/* Now choose the ports to give the new program. */
boot->nports = nports < INIT_PORT_MAX ? INIT_PORT_MAX : nports;
- vm_allocate (mach_task_self (),
- (vm_address_t *) &boot->portarray,
- boot->nports * sizeof (mach_port_t), 1);
+ boot->portarray = mmap (0, boot->nports * sizeof (mach_port_t),
+ PROT_READ|PROT_WRITE, MAP_ANON, 0, 0);
/* Start by copying the array as passed. */
for (i = 0; i < nports; ++i)
boot->portarray[i] = portarray[i];
diff --git a/exec/hashexec.c b/exec/hashexec.c
index dabd7c00..03981da4 100644
--- a/exec/hashexec.c
+++ b/exec/hashexec.c
@@ -318,11 +318,15 @@ check_hashbang (struct execdata *e,
= (argvlen - strlen (argv) - 1) /* existing args - old argv[0] */
+ interp_len + len + namelen; /* New args */
- e->error = vm_allocate (mach_task_self (),
- (vm_address_t *) &new_argv,
- new_argvlen, 1);
- if (e->error)
- return e->error;
+ new_argv = mmap (0, new_argvlen, PROT_READ|PROT_WRITE,
+ MAP_ANON, 0, 0);
+ if (new_argv == (caddr_t) -1)
+ {
+ e->error = errno;
+ return e->error;
+ }
+ else
+ e->error = 0;
if (! setjmp (args_faulted))
{