From ed481f9799f2bd08a7541a5fe0a887dc5c7fd4a9 Mon Sep 17 00:00:00 2001 From: Alan Modra Date: Mon, 14 Oct 2019 20:29:12 +1030 Subject: [PATCH] Simplify power of two test * bfd.c (bfd_check_compression_header): Check for powers of two with x == (x & -x). --- bfd/ChangeLog | 5 +++++ bfd/bfd.c | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/bfd/ChangeLog b/bfd/ChangeLog index a1eaef95d8d..4d8db193f2e 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,3 +1,8 @@ +2019-10-15 Alan Modra + + * bfd.c (bfd_check_compression_header): Check for powers of two + with x == (x & -x). + 2019-10-14 Alan Modra * syms.c (struct indexentry): Add idx field. diff --git a/bfd/bfd.c b/bfd/bfd.c index af2c192260d..b3078eaa525 100644 --- 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); -- 2.30.2