[PATCH] D17660: ubsan: Fix endianness check in Value::getFloatValue for gcc

Marcin Koƛcielnicki via llvm-commits llvm-commits at lists.llvm.org
Fri Feb 26 15:26:14 PST 2016


koriakin created this revision.
koriakin added a subscriber: llvm-commits.
koriakin set the repository for this revision to rL LLVM.
koriakin added a project: Sanitizers.

It currently uses #if defined(__BIG_ENDIAN__), which is not supported
by gcc, and will silently fall through to the little endian branch,
breaking display of float values by ubsan.  Use __BYTE_ORDER__ ==
__ORDER_BIG_ENDIAN__ as the condition instead, which is supported
by both clang and gcc.
    
Noticed while porting ubsan to s390x.


Repository:
  rL LLVM

http://reviews.llvm.org/D17660

Files:
  lib/ubsan/ubsan_value.cc

Index: lib/ubsan/ubsan_value.cc
===================================================================
--- lib/ubsan/ubsan_value.cc
+++ lib/ubsan/ubsan_value.cc
@@ -83,7 +83,7 @@
 #endif
       case 32: {
         float Value;
-#if defined(__BIG_ENDIAN__)
+#if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
        // For big endian the float value is in the last 4 bytes.
        // On some targets we may only have 4 bytes so we count backwards from
        // the end of Val to account for both the 32-bit and 64-bit cases.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D17660.49257.patch
Type: text/x-patch
Size: 517 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160226/dbe5545c/attachment.bin>


More information about the llvm-commits mailing list