aboutsummaryrefslogtreecommitdiff
path: root/bfd
diff options
context:
space:
mode:
authorAlan Modra <amodra@gmail.com>2011-04-20 07:17:01 +0000
committerAlan Modra <amodra@gmail.com>2011-04-20 07:17:01 +0000
commit9e6619e285873fe1cb002da4bb7749be40a5627c (patch)
tree93aa67371935dfa970f89ec5b84e50e50dd7c5c0 /bfd
parent595213d4408b3608441bb78fd5ee49efb5b8b97f (diff)
downloadgdb-9e6619e285873fe1cb002da4bb7749be40a5627c.zip
gdb-9e6619e285873fe1cb002da4bb7749be40a5627c.tar.gz
gdb-9e6619e285873fe1cb002da4bb7749be40a5627c.tar.bz2
* 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.
Diffstat (limited to 'bfd')
-rw-r--r--bfd/ChangeLog4
-rw-r--r--bfd/elflink.c7
-rw-r--r--bfd/libbfd.c6
3 files changed, 14 insertions, 3 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index afa1cf2..5a15a6c 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -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.
diff --git a/bfd/elflink.c b/bfd/elflink.c
index 3c95b57..3a4d22c 100644
--- a/bfd/elflink.c
+++ b/bfd/elflink.c
@@ -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)
diff --git a/bfd/libbfd.c b/bfd/libbfd.c
index 4e5813a..cec13d9 100644
--- a/bfd/libbfd.c
+++ b/bfd/libbfd.c
@@ -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;
}