summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--exec/exec.c23
-rw-r--r--exec/priv.h4
2 files changed, 27 insertions, 0 deletions
diff --git a/exec/exec.c b/exec/exec.c
index f139792b..6eb81c8a 100644
--- a/exec/exec.c
+++ b/exec/exec.c
@@ -207,6 +207,17 @@ load_section (void *section, struct execdata *u)
}
}
+ /* If this segment is executable, adjust start_code and end_code
+ so that this mapping is within that range. */
+ if (vm_prot & VM_PROT_EXECUTE)
+ {
+ if (u->start_code == 0 || u->start_code > addr)
+ u->start_code = addr;
+
+ if (u->end_code < addr + memsz)
+ u->end_code = addr + memsz;
+ }
+
if (mapstart > addr)
{
/* We must read and copy in the space in the section before the
@@ -445,6 +456,9 @@ prepare (file_t file, struct execdata *e)
e->interp.section = NULL;
+ e->start_code = 0;
+ e->end_code = 0;
+
/* Initialize E's stdio stream. */
prepare_stream (e);
@@ -1399,6 +1413,15 @@ do_exec (file_t file,
}
boot->user_entry = e.entry; /* already adjusted in `load' */
+ /* Set the start_code and end_code values for this process.
+ /hurd/exec is used to start /hurd/proc, so at this point there is
+ no proc server, so we need to be careful here. */
+ if (boot->portarray[INIT_PORT_PROC] != MACH_PORT_NULL)
+ e.error = proc_set_code (boot->portarray[INIT_PORT_PROC],
+ e.start_code, e.end_code);
+ if (e.error)
+ goto out;
+
/* Create the initial thread. */
e.error = thread_create (newtask, &thread);
if (e.error)
diff --git a/exec/priv.h b/exec/priv.h
index b9c6e990..85e03aee 100644
--- a/exec/priv.h
+++ b/exec/priv.h
@@ -73,6 +73,10 @@ struct execdata
vm_address_t entry;
file_t file;
+ /* Set by load_section. */
+ vm_address_t start_code;
+ vm_address_t end_code;
+
/* Note that if `file_data' (below) is set, then these just point
into that and should not be deallocated (file_data is malloc'd). */
char *map_buffer; /* Our mapping window or read buffer. */