Page MenuHomePhabricator

sanitizer: Fix endianness checks for gcc
ClosedPublic

Authored by koriakin on Feb 26 2016, 3:26 PM.

Details

Summary

BIG_ENDIAN and LITTLE_ENDIAN are not supported by gcc, which
eg. for ubsan Value::getFloatValue will silently fall through to
the little endian branch, breaking display of float values by ubsan.
Use BYTE_ORDER == ORDER_BIG/LITTLE_ENDIAN as the condition
instead, which is supported by both clang and gcc.

Noticed while porting ubsan to s390x.

Diff Detail

Repository
rL LLVM

Event Timeline

koriakin retitled this revision from to ubsan: Fix endianness check in Value::getFloatValue for gcc.
koriakin updated this object.
koriakin set the repository for this revision to rL LLVM.
koriakin added a project: Restricted Project.
koriakin added a subscriber: llvm-commits.
samsonov edited edge metadata.Mar 7 2016, 5:37 PM

We use __BIG_ENDIAN__ and __LITTLE_ENDIAN__ macro in a few places in sanitizers. Let's update all these use cases to a more portable form for consistency.

koriakin retitled this revision from ubsan: Fix endianness check in Value::getFloatValue for gcc to sanitizer: Fix endianness checks for gcc.
koriakin updated this object.
koriakin edited edge metadata.
koriakin removed rL LLVM as the repository for this revision.

Added a few other places in sanitizers. There are a few uses left, but these are in areas that shouldn't be hit by gcc/clang.

samsonov accepted this revision.Mar 8 2016, 12:04 PM
samsonov edited edge metadata.

LGTM. Thank you for fixing this!

This revision is now accepted and ready to land.Mar 8 2016, 12:04 PM

I don't have svn write access, how can I get this patch commited?

This revision was automatically updated to reflect the committed changes.