Handle unaligned mapping of .gdb_index
[deliverable/binutils-gdb.git] / gdb / dwarf2 / index-common.h
index fa762c400fab4d650148e817b181b3da7328651e..861807475332b9bb938c4527029c587da82152ab 100644 (file)
    architecture-independent.  */
 typedef uint32_t offset_type;
 
-#if WORDS_BIGENDIAN
-
-/* Convert VALUE between big- and little-endian.  */
+/* Unpack a 32-bit little-endian value.  */
 
 static inline offset_type
-byte_swap (offset_type value)
+gdb_index_unpack (const gdb_byte *value)
 {
-  offset_type result;
-
-  result = (value & 0xff) << 24;
-  result |= (value & 0xff00) << 8;
-  result |= (value & 0xff0000) >> 8;
-  result |= (value & 0xff000000) >> 24;
-  return result;
+  return (offset_type) extract_unsigned_integer (value, sizeof (offset_type),
+                                                BFD_ENDIAN_LITTLE);
 }
 
-#define MAYBE_SWAP(V)  byte_swap (V)
-
-#else
-#define MAYBE_SWAP(V) static_cast<offset_type> (V)
-#endif /* WORDS_BIGENDIAN */
-
 /* The hash function for strings in the mapped index.  This is the same as
    SYMBOL_HASH_NEXT, but we keep a separate copy to maintain control over the
    implementation.  This is necessary because the hash function is tied to the
This page took 0.026757 seconds and 4 git commands to generate.