libctf, binutils: fix big-endian libctf archive opening
authorNick Alcock <nick.alcock@oracle.com>
Wed, 1 Jul 2020 19:10:17 +0000 (20:10 +0100)
committerNick Alcock <nick.alcock@oracle.com>
Wed, 22 Jul 2020 17:05:32 +0000 (18:05 +0100)
The recent commit "libctf, binutils: support CTF archives like objdump"
broke opening of CTF archives on big-endian platforms.

This didn't affect anyone much before now because the linker never
emitted CTF archives because it wasn't detecting ambiguous types
properly: now it does, and this bug becomes obvious.

Fix trivial.

libctf/
* ctf-archive.c (ctf_arc_bufopen): Endian-swap the archive magic
number if needed.

libctf/ChangeLog
libctf/ctf-archive.c

index 803e8dea99cf5413437b19c91738cc60a11e8485..cfb9d01b80322176304d42bf14bda99f396e27b4 100644 (file)
@@ -1,3 +1,8 @@
+2020-07-22  Nick Alcock  <nick.alcock@oracle.com>
+
+       * ctf-archive.c (ctf_arc_bufopen): Endian-swap the archive magic
+       number if needed.
+
 2020-07-22  Nick Alcock  <nick.alcock@oracle.com>
 
        * ctf-impl.h (ctf_list_splice): New.
index 457855207bffd349f95d0fb801b238e558c5eac2..87e682c3943a18006e2a80a75b9f71e2d94298d8 100644 (file)
@@ -386,7 +386,7 @@ ctf_arc_bufopen (const ctf_sect_t *ctfsect, const ctf_sect_t *symsect,
   ctf_file_t *fp = NULL;
 
   if (ctfsect->cts_size > sizeof (uint64_t) &&
-      ((*(uint64_t *) ctfsect->cts_data) == CTFA_MAGIC))
+      (le64toh ((*(uint64_t *) ctfsect->cts_data)) == CTFA_MAGIC))
     {
       /* The archive is mmappable, so this operation is trivial.