]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
libctf: fix ctf_archive_count return value on big-endian
authorNick Alcock <nick.alcock@oracle.com>
Tue, 30 Jul 2024 11:28:04 +0000 (12:28 +0100)
committerNick Alcock <nick.alcock@oracle.com>
Wed, 31 Jul 2024 20:10:06 +0000 (21:10 +0100)
This failed to properly byteswap its return value.

The ctf_archive format predates the idea of "just write natively and
flip on open", and byteswaps all over the place.  It's too easy to
forget one.  The next revision of the archive format (not versioned,
so we just tweak the magic number instead) should be native-endianned
like the dicts inside it are.

libctf/
* ctf-archive.c (ctf_archive_count): Byteswap return value.

libctf/ctf-archive.c

index 0034bf0982a5189d77e99c2037d46584acf0e0d3..b73999cacb59661a98bbd98a6ada449e99b7da2c 100644 (file)
@@ -785,7 +785,7 @@ ctf_archive_count (const ctf_archive_t *wrapper)
   if (!wrapper->ctfi_is_archive)
     return 1;
 
-  return wrapper->ctfi_archive->ctfa_ndicts;
+  return le64toh (wrapper->ctfi_archive->ctfa_ndicts);
 }
 
 /* Look up a symbol in an archive by name or index (if the name is set, a lookup