From: Nick Alcock Date: Wed, 1 Jul 2020 19:10:17 +0000 (+0100) Subject: libctf, binutils: fix big-endian libctf archive opening X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=4533ed564d6953990210ba63c091009380ec2327;p=binutils-gdb.git libctf, binutils: fix big-endian libctf archive opening 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. --- diff --git a/libctf/ChangeLog b/libctf/ChangeLog index 803e8dea99c..cfb9d01b803 100644 --- a/libctf/ChangeLog +++ b/libctf/ChangeLog @@ -1,3 +1,8 @@ +2020-07-22 Nick Alcock + + * ctf-archive.c (ctf_arc_bufopen): Endian-swap the archive magic + number if needed. + 2020-07-22 Nick Alcock * ctf-impl.h (ctf_list_splice): New. diff --git a/libctf/ctf-archive.c b/libctf/ctf-archive.c index 457855207bf..87e682c3943 100644 --- a/libctf/ctf-archive.c +++ b/libctf/ctf-archive.c @@ -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.