[PATCH] Fix sancov.py to once again support big endian
Bill Seurer
seurer at linux.vnet.ibm.com
Tue Mar 24 15:45:19 PDT 2015
Hi wschmidt, kbarton, kcc, nemanjai,
Some recent changes to sancov.py broke ASAN for big endian. This fixes it.
http://reviews.llvm.org/D8594
Files:
projects/compiler-rt/lib/sanitizer_common/scripts/sancov.py
Index: projects/compiler-rt/lib/sanitizer_common/scripts/sancov.py
===================================================================
--- projects/compiler-rt/lib/sanitizer_common/scripts/sancov.py
+++ projects/compiler-rt/lib/sanitizer_common/scripts/sancov.py
@@ -21,32 +21,35 @@
def CheckBits(bits):
if bits != 32 and bits != 64:
- raise Exception("Wrond bitness: %d" % bits)
+ raise Exception("Wrong bitness: %d" % bits)
def TypeCodeForBits(bits):
CheckBits(bits)
return 'L' if bits == 64 else 'I'
-kMagic64 = 0xC0BFFFFFFFFFFF64
-kMagic32 = 0xC0BFFFFFFFFFFF32
kMagic32SecondHalf = 0xFFFFFF32;
kMagic64SecondHalf = 0xFFFFFF64;
kMagicFirstHalf = 0xC0BFFFFF;
def MagicForBits(bits):
CheckBits(bits)
- # Little endian.
- return [kMagic64SecondHalf if bits == 64 else kMagic32SecondHalf, kMagicFirstHalf]
+ if sys.byteorder == 'little':
+ return [kMagic64SecondHalf if bits == 64 else kMagic32SecondHalf, kMagicFirstHalf]
+ else:
+ return [kMagicFirstHalf, kMagic64SecondHalf if bits == 64 else kMagic32SecondHalf]
def ReadMagicAndReturnBitness(f, path):
magic_bytes = f.read(8)
magic_words = struct.unpack('II', magic_bytes);
bits = 0
- # Assuming little endian.
- if magic_words[1] == kMagicFirstHalf:
- if magic_words[0] == kMagic64SecondHalf:
+ if sys.byteorder == 'little':
+ idx=1
+ else:
+ idx=0
+ if magic_words[idx] == kMagicFirstHalf:
+ if magic_words[1-idx] == kMagic64SecondHalf:
bits = 64
- elif magic_words[0] == kMagic32SecondHalf:
+ elif magic_words[1-idx] == kMagic32SecondHalf:
bits = 32
if bits == 0:
raise Exception('Bad magic word in %s' % path)
EMAIL PREFERENCES
http://reviews.llvm.org/settings/panel/emailpreferences/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D8594.22610.patch
Type: text/x-patch
Size: 1669 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150324/cdf7f56e/attachment.bin>
More information about the llvm-commits
mailing list