Simplify power of two test
authorAlan Modra <amodra@gmail.com>
Mon, 14 Oct 2019 09:59:12 +0000 (20:29 +1030)
committerAlan Modra <amodra@gmail.com>
Tue, 15 Oct 2019 05:30:54 +0000 (16:00 +1030)
* bfd.c (bfd_check_compression_header): Check for powers of two
with x == (x & -x).

bfd/ChangeLog
bfd/bfd.c

index a1eaef95d8d904ea72b4655679ff2704dddf9eb9..4d8db193f2e61bed7df068d82cdb2608d016f6c5 100644 (file)
@@ -1,3 +1,8 @@
+2019-10-15  Alan Modra  <amodra@gmail.com>
+
+       * bfd.c (bfd_check_compression_header): Check for powers of two
+       with x == (x & -x).
+
 2019-10-14  Alan Modra  <amodra@gmail.com>
 
        * syms.c (struct indexentry): Add idx field.
index af2c192260d4b776995b8128ac9a195c530c1c8c..b3078eaa525063e81907a1de3a06f4f4fb4766e6 100644 (file)
--- a/bfd/bfd.c
+++ b/bfd/bfd.c
@@ -2635,7 +2635,7 @@ bfd_check_compression_header (bfd *abfd, bfd_byte *contents,
          chdr.ch_addralign = bfd_get_64 (abfd, &echdr->ch_addralign);
        }
       if (chdr.ch_type == ELFCOMPRESS_ZLIB
-         && chdr.ch_addralign == (1U << bfd_log2 (chdr.ch_addralign)))
+         && chdr.ch_addralign == (chdr.ch_addralign & -chdr.ch_addralign))
        {
          *uncompressed_size = chdr.ch_size;
          *uncompressed_alignment_power = bfd_log2 (chdr.ch_addralign);