wrap munmap to prevent unwanted unmaps
[ginge.git] / loader / loader.c
index df50542..7e71d4d 100644 (file)
@@ -1,4 +1,9 @@
-// vim:shiftwidth=2:expandtab
+/*
+ * GINGE - GINGE Is Not Gp2x Emulator
+ * (C) notaz, 2010-2011
+ *
+ * This work is licensed under the MAME license, see COPYING file for details.
+ */
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
@@ -6,6 +11,7 @@
 #include <sys/mman.h>
 
 #include "header.h"
+#include "realfuncs.h"
 
 #define CHECK_(val, fail_operator, expect, err_msg) \
   if (val fail_operator expect) { \
@@ -73,7 +79,7 @@ int main(int argc, char *argv[])
 
   for (i = 0; i < ARRAY_SIZE(maps); i++) {
     ret = fscanf(fi, "%lx-%lx %*s %*s %*s %*s %*s\n", &maps[i].start, &maps[i].end);
-    if (ret == 0)
+    if (ret <= 0)
       break;
     CHECK_EQ(ret, 2, "maps parse error");
   }
@@ -124,7 +130,7 @@ int main(int argc, char *argv[])
       return 1;
     }
 
-    printf("load %d %08x-%08x from %08x\n", phdr[i].p_type,
+    log("load %d %08x-%08x from %08x\n", phdr[i].p_type,
       phdr[i].p_vaddr, end_addr, phdr[i].p_offset);
 
     align = phdr[i].p_vaddr & 0xfff;
@@ -169,10 +175,11 @@ int main(int argc, char *argv[])
     stack_frame[sfp++] = (long)environ[i];
   stack_frame[sfp++] = 0;
 
-  printf("entering %08x, %d stack entries\n", hdr.e_entry, sfp);
+  log("entering %08x, %d stack entries\n", hdr.e_entry, sfp);
   do_entry(hdr.e_entry, stack_frame, sfp, NULL);
 
   fprintf(stderr, "do_entry failed!\n");
   return 1;
 }
 
+// vim:shiftwidth=2:expandtab