This is the mail archive of the binutils@sources.redhat.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: [PATCH] Include alloca.h for bfd


Ian Lance Taylor wrote:
> Thiemo Seufer <ica2_ts@csv.ica.uni-stuttgart.de> writes:
> 
> > this checks for inclusion of alloca.h, which is required on IRIX6.5
> > to compile e.g. linker.c.
> 
> This patch is incorrect.  Any declaration of alloca or inclusions of
> alloca.h must be done as in gas/as.h.

Uh, that's a really ugly piece of code.

> In the past I did not permit alloca to be used in BFD, because on
> systems which do not have alloca the version in libiberty would call
> xmalloc, which might cause the program to crash when it ran out of
> memory.  I believe that BFD should never crash because it runs out of
> memory; instead, it should return the appropriate error to the caller.
> (That's why I wrote the objalloc interface when obstacks were changed
> to no longer support a failure to allocate memory.)  However, I do not
> know what the current thinking is on alloca in BFD.

Well, alloca() is called in BFD:
bfd/elfxx-ia64.c:             char *once_name = alloca (len2 + strlen (sname) - len + 1);
bfd/elfxx-ia64.c:      addr_name = alloca (len);
bfd/som.c:  unsigned char *tmp_space = alloca (tmp_space_size);
bfd/som.c:            tmp_space = alloca (tmp_space_size);
bfd/som.c:  unsigned char *tmp_space = alloca (tmp_space_size);
bfd/som.c:                tmp_space = alloca (tmp_space_size);
bfd/som.c:            tmp_space = alloca (tmp_space_size);
bfd/elf64-hppa.c:             new_name = alloca (strlen (h->root.root.string) + 2);
bfd/elf64-hppa.c:         new_name = alloca (strlen (h->root.root.string) + 2);
bfd/vms-hdr.c:      fname = (char *) alloca (strlen (fptr) + 1);
bfd/linker.c:         char *buf = alloca (strlen (h->root.string) + 10);

The last one causes the build with native tools on IRIX6.5 to fail.
This patch lets it compile.


Thiemo


2001-08-21  Thiemo Seufer <seufer@csv.ica.uni-stuttgart.de>

	/bfd/ChangeLog
	* sysdep.h (HAVE_ALLOCA): Check for inclusion of alloca.h, needed
	on irix6.


diff -BurpNX /bigdisk/src/binutils-exclude src-orig/bfd/sysdep.h src/bfd/sysdep.h
--- src-orig/bfd/sysdep.h	Tue Aug 21 19:13:51 2001
+++ src/bfd/sysdep.h	Tue Aug 21 22:54:13 2001
@@ -26,6 +26,35 @@ Foundation, Inc., 59 Temple Place - Suit
 
 #include "config.h"
 
+/* This is the code recommended in the autoconf documentation, almost
+   verbatim.  If it doesn't work for you, let me know, and notify
+   djm@gnu.ai.mit.edu as well.  */
+/* Added void* version for STDC case.  This is to be compatible with
+   the declaration in bison.simple, used for m68k operand parsing.
+   --KR 1995.08.08 */
+/* Force void* decl for hpux.  This is what Bison uses.  --KR 1995.08.16 */
+
+#ifndef __GNUC__
+# if HAVE_ALLOCA_H
+#  include <alloca.h>
+# else
+#  ifdef _AIX
+/* Indented so that pre-ansi C compilers will ignore it, rather than
+   choke on it.  Some versions of AIX require this to be the first
+   thing in the file.  */
+ #pragma alloca
+#  else
+#   ifndef alloca /* predefined by HP cc +Olibcalls */
+#    if !defined (__STDC__) && !defined (__hpux)
+extern char *alloca ();
+#    else
+extern void *alloca ();
+#    endif /* __STDC__, __hpux */
+#   endif /* alloca */
+#  endif /* _AIX */
+# endif /* HAVE_ALLOCA_H */
+#endif /* __GNUC__ */
+
 #ifdef HAVE_STDDEF_H
 #include <stddef.h>
 #endif


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