* [RFA] fix bfd multi-arch compilation failure
@ 2009-03-17 23:59 Pierre Muller
2009-03-18 0:08 ` H.J. Lu
2009-03-18 11:46 ` Alan Modra
0 siblings, 2 replies; 4+ messages in thread
From: Pierre Muller @ 2009-03-17 23:59 UTC (permalink / raw)
To: gdb-patches, binutils
Hi,
I tried to do a compilation of
gdb with --enable-targets=all --enable-64-bits-bfd
on OpenSolaris 2008.11.
I found two problems in bfd directory,
related to uses of alloca without
including <alloca.h>
I added
#include <alloca.h>
garded by #ifdef HAVE_ALLOCA_H
as I suppose that on some systems
alloca is builtin and thus does not require any header.
Is this OK to check in?
Pierre Muller
Pascal language support maintainer for GDB
ChangeLog entry:
2009-03-18 Pierre Muller <muller@ics.u-strasbg.fr>
* elf32-m68hc1x.c: Add alloca header.
* xsym.c: Ditto.
Index: bfd/elf32-m68hc1x.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-m68hc1x.c,v
retrieving revision 1.33
diff -u -p -r1.33 elf32-m68hc1x.c
--- bfd/elf32-m68hc1x.c 12 Mar 2008 08:36:59 -0000 1.33
+++ bfd/elf32-m68hc1x.c 17 Mar 2009 23:18:58 -0000
@@ -20,6 +20,9 @@
Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
MA 02110-1301, USA. */
+#ifdef HAVE_ALLOCA_H
+#include <alloca.h>
+#endif
#include "sysdep.h"
#include "bfd.h"
#include "bfdlink.h"
Index: bfd/xsym.c
===================================================================
RCS file: /cvs/src/src/bfd/xsym.c,v
retrieving revision 1.23
diff -u -p -r1.23 xsym.c
--- bfd/xsym.c 30 Jul 2008 04:34:56 -0000 1.23
+++ bfd/xsym.c 17 Mar 2009 23:18:58 -0000
@@ -23,6 +23,9 @@
#include "xsym.h"
#include "bfd.h"
#include "libbfd.h"
+#ifdef HAVE_ALLOCA_H
+#include <alloca.h>
+#endif
#define bfd_sym_close_and_cleanup
_bfd_generic_close_and_clea
nup
#define bfd_sym_bfd_free_cached_info
_bfd_generic_bfd_free_cache
d_info
cvs diff: Diffing bfd/doc
cvs diff: Diffing bfd/hosts
cvs diff: Diffing bfd/po
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [RFA] fix bfd multi-arch compilation failure
2009-03-17 23:59 [RFA] fix bfd multi-arch compilation failure Pierre Muller
@ 2009-03-18 0:08 ` H.J. Lu
2009-03-18 11:46 ` Alan Modra
1 sibling, 0 replies; 4+ messages in thread
From: H.J. Lu @ 2009-03-18 0:08 UTC (permalink / raw)
To: Pierre Muller; +Cc: gdb-patches, binutils
On Tue, Mar 17, 2009 at 4:26 PM, Pierre Muller <muller@ics.u-strasbg.fr> wrote:
> Hi,
> I tried to do a compilation of
> gdb with --enable-targets=all --enable-64-bits-bfd
> on OpenSolaris 2008.11.
>
> I found two problems in bfd directory,
> related to uses of alloca without
> including <alloca.h>
>
> I added
> #include <alloca.h>
> garded by #ifdef HAVE_ALLOCA_H
> as I suppose that on some systems
> alloca is builtin and thus does not require any header.
>
>
> Is this OK to check in?
>
>
> Pierre Muller
> Pascal language support maintainer for GDB
>
>
>
> ChangeLog entry:
>
> 2009-03-18 Pierre Muller <muller@ics.u-strasbg.fr>
>
> * elf32-m68hc1x.c: Add alloca header.
> * xsym.c: Ditto.
>
>
> Index: bfd/elf32-m68hc1x.c
> ===================================================================
> RCS file: /cvs/src/src/bfd/elf32-m68hc1x.c,v
> retrieving revision 1.33
> diff -u -p -r1.33 elf32-m68hc1x.c
> --- bfd/elf32-m68hc1x.c 12 Mar 2008 08:36:59 -0000 1.33
> +++ bfd/elf32-m68hc1x.c 17 Mar 2009 23:18:58 -0000
> @@ -20,6 +20,9 @@
> Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
> MA 02110-1301, USA. */
>
> +#ifdef HAVE_ALLOCA_H
> +#include <alloca.h>
> +#endif
> #include "sysdep.h"
> #include "bfd.h"
> #include "bfdlink.h"
That is wrong. Please see how it is handled in elf64-hppa.c.
--
H.J.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [RFA] fix bfd multi-arch compilation failure
2009-03-17 23:59 [RFA] fix bfd multi-arch compilation failure Pierre Muller
2009-03-18 0:08 ` H.J. Lu
@ 2009-03-18 11:46 ` Alan Modra
2009-03-18 13:05 ` Alan Modra
1 sibling, 1 reply; 4+ messages in thread
From: Alan Modra @ 2009-03-18 11:46 UTC (permalink / raw)
To: Pierre Muller; +Cc: gdb-patches, binutils
On Wed, Mar 18, 2009 at 12:26:53AM +0100, Pierre Muller wrote:
> I found two problems in bfd directory,
> related to uses of alloca without
> including <alloca.h>
I think it's slightly crazy that we have multiple places trying to
handle alloca declarations, some quite different from the others.
Some time ago I added include/alloca-conf.h and used it, but
apparently the original alloca-conf.h failed to work in some cases.
Unfortunately, instead of fixing alloca-conf.h, the version in
gas/as.h was copied into bfd/elf64-hppa.c and bfd/som.c, then further
tweaked. This patch gets us back to just one file with alloca magic.
Note that we aren't supposed to use alloca in BFD because on systems
which do not have alloca the version in libiberty calls xmalloc, which
might cause the program to crash when it runs out of memory. BFD
ought to return an error status instead. However, I don't care enough
to force this on other people, or fix their code.
include/
* alloca-conf.h: Revise based on autoconf-2.61, autoconf-2.13
documentation.
bfd/
* elf32-m68hc1x.c: Include alloca-conf.h.
* xsym.c: Likewise.
* elf64-hppa.c: Likewise. Remove existing #if's handling alloca.
* som.c: Likewise.
* Makefile.am: Run "make dep-am".
* Makefile.in: Regenerate.
binutils/
* sysdep.h: Include alloca-conf.h instead of config.h and remove
existing #if's handling alloca.
* Makefile.am: Run "make dep-am".
* Makefile.in: Regenerate.
gas/
* as.h: Include alloca-conf.h instead of config.h and remove
existing #if's handling alloca.
* Makefile.am: Run "make dep-am".
* Makefile.in: Regenerate.
opcodes/
* Makefile.am: Run "make dep-am".
* Makefile.in: Regenerate.
* openrisc-opc.c: Regenerate.
ld/
* ld.h: Remove alloca handling.
Index: include/alloca-conf.h
===================================================================
RCS file: /cvs/src/src/include/alloca-conf.h,v
retrieving revision 1.1
diff -c -p -r1.1 alloca-conf.h
*** include/alloca-conf.h 28 Sep 2000 08:00:54 -0000 1.1
--- include/alloca-conf.h 18 Mar 2009 07:49:36 -0000
***************
*** 1,24 ****
#include "config.h"
! #if defined(__GNUC__) && !defined(C_ALLOCA)
! # ifndef alloca
! # define alloca __builtin_alloca
! # endif
! #else /* ! defined (__GNUC__) */
! # ifdef _AIX
! #pragma alloca
# else
! # if defined(HAVE_ALLOCA_H) && !defined(C_ALLOCA)
! # include <alloca.h>
! # else /* ! defined (HAVE_ALLOCA_H) */
! # ifdef __STDC__
! extern PTR alloca (size_t);
! # else /* ! defined (__STDC__) */
! extern PTR alloca ();
! # endif /* ! defined (__STDC__) */
! # endif /* ! defined (HAVE_ALLOCA_H) */
! # ifdef _WIN32
! # include <malloc.h>
# endif
! # endif /* ! defined (_AIX) */
! #endif /* ! defined (__GNUC__) */
--- 1,44 ----
#include "config.h"
! /* This is a merge of code recommended in the autoconf-2.61 documentation
! with that recommended in the autoconf-2.13 documentation, with added
! tweaks to heed C_ALLOCA. */
!
! #if defined HAVE_ALLOCA_H && !defined C_ALLOCA
! # include <alloca.h>
! #else
! # if defined __GNUC__ && !defined C_ALLOCA
! # if !defined alloca
! # define alloca __builtin_alloca
! # endif
! # else
! # if defined _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 except for comments and preprocessor directives. */
! #pragma alloca
# else
! # if defined _MSC_VER && !defined C_ALLOCA
! # include <malloc.h>
! # define alloca _alloca
! # else
! # if !defined alloca
! # if defined __STDC__ || defined __hpux
! # if defined HAVE_STDDEF_H
! # include <stddef.h>
! # if defined __cplusplus
! extern "C" void *alloca (size_t);
! # else
! extern void *alloca (size_t);
! # endif
! # else
! extern void *alloca ();
! # endif
! # else
! extern char *alloca ();
! # endif
! # endif
! # endif
# endif
! # endif
! #endif
Index: bfd/elf32-m68hc1x.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-m68hc1x.c,v
retrieving revision 1.33
diff -u -p -r1.33 elf32-m68hc1x.c
--- bfd/elf32-m68hc1x.c 12 Mar 2008 08:36:59 -0000 1.33
+++ bfd/elf32-m68hc1x.c 18 Mar 2009 06:06:49 -0000
@@ -20,6 +20,7 @@
Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
MA 02110-1301, USA. */
+#include "alloca-conf.h"
#include "sysdep.h"
#include "bfd.h"
#include "bfdlink.h"
Index: bfd/elf64-hppa.c
===================================================================
RCS file: /cvs/src/src/bfd/elf64-hppa.c,v
retrieving revision 1.90
diff -u -p -r1.90 elf64-hppa.c
--- bfd/elf64-hppa.c 1 Mar 2009 17:08:54 -0000 1.90
+++ bfd/elf64-hppa.c 18 Mar 2009 06:06:59 -0000
@@ -19,6 +19,7 @@
Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
MA 02110-1301, USA. */
+#include "alloca-conf.h"
#include "sysdep.h"
#include "bfd.h"
#include "libbfd.h"
@@ -27,31 +28,6 @@
#include "libhppa.h"
#include "elf64-hppa.h"
-/* This is the code recommended in the autoconf documentation, almost
- verbatim. */
-#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 */
-#else
-extern void *alloca (size_t);
-#endif /* __GNUC__ */
-
#define ARCH_SIZE 64
Index: bfd/som.c
===================================================================
RCS file: /cvs/src/src/bfd/som.c,v
retrieving revision 1.72
diff -u -p -r1.72 som.c
--- bfd/som.c 7 Mar 2009 23:38:13 -0000 1.72
+++ bfd/som.c 18 Mar 2009 06:07:20 -0000
@@ -23,6 +23,7 @@
Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA
02110-1301, USA. */
+#include "alloca-conf.h"
#include "sysdep.h"
#include "bfd.h"
@@ -37,32 +38,6 @@
#include <machine/reg.h>
#include <sys/file.h>
-/* This is the code recommended in the autoconf documentation, almost
- verbatim. */
-
-#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 */
-#else
-extern void *alloca (size_t);
-#endif /* __GNUC__ */
-
static bfd_reloc_status_type hppa_som_reloc
(bfd *, arelent *, asymbol *, void *, asection *, bfd *, char **);
static bfd_boolean som_mkobject (bfd *);
Index: bfd/xsym.c
===================================================================
RCS file: /cvs/src/src/bfd/xsym.c,v
retrieving revision 1.23
diff -u -p -r1.23 xsym.c
--- bfd/xsym.c 30 Jul 2008 04:34:56 -0000 1.23
+++ bfd/xsym.c 18 Mar 2009 06:07:20 -0000
@@ -19,6 +19,7 @@
Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
MA 02110-1301, USA. */
+#include "alloca-conf.h"
#include "sysdep.h"
#include "xsym.h"
#include "bfd.h"
Index: binutils/sysdep.h
===================================================================
RCS file: /cvs/src/src/binutils/sysdep.h,v
retrieving revision 1.6
diff -u -p -r1.6 sysdep.h
--- binutils/sysdep.h 3 Feb 2009 15:48:50 -0000 1.6
+++ binutils/sysdep.h 18 Mar 2009 06:07:27 -0000
@@ -22,7 +22,7 @@
#ifndef _BIN_SYSDEP_H
#define _BIN_SYSDEP_H
-#include "config.h"
+#include "alloca-conf.h"
#include "ansidecl.h"
#include <stdio.h>
#include <sys/types.h>
@@ -123,23 +123,6 @@ extern int vsnprintf(char *, size_t, con
#define SEEK_END 2
#endif
-#if defined(__GNUC__) && !defined(C_ALLOCA)
-# undef alloca
-# define alloca __builtin_alloca
-#else
-# if defined(HAVE_ALLOCA_H) && !defined(C_ALLOCA)
-# include <alloca.h>
-# else
-# ifndef alloca /* predefined by HP cc +Olibcalls */
-# if !defined (__STDC__) && !defined (__hpux)
-char *alloca ();
-# else
-void *alloca ();
-# endif /* __STDC__, __hpux */
-# endif /* alloca */
-# endif /* HAVE_ALLOCA_H */
-#endif
-
#ifdef HAVE_LOCALE_H
# ifndef ENABLE_NLS
/* The Solaris version of locale.h always includes libintl.h. If we have
Index: gas/as.h
===================================================================
RCS file: /cvs/src/src/gas/as.h,v
retrieving revision 1.61
diff -u -p -r1.61 as.h
--- gas/as.h 12 Aug 2008 23:39:30 -0000 1.61
+++ gas/as.h 18 Mar 2009 06:07:32 -0000
@@ -36,36 +36,7 @@
COMMON as "".
If TEST is #defined, then we are testing a module: #define COMMON as "". */
-#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__ */
+#include "alloca-conf.h"
/* Prefer varargs for non-ANSI compiler, since some will barf if the
ellipsis definition is used with a no-arguments declaration. */
Index: opcodes/openrisc-opc.c
===================================================================
RCS file: /cvs/src/src/opcodes/openrisc-opc.c,v
retrieving revision 1.12
diff -u -p -r1.12 openrisc-opc.c
--- opcodes/openrisc-opc.c 5 Jul 2007 09:49:02 -0000 1.12
+++ opcodes/openrisc-opc.c 18 Mar 2009 06:08:06 -0000
@@ -671,7 +671,10 @@ openrisc_cgen_init_opcode_table (CGEN_CP
const CGEN_OPCODE *oc = & openrisc_cgen_macro_insn_opcode_table[0];
CGEN_INSN *insns = xmalloc (num_macros * sizeof (CGEN_INSN));
- memset (insns, 0, num_macros * sizeof (CGEN_INSN));
+ /* This test has been added to avoid a warning generated
+ if memset is called with a third argument of value zero. */
+ if (num_macros >= 1)
+ memset (insns, 0, num_macros * sizeof (CGEN_INSN));
for (i = 0; i < num_macros; ++i)
{
insns[i].base = &ib[i];
Index: ld/ld.h
===================================================================
RCS file: /cvs/src/src/ld/ld.h,v
retrieving revision 1.42
diff -u -p -r1.42 ld.h
--- ld/ld.h 26 Jan 2009 15:23:39 -0000 1.42
+++ ld/ld.h 18 Mar 2009 08:13:20 -0000
@@ -32,24 +32,6 @@
#define SEEK_END 2
#endif
-#if defined(__GNUC__) && !defined(C_ALLOCA)
-# undef alloca
-# define alloca __builtin_alloca
-#else
-# if defined(HAVE_ALLOCA_H) && !defined(C_ALLOCA)
-# include <alloca.h>
-# else
-# ifndef alloca /* predefined by HP cc +Olibcalls */
-# if !defined (__STDC__) && !defined (__hpux)
-char *alloca ();
-# else
-void *alloca ();
-# endif /* __STDC__, __hpux */
-# endif /* alloca */
-# endif /* HAVE_ALLOCA_H */
-#endif
-
-
#ifdef HAVE_LOCALE_H
# ifndef ENABLE_NLS
/* The Solaris version of locale.h always includes libintl.h. If we have
--
Alan Modra
Australia Development Lab, IBM
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [RFA] fix bfd multi-arch compilation failure
2009-03-18 11:46 ` Alan Modra
@ 2009-03-18 13:05 ` Alan Modra
0 siblings, 0 replies; 4+ messages in thread
From: Alan Modra @ 2009-03-18 13:05 UTC (permalink / raw)
To: Pierre Muller, gdb-patches, binutils
On Wed, Mar 18, 2009 at 09:35:16PM +1030, Alan Modra wrote:
> tweaked. This patch gets us back to just one file with alloca magic.
Missed a couple.
bfd/
* vms-hdr.c: Don't include alloca.h.
opcodes/
* cgen-opc.c: Include alloca-conf.h rather than alloca.h.
* Makefile.am: Run "make dep-am".
* Makefile.in: Regenerate.
Index: bfd/vms-hdr.c
===================================================================
RCS file: /cvs/src/src/bfd/vms-hdr.c,v
retrieving revision 1.23
diff -u -p -r1.23 vms-hdr.c
--- bfd/vms-hdr.c 23 Feb 2009 09:28:43 -0000 1.23
+++ bfd/vms-hdr.c 18 Mar 2009 11:42:36 -0000
@@ -52,10 +52,6 @@
#include "vms.h"
-#ifdef HAVE_ALLOCA_H
-#include <alloca.h>
-#endif
-
static struct module *new_module (bfd *);
static void parse_module
(bfd *, struct module *, unsigned char *, unsigned int);
Index: opcodes/cgen-opc.c
===================================================================
RCS file: /cvs/src/src/opcodes/cgen-opc.c,v
retrieving revision 1.18
diff -u -p -r1.18 cgen-opc.c
--- opcodes/cgen-opc.c 5 Jul 2007 09:49:00 -0000 1.18
+++ opcodes/cgen-opc.c 18 Mar 2009 11:42:37 -0000
@@ -19,6 +19,7 @@
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */
+#include "alloca-conf.h"
#include "sysdep.h"
#include <stdio.h>
#include "ansidecl.h"
@@ -28,10 +29,6 @@
#include "symcat.h"
#include "opcode/cgen.h"
-#ifdef HAVE_ALLOCA_H
-#include <alloca.h>
-#endif
-
static unsigned int hash_keyword_name
(const CGEN_KEYWORD *, const char *, int);
static unsigned int hash_keyword_value
Index: opcodes/Makefile.am
===================================================================
RCS file: /cvs/src/src/opcodes/Makefile.am,v
retrieving revision 1.134
diff -u -p -r1.134 Makefile.am
--- opcodes/Makefile.am 18 Mar 2009 11:27:18 -0000 1.134
+++ opcodes/Makefile.am 18 Mar 2009 11:42:37 -0000
@@ -715,9 +715,10 @@ cgen-bitset.lo: cgen-bitset.c $(INCDIR)/
cgen-dis.lo: cgen-dis.c sysdep.h config.h $(INCDIR)/ansidecl.h \
$(INCDIR)/libiberty.h $(BFD_H) $(INCDIR)/symcat.h $(INCDIR)/opcode/cgen.h \
$(INCDIR)/opcode/cgen-bitset.h
-cgen-opc.lo: cgen-opc.c sysdep.h config.h $(INCDIR)/ansidecl.h \
- $(INCDIR)/libiberty.h $(INCDIR)/safe-ctype.h $(BFD_H) \
- $(INCDIR)/symcat.h $(INCDIR)/opcode/cgen.h $(INCDIR)/opcode/cgen-bitset.h
+cgen-opc.lo: cgen-opc.c $(INCDIR)/alloca-conf.h config.h \
+ sysdep.h $(INCDIR)/ansidecl.h $(INCDIR)/libiberty.h \
+ $(INCDIR)/safe-ctype.h $(BFD_H) $(INCDIR)/symcat.h \
+ $(INCDIR)/opcode/cgen.h $(INCDIR)/opcode/cgen-bitset.h
cr16-dis.lo: cr16-dis.c $(INCDIR)/dis-asm.h $(BFD_H) \
$(INCDIR)/ansidecl.h $(INCDIR)/symcat.h sysdep.h config.h \
$(INCDIR)/opcode/cr16.h $(INCDIR)/libiberty.h
--
Alan Modra
Australia Development Lab, IBM
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2009-03-18 11:46 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-03-17 23:59 [RFA] fix bfd multi-arch compilation failure Pierre Muller
2009-03-18 0:08 ` H.J. Lu
2009-03-18 11:46 ` Alan Modra
2009-03-18 13:05 ` Alan Modra
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox