This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
spu malloc fix
- From: Alan Modra <amodra at gmail dot com>
- To: binutils at sourceware dot org
- Date: Mon, 27 Feb 2012 09:24:13 +1030
- Subject: spu malloc fix
- Authentication-results: mr.google.com; spf=pass (google.com: domain of amodra@gmail.com designates 10.68.240.100 as permitted sender) smtp.mail=amodra@gmail.com; dkim=pass header.i=amodra@gmail.com
When running the spu-elf testsuite my new x86_64 box is spitting out
*** glibc detected *** ./ld-new: free(): invalid next size (fast): 0x0000000001c45af0 ***
I don't know why this never showed up before on the older x86 machine,
likely the older version of glibc on that box had different malloc /
free. Curiously, this problem doesn't show up on bigendian hosts
like powerpc64, the usual host for spu targetted binutils. That's
because the NUL string terminator overwrites the most significant byte
of the size, which happens to be zero already.
* elf32-spu.c (build_stub): Fix malloc under-allocation.
Index: bfd/elf32-spu.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-spu.c,v
retrieving revision 1.102
diff -u -p -r1.102 elf32-spu.c
--- bfd/elf32-spu.c 19 Oct 2011 07:17:18 -0000 1.102
+++ bfd/elf32-spu.c 26 Feb 2012 03:49:08 -0000
@@ -1425,7 +1425,7 @@ build_stub (struct bfd_link_info *info,
add = (int) irela->r_addend & 0xffffffff;
if (add != 0)
len += 1 + 8;
- name = bfd_malloc (len);
+ name = bfd_malloc (len + 1);
if (name == NULL)
return FALSE;
--
Alan Modra
Australia Development Lab, IBM