[llvm] r204513 - InstrProf: Change magic number to have non-text characters

Duncan P. N. Exon Smith dexonsmith at apple.com
Fri Mar 21 13:42:37 PDT 2014


Author: dexonsmith
Date: Fri Mar 21 15:42:37 2014
New Revision: 204513

URL: http://llvm.org/viewvc/llvm-project?rev=204513&view=rev
Log:
InstrProf: Change magic number to have non-text characters

Include non-text characters in the magic number so that text files can't
match.

<rdar://problem/15950346>

Modified:
    llvm/trunk/lib/ProfileData/InstrProfReader.cpp
    llvm/trunk/test/tools/llvm-profdata/Inputs/binary.profdata
    llvm/trunk/test/tools/llvm-profdata/raw-magic-but-no-header.test

Modified: llvm/trunk/lib/ProfileData/InstrProfReader.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ProfileData/InstrProfReader.cpp?rev=204513&r1=204512&r2=204513&view=diff
==============================================================================
--- llvm/trunk/lib/ProfileData/InstrProfReader.cpp (original)
+++ llvm/trunk/lib/ProfileData/InstrProfReader.cpp Fri Mar 21 15:42:37 2014
@@ -90,14 +90,14 @@ RawInstrProfReader::RawInstrProfReader(s
 
 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) {

Modified: llvm/trunk/test/tools/llvm-profdata/Inputs/binary.profdata
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/llvm-profdata/Inputs/binary.profdata?rev=204513&r1=204512&r2=204513&view=diff
==============================================================================
Binary files llvm/trunk/test/tools/llvm-profdata/Inputs/binary.profdata (original) and llvm/trunk/test/tools/llvm-profdata/Inputs/binary.profdata Fri Mar 21 15:42:37 2014 differ

Modified: llvm/trunk/test/tools/llvm-profdata/raw-magic-but-no-header.test
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/llvm-profdata/raw-magic-but-no-header.test?rev=204513&r1=204512&r2=204513&view=diff
==============================================================================
--- llvm/trunk/test/tools/llvm-profdata/raw-magic-but-no-header.test (original)
+++ llvm/trunk/test/tools/llvm-profdata/raw-magic-but-no-header.test Fri Mar 21 15:42:37 2014
@@ -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





More information about the llvm-commits mailing list