[libunwind] r365505 - [libunwind] Fix Unwind-EHABI.cpp:getByte on big-endian targets

Mikhail Maltsev via cfe-commits cfe-commits at lists.llvm.org
Tue Jul 9 08:29:06 PDT 2019


Author: miyuki
Date: Tue Jul  9 08:29:06 2019
New Revision: 365505

URL: http://llvm.org/viewvc/llvm-project?rev=365505&view=rev
Log:
[libunwind] Fix Unwind-EHABI.cpp:getByte on big-endian targets

Summary:
The function getByte is dependent on endianness and the current
behavior is incorrect on big-endian targets.

This patch fixes the issue.

Reviewers: phosek, ostannard, dmgreen, christof, chill

Reviewed By: ostannard, chill

Subscribers: chill, christof, libcxx-commits

Tags: #libc

Differential Revision: https://reviews.llvm.org/D64402

Modified:
    libunwind/trunk/src/Unwind-EHABI.cpp

Modified: libunwind/trunk/src/Unwind-EHABI.cpp
URL: http://llvm.org/viewvc/llvm-project/libunwind/trunk/src/Unwind-EHABI.cpp?rev=365505&r1=365504&r2=365505&view=diff
==============================================================================
--- libunwind/trunk/src/Unwind-EHABI.cpp (original)
+++ libunwind/trunk/src/Unwind-EHABI.cpp Tue Jul  9 08:29:06 2019
@@ -31,7 +31,11 @@ namespace {
 // signinficant byte.
 uint8_t getByte(const uint32_t* data, size_t offset) {
   const uint8_t* byteData = reinterpret_cast<const uint8_t*>(data);
+#ifdef __LITTLE_ENDIAN__
   return byteData[(offset & ~(size_t)0x03) + (3 - (offset & (size_t)0x03))];
+#else
+  return byteData[offset];
+#endif
 }
 
 const char* getNextWord(const char* data, uint32_t* out) {




More information about the cfe-commits mailing list