This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: as.exe: out of memory allocating 4294967280 bytes
- From: Alan Modra <amodra at gmail dot com>
- To: "Simonov, Vladimir" <Vladimir dot Simonov at acronis dot com>
- Cc: "binutils at sourceware dot org" <binutils at sourceware dot org>
- Date: Sat, 27 Oct 2012 12:57:21 +1030
- Subject: Re: as.exe: out of memory allocating 4294967280 bytes
- References: <F0AD13EFC234B549BBA4FCA20755EB2485A96967@Rus-mbx-1.ru.corp.acronis.com>
On Fri, Oct 26, 2012 at 06:13:53PM +0000, Simonov, Vladimir wrote:
> IMO the problem is in gas\sb.c
> static void
> sb_check (sb *ptr, size_t len)
> ...
> #if GCC_VERSION >= 3004
> max = (size_t) 1 << (CHAR_BIT * sizeof (want) - __builtin_clzl (want));
> #else
> ...
> "want" size_t type which is 64-bit. Replace __builtin_clzl with __builtin_clzll fixes the problem.
>
> CVS head has the same code. I'm not sure either it my cross tools mis-configuration or real bug in as.
> If the second, it is strange - the code was committed 4 months ago...
It's a bug. I didn't consider strange hosts that have sizeof(long) !=
sizeof(size_t). Does the following fix your problem?
* sb.c (sb_check): Use __builtin_clzll when size_t is not the
same size as long.
Index: gas/sb.c
===================================================================
RCS file: /cvs/src/src/gas/sb.c,v
retrieving revision 1.20
diff -u -p -r1.20 sb.c
--- gas/sb.c 9 Jun 2012 13:22:00 -0000 1.20
+++ gas/sb.c 27 Oct 2012 02:25:08 -0000
@@ -137,7 +137,10 @@ sb_check (sb *ptr, size_t len)
if ((ssize_t) want < 0)
as_fatal ("string buffer overflow");
#if GCC_VERSION >= 3004
- max = (size_t) 1 << (CHAR_BIT * sizeof (want) - __builtin_clzl (want));
+ max = (size_t) 1 << (CHAR_BIT * sizeof (want)
+ - (sizeof (want) == sizeof (long)
+ ? __builtin_clzl (want)
+ : __builtin_clzll ((long long) want)));
#else
max = 128;
while (want > max)
--
Alan Modra
Australia Development Lab, IBM