[binutils-gdb] Fix for -Wstringop-overflow false positive
Michael Matz
matz@sourceware.org
Thu Oct 17 15:48:26 GMT 2024
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=22ae2e1f702883e6e27d3ad96ee81a6266fbc51c
commit 22ae2e1f702883e6e27d3ad96ee81a6266fbc51c
Author: Michael Matz <matz@suse.de>
Date: Thu Oct 17 17:42:40 2024 +0200
Fix for -Wstringop-overflow false positive
the way the overflow check was written wasn't understood by some
GCC versions and produced false positives for the memset call being
called potentially with object sizes that are larger than half
address-space.
Diff:
---
bfd/merge.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/bfd/merge.c b/bfd/merge.c
index c811bc57eae..abb0269227e 100644
--- a/bfd/merge.c
+++ b/bfd/merge.c
@@ -181,9 +181,9 @@ sec_merge_maybe_resize (struct sec_merge_hash *table, unsigned added)
do
{
- newnb *= 2;
- if (!(unsigned int)newnb)
+ if (newnb >> (8 * sizeof(mapofs_type) - 1))
return false;
+ newnb *= 2;
}
while (NEEDS_RESIZE (bfdtab->count + added, newnb));
More information about the Binutils-cvs
mailing list