bug-hurd
[Top][All Lists]
Advanced

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

[PATCH gnumach] XXX


From: Justus Winter
Subject: [PATCH gnumach] XXX
Date: Mon, 2 Feb 2015 12:26:51 +0100

---
 kern/bootstrap.c | 36 ++++++++++++++++++++++++++++++------
 1 file changed, 30 insertions(+), 6 deletions(-)

diff --git a/kern/bootstrap.c b/kern/bootstrap.c
index 4edae7b..9c2eb87 100644
--- a/kern/bootstrap.c
+++ b/kern/bootstrap.c
@@ -35,6 +35,7 @@
 
 #include <mach/port.h>
 #include <mach/message.h>
+#include <mach/exec/elf.h>
 #include <machine/locore.h>
 #include <machine/vm_param.h>
 #include <machine/pcb.h>
@@ -422,23 +423,19 @@ boot_read(void *handle, vm_offset_t file_ofs, void *buf, 
vm_size_t size,
 }
 
 static int
-read_exec(void *handle, vm_offset_t file_ofs, vm_size_t file_size,
+read_in(void *handle, vm_offset_t file_ofs, vm_size_t file_size,
                     vm_offset_t mem_addr, vm_size_t mem_size,
-                    exec_sectype_t sec_type)
+                    vm_prot_t mem_prot)
 {
   struct multiboot_module *mod = handle;
 
        vm_map_t user_map = current_task()->map;
        vm_offset_t start_page, end_page;
-       vm_prot_t mem_prot = sec_type & EXEC_SECTYPE_PROT_MASK;
        int err;
 
        if (mod->mod_start + file_ofs + file_size > mod->mod_end)
          return -1;
 
-       if (!(sec_type & EXEC_SECTYPE_ALLOC))
-               return 0;
-
        assert(mem_size > 0);
        assert(mem_size >= file_size);
 
@@ -470,6 +467,19 @@ read_exec(void *handle, vm_offset_t file_ofs, vm_size_t 
file_size,
        return 0;
 }
 
+static int
+read_exec(void *handle, vm_offset_t file_ofs, vm_size_t file_size,
+                    vm_offset_t mem_addr, vm_size_t mem_size,
+                    exec_sectype_t sec_type)
+{
+       if (!(sec_type & EXEC_SECTYPE_ALLOC))
+         return 0;
+
+       return read_in (handle, file_ofs, file_size,
+                       mem_addr, mem_size,
+                       sec_type & EXEC_SECTYPE_PROT_MASK);
+}
+
 static void copy_bootstrap(void *e, exec_info_t *boot_exec_info)
 {
        //register vm_map_t     user_map = current_task()->map;
@@ -746,9 +756,20 @@ static void user_bootstrap(void)
   exec_info_t boot_exec_info;
   int err;
   char **av;
+  boolean_t executable = TRUE;
 
   /* Load this task up from the executable file in the module.  */
   err = exec_load(boot_read, read_exec, info->mod, &boot_exec_info);
+  if (err == EX_NOT_EXECUTABLE)
+    {
+      struct multiboot_module *mod = info->mod;
+      printf("reading %d bytes into map %p\n", mod->mod_end - mod->mod_start, 
current_task()->map);
+      err = read_in (mod,
+                    0, mod->mod_end - mod->mod_start,
+                    0, mod->mod_end - mod->mod_start,
+                    VM_PROT_READ);
+      executable = FALSE;
+    }
   if (err)
     panic ("Cannot load user executable module (error code %d): %s",
           err, info->argv[0]);
@@ -770,6 +791,9 @@ static void user_bootstrap(void)
   info->done = 1;
   thread_wakeup ((event_t) info);
 
+  if (! executable)
+    thread_terminate (current_thread ());
+
   /*
    * Exit to user thread.
    */
-- 
2.1.4




reply via email to

[Prev in Thread] Current Thread [Next in Thread]