From 091c8253f5155e2446a930531a38dc5292585226 Mon Sep 17 00:00:00 2001 From: "Duncan P. N. Exon Smith" Date: Fri, 21 Mar 2014 20:42:37 +0000 Subject: [PATCH] InstrProf: Change magic number to have non-text characters Include non-text characters in the magic number so that text files can't match. llvm-svn: 204513 --- lib/ProfileData/InstrProfReader.cpp | 16 ++++++++-------- .../llvm-profdata/Inputs/binary.profdata | Bin 1384 -> 1384 bytes .../raw-magic-but-no-header.test | 4 ++-- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/lib/ProfileData/InstrProfReader.cpp b/lib/ProfileData/InstrProfReader.cpp index a95d9bc3b08..f923ad2ddd9 100644 --- a/lib/ProfileData/InstrProfReader.cpp +++ b/lib/ProfileData/InstrProfReader.cpp @@ -90,14 +90,14 @@ RawInstrProfReader::RawInstrProfReader(std::unique_ptr DataBuffer) static uint64_t getRawMagic() { return - uint64_t('l') << 56 | - uint64_t('p') << 48 | - uint64_t('r') << 40 | - uint64_t('o') << 32 | - uint64_t('f') << 24 | - uint64_t('r') << 16 | - uint64_t('a') << 8 | - uint64_t('w'); + uint64_t(255) << 56 | + uint64_t('l') << 48 | + uint64_t('p') << 40 | + uint64_t('r') << 32 | + uint64_t('o') << 24 | + uint64_t('f') << 16 | + uint64_t('r') << 8 | + uint64_t(129); } bool RawInstrProfReader::hasFormat(const MemoryBuffer &DataBuffer) { diff --git a/test/tools/llvm-profdata/Inputs/binary.profdata b/test/tools/llvm-profdata/Inputs/binary.profdata index 156c483d15f1979512b7599f89bfdba1e2d08bd8..e8cef21de5f258c5e08a1089280f282be0a77455 100644 GIT binary patch delta 405 zcmaFC^@59|u_!ISs37P6L=MGzhs&Id3=9l6oFOz1kj(5b<{9 delta 405 zcmaFC^@59|Jh3P(zo;N*B8OsqLIDdS0|Ud2WC+azWV1jqkb;YMK-GcdxuF;&{{*UU z1ymj+#|gzC`43QehD3<@tUxg_Cc?l#BA~~?0K^dwb0;+%ys0ld)^r7+#pz6vr2-rg9 g4?yL`fnrQh43c+*%AbJB!}O(qBpEg@V?4wR047{2p#T5? diff --git a/test/tools/llvm-profdata/raw-magic-but-no-header.test b/test/tools/llvm-profdata/raw-magic-but-no-header.test index e899ece2755..6db723c3e25 100644 --- a/test/tools/llvm-profdata/raw-magic-but-no-header.test +++ b/test/tools/llvm-profdata/raw-magic-but-no-header.test @@ -1,6 +1,6 @@ -RUN: printf "warforpl" > %t +RUN: printf '\201rforpl\377' > %t RUN: not llvm-profdata show %t 2>&1 | FileCheck %s -RUN: printf "lprofraw" > %t +RUN: printf '\377lprofr\201' > %t RUN: not llvm-profdata show %t 2>&1 | FileCheck %s CHECK: error: {{.+}}: Invalid header