aboutsummaryrefslogtreecommitdiff
path: root/bfd
diff options
context:
space:
mode:
authorAlan Modra <amodra@gmail.com>2019-10-14 20:29:12 +1030
committerAlan Modra <amodra@gmail.com>2019-10-15 16:00:54 +1030
commited481f9799f2bd08a7541a5fe0a887dc5c7fd4a9 (patch)
tree35fb1ae9da0260f6ae763809a43e32e46f23e234 /bfd
parentb7be2d03fb2f873e0db74c84846df97787fc0dc6 (diff)
downloadgdb-ed481f9799f2bd08a7541a5fe0a887dc5c7fd4a9.zip
gdb-ed481f9799f2bd08a7541a5fe0a887dc5c7fd4a9.tar.gz
gdb-ed481f9799f2bd08a7541a5fe0a887dc5c7fd4a9.tar.bz2
Simplify power of two test
* bfd.c (bfd_check_compression_header): Check for powers of two with x == (x & -x).
Diffstat (limited to 'bfd')
-rw-r--r--bfd/ChangeLog5
-rw-r--r--bfd/bfd.c2
2 files changed, 6 insertions, 1 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index a1eaef9..4d8db19 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -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.
diff --git a/bfd/bfd.c b/bfd/bfd.c
index af2c192..b3078ea 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);