Index: llvm/trunk/lib/ProfileData/Coverage/CoverageMappingReader.cpp =================================================================== --- llvm/trunk/lib/ProfileData/Coverage/CoverageMappingReader.cpp +++ llvm/trunk/lib/ProfileData/Coverage/CoverageMappingReader.cpp @@ -491,6 +491,13 @@ return coveragemap_error::malformed; ProfileNames.create(Data.substr(0, ProfileNamesSize), Address); CoverageMapping = Data.substr(ProfileNamesSize); + // Skip the padding bytes because coverage map data has an alignment of 8. + if (CoverageMapping.size() < 1) + return coveragemap_error::truncated; + size_t Pad = alignmentAdjustment(CoverageMapping.data(), 8); + if (CoverageMapping.size() < Pad) + return coveragemap_error::malformed; + CoverageMapping = CoverageMapping.substr(Pad); return std::error_code(); } Index: llvm/trunk/tools/llvm-cov/TestingSupport.cpp =================================================================== --- llvm/trunk/tools/llvm-cov/TestingSupport.cpp +++ llvm/trunk/tools/llvm-cov/TestingSupport.cpp @@ -88,7 +88,11 @@ OS << "llvmcovmtestdata"; encodeULEB128(ProfileNamesData.size(), OS); encodeULEB128(ProfileNamesAddress, OS); - OS << ProfileNamesData << CoverageMappingData; + OS << ProfileNamesData; + // Coverage mapping data is expected to have an alignment of 8. + for (unsigned Pad = OffsetToAlignment(OS.tell(), 8); Pad; --Pad) + OS.write(uint8_t(0)); + OS << CoverageMappingData; return 0; }