Browse Source

minor changes

Chia-Che Tsai 8 years ago
parent
commit
3f80ead12c

File diff suppressed because it is too large
+ 0 - 0
LibOS/shim/src/.packed/shim.sha384


BIN
LibOS/shim/src/.packed/shim.tar.gz


+ 3 - 3
LibOS/shim/src/bookkeep/shim_vma.c

@@ -230,7 +230,7 @@ static int __bkeep_mmap (void * addr, int length,
     struct shim_vma * tmp = __lookup_supervma(addr, length, &prev);
     int ret = 0;
 
-    debug("bkeep_mmap: %p - %p\n", addr, addr + length);
+    debug("bkeep_mmap: %p-%p\n", addr, addr + length);
 
     if (file)
         get_handle(file);
@@ -351,7 +351,7 @@ static int __bkeep_munmap (void * addr, int length, const int * flags)
 {
     struct shim_vma * tmp, * n;
 
-    debug("bkeep_unmmap: %p - %p\n", addr, addr + length);
+    debug("bkeep_unmmap: %p-%p\n", addr, addr + length);
 
     list_for_each_entry_safe(tmp, n, &vma_list, list) {
         if (test_vma_equal (tmp, addr, length)) {
@@ -438,7 +438,7 @@ static int __bkeep_mprotect (void * addr, int length, int prot,
     struct shim_vma * tmp = __lookup_vma(addr, length);
     int ret;
 
-    debug("bkeep_mprotect: %p - %p\n", addr, addr + length);
+    debug("bkeep_mprotect: %p-%p\n", addr, addr + length);
 
     if (tmp) {
         /* exact match */

+ 32 - 14
LibOS/shim/src/shim_init.c

@@ -143,13 +143,20 @@ unsigned long parse_int (const char * str)
     return num;
 }
 
-long int * glibc_option (const char * opt)
+long int glibc_option (const char * opt)
 {
     char cfg[CONFIG_MAX];
 
     if (!memcmp(opt, "heap_size", 9)) {
-        return get_config(root_config, "glibc.heap_size", cfg, CONFIG_MAX) < 0 ?
-            -ENOENT : parse_int(cfg);
+        int ret = get_config(root_config, "glibc.heap_size", cfg, CONFIG_MAX);
+        if (ret < 0) {
+            debug("no glibc option: %s (err=%d)\n", opt, ret);
+            return -ENOENT;
+        }
+
+        long int heap_size = parse_int(cfg);
+        debug("glibc option: heap_size = %ld\n", heap_size);
+        return (long int) heap_size;
     }
 
     return -EINVAL;
@@ -440,22 +447,33 @@ static void __free (void * mem)
 
 int init_manifest (PAL_HANDLE manifest_handle)
 {
-    PAL_STREAM_ATTR attr;
+    void * addr;
+    unsigned int size;
 
-    if (!DkStreamAttributesQuerybyHandle(manifest_handle, &attr))
-        return -PAL_ERRNO;
+    if (PAL_CB(manifest_preload.start)) {
+        addr = PAL_CB(manifest_preload.start);
+        size = PAL_CB(manifest_preload.end) - PAL_CB(manifest_preload.start);
+    } else {
+        PAL_STREAM_ATTR attr;
+        if (!DkStreamAttributesQuerybyHandle(manifest_handle, &attr))
+            return -PAL_ERRNO;
 
-    size_t cfg_size = attr.pending_size;
-    void * cfg_addr = (void *) DkStreamMap(manifest_handle, NULL,
-                                  PAL_PROT_READ|PAL_PROT_WRITECOPY, 0,
-                                  ALIGN_UP(cfg_size));
+        size = attr.pending_size;
+        addr = (void *) DkStreamMap(manifest_handle, NULL,
+                                  PAL_PROT_READ, 0,
+                                  ALIGN_UP(size));
 
-    if (!cfg_addr)
-        return -PAL_ERRNO;
+        if (!addr)
+            return -PAL_ERRNO;
+    }
+
+    bkeep_mmap(addr, ALIGN_UP(size), PROT_READ,
+               MAP_PRIVATE|MAP_ANONYMOUS|VMA_INTERNAL, NULL, 0,
+               "[manifest]");
 
     root_config = malloc(sizeof(struct config_store));
-    root_config->raw_data = cfg_addr;
-    root_config->raw_size = cfg_size;
+    root_config->raw_data = addr;
+    root_config->raw_size = size;
     root_config->malloc = __malloc;
     root_config->free = __free;
 

+ 1 - 1
Pal/src/db_main.c

@@ -354,7 +354,7 @@ void pal_main (PAL_NUM pal_token, void * pal_addr,
     }
 
     /* load manifest if there is one */
-    if (manifest_handle) {
+    if (manifest_handle && !pal_state.root_config) {
 #if PROFILING == 1
         unsigned long before_load_manifest = _DkSystemTimeQuery();
 #endif

+ 2 - 0
Pal/src/pal.h

@@ -140,6 +140,8 @@ typedef struct {
     PAL_PTR_RANGE user_address;
     /* address where executable is loaded */
     PAL_PTR_RANGE executable_range;
+    /* manifest preloaded here */
+    PAL_PTR_RANGE manifest_preload;
 
     /***** Host information *****/
     /* host page size / allocation alignment */

Some files were not shown because too many files changed in this diff