]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
* libbfd.c (bfd_log2): Do return rounded up value.
authorAlan Modra <amodra@gmail.com>
Wed, 20 Apr 2011 07:17:01 +0000 (07:17 +0000)
committerAlan Modra <amodra@gmail.com>
Wed, 20 Apr 2011 07:17:01 +0000 (07:17 +0000)
* elflink.c (bfd_elf_size_dynsym_hash_dynstr): Replace bfd_log2
call with expanded old round down version of the function.

bfd/ChangeLog
bfd/elflink.c
bfd/libbfd.c

index afa1cf269d84218b517a22114d34136a6bdfb396..5a15a6c28339bdea5fdf479a72f907bbdc9af713 100644 (file)
@@ -1,5 +1,9 @@
 2011-04-20  Alan Modra  <amodra@gmail.com>
 
+       * libbfd.c (bfd_log2): Do return rounded up value.
+       * elflink.c (bfd_elf_size_dynsym_hash_dynstr): Replace bfd_log2
+       call with expanded old round down version of the function.
+
        * archive.c (_bfd_get_elt_at_filepos): Don't release n_nfd.
        * elflink.c (elf_link_add_object_symbols): Delete redundant code.
 
index 3c95b572151f2b3527e3e3698b0fdef5aba14bbd..3a4d22c4cf873e8591417f5dee4dfcd09b23609b 100644 (file)
@@ -6537,10 +6537,13 @@ bfd_elf_size_dynsym_hash_dynstr (bfd *output_bfd, struct bfd_link_info *info)
            }
          else
            {
-             unsigned long int maskwords, maskbitslog2;
+             unsigned long int maskwords, maskbitslog2, x;
              BFD_ASSERT (cinfo.min_dynindx != -1);
 
-             maskbitslog2 = bfd_log2 (cinfo.nsyms) + 1;
+             x = cinfo.nsyms;
+             maskbitslog2 = 1;
+             while ((x >>= 1) != 0)
+               ++maskbitslog2;
              if (maskbitslog2 < 3)
                maskbitslog2 = 5;
              else if ((1 << (maskbitslog2 - 2)) & cinfo.nsyms)
index 4e5813aaf76381b8ee3a2d6ee621c0e352d52faa..cec13d9513294acac9524e7b86e068f56fcef515 100644 (file)
@@ -979,8 +979,12 @@ bfd_log2 (bfd_vma x)
 {
   unsigned int result = 0;
 
-  while ((x = (x >> 1)) != 0)
+  if (x <= 1)
+    return result;
+  --x;
+  do
     ++result;
+  while ((x >>= 1) != 0);
   return result;
 }