[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 15/16] exec: keep track of the range where executable segments ar
From: |
Justus Winter |
Subject: |
[PATCH 15/16] exec: keep track of the range where executable segments are mapped |
Date: |
Mon, 5 Aug 2013 12:06:39 +0200 |
Keep track of the range where executable segments are mapped into
memory and hand that information over to the proc server.
* exec/priv.h (struct execdata): Add {start,end}_code.
* exec/exec.c (prepare): Initialize {start,end}_code.
(load_section): Update {start,end}_code.
(do_exec): Use proc_set_code to hand {start,end}_code to the proc server.
---
exec/exec.c | 23 +++++++++++++++++++++++
exec/priv.h | 4 ++++
2 files changed, 27 insertions(+)
diff --git a/exec/exec.c b/exec/exec.c
index 30a5e00..de796f9 100644
--- a/exec/exec.c
+++ b/exec/exec.c
@@ -289,6 +289,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
@@ -732,6 +743,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);
@@ -1851,6 +1865,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 dbecb7a..61c0e72 100644
--- a/exec/priv.h
+++ b/exec/priv.h
@@ -88,6 +88,10 @@ struct execdata
vm_address_t entry;
file_t file;
+ /* Set by load_section. */
+ vm_address_t start_code;
+ vm_address_t end_code;
+
#ifndef EXECDATA_STREAM
/* Note that if `file_data' (below) is set, then these just point
--
1.7.10.4
- [PATCH 05/16] proc: add proc_mark_important server code, (continued)
- [PATCH 05/16] proc: add proc_mark_important server code, Justus Winter, 2013/08/05
- [PATCH 06/16] hurd: add proc_mark_important, Justus Winter, 2013/08/05
- [PATCH 07/16] init: Mark all of inits children and init itself as important, Justus Winter, 2013/08/05
- [PATCH 08/16] libdiskfs: register libdiskfs-based translators as important, Justus Winter, 2013/08/05
- [PATCH 09/16] libnetfs: register libnetfs-based translators as important, Justus Winter, 2013/08/05
- [PATCH 10/16] libtrivfs: register libtrivfs-based translators as important, Justus Winter, 2013/08/05
- [PATCH 11/16] mach-defpager: register mach-defpager translators as important, Justus Winter, 2013/08/05
- [PATCH 12/16] trans: register symlink translators as important, Justus Winter, 2013/08/05
- [PATCH 13/16] proc: keep track of {start,end}_code, Justus Winter, 2013/08/05
- [PATCH 14/16] hurd: add proc_{get,set}_code, Justus Winter, 2013/08/05
- [PATCH 15/16] exec: keep track of the range where executable segments are mapped,
Justus Winter <=
- [PATCH 16/16] Build fixes: Build processUser.o and link against it, Justus Winter, 2013/08/05
- [PATCH] Make start_code and end_code available in /proc/*/stat, Justus Winter, 2013/08/05
Make sysvinit pid 1, fix killall5 (2), Justus Winter, 2013/08/15