aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2018-04-04 17:18:14 +0000
committerJakub Jelinek <jakub@redhat.com>2018-04-04 17:18:14 +0000
commit35e81d985c4bc1f96ec04ca2b260522964e64756 (patch)
tree0fc23d219540f64c9e5f4d9e269450d14560245f
parentcf98e0cb2a0136c4bda636e2c2b68de8ff4e8c17 (diff)
PR other/85161
* elf.c (elf_zlib_fetch): Fix up predefined macro names in test for big endian, only use 32-bit loads if endianity macros are predefined and indicate big or little endian. git-svn-id: https://gcc.gnu.org/svn/gcc/trunk@259096 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--libbacktrace/ChangeLog7
-rw-r--r--libbacktrace/elf.c9
2 files changed, 15 insertions, 1 deletions
diff --git a/libbacktrace/ChangeLog b/libbacktrace/ChangeLog
index 64733a82ca2..85c8742b8a8 100644
--- a/libbacktrace/ChangeLog
+++ b/libbacktrace/ChangeLog
@@ -1,3 +1,10 @@
+2018-04-04 Jakub Jelinek <jakub@redhat.com>
+
+ PR other/85161
+ * elf.c (elf_zlib_fetch): Fix up predefined macro names in test for
+ big endian, only use 32-bit loads if endianity macros are predefined
+ and indicate big or little endian.
+
2018-02-14 Igor Tsimbalist <igor.v.tsimbalist@intel.com>
PR target/84148
diff --git a/libbacktrace/elf.c b/libbacktrace/elf.c
index 19da5a97b23..0fd5e6f9d0d 100644
--- a/libbacktrace/elf.c
+++ b/libbacktrace/elf.c
@@ -1086,12 +1086,19 @@ elf_zlib_fetch (const unsigned char **ppin, const unsigned char *pinend,
return 0;
}
+#if defined(__BYTE_ORDER__) && defined(__ORDER_LITTLE_ENDIAN__) \
+ && defined(__ORDER_BIG_ENDIAN__) \
+ && (__BYTE_ORDER__ == __ORDER_BIG_ENDIAN__ \
+ || __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__)
/* We've ensured that PIN is aligned. */
next = *(const uint32_t *)pin;
-#if __BYTE_ORDER == __ORDER_BIG_ENDIAN
+#if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
next = __builtin_bswap32 (next);
#endif
+#else
+ next = pin[0] | (pin[1] << 8) | (pin[2] << 16) | (pin[3] << 24);
+#endif
val |= (uint64_t)next << bits;
bits += 32;