diff --git a/compiler-rt/test/profile/Linux/corrupted-profile.c b/compiler-rt/test/profile/Linux/corrupted-profile.c --- a/compiler-rt/test/profile/Linux/corrupted-profile.c +++ b/compiler-rt/test/profile/Linux/corrupted-profile.c @@ -42,10 +42,15 @@ if (Buf == MAP_FAILED) bail("mmap"); + // The binary IDs size is the 3rd uint64_t in the header. This size should + // already account for padding. + uint64_t BinaryIdsSize; + memcpy(&BinaryIdsSize, &Buf[2 * 8], sizeof(BinaryIdsSize)); + // We're trying to make the first CounterPtr invalid. // 11 64-bit words as header. // CounterPtr is the third 64-bit word field. - memset(&Buf[11 * 8 + 2 * 8], 0xAB, 8); + memset(&Buf[11 * 8 + BinaryIdsSize + 2 * 8], 0xAB, 8); if (munmap(Buf, FileSize)) bail("munmap");