| OLD | NEW |
| 1 //===- subzero/src/IceASanInstrumentation.cpp - ASan ------------*- C++ -*-===// | 1 //===- subzero/src/IceASanInstrumentation.cpp - ASan ------------*- 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 29 matching lines...) Expand all Loading... |
| 40 llvm::NaClBitcodeRecord::RecordVector(RzSize, 'R'); | 40 llvm::NaClBitcodeRecord::RecordVector(RzSize, 'R'); |
| 41 | 41 |
| 42 // In order to instrument the code correctly, the .pexe must not have had its | 42 // In order to instrument the code correctly, the .pexe must not have had its |
| 43 // symbols stripped. | 43 // symbols stripped. |
| 44 using string_map = std::unordered_map<std::string, std::string>; | 44 using string_map = std::unordered_map<std::string, std::string>; |
| 45 using string_set = std::unordered_set<std::string>; | 45 using string_set = std::unordered_set<std::string>; |
| 46 // TODO(tlively): Handle all allocation functions | 46 // TODO(tlively): Handle all allocation functions |
| 47 const string_map FuncSubstitutions = {{"malloc", "__asan_malloc"}, | 47 const string_map FuncSubstitutions = {{"malloc", "__asan_malloc"}, |
| 48 {"free", "__asan_free"}, | 48 {"free", "__asan_free"}, |
| 49 {"calloc", "__asan_calloc"}, | 49 {"calloc", "__asan_calloc"}, |
| 50 {"__asan_dummy_calloc", "__asan_calloc"}}; | 50 {"__asan_dummy_calloc", "__asan_calloc"}, |
| 51 {"realloc", "__asan_realloc"}}; |
| 51 const string_set FuncBlackList = {"_Balloc"}; | 52 const string_set FuncBlackList = {"_Balloc"}; |
| 52 | 53 |
| 53 llvm::NaClBitcodeRecord::RecordVector sizeToByteVec(SizeT Size) { | 54 llvm::NaClBitcodeRecord::RecordVector sizeToByteVec(SizeT Size) { |
| 54 llvm::NaClBitcodeRecord::RecordVector SizeContents; | 55 llvm::NaClBitcodeRecord::RecordVector SizeContents; |
| 55 for (unsigned i = 0; i < sizeof(Size); ++i) { | 56 for (unsigned i = 0; i < sizeof(Size); ++i) { |
| 56 SizeContents.emplace_back(Size % (1 << CHAR_BIT)); | 57 SizeContents.emplace_back(Size % (1 << CHAR_BIT)); |
| 57 Size >>= CHAR_BIT; | 58 Size >>= CHAR_BIT; |
| 58 } | 59 } |
| 59 return SizeContents; | 60 return SizeContents; |
| 60 } | 61 } |
| (...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 338 Call->addArg(Ctx->getConstantSym(0, Ctx->getGlobalString(RzArrayName))); | 339 Call->addArg(Ctx->getConstantSym(0, Ctx->getGlobalString(RzArrayName))); |
| 339 Call->addArg(Ctx->getConstantSym(0, Ctx->getGlobalString(RzSizesName))); | 340 Call->addArg(Ctx->getConstantSym(0, Ctx->getGlobalString(RzSizesName))); |
| 340 } | 341 } |
| 341 | 342 |
| 342 // TODO(tlively): make this more efficient with swap idiom | 343 // TODO(tlively): make this more efficient with swap idiom |
| 343 void ASanInstrumentation::finishFunc(Cfg *) { | 344 void ASanInstrumentation::finishFunc(Cfg *) { |
| 344 ICE_TLS_GET_FIELD(LocalDtors)->clear(); | 345 ICE_TLS_GET_FIELD(LocalDtors)->clear(); |
| 345 } | 346 } |
| 346 | 347 |
| 347 } // end of namespace Ice | 348 } // end of namespace Ice |
| OLD | NEW |