[llvm-commits] [poolalloc] r132698 - /poolalloc/trunk/runtime/DynamicTypeChecks/TypeRuntime.c

Arushi Aggarwal aggarwa4 at illinois.edu
Mon Jun 6 17:08:40 PDT 2011


Author: aggarwa4
Date: Mon Jun  6 19:08:40 2011
New Revision: 132698

URL: http://llvm.org/viewvc/llvm-project?rev=132698&view=rev
Log:
1. Add a few asserts.
2. __ctype_b_loc and related functions in LLVM seem to 
use int** instead of short **. Fixes 197.parser errors.
3. Also, array returned by __ctype_b_loc can be accessed
with index -128 to 255.

Modified:
    poolalloc/trunk/runtime/DynamicTypeChecks/TypeRuntime.c

Modified: poolalloc/trunk/runtime/DynamicTypeChecks/TypeRuntime.c
URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/runtime/DynamicTypeChecks/TypeRuntime.c?rev=132698&r1=132697&r2=132698&view=diff
==============================================================================
--- poolalloc/trunk/runtime/DynamicTypeChecks/TypeRuntime.c (original)
+++ poolalloc/trunk/runtime/DynamicTypeChecks/TypeRuntime.c Mon Jun  6 19:08:40 2011
@@ -36,9 +36,15 @@
     fflush(stderr);
     assert(0 && "MAP_FAILED");
   }
+  assert(res < SIZE && "wrong mapped address");
   return res;
 }
 
+void trackStringInput(void *ptr, uint32_t tag) {
+  trackInitInst(ptr, strlen(ptr) + 1, tag);
+}
+
+
 /**
  * Initialize the shadow memory which records the 1:1 mapping of addresses to types.
  */
@@ -138,6 +144,7 @@
 void trackLoadInst(void *ptr, uint8_t typeNumber, uint64_t size, uint32_t tag) {
   uint8_t i = 1;
   uintptr_t p = maskAddress(ptr);
+  assert(p + size < SIZE);
 
   /* Check if this an initialized but untyped memory.*/
   if (typeNumber != shadow_begin[p]) {
@@ -164,10 +171,10 @@
       break;
     }
   }
-
 #if DEBUG
   printf("Load: %p, %p = actual: %u, expect: %u | %lu  bytes %d \n", ptr, (void *)p, typeNumber, shadow_begin[p], size, tag);
 #endif
+
 }
 
 /**
@@ -209,8 +216,11 @@
  * Initialize metadata for the pointer returned by __ctype_b_loc
  */
 void trackctype(void *ptr, uint32_t tag) {
-  trackInitInst(ptr, sizeof(short*), tag);
-  trackInitInst(*(short**)ptr, sizeof(short)*384, tag);
+  char *p, p1;
+  trackInitInst(ptr, sizeof(int*), tag);
+  p = *(int**)ptr;
+  p1 = p + (-128 * sizeof(int));
+  trackInitInst(p1, sizeof(int)*384, tag);
 }
 
 /**





More information about the llvm-commits mailing list