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]

PATCH: Fix bfd.c (Re: Tracking down a build breakage)


On Sat, Aug 11, 2001 at 12:44:11PM -0400, Kazu Hirata wrote:
> Hi,
> 
> I recently reported to bug-binutils that the h8300 port had a build
> breakage.
> 
> http://sources.redhat.com/ml/bug-binutils/2001-q3/msg00057.html
> 

You have an incomplete source. I use

# cvs co binutils

to update my CVS tree.

But my bfd_sprintf_vma/bfd_fprintf_vma change does break any BFD
which doesn't include elf.lo. It seems to me that we should only
check bfd_target_elf_flavour when elf is configured in BFD. Here
is a patch. Any comments?


H.J.
-----
2001-08-11  H.J. Lu  <hjl@gnu.org>

	* Makefile.am (BFD_DEFINES): New. Substituted by @bfd_defines@.
	(INCLUDES): Add $(BFD_DEFINES).
	* Makefile.in: Regenerated.

	* configure.in (bfd_defines): Add -DHAVE_BFD_ELF if elf.lo
	is in $bfd_backend.
	(AC_SUBST(bfd_defines)): Added.
	* configure: Regenerated.

	* bfd.c (bfd_sprintf_vma): Check ELF only if HAVE_BFD_ELF is
	defined.
	(bfd_fprintf_vma): Likewise.

Index: bfd.c
===================================================================
RCS file: /work/cvs/gnu/binutils/bfd/bfd.c,v
retrieving revision 1.1.1.13
diff -u -p -r1.1.1.13 bfd.c
--- bfd.c	2001/08/10 18:46:20	1.1.1.13
+++ bfd.c	2001/08/11 17:26:22
@@ -1265,24 +1265,28 @@ bfd_record_phdr (abfd, type, flags_valid
 
 void
 bfd_sprintf_vma (abfd, buf, value)
-     bfd *abfd;
+     bfd *abfd ATTRIBUTE_UNUSED;
      char *buf;
      bfd_vma value;
 {
+#ifdef HAVE_BFD_ELF
   if (bfd_get_flavour (abfd) == bfd_target_elf_flavour)
     bfd_elf_sprintf_vma (abfd, buf, value);
   else
+#endif
     sprintf_vma (buf, value);
 }
 
 void
 bfd_fprintf_vma (abfd, stream, value)
-     bfd *abfd;
+     bfd *abfd ATTRIBUTE_UNUSED;
      PTR stream;
      bfd_vma value;
 {
+#ifdef HAVE_BFD_ELF
   if (bfd_get_flavour (abfd) == bfd_target_elf_flavour)
     bfd_elf_fprintf_vma (abfd, stream, value);
   else
+#endif
     fprintf_vma ((FILE *) stream, value);
 }
Index: Makefile.am
===================================================================
RCS file: /work/cvs/gnu/binutils/bfd/Makefile.am,v
retrieving revision 1.47
diff -u -p -r1.47 Makefile.am
--- Makefile.am	2001/07/24 16:33:47	1.47
+++ Makefile.am	2001/08/11 17:26:23
@@ -475,9 +475,12 @@ WORDSIZE = @wordsize@
 ALL_BACKENDS = @all_backends@
 BFD_BACKENDS = @bfd_backends@
 BFD_MACHINES = @bfd_machines@
+BFD_DEFINES = @bfd_defines@
 TDEFAULTS = @tdefaults@
 
-INCLUDES = -D_GNU_SOURCE @HDEFINES@ @COREFLAG@ @TDEFINES@ $(CSEARCH) $(CSWITCHES) -I$(srcdir)/../intl -I../intl
+INCLUDES = -D_GNU_SOURCE @HDEFINES@ @COREFLAG@ @TDEFINES@ \
+	   $(BFD_DEFINES) $(CSEARCH) $(CSWITCHES) \
+	   -I$(srcdir)/../intl -I../intl
 
 # C source files that correspond to .o's.
 SOURCE_CFILES = \
Index: Makefile.in
===================================================================
RCS file: /work/cvs/gnu/binutils/bfd/Makefile.in,v
retrieving revision 1.54
diff -u -p -r1.54 Makefile.in
--- Makefile.in	2001/07/24 16:33:48	1.54
+++ Makefile.in	2001/08/11 17:26:23
@@ -114,6 +114,7 @@ WIN32LDFLAGS = @WIN32LDFLAGS@
 WIN32LIBADD = @WIN32LIBADD@
 all_backends = @all_backends@
 bfd_backends = @bfd_backends@
+bfd_defines = @bfd_defines@
 bfd_machines = @bfd_machines@
 l = @l@
 tdefaults = @tdefaults@
@@ -604,10 +605,14 @@ WORDSIZE = @wordsize@
 ALL_BACKENDS = @all_backends@
 BFD_BACKENDS = @bfd_backends@
 BFD_MACHINES = @bfd_machines@
+BFD_DEFINES = @bfd_defines@
 TDEFAULTS = @tdefaults@
 
-INCLUDES = -D_GNU_SOURCE @HDEFINES@ @COREFLAG@ @TDEFINES@ $(CSEARCH) $(CSWITCHES) -I$(srcdir)/../intl -I../intl
+INCLUDES = -D_GNU_SOURCE @HDEFINES@ @COREFLAG@ @TDEFINES@ \
+	   $(BFD_DEFINES) $(CSEARCH) $(CSWITCHES) \
+	   -I$(srcdir)/../intl -I../intl
 
+
 # C source files that correspond to .o's.
 SOURCE_CFILES = \
 	$(BFD_LIBS_CFILES) \
Index: configure.in
===================================================================
RCS file: /work/cvs/gnu/binutils/bfd/configure.in,v
retrieving revision 1.165
diff -u -p -r1.165 configure.in
--- configure.in	2001/08/10 17:03:21	1.165
+++ configure.in	2001/08/11 17:26:23
@@ -128,6 +128,8 @@ BFD_NEED_DECLARATION(realloc)
 BFD_NEED_DECLARATION(free)
 BFD_NEED_DECLARATION(getenv)
 
+bfd_defines=
+
 # If we are configured native, pick a core file support file.
 COREFILE=
 COREFLAG=
@@ -702,6 +704,12 @@ ta="$f"
 bfd_backends="$tb"
 bfd_machines="$ta"
 
+case "$bfd_backends" in
+*elf.lo*)
+  bfd_defines="$bfd_defines -DHAVE_BFD_ELF"
+  ;;
+esac
+
 if test x${all_targets} = xtrue ; then
   bfd_backends="${bfd_backends}"' $(ALL_BACKENDS)'
   bfd_machines="${bfd_machines}"' $(ALL_MACHINES)'
@@ -738,6 +746,7 @@ AC_SUBST(wordsize)
 AC_SUBST(all_backends)
 AC_SUBST(bfd_backends)
 AC_SUBST(bfd_machines)
+AC_SUBST(bfd_defines)
 
 tdefaults=""
 test -n "${defvec}" && tdefaults="${tdefaults} -DDEFAULT_VECTOR=${defvec}"


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