Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(171)

Side by Side Diff: runtime/szrt_asan.c

Issue 2165393002: Subzero: small cleanups (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | tests_lit/asan_tests/errors.ll » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 //===- subzero/runtime/szrt_asan.c - AddressSanitizer Runtime -----*- C -*-===// 1 //===- subzero/runtime/szrt_asan.c - AddressSanitizer Runtime -----*- C -*-===//
2 // 2 //
3 // The Subzero Code Generator 3 // The Subzero Code Generator
4 // 4 //
5 // This file is distributed under the University of Illinois Open Source 5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details. 6 // License. See LICENSE.TXT for details.
7 // 7 //
8 //===----------------------------------------------------------------------===// 8 //===----------------------------------------------------------------------===//
9 /// 9 ///
10 /// \file 10 /// \file
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 if (new_alloc == NULL) 189 if (new_alloc == NULL)
190 return NULL; 190 return NULL;
191 size_t copyable = (size < old_size) ? size : old_size; 191 size_t copyable = (size < old_size) ? size : old_size;
192 memcpy(new_alloc, ptr, copyable); 192 memcpy(new_alloc, ptr, copyable);
193 __asan_free(ptr); 193 __asan_free(ptr);
194 return new_alloc; 194 return new_alloc;
195 } 195 }
196 196
197 void __asan_free(char *ptr) { 197 void __asan_free(char *ptr) {
198 DUMP("free() called on %p\n", ptr); 198 DUMP("free() called on %p\n", ptr);
199 void *rz_left, *rz_right; 199 char *rz_left, *rz_right;
200 __asan_get_redzones(ptr, &rz_left, &rz_right); 200 __asan_get_redzones(ptr, &rz_left, &rz_right);
201 size_t rz_right_size = *(size_t *)rz_right; 201 size_t rz_right_size = *(size_t *)rz_right;
202 __asan_unpoison(rz_left, RZ_SIZE); 202 __asan_unpoison(rz_left, RZ_SIZE);
203 __asan_unpoison(rz_right, rz_right_size); 203 __asan_unpoison(rz_right, rz_right_size);
204 free(rz_left); 204 free(rz_left);
205 } 205 }
206 206
207 void __asan_poison(char *ptr, int size) { 207 void __asan_poison(char *ptr, int size) {
208 char *end = ptr + size; 208 char *end = ptr + size;
209 assert(IS_SHADOW_ALIGNED(end)); 209 assert(IS_SHADOW_ALIGNED(end));
(...skipping 16 matching lines...) Expand all
226 assert(size < 2 * RZ_SIZE); 226 assert(size < 2 * RZ_SIZE);
227 DUMP("unpoison %d bytes at %p: %p - %p\n", size, ptr, MEM2SHADOW(ptr), 227 DUMP("unpoison %d bytes at %p: %p - %p\n", size, ptr, MEM2SHADOW(ptr),
228 MEM2SHADOW(end)); 228 MEM2SHADOW(end));
229 *(char *)MEM2SHADOW(ptr) = 0; 229 *(char *)MEM2SHADOW(ptr) = 0;
230 ptr += SHADOW_OFFSET(size); 230 ptr += SHADOW_OFFSET(size);
231 assert(IS_SHADOW_ALIGNED(ptr)); 231 assert(IS_SHADOW_ALIGNED(ptr));
232 for (; ptr != end; ptr += SHADOW_SCALE) { 232 for (; ptr != end; ptr += SHADOW_SCALE) {
233 *(char *)MEM2SHADOW(ptr) = 0; 233 *(char *)MEM2SHADOW(ptr) = 0;
234 } 234 }
235 } 235 }
OLDNEW
« no previous file with comments | « no previous file | tests_lit/asan_tests/errors.ll » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698