diff --git a/compiler-rt/lib/asan/asan_allocator.h b/compiler-rt/lib/asan/asan_allocator.h --- a/compiler-rt/lib/asan/asan_allocator.h +++ b/compiler-rt/lib/asan/asan_allocator.h @@ -72,7 +72,7 @@ } return false; } - bool AddrIsAtLeft(uptr addr, uptr access_size, sptr *offset) const { + bool AddrIsBefore(uptr addr, uptr access_size, sptr *offset) const { (void)access_size; if (addr < Beg()) { *offset = Beg() - addr; @@ -80,7 +80,7 @@ } return false; } - bool AddrIsAtRight(uptr addr, uptr access_size, sptr *offset) const { + bool AddrIsAfter(uptr addr, uptr access_size, sptr *offset) const { if (addr + access_size > End()) { *offset = addr - End(); return true; diff --git a/compiler-rt/lib/asan/asan_allocator.cpp b/compiler-rt/lib/asan/asan_allocator.cpp --- a/compiler-rt/lib/asan/asan_allocator.cpp +++ b/compiler-rt/lib/asan/asan_allocator.cpp @@ -68,18 +68,17 @@ } // The memory chunk allocated from the underlying allocator looks like this: -// L L L L L L H H U U U U U U R R -// L -- left redzone words (0 or more bytes) -// H -- ChunkHeader (16 bytes), which is also a part of the left redzone. +// F F F F F F H H U U U U U U B B +// F -- front redzone words (0 or more bytes) +// H -- ChunkHeader (16 bytes), which is also a part of the front redzone. // U -- user memory. -// R -- right redzone (0 or more bytes) +// B -- back redzone (0 or more bytes) // ChunkBase consists of ChunkHeader and other bytes that overlap with user // memory. -// If the left redzone is greater than the ChunkHeader size we store a magic -// value in the first uptr word of the memory block and store the address of -// ChunkBase in the next uptr. -// M B L L L L L L L L L H H U U U U U U +// If the front redzone is greater than the ChunkHeader size we store a +// magic value in the first uptr word of the memory block and store the address +// of ChunkBase in the next uptr. M B F F F F F F F F F H H U U U U U U // | ^ // ---------------------| // M -- magic value kAllocBegMagic @@ -211,7 +210,7 @@ } PoisonShadow(m->Beg(), RoundUpTo(m->UsedSize(), ASAN_SHADOW_GRANULARITY), - kAsanHeapLeftRedzoneMagic); + kAsanHeapFrontRedzoneMagic); // Statistics. AsanStats &thread_stats = GetCurrentThreadStats(); @@ -242,7 +241,7 @@ typedef AsanQuarantine::Cache QuarantineCache; void AsanMapUnmapCallback::OnMap(uptr p, uptr size) const { - PoisonShadow(p, size, kAsanHeapLeftRedzoneMagic); + PoisonShadow(p, size, kAsanHeapFrontRedzoneMagic); // Statistics. AsanStats &thread_stats = GetCurrentThreadStats(); thread_stats.mmaps++; @@ -355,18 +354,18 @@ uptr chunk_end = chunk + allocated_size; if (chunk < beg && beg < end && end <= chunk_end) { // Looks like a valid AsanChunk in use, poison redzones only. - PoisonShadow(chunk, beg - chunk, kAsanHeapLeftRedzoneMagic); + PoisonShadow(chunk, beg - chunk, kAsanHeapFrontRedzoneMagic); uptr end_aligned_down = RoundDownTo(end, ASAN_SHADOW_GRANULARITY); - FastPoisonShadowPartialRightRedzone( + FastPoisonShadowPartialFrontRedzone( end_aligned_down, end - end_aligned_down, - chunk_end - end_aligned_down, kAsanHeapLeftRedzoneMagic); + chunk_end - end_aligned_down, kAsanHeapFrontRedzoneMagic); return; } } // This is either not an AsanChunk or freed or quarantined AsanChunk. // In either case, poison everything. - PoisonShadow(chunk, allocated_size, kAsanHeapLeftRedzoneMagic); + PoisonShadow(chunk, allocated_size, kAsanHeapFrontRedzoneMagic); } void ReInitialize(const AllocatorOptions &options) { @@ -428,34 +427,35 @@ } // We have an address between two chunks, and we want to report just one. - AsanChunk *ChooseChunk(uptr addr, AsanChunk *left_chunk, - AsanChunk *right_chunk) { - if (!left_chunk) - return right_chunk; - if (!right_chunk) - return left_chunk; + AsanChunk *ChooseChunk(uptr addr, AsanChunk *chunk_before, + AsanChunk *chunk_after) { + if (!chunk_before) + return chunk_after; + if (!chunk_after) + return chunk_before; // Prefer an allocated chunk over freed chunk and freed chunk // over available chunk. - u8 left_state = atomic_load(&left_chunk->chunk_state, memory_order_relaxed); - u8 right_state = - atomic_load(&right_chunk->chunk_state, memory_order_relaxed); - if (left_state != right_state) { - if (left_state == CHUNK_ALLOCATED) - return left_chunk; - if (right_state == CHUNK_ALLOCATED) - return right_chunk; - if (left_state == CHUNK_QUARANTINE) - return left_chunk; - if (right_state == CHUNK_QUARANTINE) - return right_chunk; + u8 state_before = + atomic_load(&chunk_before->chunk_state, memory_order_relaxed); + u8 state_after = + atomic_load(&chunk_after->chunk_state, memory_order_relaxed); + if (state_before != state_after) { + if (state_before == CHUNK_ALLOCATED) + return chunk_before; + if (state_after == CHUNK_ALLOCATED) + return chunk_after; + if (state_before == CHUNK_QUARANTINE) + return chunk_before; + if (state_after == CHUNK_QUARANTINE) + return chunk_after; } // Same chunk_state: choose based on offset. sptr l_offset = 0, r_offset = 0; - CHECK(AsanChunkView(left_chunk).AddrIsAtRight(addr, 1, &l_offset)); - CHECK(AsanChunkView(right_chunk).AddrIsAtLeft(addr, 1, &r_offset)); + CHECK(AsanChunkView(chunk_before).AddrIsAfter(addr, 1, &l_offset)); + CHECK(AsanChunkView(chunk_after).AddrIsBefore(addr, 1, &r_offset)); if (l_offset < r_offset) - return left_chunk; - return right_chunk; + return chunk_before; + return chunk_after; } bool UpdateAllocationStack(uptr addr, BufferedStackTrace *stack) { @@ -503,7 +503,7 @@ if (alignment > min_alignment) needed_size += alignment; // If we are allocating from the secondary allocator, there will be no - // automatic right redzone, so add the right redzone manually. + // automatic back redzone, so add the back redzone manually. if (!PrimaryAllocator::CanAllocate(needed_size, alignment)) needed_size += rz_size; CHECK(IsAligned(needed_size, min_alignment)); @@ -542,7 +542,8 @@ // time, for example, due to flags()->start_disabled. // Anyway, poison the block before using it for anything else. uptr allocated_size = allocator.GetActuallyAllocatedSize(allocated); - PoisonShadow((uptr)allocated, allocated_size, kAsanHeapLeftRedzoneMagic); + PoisonShadow((uptr)allocated, allocated_size, + kAsanHeapFrontRedzoneMagic); } uptr alloc_beg = reinterpret_cast(allocated); @@ -801,17 +802,17 @@ AsanChunkView FindHeapChunkByAddress(uptr addr) { AsanChunk *m1 = GetAsanChunkByAddr(addr); sptr offset = 0; - if (!m1 || AsanChunkView(m1).AddrIsAtLeft(addr, 1, &offset)) { - // The address is in the chunk's left redzone, so maybe it is actually - // a right buffer overflow from the other chunk before. - // Search a bit before to see if there is another chunk. + if (!m1 || AsanChunkView(m1).AddrIsBefore(addr, 1, &offset)) { + // The address is in the chunk's front redzone, so maybe it is + // actually a buffer overflow from another chunk before. Search a bit + // before to see if there is another chunk. AsanChunk *m2 = nullptr; for (uptr l = 1; l < GetPageSizeCached(); l++) { m2 = GetAsanChunkByAddr(addr - l); if (m2 == m1) continue; // Still the same chunk. break; } - if (m2 && AsanChunkView(m2).AddrIsAtRight(addr, 1, &offset)) + if (m2 && AsanChunkView(m2).AddrIsAfter(addr, 1, &offset)) m1 = ChooseChunk(addr, m2, m1); } return AsanChunkView(m1); diff --git a/compiler-rt/lib/asan/asan_descriptions.h b/compiler-rt/lib/asan/asan_descriptions.h --- a/compiler-rt/lib/asan/asan_descriptions.h +++ b/compiler-rt/lib/asan/asan_descriptions.h @@ -49,14 +49,14 @@ const char *ShadowByte(u8 byte) { switch (byte) { - case kAsanHeapLeftRedzoneMagic: + case kAsanHeapFrontRedzoneMagic: case kAsanArrayCookieMagic: return Red(); case kAsanHeapFreeMagic: return Magenta(); - case kAsanStackLeftRedzoneMagic: + case kAsanStackFrontRedzoneMagic: case kAsanStackMidRedzoneMagic: - case kAsanStackRightRedzoneMagic: + case kAsanStackBackRedzoneMagic: return Red(); case kAsanStackAfterReturnMagic: return Magenta(); @@ -64,8 +64,8 @@ return Cyan(); case kAsanUserPoisonedMemoryMagic: case kAsanContiguousContainerOOBMagic: - case kAsanAllocaLeftMagic: - case kAsanAllocaRightMagic: + case kAsanAllocaFrontMagic: + case kAsanAllocaBackMagic: return Blue(); case kAsanStackUseAfterScopeMagic: return Magenta(); @@ -101,8 +101,8 @@ bool DescribeAddressIfShadow(uptr addr); enum AccessType { - kAccessTypeLeft, - kAccessTypeRight, + kAccessTypeBefore, + kAccessTypeAfter, kAccessTypeInside, kAccessTypeUnknown, // This means we have an AddressSanitizer bug! }; diff --git a/compiler-rt/lib/asan/asan_descriptions.cpp b/compiler-rt/lib/asan/asan_descriptions.cpp --- a/compiler-rt/lib/asan/asan_descriptions.cpp +++ b/compiler-rt/lib/asan/asan_descriptions.cpp @@ -104,10 +104,10 @@ AsanChunkView chunk, uptr addr, uptr access_size) { descr->bad_addr = addr; - if (chunk.AddrIsAtLeft(addr, access_size, &descr->offset)) { - descr->access_type = kAccessTypeLeft; - } else if (chunk.AddrIsAtRight(addr, access_size, &descr->offset)) { - descr->access_type = kAccessTypeRight; + if (chunk.AddrIsBefore(addr, access_size, &descr->offset)) { + descr->access_type = kAccessTypeBefore; + } else if (chunk.AddrIsAfter(addr, access_size, &descr->offset)) { + descr->access_type = kAccessTypeAfter; if (descr->offset < 0) { descr->bad_addr -= descr->offset; descr->offset = 0; @@ -128,11 +128,11 @@ InternalScopedString str; str.append("%s", d.Location()); switch (descr.access_type) { - case kAccessTypeLeft: + case kAccessTypeBefore: str.append("%p is located %zd bytes before", (void *)descr.bad_addr, descr.offset); break; - case kAccessTypeRight: + case kAccessTypeAfter: str.append("%p is located %zd bytes after", (void *)descr.bad_addr, descr.offset); break; diff --git a/compiler-rt/lib/asan/asan_errors.cpp b/compiler-rt/lib/asan/asan_errors.cpp --- a/compiler-rt/lib/asan/asan_errors.cpp +++ b/compiler-rt/lib/asan/asan_errors.cpp @@ -410,7 +410,7 @@ // If we are accessing 16 bytes, look at the second shadow byte. if (*shadow_addr == 0 && access_size > ASAN_SHADOW_GRANULARITY) shadow_addr++; - // If we are in the partial right redzone, look at the next shadow byte. + // If we are in the partial front redzone, look at the next shadow byte. if (*shadow_addr > 0 && *shadow_addr < 128) shadow_addr++; bool far_from_bounds = false; shadow_val = *shadow_addr; @@ -418,7 +418,7 @@ // For use-after-frees reads are almost as bad as writes. int read_after_free_bonus = 0; switch (shadow_val) { - case kAsanHeapLeftRedzoneMagic: + case kAsanHeapFrontRedzoneMagic: case kAsanArrayCookieMagic: bug_descr = "heap-buffer-overflow"; bug_type_score = 10; @@ -429,7 +429,7 @@ bug_type_score = 20; if (!is_write) read_after_free_bonus = 18; break; - case kAsanStackLeftRedzoneMagic: + case kAsanStackFrontRedzoneMagic: bug_descr = "stack-buffer-underflow"; bug_type_score = 25; far_from_bounds = AdjacentShadowValuesAreFullyPoisoned(shadow_addr); @@ -439,7 +439,7 @@ bug_type_score = 1; break; case kAsanStackMidRedzoneMagic: - case kAsanStackRightRedzoneMagic: + case kAsanStackBackRedzoneMagic: bug_descr = "stack-buffer-overflow"; bug_type_score = 25; far_from_bounds = AdjacentShadowValuesAreFullyPoisoned(shadow_addr); @@ -470,8 +470,8 @@ bug_descr = "intra-object-overflow"; bug_type_score = 10; break; - case kAsanAllocaLeftMagic: - case kAsanAllocaRightMagic: + case kAsanAllocaFrontMagic: + case kAsanAllocaBackMagic: bug_descr = "dynamic-stack-buffer-overflow"; bug_type_score = 25; far_from_bounds = AdjacentShadowValuesAreFullyPoisoned(shadow_addr); @@ -506,33 +506,30 @@ for (u8 i = 1; i < ASAN_SHADOW_GRANULARITY; i++) PrintShadowByte(str, "", i, " "); str->append("\n"); - PrintShadowByte(str, " Heap left redzone: ", - kAsanHeapLeftRedzoneMagic); - PrintShadowByte(str, " Freed heap region: ", kAsanHeapFreeMagic); - PrintShadowByte(str, " Stack left redzone: ", - kAsanStackLeftRedzoneMagic); - PrintShadowByte(str, " Stack mid redzone: ", + PrintShadowByte(str, " Heap front redzone: ", kAsanHeapFrontRedzoneMagic); + PrintShadowByte(str, " Freed heap region: ", kAsanHeapFreeMagic); + PrintShadowByte(str, " Stack front redzone: ", kAsanStackFrontRedzoneMagic); + PrintShadowByte(str, " Stack mid redzone: ", kAsanStackMidRedzoneMagic); - PrintShadowByte(str, " Stack right redzone: ", - kAsanStackRightRedzoneMagic); - PrintShadowByte(str, " Stack after return: ", + PrintShadowByte(str, " Stack back redzone: ", kAsanStackBackRedzoneMagic); + PrintShadowByte(str, " Stack after return: ", kAsanStackAfterReturnMagic); - PrintShadowByte(str, " Stack use after scope: ", + PrintShadowByte(str, " Stack use after scope: ", kAsanStackUseAfterScopeMagic); - PrintShadowByte(str, " Global redzone: ", kAsanGlobalRedzoneMagic); - PrintShadowByte(str, " Global init order: ", + PrintShadowByte(str, " Global redzone: ", kAsanGlobalRedzoneMagic); + PrintShadowByte(str, " Global init order: ", kAsanInitializationOrderMagic); - PrintShadowByte(str, " Poisoned by user: ", + PrintShadowByte(str, " Poisoned by user: ", kAsanUserPoisonedMemoryMagic); - PrintShadowByte(str, " Container overflow: ", + PrintShadowByte(str, " Container overflow: ", kAsanContiguousContainerOOBMagic); - PrintShadowByte(str, " Array cookie: ", + PrintShadowByte(str, " Array cookie: ", kAsanArrayCookieMagic); - PrintShadowByte(str, " Intra object redzone: ", + PrintShadowByte(str, " Intra object redzone: ", kAsanIntraObjectRedzone); - PrintShadowByte(str, " ASan internal: ", kAsanInternalHeapMagic); - PrintShadowByte(str, " Left alloca redzone: ", kAsanAllocaLeftMagic); - PrintShadowByte(str, " Right alloca redzone: ", kAsanAllocaRightMagic); + PrintShadowByte(str, " ASan internal: ", kAsanInternalHeapMagic); + PrintShadowByte(str, " Front alloca redzone: ", kAsanAllocaFrontMagic); + PrintShadowByte(str, " Back alloca redzone: ", kAsanAllocaBackMagic); } static void PrintShadowBytes(InternalScopedString *str, const char *before, diff --git a/compiler-rt/lib/asan/asan_fake_stack.h b/compiler-rt/lib/asan/asan_fake_stack.h --- a/compiler-rt/lib/asan/asan_fake_stack.h +++ b/compiler-rt/lib/asan/asan_fake_stack.h @@ -140,7 +140,7 @@ return ((uptr)1) << (class_id + kMinStackFrameSizeLog); } - // The fake frame is guaranteed to have a right redzone. + // The fake frame is guaranteed to have a back redzone. // We use the last word of that redzone to store the address of the flag // that corresponds to the current frame to make faster deallocation. static u8 **SavedFlagPtr(uptr x, uptr class_id) { diff --git a/compiler-rt/lib/asan/asan_fake_stack.cpp b/compiler-rt/lib/asan/asan_fake_stack.cpp --- a/compiler-rt/lib/asan/asan_fake_stack.cpp +++ b/compiler-rt/lib/asan/asan_fake_stack.cpp @@ -289,15 +289,16 @@ SANITIZER_INTERFACE_ATTRIBUTE void __asan_alloca_poison(uptr addr, uptr size) { - uptr LeftRedzoneAddr = addr - kAllocaRedzoneSize; + uptr FrontRedzoneAddr = addr - kAllocaRedzoneSize; uptr PartialRzAddr = addr + size; uptr RightRzAddr = (PartialRzAddr + kAllocaRedzoneMask) & ~kAllocaRedzoneMask; uptr PartialRzAligned = PartialRzAddr & ~(ASAN_SHADOW_GRANULARITY - 1); - FastPoisonShadow(LeftRedzoneAddr, kAllocaRedzoneSize, kAsanAllocaLeftMagic); - FastPoisonShadowPartialRightRedzone( + FastPoisonShadow(FrontRedzoneAddr, kAllocaRedzoneSize, + kAsanAllocaFrontMagic); + FastPoisonShadowPartialFrontRedzone( PartialRzAligned, PartialRzAddr % ASAN_SHADOW_GRANULARITY, - RightRzAddr - PartialRzAligned, kAsanAllocaRightMagic); - FastPoisonShadow(RightRzAddr, kAllocaRedzoneSize, kAsanAllocaRightMagic); + RightRzAddr - PartialRzAligned, kAsanAllocaBackMagic); + FastPoisonShadow(RightRzAddr, kAllocaRedzoneSize, kAsanAllocaBackMagic); } SANITIZER_INTERFACE_ATTRIBUTE diff --git a/compiler-rt/lib/asan/asan_globals.cpp b/compiler-rt/lib/asan/asan_globals.cpp --- a/compiler-rt/lib/asan/asan_globals.cpp +++ b/compiler-rt/lib/asan/asan_globals.cpp @@ -65,7 +65,7 @@ FastPoisonShadow(g.beg + aligned_size, g.size_with_redzone - aligned_size, kAsanGlobalRedzoneMagic); if (g.size != aligned_size) { - FastPoisonShadowPartialRightRedzone( + FastPoisonShadowPartialFrontRedzone( g.beg + RoundDownTo(g.size, ASAN_SHADOW_GRANULARITY), g.size % ASAN_SHADOW_GRANULARITY, ASAN_SHADOW_GRANULARITY, kAsanGlobalRedzoneMagic); diff --git a/compiler-rt/lib/asan/asan_internal.h b/compiler-rt/lib/asan/asan_internal.h --- a/compiler-rt/lib/asan/asan_internal.h +++ b/compiler-rt/lib/asan/asan_internal.h @@ -137,11 +137,11 @@ extern void (*death_callback)(void); // These magic values are written to shadow for better error // reporting. -const int kAsanHeapLeftRedzoneMagic = 0xfa; +const int kAsanHeapFrontRedzoneMagic = 0xfa; const int kAsanHeapFreeMagic = 0xfd; -const int kAsanStackLeftRedzoneMagic = 0xf1; +const int kAsanStackFrontRedzoneMagic = 0xf1; const int kAsanStackMidRedzoneMagic = 0xf2; -const int kAsanStackRightRedzoneMagic = 0xf3; +const int kAsanStackBackRedzoneMagic = 0xf3; const int kAsanStackAfterReturnMagic = 0xf5; const int kAsanInitializationOrderMagic = 0xf6; const int kAsanUserPoisonedMemoryMagic = 0xf7; @@ -151,8 +151,8 @@ const int kAsanInternalHeapMagic = 0xfe; const int kAsanArrayCookieMagic = 0xac; const int kAsanIntraObjectRedzone = 0xbb; -const int kAsanAllocaLeftMagic = 0xca; -const int kAsanAllocaRightMagic = 0xcb; +const int kAsanAllocaFrontMagic = 0xca; +const int kAsanAllocaBackMagic = 0xcb; static const uptr kCurrentStackFrameMagic = 0x41B58AB3; static const uptr kRetiredStackFrameMagic = 0x45E0360E; diff --git a/compiler-rt/lib/asan/asan_mapping_sparc64.h b/compiler-rt/lib/asan/asan_mapping_sparc64.h --- a/compiler-rt/lib/asan/asan_mapping_sparc64.h +++ b/compiler-rt/lib/asan/asan_mapping_sparc64.h @@ -37,7 +37,7 @@ #define kLowShadowEnd MEM_TO_SHADOW(kLowMemEnd) // But of course there is the huge hole between the high shadow memory, -// which is in the low part, and the beginning of the high part. +// whichs in the low part, and the beginning of the high part. #define kHighMemBeg (-(1ULL << (VMA_BITS - 1))) diff --git a/compiler-rt/lib/asan/asan_poisoning.h b/compiler-rt/lib/asan/asan_poisoning.h --- a/compiler-rt/lib/asan/asan_poisoning.h +++ b/compiler-rt/lib/asan/asan_poisoning.h @@ -28,12 +28,10 @@ // Poisons the shadow memory for "redzone_size" bytes starting from // "addr + size". -void PoisonShadowPartialRightRedzone(uptr addr, - uptr size, - uptr redzone_size, - u8 value); +void PoisonShadowPartialBackRedzone(uptr addr, uptr size, + uptr redzone_size, u8 value); -// Fast versions of PoisonShadow and PoisonShadowPartialRightRedzone that +// Fast versions of PoisonShadow and PoisonShadowPartialBackRedzone that // assume that memory addresses are properly aligned. Use in // performance-critical code with care. ALWAYS_INLINE void FastPoisonShadow(uptr aligned_beg, uptr aligned_size, @@ -73,8 +71,10 @@ #endif // SANITIZER_FUCHSIA } -ALWAYS_INLINE void FastPoisonShadowPartialRightRedzone( - uptr aligned_addr, uptr size, uptr redzone_size, u8 value) { +ALWAYS_INLINE void FastPoisonShadowPartialFrontRedzone(uptr aligned_addr, + uptr size, + uptr redzone_size, + u8 value) { DCHECK(CanPoisonMemory()); bool poison_partial = flags()->poison_partial; u8 *shadow = (u8*)MEM_TO_SHADOW(aligned_addr); diff --git a/compiler-rt/lib/asan/asan_poisoning.cpp b/compiler-rt/lib/asan/asan_poisoning.cpp --- a/compiler-rt/lib/asan/asan_poisoning.cpp +++ b/compiler-rt/lib/asan/asan_poisoning.cpp @@ -42,14 +42,12 @@ FastPoisonShadow(addr, size, value); } -void PoisonShadowPartialRightRedzone(uptr addr, - uptr size, - uptr redzone_size, - u8 value) { +void PoisonShadowPartialBackRedzone(uptr addr, uptr size, + uptr redzone_size, u8 value) { if (!CanPoisonMemory()) return; CHECK(AddrIsAlignedByGranularity(addr)); CHECK(AddrIsInMem(addr)); - FastPoisonShadowPartialRightRedzone(addr, size, redzone_size, value); + FastPoisonShadowPartialFrontRedzone(addr, size, redzone_size, value); } struct ShadowSegmentEndpoint { @@ -96,10 +94,10 @@ // mapping invariant is preserved (see detailed mapping description here: // https://github.com/google/sanitizers/wiki/AddressSanitizerAlgorithm). // -// * if user asks to poison region [left, right), the program poisons -// at least [left, AlignDown(right)). -// * if user asks to unpoison region [left, right), the program unpoisons -// at most [AlignDown(left), right). +// * if user asks to poison region [low, high), the program poisons +// at least [low, AlignDown(high)). +// * if user asks to unpoison region [low, high), the program unpoisons +// at most [AlignDown(low), high). void __asan_poison_memory_region(void const volatile *addr, uptr size) { if (!flags()->allow_user_poisoning || size == 0) return; uptr beg_addr = (uptr)addr; @@ -284,7 +282,7 @@ } // This is a simplified version of __asan_(un)poison_memory_region, which -// assumes that left border of region to be poisoned is properly aligned. +// assumes that low border of region to be poisoned is properly aligned. static void PoisonAlignedStackMemory(uptr addr, uptr size, bool do_poison) { if (size == 0) return; uptr aligned_size = size & ~(ASAN_SHADOW_GRANULARITY - 1); diff --git a/compiler-rt/lib/asan/asan_premap_shadow.cpp b/compiler-rt/lib/asan/asan_premap_shadow.cpp --- a/compiler-rt/lib/asan/asan_premap_shadow.cpp +++ b/compiler-rt/lib/asan/asan_premap_shadow.cpp @@ -29,8 +29,8 @@ return RoundUpTo(GetMaxVirtualAddress() >> ASAN_SHADOW_SCALE, granularity); } -// Returns an address aligned to 8 pages, such that one page on the left and -// PremapShadowSize() bytes on the right of it are mapped r/o. +// Returns an address aligned to 8 pages, such that one front page and +// PremapShadowSize() back bytes are mapped r/o. uptr PremapShadow() { return MapDynamicShadow(PremapShadowSize(), /*mmap_alignment_scale*/ 3, /*min_shadow_base_alignment*/ 0, kHighMemEnd); diff --git a/compiler-rt/lib/asan/asan_report.cpp b/compiler-rt/lib/asan/asan_report.cpp --- a/compiler-rt/lib/asan/asan_report.cpp +++ b/compiler-rt/lib/asan/asan_report.cpp @@ -377,37 +377,37 @@ // 256B in shadow memory can be iterated quite fast static const uptr kMaxOffset = 2048; - uptr left = a1 < a2 ? a1 : a2; - uptr right = a1 < a2 ? a2 : a1; - uptr offset = right - left; + uptr low = a1 < a2 ? a1 : a2; + uptr high = a1 < a2 ? a2 : a1; + uptr offset = high - low; if (offset <= kMaxOffset) - return __asan_region_is_poisoned(left, offset); + return __asan_region_is_poisoned(low, offset); AsanThread *t = GetCurrentThread(); // check whether left is a stack memory pointer - if (uptr shadow_offset1 = t->GetStackVariableShadowStart(left)) { - uptr shadow_offset2 = t->GetStackVariableShadowStart(right); + if (uptr shadow_offset1 = t->GetStackVariableShadowStart(low)) { + uptr shadow_offset2 = t->GetStackVariableShadowStart(high); return shadow_offset2 == 0 || shadow_offset1 != shadow_offset2; } // check whether left is a heap memory address HeapAddressDescription hdesc1, hdesc2; - if (GetHeapAddressInformation(left, 0, &hdesc1) && + if (GetHeapAddressInformation(low, 0, &hdesc1) && hdesc1.chunk_access.access_type == kAccessTypeInside) - return !GetHeapAddressInformation(right, 0, &hdesc2) || + return !GetHeapAddressInformation(high, 0, &hdesc2) || hdesc2.chunk_access.access_type != kAccessTypeInside || hdesc1.chunk_access.chunk_begin != hdesc2.chunk_access.chunk_begin; // check whether left is an address of a global variable GlobalAddressDescription gdesc1, gdesc2; - if (GetGlobalAddressInformation(left, 0, &gdesc1)) - return !GetGlobalAddressInformation(right - 1, 0, &gdesc2) || + if (GetGlobalAddressInformation(low, 0, &gdesc1)) + return !GetGlobalAddressInformation(high - 1, 0, &gdesc2) || !gdesc1.PointsInsideTheSameVariable(gdesc2); - if (t->GetStackVariableShadowStart(right) || - GetHeapAddressInformation(right, 0, &hdesc2) || - GetGlobalAddressInformation(right - 1, 0, &gdesc2)) + if (t->GetStackVariableShadowStart(high) || + GetHeapAddressInformation(high, 0, &hdesc2) || + GetGlobalAddressInformation(high - 1, 0, &gdesc2)) return true; // At this point we know nothing about both a1 and a2 addresses. diff --git a/compiler-rt/lib/asan/asan_shadow_setup.cpp b/compiler-rt/lib/asan/asan_shadow_setup.cpp --- a/compiler-rt/lib/asan/asan_shadow_setup.cpp +++ b/compiler-rt/lib/asan/asan_shadow_setup.cpp @@ -86,7 +86,7 @@ if (Verbosity()) PrintAddressSpaceLayout(); if (full_shadow_is_available) { - // mmap the low shadow plus at least one page at the left. + // mmap the low shadow plus at least one front page. if (kLowShadowBeg) ReserveShadowMemoryRange(shadow_start, kLowShadowEnd, "low shadow"); // mmap the high shadow. @@ -98,7 +98,7 @@ MemoryRangeIsAvailable(shadow_start, kMidMemBeg - 1) && MemoryRangeIsAvailable(kMidMemEnd + 1, kHighShadowEnd)) { CHECK(kLowShadowBeg != kLowShadowEnd); - // mmap the low shadow plus at least one page at the left. + // mmap the low shadow plus at least one front page. ReserveShadowMemoryRange(shadow_start, kLowShadowEnd, "low shadow"); // mmap the mid shadow. ReserveShadowMemoryRange(kMidShadowBeg, kMidShadowEnd, "mid shadow"); diff --git a/compiler-rt/lib/asan/asan_thread.cpp b/compiler-rt/lib/asan/asan_thread.cpp --- a/compiler-rt/lib/asan/asan_thread.cpp +++ b/compiler-rt/lib/asan/asan_thread.cpp @@ -349,13 +349,13 @@ u8 *shadow_bottom = (u8*)MemToShadow(bottom); while (shadow_ptr >= shadow_bottom && - *shadow_ptr != kAsanStackLeftRedzoneMagic) { + *shadow_ptr != kAsanStackFrontRedzoneMagic) { shadow_ptr--; mem_ptr -= ASAN_SHADOW_GRANULARITY; } while (shadow_ptr >= shadow_bottom && - *shadow_ptr == kAsanStackLeftRedzoneMagic) { + *shadow_ptr == kAsanStackFrontRedzoneMagic) { shadow_ptr--; mem_ptr -= ASAN_SHADOW_GRANULARITY; } @@ -390,9 +390,9 @@ u8 *shadow_bottom = (u8*)MemToShadow(bottom); while (shadow_ptr >= shadow_bottom && - (*shadow_ptr != kAsanStackLeftRedzoneMagic && + (*shadow_ptr != kAsanStackFrontRedzoneMagic && *shadow_ptr != kAsanStackMidRedzoneMagic && - *shadow_ptr != kAsanStackRightRedzoneMagic)) + *shadow_ptr != kAsanStackBackRedzoneMagic)) shadow_ptr--; return (uptr)shadow_ptr + 1; diff --git a/compiler-rt/lib/asan/tests/asan_test.cpp b/compiler-rt/lib/asan/tests/asan_test.cpp --- a/compiler-rt/lib/asan/tests/asan_test.cpp +++ b/compiler-rt/lib/asan/tests/asan_test.cpp @@ -994,7 +994,7 @@ free(strdup(Ident("123"))); } -// Currently we create and poison redzone at right of global variables. +// Currently we create and poison redzone before global variables. static char static110[110]; const char ConstGlob[7] = {1, 2, 3, 4, 5, 6, 7}; static const char StaticConstGlob[3] = {9, 8, 7}; @@ -1035,7 +1035,7 @@ Ident(fs2); Ident(fs3); - // We don't create left redzones, so this is not 100% guaranteed to fail. + // We don't create front redzones, so this is not 100% guaranteed to fail. // But most likely will. EXPECT_DEATH(fs2[Ident(-1)] = 0, "is located.* global variable"); diff --git a/compiler-rt/test/asan/TestCases/Posix/gc-test.cpp b/compiler-rt/test/asan/TestCases/Posix/gc-test.cpp --- a/compiler-rt/test/asan/TestCases/Posix/gc-test.cpp +++ b/compiler-rt/test/asan/TestCases/Posix/gc-test.cpp @@ -12,7 +12,7 @@ #include static const int kNumThreads = 2; -static const int kLeftRedzoneSize = sizeof(void *) * 4; +static const int kFrontRedzoneSize = sizeof(void *) * 4; void *Thread(void *unused) { void *fake_stack = __asan_get_current_fake_stack(); @@ -27,7 +27,7 @@ assert(real_stack); assert((char*)beg <= (char*)&var[0]); assert((char*)end > (char*)&var[0]); - for (int i = -kLeftRedzoneSize; i < 15; i++) { + for (int i = -kFrontRedzoneSize; i < 15; i++) { void *beg1, *end1; char *ptr = &var[0] + i; void *real_stack1 = diff --git a/compiler-rt/test/asan/TestCases/Posix/start-deactivated.cpp b/compiler-rt/test/asan/TestCases/Posix/start-deactivated.cpp --- a/compiler-rt/test/asan/TestCases/Posix/start-deactivated.cpp +++ b/compiler-rt/test/asan/TestCases/Posix/start-deactivated.cpp @@ -37,12 +37,12 @@ #include "sanitizer/asan_interface.h" void test_malloc_shadow(char *p, size_t sz, bool expect_redzones) { - // Last byte of the left redzone, if present. + // Last byte of the front redzone, if present. assert((char *)__asan_region_is_poisoned(p - 1, sz + 1) == (expect_redzones ? p - 1 : nullptr)); // The user memory. assert((char *)__asan_region_is_poisoned(p, sz) == nullptr); - // First byte of the right redzone, if present. + // First byte of the front redzone, if present. assert((char *)__asan_region_is_poisoned(p, sz + 1) == (expect_redzones ? p + sz : nullptr)); } diff --git a/compiler-rt/test/asan/TestCases/Posix/unpoison-alternate-stack.cpp b/compiler-rt/test/asan/TestCases/Posix/unpoison-alternate-stack.cpp --- a/compiler-rt/test/asan/TestCases/Posix/unpoison-alternate-stack.cpp +++ b/compiler-rt/test/asan/TestCases/Posix/unpoison-alternate-stack.cpp @@ -26,8 +26,8 @@ namespace { struct TestContext { - char *LeftRedzone; - char *RightRedzone; + char *FrontRedzone; + char *BackRedzone; std::jmp_buf JmpBuf; }; @@ -42,11 +42,11 @@ char Blob[100]; // This variable must not be optimized out, because we use it // to create redzones. - c.LeftRedzone = Blob - 1; - c.RightRedzone = Blob + sizeof(Blob); + c.FrontRedzone = Blob - 1; + c.BackRedzone = Blob + sizeof(Blob); - assert(__asan_address_is_poisoned(c.LeftRedzone)); - assert(__asan_address_is_poisoned(c.RightRedzone)); + assert(__asan_address_is_poisoned(c.FrontRedzone)); + assert(__asan_address_is_poisoned(c.BackRedzone)); // Jump to avoid normal cleanup of redzone markers. Instead, // __asan_handle_no_return is called which unpoisons the stacks. @@ -59,8 +59,9 @@ if (0 == setjmp(c.JmpBuf)) poisonStackAndJump(c, [&] { longjmp(c.JmpBuf, 1); }); - assert(0 == __asan_region_is_poisoned(c.LeftRedzone, - c.RightRedzone - c.LeftRedzone)); + assert(0 == + __asan_region_is_poisoned(c.FrontRedzone, + c.BackRedzone - c.FrontRedzone)); } bool isOnSignalStack() { @@ -114,13 +115,13 @@ assert(!isOnSignalStack()); - assert(0 == __asan_region_is_poisoned( - defaultStack.LeftRedzone, - defaultStack.RightRedzone - defaultStack.LeftRedzone)); + assert(0 == __asan_region_is_poisoned(defaultStack.FrontRedzone, + defaultStack.BackRedzone - + defaultStack.FrontRedzone)); - assert(0 == __asan_region_is_poisoned( - signalStack.LeftRedzone, - signalStack.RightRedzone - signalStack.LeftRedzone)); + assert(0 == __asan_region_is_poisoned(signalStack.FrontRedzone, + signalStack.BackRedzone - + signalStack.FrontRedzone)); return nullptr; } diff --git a/compiler-rt/test/asan/TestCases/Windows/calloc_right_oob.cpp b/compiler-rt/test/asan/TestCases/Windows/calloc_oob_after.cpp rename from compiler-rt/test/asan/TestCases/Windows/calloc_right_oob.cpp rename to compiler-rt/test/asan/TestCases/Windows/calloc_oob_after.cpp --- a/compiler-rt/test/asan/TestCases/Windows/calloc_right_oob.cpp +++ b/compiler-rt/test/asan/TestCases/Windows/calloc_oob_after.cpp @@ -8,10 +8,10 @@ buffer[42] = 42; // CHECK: AddressSanitizer: heap-buffer-overflow on address [[ADDR:0x[0-9a-f]+]] // CHECK: WRITE of size 4 at [[ADDR]] thread T0 -// CHECK-NEXT: {{#0 .* main .*calloc_right_oob.cpp}}:[[@LINE-3]] +// CHECK-NEXT: {{#0 .* main .*calloc_oob_after.cpp}}:[[@LINE-3]] // CHECK: [[ADDR]] is located 0 bytes after 168-byte region // CHECK: allocated by thread T0 here: // CHECK-NEXT: {{#0 .* calloc }} -// CHECK-NEXT: {{#1 .* main .*calloc_right_oob.cpp}}:[[@LINE-8]] +// CHECK-NEXT: {{#1 .* main .*calloc_oob_after.cpp}}:[[@LINE-8]] free(buffer); } diff --git a/compiler-rt/test/asan/TestCases/Windows/calloc_left_oob.cpp b/compiler-rt/test/asan/TestCases/Windows/calloc_oob_before.cpp rename from compiler-rt/test/asan/TestCases/Windows/calloc_left_oob.cpp rename to compiler-rt/test/asan/TestCases/Windows/calloc_oob_before.cpp --- a/compiler-rt/test/asan/TestCases/Windows/calloc_left_oob.cpp +++ b/compiler-rt/test/asan/TestCases/Windows/calloc_oob_before.cpp @@ -8,10 +8,10 @@ buffer[-1] = 42; // CHECK: AddressSanitizer: heap-buffer-overflow on address [[ADDR:0x[0-9a-f]+]] // CHECK: WRITE of size 4 at [[ADDR]] thread T0 -// CHECK-NEXT: {{#0 .* main .*calloc_left_oob.cpp}}:[[@LINE-3]] +// CHECK-NEXT: {{#0 .* main .*calloc_oob_before.cpp}}:[[@LINE-3]] // CHECK: [[ADDR]] is located 4 bytes before 168-byte region // CHECK: allocated by thread T0 here: // CHECK-NEXT: {{#0 .* calloc }} -// CHECK-NEXT: {{#1 .* main .*calloc_left_oob.cpp}}:[[@LINE-8]] +// CHECK-NEXT: {{#1 .* main .*calloc_oob_before.cpp}}:[[@LINE-8]] free(buffer); } diff --git a/compiler-rt/test/asan/TestCases/Windows/dll_malloc_left_oob.cpp b/compiler-rt/test/asan/TestCases/Windows/dll_malloc_oob_before.cpp rename from compiler-rt/test/asan/TestCases/Windows/dll_malloc_left_oob.cpp rename to compiler-rt/test/asan/TestCases/Windows/dll_malloc_oob_before.cpp --- a/compiler-rt/test/asan/TestCases/Windows/dll_malloc_left_oob.cpp +++ b/compiler-rt/test/asan/TestCases/Windows/dll_malloc_oob_before.cpp @@ -9,13 +9,13 @@ buffer[-1] = 42; // CHECK: AddressSanitizer: heap-buffer-overflow on address [[ADDR:0x[0-9a-f]+]] // CHECK: WRITE of size 1 at [[ADDR]] thread T0 -// CHECK-NEXT: test_function {{.*}}dll_malloc_left_oob.cpp:[[@LINE-3]] +// CHECK-NEXT: test_function {{.*}}dll_malloc_oob_before.cpp:[[@LINE-3]] // CHECK-NEXT: main {{.*}}dll_host.cpp // // CHECK: [[ADDR]] is located 1 bytes before 42-byte region // CHECK-LABEL: allocated by thread T0 here: // CHECK-NEXT: malloc -// CHECK-NEXT: test_function {{.*}}dll_malloc_left_oob.cpp:[[@LINE-10]] +// CHECK-NEXT: test_function {{.*}}dll_malloc_oob_before.cpp:[[@LINE-10]] // CHECK-NEXT: main {{.*}}dll_host.cpp // CHECK-LABEL: SUMMARY free(buffer); diff --git a/compiler-rt/test/asan/TestCases/Windows/dll_operator_array_new_left_oob.cpp b/compiler-rt/test/asan/TestCases/Windows/dll_operator_array_new_oob_before.cpp rename from compiler-rt/test/asan/TestCases/Windows/dll_operator_array_new_left_oob.cpp rename to compiler-rt/test/asan/TestCases/Windows/dll_operator_array_new_oob_before.cpp --- a/compiler-rt/test/asan/TestCases/Windows/dll_operator_array_new_left_oob.cpp +++ b/compiler-rt/test/asan/TestCases/Windows/dll_operator_array_new_oob_before.cpp @@ -8,7 +8,7 @@ buffer[-1] = 42; // CHECK: AddressSanitizer: heap-buffer-overflow on address [[ADDR:0x[0-9a-f]+]] // CHECK: WRITE of size 1 at [[ADDR]] thread T0 -// CHECK-NEXT: test_function {{.*}}dll_operator_array_new_left_oob.cpp:[[@LINE-3]] +// CHECK-NEXT: test_function {{.*}}dll_operator_array_new_oob_before.cpp:[[@LINE-3]] // CHECK-NEXT: main {{.*}}dll_host.cpp // // CHECK: [[ADDR]] is located 1 bytes before 42-byte region @@ -17,7 +17,7 @@ // operator new/delete in DLLs when using -MT CRT. // FIXME: The 'operator new' frame should have []. // CHECK: operator new -// CHECK-NEXT: test_function {{.*}}dll_operator_array_new_left_oob.cpp:[[@LINE-13]] +// CHECK-NEXT: test_function {{.*}}dll_operator_array_new_oob_before.cpp:[[@LINE-13]] // CHECK-NEXT: main {{.*}}dll_host.cpp // CHECK-LABEL: SUMMARY delete [] buffer; diff --git a/compiler-rt/test/asan/TestCases/Windows/dll_operator_array_new_with_dtor_left_oob.cpp b/compiler-rt/test/asan/TestCases/Windows/dll_operator_array_new_with_dtor_oob_before.cpp rename from compiler-rt/test/asan/TestCases/Windows/dll_operator_array_new_with_dtor_left_oob.cpp rename to compiler-rt/test/asan/TestCases/Windows/dll_operator_array_new_with_dtor_oob_before.cpp --- a/compiler-rt/test/asan/TestCases/Windows/dll_operator_array_new_with_dtor_left_oob.cpp +++ b/compiler-rt/test/asan/TestCases/Windows/dll_operator_array_new_with_dtor_oob_before.cpp @@ -15,7 +15,7 @@ buffer[hide(-(1 + (int)sizeof(void*) / 4))].x = 42; // CHECK: AddressSanitizer: heap-buffer-overflow on address [[ADDR:0x[0-9a-f]+]] // CHECK: WRITE of size 4 at [[ADDR]] thread T0 -// CHECK-NEXT: test_function {{.*}}dll_operator_array_new_with_dtor_left_oob.cpp:[[@LINE-3]] +// CHECK-NEXT: test_function {{.*}}dll_operator_array_new_with_dtor_oob_before.cpp:[[@LINE-3]] // CHECK-NEXT: main {{.*}}dll_host.cpp // // FIXME: Currently it says "4 bytes ... left of 172-byte region", @@ -27,7 +27,7 @@ // FIXME: The operator new frame should have []. // CHECK-LABEL: allocated by thread T0 here: // CHECK: operator new -// CHECK-NEXT: test_function {{.*}}dll_operator_array_new_with_dtor_left_oob.cpp:[[@LINE-16]] +// CHECK-NEXT: test_function {{.*}}dll_operator_array_new_with_dtor_oob_before.cpp:[[@LINE-16]] // CHECK-NEXT: main {{.*}}dll_host.cpp // CHECK-LABEL: SUMMARY delete [] buffer; diff --git a/compiler-rt/test/asan/TestCases/Windows/dll_thread_stack_array_left_oob.cpp b/compiler-rt/test/asan/TestCases/Windows/dll_thread_stack_array_oob_before.cpp rename from compiler-rt/test/asan/TestCases/Windows/dll_thread_stack_array_left_oob.cpp rename to compiler-rt/test/asan/TestCases/Windows/dll_thread_stack_array_oob_before.cpp --- a/compiler-rt/test/asan/TestCases/Windows/dll_thread_stack_array_left_oob.cpp +++ b/compiler-rt/test/asan/TestCases/Windows/dll_thread_stack_array_oob_before.cpp @@ -11,10 +11,10 @@ stack_buffer[subscript] = 42; // CHECK: AddressSanitizer: stack-buffer-underflow on address [[ADDR:0x[0-9a-f]+]] // CHECK: WRITE of size 1 at [[ADDR]] thread T1 -// CHECK-NEXT: thread_proc{{.*}}dll_thread_stack_array_left_oob.cpp:[[@LINE-3]] +// CHECK-NEXT: thread_proc{{.*}}dll_thread_stack_array_oob_before.cpp:[[@LINE-3]] // // CHECK: Address [[ADDR]] is located in stack of thread T1 at offset [[OFFSET:.*]] in frame -// CHECK-NEXT: thread_proc{{.*}}dll_thread_stack_array_left_oob.cpp +// CHECK-NEXT: thread_proc{{.*}}dll_thread_stack_array_oob_before.cpp // // CHECK: 'stack_buffer'{{.*}} <== Memory access at offset [[OFFSET]] underflows this variable @@ -25,7 +25,7 @@ int test_function() { HANDLE thr = CreateThread(NULL, 0, thread_proc, NULL, 0, NULL); // CHECK-LABEL: Thread T1 created by T0 here: -// CHECK: test_function{{.*}}dll_thread_stack_array_left_oob.cpp:[[@LINE-2]] +// CHECK: test_function{{.*}}dll_thread_stack_array_oob_before.cpp:[[@LINE-2]] // CHECK-NEXT: main{{.*}}dll_host.cpp // CHECK-LABEL: SUMMARY if (thr == 0) diff --git a/compiler-rt/test/asan/TestCases/Windows/malloc_right_oob.cpp b/compiler-rt/test/asan/TestCases/Windows/malloc_oob_after.cpp rename from compiler-rt/test/asan/TestCases/Windows/malloc_right_oob.cpp rename to compiler-rt/test/asan/TestCases/Windows/malloc_oob_after.cpp --- a/compiler-rt/test/asan/TestCases/Windows/malloc_right_oob.cpp +++ b/compiler-rt/test/asan/TestCases/Windows/malloc_oob_after.cpp @@ -8,10 +8,10 @@ buffer[42] = 42; // CHECK: AddressSanitizer: heap-buffer-overflow on address [[ADDR:0x[0-9a-f]+]] // CHECK: WRITE of size 1 at [[ADDR]] thread T0 -// CHECK-NEXT: {{#0 .* main .*malloc_right_oob.cpp}}:[[@LINE-3]] +// CHECK-NEXT: {{#0 .* main .*malloc_oob_after.cpp}}:[[@LINE-3]] // CHECK: [[ADDR]] is located 0 bytes after 42-byte region // CHECK: allocated by thread T0 here: // CHECK-NEXT: {{#0 .* malloc }} -// CHECK-NEXT: {{#1 .* main .*malloc_right_oob.cpp}}:[[@LINE-8]] +// CHECK-NEXT: {{#1 .* main .*malloc_oob_after.cpp}}:[[@LINE-8]] free(buffer); } diff --git a/compiler-rt/test/asan/TestCases/Windows/malloc_left_oob.cpp b/compiler-rt/test/asan/TestCases/Windows/malloc_oob_before.cpp rename from compiler-rt/test/asan/TestCases/Windows/malloc_left_oob.cpp rename to compiler-rt/test/asan/TestCases/Windows/malloc_oob_before.cpp --- a/compiler-rt/test/asan/TestCases/Windows/malloc_left_oob.cpp +++ b/compiler-rt/test/asan/TestCases/Windows/malloc_oob_before.cpp @@ -8,10 +8,10 @@ buffer[-1] = 42; // CHECK: AddressSanitizer: heap-buffer-overflow on address [[ADDR:0x[0-9a-f]+]] // CHECK: WRITE of size 1 at [[ADDR]] thread T0 -// CHECK-NEXT: {{#0 .* main .*malloc_left_oob.cpp}}:[[@LINE-3]] +// CHECK-NEXT: {{#0 .* main .*malloc_oob_before.cpp}}:[[@LINE-3]] // CHECK: [[ADDR]] is located 1 bytes before 42-byte region // CHECK: allocated by thread T0 here: // CHECK-NEXT: {{#0 .* malloc }} -// CHECK-NEXT: {{#1 .* main .*malloc_left_oob.cpp}}:[[@LINE-8]] +// CHECK-NEXT: {{#1 .* main .*malloc_oob_before.cpp}}:[[@LINE-8]] free(buffer); } diff --git a/compiler-rt/test/asan/TestCases/Windows/operator_array_new_right_oob.cpp b/compiler-rt/test/asan/TestCases/Windows/operator_array_new_oob_after.cpp rename from compiler-rt/test/asan/TestCases/Windows/operator_array_new_right_oob.cpp rename to compiler-rt/test/asan/TestCases/Windows/operator_array_new_oob_after.cpp --- a/compiler-rt/test/asan/TestCases/Windows/operator_array_new_right_oob.cpp +++ b/compiler-rt/test/asan/TestCases/Windows/operator_array_new_oob_after.cpp @@ -8,11 +8,11 @@ buffer[42] = 42; // CHECK: AddressSanitizer: heap-buffer-overflow on address [[ADDR:0x[0-9a-f]+]] // CHECK: WRITE of size 1 at [[ADDR]] thread T0 -// CHECK: {{#0 .* main .*operator_array_new_right_oob.cpp}}:[[@LINE-3]] +// CHECK: {{#0 .* main .*operator_array_new_oob_after.cpp}}:[[@LINE-3]] // CHECK: [[ADDR]] is located 0 bytes after 42-byte region // CHECK: allocated by thread T0 here: // FIXME: The 'operator new' frame should have []. // CHECK: {{#0 .* operator new}} -// CHECK: {{#1 .* main .*operator_array_new_right_oob.cpp}}:[[@LINE-9]] +// CHECK: {{#1 .* main .*operator_array_new_oob_after.cpp}}:[[@LINE-9]] delete [] buffer; } diff --git a/compiler-rt/test/asan/TestCases/Windows/operator_array_new_left_oob.cpp b/compiler-rt/test/asan/TestCases/Windows/operator_array_new_oob_before.cpp rename from compiler-rt/test/asan/TestCases/Windows/operator_array_new_left_oob.cpp rename to compiler-rt/test/asan/TestCases/Windows/operator_array_new_oob_before.cpp --- a/compiler-rt/test/asan/TestCases/Windows/operator_array_new_left_oob.cpp +++ b/compiler-rt/test/asan/TestCases/Windows/operator_array_new_oob_before.cpp @@ -6,12 +6,12 @@ buffer[-1] = 42; // CHECK: AddressSanitizer: heap-buffer-overflow on address [[ADDR:0x[0-9a-f]+]] // CHECK: WRITE of size 1 at [[ADDR]] thread T0 -// CHECK-NEXT: {{#0 .* main .*operator_array_new_left_oob.cpp}}:[[@LINE-3]] +// CHECK-NEXT: {{#0 .* main .*operator_array_new_oob_before.cpp}}:[[@LINE-3]] // // CHECK: [[ADDR]] is located 1 bytes before 42-byte region // CHECK-LABEL: allocated by thread T0 here: // FIXME: The 'operator new' frame should have []. // CHECK-NEXT: {{#0 .* operator new}} -// CHECK-NEXT: {{#1 .* main .*operator_array_new_left_oob.cpp}}:[[@LINE-10]] +// CHECK-NEXT: {{#1 .* main .*operator_array_new_oob_before.cpp}}:[[@LINE-10]] delete [] buffer; } diff --git a/compiler-rt/test/asan/TestCases/Windows/operator_array_new_with_dtor_left_oob.cpp b/compiler-rt/test/asan/TestCases/Windows/operator_array_new_with_dtor_oob_before.cpp rename from compiler-rt/test/asan/TestCases/Windows/operator_array_new_with_dtor_left_oob.cpp rename to compiler-rt/test/asan/TestCases/Windows/operator_array_new_with_dtor_oob_before.cpp --- a/compiler-rt/test/asan/TestCases/Windows/operator_array_new_with_dtor_left_oob.cpp +++ b/compiler-rt/test/asan/TestCases/Windows/operator_array_new_with_dtor_oob_before.cpp @@ -13,7 +13,7 @@ buffer[hide(-(1 + (int)sizeof(void*) / 4))].x = 42; // CHECK: AddressSanitizer: heap-buffer-overflow on address [[ADDR:0x[0-9a-f]+]] // CHECK: WRITE of size 4 at [[ADDR]] thread T0 -// CHECK-NEXT: {{#0 .* main .*operator_array_new_with_dtor_left_oob.cpp}}:[[@LINE-3]] +// CHECK-NEXT: {{#0 .* main .*operator_array_new_with_dtor_oob_before.cpp}}:[[@LINE-3]] // // FIXME: Currently it says "4 bytes ... left of 172-byte region", // should be "8 bytes ... left of 168-byte region", see @@ -22,6 +22,6 @@ // CHECK-LABEL: allocated by thread T0 here: // FIXME: The 'operator new' frame should have []. // CHECK-NEXT: {{#0 .* operator new}} -// CHECK-NEXT: {{#1 .* main .*operator_array_new_with_dtor_left_oob.cpp}}:[[@LINE-13]] +// CHECK-NEXT: {{#1 .* main .*operator_array_new_with_dtor_oob_before.cpp}}:[[@LINE-13]] delete [] buffer; } diff --git a/compiler-rt/test/asan/TestCases/Windows/operator_new_right_oob.cpp b/compiler-rt/test/asan/TestCases/Windows/operator_new_oob_after.cpp rename from compiler-rt/test/asan/TestCases/Windows/operator_new_right_oob.cpp rename to compiler-rt/test/asan/TestCases/Windows/operator_new_oob_after.cpp --- a/compiler-rt/test/asan/TestCases/Windows/operator_new_right_oob.cpp +++ b/compiler-rt/test/asan/TestCases/Windows/operator_new_oob_after.cpp @@ -8,10 +8,10 @@ buffer[1] = 42; // CHECK: AddressSanitizer: heap-buffer-overflow on address [[ADDR:0x[0-9a-f]+]] // CHECK: WRITE of size 1 at [[ADDR]] thread T0 -// CHECK: {{#0 .* main .*operator_new_right_oob.cpp}}:[[@LINE-3]] +// CHECK: {{#0 .* main .*operator_new_oob_after.cpp}}:[[@LINE-3]] // CHECK: [[ADDR]] is located 0 bytes after 1-byte region // CHECK: allocated by thread T0 here: // CHECK: {{#0 .* operator new}} -// CHECK: {{#1 .* main .*operator_new_right_oob.cpp}}:[[@LINE-8]] +// CHECK: {{#1 .* main .*operator_new_oob_after.cpp}}:[[@LINE-8]] delete buffer; } diff --git a/compiler-rt/test/asan/TestCases/Windows/operator_new_left_oob.cpp b/compiler-rt/test/asan/TestCases/Windows/operator_new_oob_before.cpp rename from compiler-rt/test/asan/TestCases/Windows/operator_new_left_oob.cpp rename to compiler-rt/test/asan/TestCases/Windows/operator_new_oob_before.cpp --- a/compiler-rt/test/asan/TestCases/Windows/operator_new_left_oob.cpp +++ b/compiler-rt/test/asan/TestCases/Windows/operator_new_oob_before.cpp @@ -8,10 +8,10 @@ buffer[-1] = 42; // CHECK: AddressSanitizer: heap-buffer-overflow on address [[ADDR:0x[0-9a-f]+]] // CHECK: WRITE of size 1 at [[ADDR]] thread T0 -// CHECK: {{#0 .* main .*operator_new_left_oob.cpp}}:[[@LINE-3]] +// CHECK: {{#0 .* main .*operator_new_oob_before.cpp}}:[[@LINE-3]] // CHECK: [[ADDR]] is located 1 bytes before 1-byte region // CHECK: allocated by thread T0 here: // CHECK: {{#0 .* operator new}} -// CHECK: {{#1 .* main .*operator_new_left_oob.cpp}}:[[@LINE-8]] +// CHECK: {{#1 .* main .*operator_new_oob_before.cpp}}:[[@LINE-8]] delete buffer; } diff --git a/compiler-rt/test/asan/TestCases/Windows/realloc_right_oob.cpp b/compiler-rt/test/asan/TestCases/Windows/realloc_oob_after.cpp rename from compiler-rt/test/asan/TestCases/Windows/realloc_right_oob.cpp rename to compiler-rt/test/asan/TestCases/Windows/realloc_oob_after.cpp --- a/compiler-rt/test/asan/TestCases/Windows/realloc_right_oob.cpp +++ b/compiler-rt/test/asan/TestCases/Windows/realloc_oob_after.cpp @@ -8,10 +8,10 @@ buffer[42] = 42; // CHECK: AddressSanitizer: heap-buffer-overflow on address [[ADDR:0x[0-9a-f]+]] // CHECK: WRITE of size 1 at [[ADDR]] thread T0 -// CHECK-NEXT: {{#0 .* main .*realloc_right_oob.cpp}}:[[@LINE-3]] +// CHECK-NEXT: {{#0 .* main .*realloc_oob_after.cpp}}:[[@LINE-3]] // CHECK: [[ADDR]] is located 0 bytes after 42-byte region // CHECK: allocated by thread T0 here: // CHECK-NEXT: {{#0 .* realloc }} -// CHECK-NEXT: {{#1 .* main .*realloc_right_oob.cpp}}:[[@LINE-8]] +// CHECK-NEXT: {{#1 .* main .*realloc_oob_after.cpp}}:[[@LINE-8]] free(buffer); } diff --git a/compiler-rt/test/asan/TestCases/Windows/realloc_left_oob.cpp b/compiler-rt/test/asan/TestCases/Windows/realloc_oob_before.cpp rename from compiler-rt/test/asan/TestCases/Windows/realloc_left_oob.cpp rename to compiler-rt/test/asan/TestCases/Windows/realloc_oob_before.cpp --- a/compiler-rt/test/asan/TestCases/Windows/realloc_left_oob.cpp +++ b/compiler-rt/test/asan/TestCases/Windows/realloc_oob_before.cpp @@ -8,10 +8,10 @@ buffer[-1] = 42; // CHECK: AddressSanitizer: heap-buffer-overflow on address [[ADDR:0x[0-9a-f]+]] // CHECK: WRITE of size 1 at [[ADDR]] thread T0 -// CHECK-NEXT: {{#0 .* main .*realloc_left_oob.cpp}}:[[@LINE-3]] +// CHECK-NEXT: {{#0 .* main .*realloc_oob_before.cpp}}:[[@LINE-3]] // CHECK: [[ADDR]] is located 1 bytes before 42-byte region // CHECK: allocated by thread T0 here: // CHECK-NEXT: {{#0 .* realloc }} -// CHECK-NEXT: {{#1 .* main .*realloc_left_oob.cpp}}:[[@LINE-8]] +// CHECK-NEXT: {{#1 .* main .*realloc_oob_before.cpp}}:[[@LINE-8]] free(buffer); } diff --git a/compiler-rt/test/asan/TestCases/Windows/stack_array_right_oob.cpp b/compiler-rt/test/asan/TestCases/Windows/stack_array_oob_after.cpp rename from compiler-rt/test/asan/TestCases/Windows/stack_array_right_oob.cpp rename to compiler-rt/test/asan/TestCases/Windows/stack_array_oob_after.cpp --- a/compiler-rt/test/asan/TestCases/Windows/stack_array_right_oob.cpp +++ b/compiler-rt/test/asan/TestCases/Windows/stack_array_oob_after.cpp @@ -9,8 +9,8 @@ buffer[subscript] = 42; // CHECK: AddressSanitizer: stack-buffer-overflow on address [[ADDR:0x[0-9a-f]+]] // CHECK: WRITE of size 1 at [[ADDR]] thread T0 -// CHECK-NEXT: {{#0 .* main .*stack_array_right_oob.cpp}}:[[@LINE-3]] +// CHECK-NEXT: {{#0 .* main .*stack_array_oob_after.cpp}}:[[@LINE-3]] // CHECK: Address [[ADDR]] is located in stack of thread T0 at offset [[OFFSET:.*]] in frame -// CHECK-NEXT: {{#0 .* main .*stack_array_right_oob.cpp}} +// CHECK-NEXT: {{#0 .* main .*stack_array_oob_after.cpp}} // CHECK: 'buffer'{{.*}} <== Memory access at offset [[OFFSET]] overflows this variable } diff --git a/compiler-rt/test/asan/TestCases/Windows/stack_array_left_oob.cpp b/compiler-rt/test/asan/TestCases/Windows/stack_array_oob_before.cpp rename from compiler-rt/test/asan/TestCases/Windows/stack_array_left_oob.cpp rename to compiler-rt/test/asan/TestCases/Windows/stack_array_oob_before.cpp --- a/compiler-rt/test/asan/TestCases/Windows/stack_array_left_oob.cpp +++ b/compiler-rt/test/asan/TestCases/Windows/stack_array_oob_before.cpp @@ -9,8 +9,8 @@ buffer[subscript] = 42; // CHECK: AddressSanitizer: stack-buffer-underflow on address [[ADDR:0x[0-9a-f]+]] // CHECK: WRITE of size 1 at [[ADDR]] thread T0 -// CHECK-NEXT: {{#0 .* main .*stack_array_left_oob.cpp}}:[[@LINE-3]] +// CHECK-NEXT: {{#0 .* main .*stack_array_oob_before.cpp}}:[[@LINE-3]] // CHECK: Address [[ADDR]] is located in stack of thread T0 at offset [[OFFSET:.*]] in frame -// CHECK-NEXT: {{#0 .* main .*stack_array_left_oob.cpp}} +// CHECK-NEXT: {{#0 .* main .*stack_array_oob_before.cpp}} // CHECK: 'buffer'{{.*}} <== Memory access at offset [[OFFSET]] underflows this variable } diff --git a/compiler-rt/test/asan/TestCases/Windows/thread_stack_array_right_oob.cpp b/compiler-rt/test/asan/TestCases/Windows/thread_stack_array_oob_after.cpp rename from compiler-rt/test/asan/TestCases/Windows/thread_stack_array_right_oob.cpp rename to compiler-rt/test/asan/TestCases/Windows/thread_stack_array_oob_after.cpp --- a/compiler-rt/test/asan/TestCases/Windows/thread_stack_array_right_oob.cpp +++ b/compiler-rt/test/asan/TestCases/Windows/thread_stack_array_oob_after.cpp @@ -9,7 +9,7 @@ stack_buffer[subscript] = 42; // CHECK: AddressSanitizer: stack-buffer-overflow on address [[ADDR:0x[0-9a-f]+]] // CHECK: WRITE of size 1 at [[ADDR]] thread T1 -// CHECK: {{#0 .* thread_proc.*thread_stack_array_right_oob.cpp}}:[[@LINE-3]] +// CHECK: {{#0 .* thread_proc.*thread_stack_array_oob_after.cpp}}:[[@LINE-3]] // CHECK: Address [[ADDR]] is located in stack of thread T1 at offset {{.*}} in frame // CHECK: thread_proc return 0; @@ -18,7 +18,7 @@ int main(void) { HANDLE thr = CreateThread(NULL, 0, thread_proc, NULL, 0, NULL); // CHECK: Thread T1 created by T0 here: -// CHECK: {{#[01] .* main .*thread_stack_array_right_oob.cpp}}:[[@LINE-2]] +// CHECK: {{#[01] .* main .*thread_stack_array_oob_after.cpp}}:[[@LINE-2]] // A failure to create a thread should fail the test! if (thr == 0) return 0; diff --git a/compiler-rt/test/asan/TestCases/Windows/thread_stack_array_left_oob.cpp b/compiler-rt/test/asan/TestCases/Windows/thread_stack_array_oob_before.cpp rename from compiler-rt/test/asan/TestCases/Windows/thread_stack_array_left_oob.cpp rename to compiler-rt/test/asan/TestCases/Windows/thread_stack_array_oob_before.cpp --- a/compiler-rt/test/asan/TestCases/Windows/thread_stack_array_left_oob.cpp +++ b/compiler-rt/test/asan/TestCases/Windows/thread_stack_array_oob_before.cpp @@ -9,7 +9,7 @@ stack_buffer[subscript] = 42; // CHECK: AddressSanitizer: stack-buffer-underflow on address [[ADDR:0x[0-9a-f]+]] // CHECK: WRITE of size 1 at [[ADDR]] thread T1 -// CHECK: {{#0 .* thread_proc.*thread_stack_array_left_oob.cpp}}:[[@LINE-3]] +// CHECK: {{#0 .* thread_proc.*thread_stack_array_oob_before.cpp}}:[[@LINE-3]] // CHECK: Address [[ADDR]] is located in stack of thread T1 at offset {{.*}} in frame // CHECK: thread_proc return 0; @@ -18,7 +18,7 @@ int main() { HANDLE thr = CreateThread(NULL, 0, thread_proc, NULL, 0, NULL); // CHECK: Thread T1 created by T0 here: -// CHECK: {{#[01] .* main .*thread_stack_array_left_oob.cpp}}:[[@LINE-2]] +// CHECK: {{#[01] .* main .*thread_stack_array_oob_before.cpp}}:[[@LINE-2]] // A failure to create a thread should fail the test! if (thr == 0) return 0; diff --git a/llvm/include/llvm/Transforms/Utils/ASanStackFrameLayout.h b/llvm/include/llvm/Transforms/Utils/ASanStackFrameLayout.h --- a/llvm/include/llvm/Transforms/Utils/ASanStackFrameLayout.h +++ b/llvm/include/llvm/Transforms/Utils/ASanStackFrameLayout.h @@ -20,9 +20,9 @@ // These magic constants should be the same as in // in asan_internal.h from ASan runtime in compiler-rt. -static const int kAsanStackLeftRedzoneMagic = 0xf1; +static const int kAsanStackFrontRedzoneMagic = 0xf1; static const int kAsanStackMidRedzoneMagic = 0xf2; -static const int kAsanStackRightRedzoneMagic = 0xf3; +static const int kAsanStackBackRedzoneMagic = 0xf3; static const int kAsanStackUseAfterReturnMagic = 0xf5; static const int kAsanStackUseAfterScopeMagic = 0xf8; diff --git a/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp b/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp --- a/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp +++ b/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp @@ -2265,8 +2265,9 @@ Type *Ty = G->getValueType(); const uint64_t SizeInBytes = DL.getTypeAllocSize(Ty); - const uint64_t RightRedzoneSize = getRedzoneSizeForGlobal(SizeInBytes); - Type *RightRedZoneTy = ArrayType::get(IRB.getInt8Ty(), RightRedzoneSize); + const uint64_t SucceedingRedzoneSize = getRedzoneSizeForGlobal(SizeInBytes); + Type *RightRedZoneTy = + ArrayType::get(IRB.getInt8Ty(), SucceedingRedzoneSize); StructType *NewTy = StructType::get(Ty, RightRedZoneTy); Constant *NewInitializer = ConstantStruct::get( @@ -2346,7 +2347,7 @@ GlobalStructTy, ConstantExpr::getPointerCast(InstrumentedGlobal, IntptrTy), ConstantInt::get(IntptrTy, SizeInBytes), - ConstantInt::get(IntptrTy, SizeInBytes + RightRedzoneSize), + ConstantInt::get(IntptrTy, SizeInBytes + SucceedingRedzoneSize), ConstantExpr::getPointerCast(Name, IntptrTy), ConstantExpr::getPointerCast(ModuleName, IntptrTy), ConstantInt::get(IntptrTy, MD.IsDynInit), diff --git a/llvm/lib/Transforms/Utils/ASanStackFrameLayout.cpp b/llvm/lib/Transforms/Utils/ASanStackFrameLayout.cpp --- a/llvm/lib/Transforms/Utils/ASanStackFrameLayout.cpp +++ b/llvm/lib/Transforms/Utils/ASanStackFrameLayout.cpp @@ -118,7 +118,7 @@ SmallVector SB; SB.clear(); const uint64_t Granularity = Layout.Granularity; - SB.resize(Vars[0].Offset / Granularity, kAsanStackLeftRedzoneMagic); + SB.resize(Vars[0].Offset / Granularity, kAsanStackFrontRedzoneMagic); for (const auto &Var : Vars) { SB.resize(Var.Offset / Granularity, kAsanStackMidRedzoneMagic); @@ -126,7 +126,7 @@ if (Var.Size % Granularity) SB.push_back(Var.Size % Granularity); } - SB.resize(Layout.FrameSize / Granularity, kAsanStackRightRedzoneMagic); + SB.resize(Layout.FrameSize / Granularity, kAsanStackBackRedzoneMagic); return SB; } diff --git a/llvm/unittests/Transforms/Utils/ASanStackFrameLayoutTest.cpp b/llvm/unittests/Transforms/Utils/ASanStackFrameLayoutTest.cpp --- a/llvm/unittests/Transforms/Utils/ASanStackFrameLayoutTest.cpp +++ b/llvm/unittests/Transforms/Utils/ASanStackFrameLayoutTest.cpp @@ -17,8 +17,8 @@ std::ostringstream os; for (size_t i = 0, n = ShadowBytes.size(); i < n; i++) { switch (ShadowBytes[i]) { - case kAsanStackLeftRedzoneMagic: os << "L"; break; - case kAsanStackRightRedzoneMagic: os << "R"; break; + case kAsanStackFrontRedzoneMagic: os << "F"; break; + case kAsanStackBackRedzoneMagic: os << "B"; break; case kAsanStackMidRedzoneMagic: os << "M"; break; case kAsanStackUseAfterScopeMagic: os << "S"; @@ -69,65 +69,65 @@ VAR(a, 105, 103, 1, 0); VAR(a, 200, 97, 1, 0); - TEST_LAYOUT({a1_1}, 8, 16, "1 16 1 4 a1_1", "LL1R", "LL1R"); - TEST_LAYOUT({a1_1}, 16, 16, "1 16 1 4 a1_1", "L1R", "L1R"); - TEST_LAYOUT({a1_1}, 32, 32, "1 32 1 4 a1_1", "L1R", "L1R"); - TEST_LAYOUT({a1_1}, 64, 64, "1 64 1 4 a1_1", "L1R", "L1R"); - TEST_LAYOUT({p1_32}, 8, 32, "1 32 1 8 p1_32:15", "LLLL1RRR", "LLLL1RRR"); - TEST_LAYOUT({p1_32}, 8, 64, "1 64 1 8 p1_32:15", "LLLLLLLL1RRRRRRR", - "LLLLLLLL1RRRRRRR"); + TEST_LAYOUT({a1_1}, 8, 16, "1 16 1 4 a1_1", "FF1B", "FF1B"); + TEST_LAYOUT({a1_1}, 16, 16, "1 16 1 4 a1_1", "F1B", "F1B"); + TEST_LAYOUT({a1_1}, 32, 32, "1 32 1 4 a1_1", "F1B", "F1B"); + TEST_LAYOUT({a1_1}, 64, 64, "1 64 1 4 a1_1", "F1B", "F1B"); + TEST_LAYOUT({p1_32}, 8, 32, "1 32 1 8 p1_32:15", "FFFF1BBB", "FFFF1BBB"); + TEST_LAYOUT({p1_32}, 8, 64, "1 64 1 8 p1_32:15", "FFFFFFFF1BBBBBBB", + "FFFFFFFF1BBBBBBB"); - TEST_LAYOUT({a1_1}, 8, 32, "1 32 1 4 a1_1", "LLLL1RRR", "LLLL1RRR"); - TEST_LAYOUT({a2_1}, 8, 32, "1 32 2 4 a2_1", "LLLL2RRR", "LLLL2RRR"); - TEST_LAYOUT({a3_1}, 8, 32, "1 32 3 4 a3_1", "LLLL3RRR", "LLLL3RRR"); - TEST_LAYOUT({a4_1}, 8, 32, "1 32 4 4 a4_1", "LLLL4RRR", "LLLL4RRR"); - TEST_LAYOUT({a7_1}, 8, 32, "1 32 7 4 a7_1", "LLLL7RRR", "LLLL7RRR"); - TEST_LAYOUT({a8_1}, 8, 32, "1 32 8 4 a8_1", "LLLL0RRR", "LLLLSRRR"); - TEST_LAYOUT({a9_1}, 8, 32, "1 32 9 4 a9_1", "LLLL01RR", "LLLL01RR"); - TEST_LAYOUT({a16_1}, 8, 32, "1 32 16 5 a16_1", "LLLL00RR", "LLLLSSRR"); + TEST_LAYOUT({a1_1}, 8, 32, "1 32 1 4 a1_1", "FFFF1BBB", "FFFF1BBB"); + TEST_LAYOUT({a2_1}, 8, 32, "1 32 2 4 a2_1", "FFFF2BBB", "FFFF2BBB"); + TEST_LAYOUT({a3_1}, 8, 32, "1 32 3 4 a3_1", "FFFF3BBB", "FFFF3BBB"); + TEST_LAYOUT({a4_1}, 8, 32, "1 32 4 4 a4_1", "FFFF4BBB", "FFFF4BBB"); + TEST_LAYOUT({a7_1}, 8, 32, "1 32 7 4 a7_1", "FFFF7BBB", "FFFF7BBB"); + TEST_LAYOUT({a8_1}, 8, 32, "1 32 8 4 a8_1", "FFFF0BBB", "FFFFSBBB"); + TEST_LAYOUT({a9_1}, 8, 32, "1 32 9 4 a9_1", "FFFF01BB", "FFFF01BB"); + TEST_LAYOUT({a16_1}, 8, 32, "1 32 16 5 a16_1", "FFFF00BB", "FFFFSSBB"); TEST_LAYOUT({p1_256}, 8, 32, "1 256 1 11 p1_256:2700", - "LLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLL1RRR", - "LLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLL1RRR"); - TEST_LAYOUT({a41_1}, 8, 32, "1 32 41 7 a41_1:7", "LLLL000001RRRRRR", - "LLLLSS0001RRRRRR"); - TEST_LAYOUT({a105_1}, 8, 32, "1 32 105 6 a105_1", "LLLL00000000000001RRRRRR", - "LLLLSSSSSSSSSSSSS1RRRRRR"); + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF1BBB", + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF1BBB"); + TEST_LAYOUT({a41_1}, 8, 32, "1 32 41 7 a41_1:7", "FFFF000001BBBBBB", + "FFFFSS0001BBBBBB"); + TEST_LAYOUT({a105_1}, 8, 32, "1 32 105 6 a105_1", "FFFF00000000000001BBBBBB", + "FFFFSSSSSSSSSSSSS1BBBBBB"); { SmallVector t = {a1_1, p1_256}; TEST_LAYOUT(t, 8, 32, "2 256 1 11 p1_256:2700 272 1 4 a1_1", - "LLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLL1M1R", - "LLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLL1M1R"); + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF1M1B", + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF1M1B"); } { SmallVector t = {a1_1, a16_1, a41_1}; TEST_LAYOUT(t, 8, 32, "3 32 1 4 a1_1 48 16 5 a16_1 80 41 7 a41_1:7", - "LLLL1M00MM000001RRRR", "LLLL1MSSMMSS0001RRRR"); + "FFFF1M00MM000001BBBB", "FFFF1MSSMMSS0001BBBB"); } - TEST_LAYOUT({a2_1}, 32, 32, "1 32 2 4 a2_1", "L2R", "L2R"); - TEST_LAYOUT({a9_1}, 32, 32, "1 32 9 4 a9_1", "L9R", "L9R"); - TEST_LAYOUT({a16_1}, 32, 32, "1 32 16 5 a16_1", "L16R", "LSR"); + TEST_LAYOUT({a2_1}, 32, 32, "1 32 2 4 a2_1", "F2B", "F2B"); + TEST_LAYOUT({a9_1}, 32, 32, "1 32 9 4 a9_1", "F9B", "F9B"); + TEST_LAYOUT({a16_1}, 32, 32, "1 32 16 5 a16_1", "F16B", "FSB"); TEST_LAYOUT({p1_256}, 32, 32, "1 256 1 11 p1_256:2700", - "LLLLLLLL1R", "LLLLLLLL1R"); - TEST_LAYOUT({a41_1}, 32, 32, "1 32 41 7 a41_1:7", "L09R", - "LS9R"); - TEST_LAYOUT({a105_1}, 32, 32, "1 32 105 6 a105_1", "L0009R", - "LSSSSR"); - TEST_LAYOUT({a200_1}, 32, 32, "1 32 200 6 a200_1", "L0000008RR", - "LSSSS008RR"); + "FFFFFFFF1B", "FFFFFFFF1B"); + TEST_LAYOUT({a41_1}, 32, 32, "1 32 41 7 a41_1:7", "F09B", + "FS9B"); + TEST_LAYOUT({a105_1}, 32, 32, "1 32 105 6 a105_1", "F0009B", + "FSSSSB"); + TEST_LAYOUT({a200_1}, 32, 32, "1 32 200 6 a200_1", "F0000008BB", + "FSSSS008BB"); { SmallVector t = {a1_1, p1_256}; TEST_LAYOUT(t, 32, 32, "2 256 1 11 p1_256:2700 320 1 4 a1_1", - "LLLLLLLL1M1R", "LLLLLLLL1M1R"); + "FFFFFFFF1M1B", "FFFFFFFF1M1B"); } { SmallVector t = {a1_1, a16_1, a41_1}; TEST_LAYOUT(t, 32, 32, "3 32 1 4 a1_1 96 16 5 a16_1 160 41 7 a41_1:7", - "L1M16M09R", "L1MSMS9R"); + "F1M16M09B", "F1MSMS9B"); } #undef VAR #undef TEST_LAYOUT