This is the mail archive of the binutils@sourceware.org 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]
Other format: [Raw text]

Re: Build failure due to .incbin


On Mon, Feb 26, 2007 at 03:13:21PM +0100, Segher Boessenkool wrote:
> A fourth option is to use a "bin2c" kind of build tool,

I was trying to avoid that, but

> Except those symbols need to have an extra underscore in the
> assembler source file, with the Darwin assembler.  (Sorry I
> didn't mention this earlier, I only noticed after I sent the
> mail).

this means none of my ideas will work.  The syms created by
"ld -r -b binary" don't have an extra underscore, probably a bug, and
deciding whether a host (rather than a target) needs the extra
underscore adds yet more mess to configure.

Oh well, bin2c is easy to write, especially if you steal SET_BINARY
from textutils.

bfd/
	* elf32-spu.h (struct _ovl_stream): Make "start" and "end" const.
	* elf32-spu.c (ovl_mgr_pread): Add const to casts.
binutils/
	* bin2c.c: New file.
	* Makefile.am (EXTRA_PROGRAMS): Add bin2c.
	(CFILES): Add bin2c.c.
	(bin2c_SOURCES): Define.
	(bin2c.o): Dependencies from "make dep-am".
	* configure.in (BUILD_MISC): Add bin2c.
	* version.c: Update year.
	* po/POTFILES.in: Regenerate.
	* Makefile.in: Regenerate.
	* configure: Regenerate.
ld/
	* Makefile.am (ALL_EMUL_EXTRA_OFILES): Remove spu_inc.o.
	(eelf32_spu.c): Adjust dependencies.
	* Makefile.in: Regenerate.
	* emultempl/spuelf.em (ovl_mgr): New array.  Insert spu_ovl.o
	code using bin2c.
	(_binary_spu_ovl_o_start, _binary_spu_ovl_o_end): Delete.
	(ovl_mgr_stream): Update.
	* emultempl/spu_inc.s: Delete.
	* emultempl/spu_none.s: Delete.

Index: bfd/elf32-spu.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-spu.c,v
retrieving revision 1.3
diff -u -p -r1.3 elf32-spu.c
--- bfd/elf32-spu.c	21 Feb 2007 02:48:22 -0000	1.3
+++ bfd/elf32-spu.c	27 Feb 2007 03:14:36 -0000
@@ -1069,7 +1069,7 @@ ovl_mgr_pread (struct bfd *abfd ATTRIBUT
   size_t max;
 
   os = (struct _ovl_stream *) stream;
-  max = (char *) os->end - (char *) os->start;
+  max = (const char *) os->end - (const char *) os->start;
 
   if ((ufile_ptr) offset >= max)
     return 0;
@@ -1078,7 +1078,7 @@ ovl_mgr_pread (struct bfd *abfd ATTRIBUT
   if (count > max - offset)
     count = max - offset;
 
-  memcpy (buf, (char *) os->start + offset, count);
+  memcpy (buf, (const char *) os->start + offset, count);
   return count;
 }
 
Index: bfd/elf32-spu.h
===================================================================
RCS file: /cvs/src/src/bfd/elf32-spu.h,v
retrieving revision 1.1
diff -u -p -r1.1 elf32-spu.h
--- bfd/elf32-spu.h	25 Oct 2006 06:49:20 -0000	1.1
+++ bfd/elf32-spu.h	27 Feb 2007 03:14:36 -0000
@@ -33,8 +33,8 @@ struct _spu_elf_section_data
 
 struct _ovl_stream
 {
-  void *start;
-  void *end;
+  const void *start;
+  const void *end;
 };
 
 extern void spu_elf_plugin (int);
Index: binutils/Makefile.am
===================================================================
RCS file: /cvs/src/src/binutils/Makefile.am,v
retrieving revision 1.81
diff -u -p -r1.81 Makefile.am
--- binutils/Makefile.am	17 Feb 2007 13:33:53 -0000	1.81
+++ binutils/Makefile.am	27 Feb 2007 03:14:41 -0000
@@ -58,7 +58,7 @@ bin_PROGRAMS = $(SIZE_PROG) $(OBJDUMP_PR
 ## -new, and to rename cxxfilt to c++filt.
 noinst_PROGRAMS = $(NM_PROG) $(STRIP_PROG) $(DEMANGLER_PROG)
 
-EXTRA_PROGRAMS = $(NLMCONV_PROG) srconv sysdump coffdump $(DLLTOOL_PROG) $(WINDRES_PROG) $(DLLWRAP_PROG)
+EXTRA_PROGRAMS = $(NLMCONV_PROG) srconv sysdump coffdump $(DLLTOOL_PROG) $(WINDRES_PROG) $(DLLWRAP_PROG) bin2c
 
 # Stuff that goes in tooldir/ if appropriate.
 TOOL_PROGS = nm-new strip-new ar ranlib dlltool objdump
@@ -87,7 +87,7 @@ HFILES = \
 GENERATED_HFILES = arparse.h sysroff.h sysinfo.h defparse.h rcparse.h
 
 CFILES = \
-	addr2line.c ar.c arsup.c binemul.c bucomm.c budemang.c \
+	addr2line.c ar.c arsup.c bin2c.c binemul.c bucomm.c budemang.c \
 	coffdump.c coffgrok.c cxxfilt.c \
 	dwarf.c debug.c dlltool.c dllwrap.c \
 	emul_aix.c emul_vanilla.c filemode.c \
@@ -340,6 +340,8 @@ windres_LDADD = $(BFDLIB) $(LIBIBERTY) @
 dllwrap_SOURCES = dllwrap.c version.c
 dllwrap_LDADD = $(LIBIBERTY) $(LIBINTL)
 
+bin2c_SOURCES = bin2c.c version.c
+
 
 EXTRA_DIST = arparse.c arparse.h arlex.c nlmheader.c sysinfo.c sysinfo.h \
 	syslex.c deflex.c defparse.h defparse.c rclex.c rcparse.h rcparse.c
@@ -444,6 +446,9 @@ arsup.o: arsup.c ../bfd/bfd.h $(INCDIR)/
   $(INCDIR)/symcat.h arsup.h $(INCDIR)/libiberty.h $(INCDIR)/ansidecl.h \
   bucomm.h $(INCDIR)/ansidecl.h config.h $(INCDIR)/fopen-same.h \
   $(INCDIR)/filenames.h
+bin2c.o: bin2c.c ../bfd/bfd.h $(INCDIR)/ansidecl.h \
+  $(INCDIR)/symcat.h bucomm.h $(INCDIR)/ansidecl.h config.h \
+  $(INCDIR)/fopen-same.h
 binemul.o: binemul.c binemul.h ../bfd/bfd.h $(INCDIR)/ansidecl.h \
   $(INCDIR)/symcat.h bucomm.h $(INCDIR)/ansidecl.h config.h \
   $(INCDIR)/fopen-same.h
Index: binutils/bin2c.c
===================================================================
RCS file: binutils/bin2c.c
diff -N binutils/bin2c.c
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ binutils/bin2c.c	27 Feb 2007 03:14:43 -0000
@@ -0,0 +1,104 @@
+/* bin2c.c -- dump binary file in hex format
+   Copyright 2007 Free Software Foundation, Inc.
+
+   This file is part of GNU Binutils.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 2 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software
+   Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA
+   02110-1301, USA.  */
+
+#include "bfd.h"
+#include "bucomm.h"
+
+#if !defined O_BINARY && defined _O_BINARY
+  /* For MSC-compatible compilers.  */
+# define O_BINARY _O_BINARY
+# define O_TEXT _O_TEXT
+#endif
+
+#ifdef __BEOS__
+  /* BeOS 5 has O_BINARY and O_TEXT, but they have no effect.  */
+# undef O_BINARY
+# undef O_TEXT
+#endif
+
+#if O_BINARY
+# ifndef __DJGPP__
+#  define setmode _setmode
+#  define fileno(_fp) _fileno (_fp)
+# endif /* not DJGPP */
+# define SET_BINARY(_f) \
+  do { if (!isatty (_f)) setmode (_f, O_BINARY); } while (0)
+#else
+# define SET_BINARY(f) (void) 0
+# define O_BINARY 0
+# define O_TEXT 0
+#endif /* O_BINARY */
+
+int
+main (int argc, char *argv[])
+{
+  int c;
+  int i;
+
+#if defined (HAVE_SETLOCALE) && defined (HAVE_LC_MESSAGES)
+  setlocale (LC_MESSAGES, "");
+#endif
+#if defined (HAVE_SETLOCALE)
+  setlocale (LC_CTYPE, "");
+#endif
+  bindtextdomain (PACKAGE, LOCALEDIR);
+  textdomain (PACKAGE);
+
+  if (argc != 1)
+    {
+      int ishelp = 0;
+      int isvers = 0;
+      FILE *stream;
+
+      if (argc == 2 && argv[1][0] == '-')
+	{
+	  const char *opt = &argv[1][1];
+	  if (*opt == '-')
+	    ++opt;
+	  ishelp = *opt == 'h' || *opt == 'H';
+	  isvers = *opt == 'v' || *opt == 'V';
+	}
+
+      if (isvers)
+	print_version ("bin2c");
+
+      stream = ishelp ? stdout : stderr;
+      fprintf (stream, _("Usage: %s < input_file > output_file\n"), argv[0]);
+      fprintf (stream, _("Prints bytes from stdin in hex format.\n"));
+      exit (!ishelp);
+    }
+
+  SET_BINARY (fileno (stdin));
+
+  i = 0;
+  while ((c = getc (stdin)) != EOF)
+    {
+      printf ("0x%02x,", c);
+      if (++i == 16)
+	{
+	  printf ("\n");
+	  i = 0;
+	}
+    }
+  if (i != 0)
+    printf ("\n");
+
+  exit (0);
+}
Index: binutils/configure.in
===================================================================
RCS file: /cvs/src/src/binutils/configure.in,v
retrieving revision 1.73
diff -u -p -r1.73 configure.in
--- binutils/configure.in	17 Feb 2007 13:33:54 -0000	1.73
+++ binutils/configure.in	27 Feb 2007 03:14:47 -0000
@@ -233,6 +233,7 @@ do
 	BUILD_NLMCONV='$(NLMCONV_PROG)$(EXEEXT)'
 	BUILD_SRCONV='$(SRCONV_PROG)'
 	NLMCONV_DEFS="-DNLMCONV_I386 -DNLMCONV_ALPHA -DNLMCONV_POWERPC -DNLMCONV_SPARC"
+	BUILD_MISC="${BUILD_MISC} bin2c"
     else
 	case $targ in
 changequote(,)dnl
@@ -335,7 +336,7 @@ changequote([,])dnl
 	  BUILD_WINDRES='$(WINDRES_PROG)$(EXEEXT)'
 	  ;;
 	powerpc*-*-linux* | powerpc*-*-elf*)
-	  BUILD_MISC=embedspu
+	  BUILD_MISC="${BUILD_MISC} embedspu"
 	  ;;
 	sh*-*-pe)
   	  BUILD_DLLTOOL='$(DLLTOOL_PROG)$(EXEEXT)'
@@ -345,6 +346,9 @@ changequote([,])dnl
 	  DLLTOOL_DEFS="$DLLTOOL_DEFS -DDLLTOOL_SH"
 	  BUILD_WINDRES='$(WINDRES_PROG)$(EXEEXT)'
 	  ;;
+	spu-*-*)
+	  BUILD_MISC="${BUILD_MISC} bin2c"
+	  ;;
 	mips*-*-pe)
   	  BUILD_DLLTOOL='$(DLLTOOL_PROG)$(EXEEXT)'
 	  if test -z "$DLLTOOL_DEFAULT"; then
Index: binutils/version.c
===================================================================
RCS file: /cvs/src/src/binutils/version.c,v
retrieving revision 1.11
diff -u -p -r1.11 version.c
--- binutils/version.c	8 May 2005 14:17:39 -0000	1.11
+++ binutils/version.c	27 Feb 2007 03:14:47 -0000
@@ -32,7 +32,7 @@ print_version (const char *name)
   /* This output is intended to follow the GNU standards document.  */
   /* xgettext:c-format */
   printf ("GNU %s %s\n", name, BFD_VERSION_STRING);
-  printf (_("Copyright 2005 Free Software Foundation, Inc.\n"));
+  printf (_("Copyright 2007 Free Software Foundation, Inc.\n"));
   printf (_("\
 This program is free software; you may redistribute it under the terms of\n\
 the GNU General Public License.  This program has absolutely no warranty.\n"));
Index: binutils/po/POTFILES.in
===================================================================
RCS file: /cvs/src/src/binutils/po/POTFILES.in,v
retrieving revision 1.7
diff -u -p -r1.7 POTFILES.in
--- binutils/po/POTFILES.in	25 Oct 2005 02:20:16 -0000	1.7
+++ binutils/po/POTFILES.in	27 Feb 2007 03:14:48 -0000
@@ -2,6 +2,7 @@ addr2line.c
 ar.c
 arsup.c
 arsup.h
+bin2c.c
 binemul.c
 binemul.h
 bucomm.c
Index: ld/Makefile.am
===================================================================
RCS file: /cvs/src/src/ld/Makefile.am,v
retrieving revision 1.230
diff -u -p -r1.230 Makefile.am
--- ld/Makefile.am	26 Feb 2007 08:58:15 -0000	1.230
+++ ld/Makefile.am	27 Feb 2007 03:15:14 -0000
@@ -422,8 +422,7 @@ ALL_64_EMULATIONS = \
 ALL_EMUL_EXTRA_OFILES = \
 	deffilep.o \
 	pe-dll.o \
-	pep-dll.o \
-	spu_inc.o
+	pep-dll.o
 
 CFILES = ldctor.c ldemul.c ldexp.c ldfile.c ldlang.c \
 	ldmain.c ldmisc.c ldver.c ldwrite.c lexsup.c \
@@ -722,16 +721,9 @@ eelf32_sparc_vxworks.c: $(srcdir)/emulpa
   $(srcdir)/scripttempl/elf.sc ${GEN_DEPENDS}
 	${GENSCRIPTS} elf32_sparc_vxworks "$(tdir_elf32_sparc_vxworks)"
 eelf32_spu.c: $(srcdir)/emulparams/elf32_spu.sh $(srcdir)/emultempl/spuelf.em \
+  $(srcdir)/emultempl/spu_ovl.o \
   $(ELF_DEPS) $(srcdir)/scripttempl/elf.sc ${GEN_DEPENDS}
 	${GENSCRIPTS} elf32_spu "$(tdir_elf32_spu)"
-spu_inc.o: $(srcdir)/emultempl/spu_inc.s $(srcdir)/emultempl/spu_none.s \
-  $(srcdir)/emultempl/spu_ovl.o
-	cp $(srcdir)/emultempl/spu_ovl.o spu_ovl.o; \
-	if ! ld -r -o $@ -b binary spu_ovl.o; then \
-	  if ! $(CC) -c -o $@ $(srcdir)/emultempl/spu_inc.s; then \
-	    $(CC) -c -o $@ $(srcdir)/emultempl/spu_none.s; \
-	  fi \
-	fi
 $(srcdir)/emultempl/spu_ovl.o: @MAINT@ $(srcdir)/emultempl/spu_ovl.S
 	cpp -DOVLY_IRQ_SAVE $(srcdir)/emultempl/spu_ovl.S spu_ovl.s
 	if ../gas/as-new --version \
Index: ld/emultempl/spuelf.em
===================================================================
RCS file: /cvs/src/src/ld/emultempl/spuelf.em,v
retrieving revision 1.2
diff -u -p -r1.2 spuelf.em
--- ld/emultempl/spuelf.em	26 Feb 2007 08:58:16 -0000	1.2
+++ ld/emultempl/spuelf.em	27 Feb 2007 03:15:25 -0000
@@ -38,12 +38,17 @@ static int emit_stub_syms = 0;
 static bfd_vma local_store_lo = 0;
 static bfd_vma local_store_hi = 0x3ffff;
 
-extern void *_binary_spu_ovl_o_start;
-extern void *_binary_spu_ovl_o_end;
+static const char ovl_mgr[] = {
+EOF
+
+../binutils/bin2c < ${srcdir}/emultempl/spu_ovl.o >> e${EMULATION_NAME}.c
+
+cat >>e${EMULATION_NAME}.c <<EOF
+};
 
 static const struct _ovl_stream ovl_mgr_stream = {
-  &_binary_spu_ovl_o_start,
-  &_binary_spu_ovl_o_end
+  ovl_mgr,
+  ovl_mgr + sizeof (ovl_mgr)
 };
 
 static asection *toe = NULL;

-- 
Alan Modra
IBM OzLabs - Linux Technology Centre


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