This is the mail archive of the binutils@sourceware.cygnus.com mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: coffcode.h uses non-ISO-C: int a[f()];


> Mailing-List: contact binutils-help@sourceware.cygnus.com; run by ezmlm
> List-Unsubscribe: <mailto:binutils-unsubscribe-geoffk=cygnus.com@sourceware.cygnus.com>
> List-Subscribe: <mailto:binutils-subscribe@sourceware.cygnus.com>
> List-Archive: <http://sourceware.cygnus.com/ml/binutils/>
> List-Post: <mailto:binutils@sourceware.cygnus.com>
> List-Help: <mailto:binutils-help@sourceware.cygnus.com>, <http://sourceware.cygnus.com/ml/#faqs>
> Date: Tue, 15 Feb 2000 19:19:31 +1100
> From: Andrew Cagney <ac131313@cygnus.com>
> Organization: Cygnus Solutions
> X-Accept-Language: en
> 
> Hello,
> 
> coffcode.h contains the gccism:
> 
> diff -p -r1.29 coffcode.h
> *** coffcode.h  2000/02/10 21:21:55     1.29
> --- coffcode.h  2000/02/15 08:10:45
> *************** coff_set_arch_mach_hook (abfd, filehdr)
> *** 1880,1886 ****
>               cputype = 0;
>             else
>               {
> !               bfd_byte buf[bfd_coff_symesz (abfd)];
>                 struct internal_syment sym;
>   
>                 if (bfd_seek (abfd, obj_sym_filepos (abfd), SEEK_SET) !=
> 0
> 
> which stops it being compiled by AIX's native compiler - a constant is
> needed.
> 
> Roughtly, what is the correct way if fixing this?  alloca() or
> bfd_malloc() / bfd_free()?

bfd_malloc() / bfd_free().

I have a patch for this, which I'd forgotten about.

OK to commit?

-- 
- Geoffrey Keating <geoffk@cygnus.com>

===File ~geoffkc/patches/rs6000-coffcodearray.patch=========
2000-02-12  Geoff Keating  <geoffk@cygnus.com>

	* coffcode.h (coff_set_arch_mach_hook): Don't use variable-size
	arrays.

Index: coffcode.h
===================================================================
RCS file: /cvs/cvsfiles/devo/bfd/coffcode.h,v
retrieving revision 1.344.8.1
retrieving revision 1.344.8.2
diff -u -r1.344.8.1 -r1.344.8.2
--- coffcode.h	2000/02/05 16:43:05	1.344.8.1
+++ coffcode.h	2000/02/14 05:16:18	1.344.8.2
@@ -1561,17 +1561,23 @@
 	      cputype = 0;
 	    else
 	      {
-		bfd_byte buf[bfd_coff_symesz (abfd)];
+		bfd_byte *buf;
 		struct internal_syment sym;
 
+		buf = (bfd_byte *) bfd_malloc (bfd_coff_symesz (abfd));
 		if (bfd_seek (abfd, obj_sym_filepos (abfd), SEEK_SET) != 0
-		    || bfd_read (buf, 1, bfd_coff_symesz (abfd), abfd) != bfd_coff_symesz (abfd))
-		  return false;
+		    || (bfd_read (buf, 1, bfd_coff_symesz (abfd), abfd) 
+			!= bfd_coff_symesz (abfd)))
+		  {
+		    bfd_free (buf);
+		    return false;
+		  }
 		coff_swap_sym_in (abfd, (PTR) buf, (PTR) &sym);
 		if (sym.n_sclass == C_FILE)
 		  cputype = sym.n_type & 0xff;
 		else
 		  cputype = 0;
+		bfd_free (buf);
 	      }
 	  }
 
============================================================

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]