diff options
author | Duncan P. N. Exon Smith <dexonsmith@apple.com> | 2014-03-21 20:42:40 +0000 |
---|---|---|
committer | Duncan P. N. Exon Smith <dexonsmith@apple.com> | 2014-03-21 20:42:40 +0000 |
commit | f313aa076ea04eaee4fb420db46a93ad6c7db6c4 (patch) | |
tree | 10849b1c38af6d013c9b6244e6f096018c6771e6 /lib/profile/InstrProfiling.c | |
parent | 44711f4e1d555e61d61a4575ccdc49905962f762 (diff) |
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>
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@204514 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/profile/InstrProfiling.c')
-rw-r--r-- | lib/profile/InstrProfiling.c | 25 |
1 files changed, 16 insertions, 9 deletions
diff --git a/lib/profile/InstrProfiling.c b/lib/profile/InstrProfiling.c index de88f1ba3..970907c40 100644 --- a/lib/profile/InstrProfiling.c +++ b/lib/profile/InstrProfiling.c @@ -11,16 +11,23 @@ #include <string.h> uint64_t __llvm_profile_get_magic(void) { - /* Magic number to detect file format and endianness. */ + /* Magic number to detect file format and endianness. + * + * Use 255 at one end, since no UTF-8 file can use that character. Avoid 0, + * so that utilities like strings doesn't grab it as a string. 129 is high + * enough to be interesting. + * + * Use "lprofr" in the centre to stand for "LLVM Profile Raw". + */ 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; } uint64_t __llvm_profile_get_version(void) { |