This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
Re: How to generate diffs on binary file from CVS?
- To: DJ Delorie <dj at delorie dot com>
- Subject: Re: How to generate diffs on binary file from CVS?
- From: "H . J . Lu" <hjl at lucon dot org>
- Date: Sat, 4 Aug 2001 11:01:58 -0700
- Cc: binutils at sourceware dot cygnus dot com
- References: <20010726174004.A10789@lucon.org> <200107270042.UAA22048@greed.delorie.com> <20010726174535.A10958@lucon.org> <200107270046.UAA22193@greed.delorie.com> <20010726181014.A11475@lucon.org> <200107270111.VAA19864@envy.delorie.com> <20010726181756.A11581@lucon.org> <20010804012151.A3106@lucon.org>
On Sat, Aug 04, 2001 at 01:21:51AM -0700, H . J . Lu wrote:
>
> I wrote a small program with the existing portable code in binutils
> to generate bmp1.bmp. It seems to work for me. Any comments?
>
Here is an update. If it is ok, I will send in a patch for testsuite.
H.J.
-----
2001-08-04 H.J. Lu <hjl@gnu.org>
* configure.in (BUILD_BINARY): New. Set if $BUILD_WINDRES is
set. Substitute.
* configure: Renerated.
* Makefile.am (BINARY_PROG): New.
(noinst_PROGRAMS): Add @BUILD_BINARY@.
(EXTRA_PROGRAMS): Add binary.
(HFILES): Add binary.h.
(CFILES): Add binary.c.
(binary_SOURCES): Set to binary.c.
(install-exec-local): Don't install binary$(EXEEXT).
(binary.o): New dependency.
* Makefile.in: Renerated.
* binary.c: New file.
* binary.h: Likewise.
Index: configure.in
===================================================================
RCS file: /work/cvs/gnu/binutils/binutils/configure.in,v
retrieving revision 1.15
diff -u -p -r1.15 configure.in
--- configure.in 2001/08/04 00:17:46 1.15
+++ configure.in 2001/08/04 17:49:17
@@ -183,6 +183,7 @@ BUILD_SRCONV=
BUILD_DLLTOOL=
DLLTOOL_DEFS=
BUILD_WINDRES=
+BUILD_BINARY=
BUILD_DLLWRAP=
BUILD_MISC=
OBJDUMP_DEFS=
@@ -281,12 +282,17 @@ if test "${with_windres+set}" = set; the
BUILD_WINDRES='$(WINDRES_PROG)$(EXEEXT)'
fi
+if test -n "$BUILD_WINDRES"; then
+ BUILD_BINARY='$(BINARY_PROG)$(EXEEXT)'
+fi
+
AC_SUBST(NLMCONV_DEFS)
AC_SUBST(BUILD_NLMCONV)
AC_SUBST(BUILD_SRCONV)
AC_SUBST(BUILD_DLLTOOL)
AC_SUBST(DLLTOOL_DEFS)
AC_SUBST(BUILD_WINDRES)
+AC_SUBST(BUILD_BINARY)
AC_SUBST(BUILD_DLLWRAP)
AC_SUBST(BUILD_MISC)
AC_SUBST(OBJDUMP_DEFS)
Index: Makefile.am
===================================================================
RCS file: /work/cvs/gnu/binutils/binutils/Makefile.am,v
retrieving revision 1.20
diff -u -p -r1.20 Makefile.am
--- Makefile.am 2001/06/19 17:57:42 1.20
+++ Makefile.am 2001/08/04 17:49:17
@@ -49,6 +49,7 @@ NLMCONV_PROG=nlmconv
DLLTOOL_PROG=dlltool
WINDRES_PROG=windres
DLLWRAP_PROG=dllwrap
+BINARY_PROG=binary
SRCONV_PROG=srconv$(EXEEXT) sysdump$(EXEEXT) coffdump$(EXEEXT)
@@ -58,9 +59,11 @@ bin_PROGRAMS = $(SIZE_PROG) $(OBJDUMP_PR
## We need a special rule to install the programs which are built with
## -new, and to rename cxxfilt to c++filt.
-noinst_PROGRAMS = $(NM_PROG) $(STRIP_PROG) $(DEMANGLER_PROG)
+noinst_PROGRAMS = $(NM_PROG) $(STRIP_PROG) $(DEMANGLER_PROG) \
+ @BUILD_BINARY@
-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) binary
# Stuff that goes in tooldir/ if appropriate
TOOL_PROGS = nm-new strip-new ar ranlib dlltool
@@ -74,7 +77,7 @@ MKDEP = gcc -MM
INCLUDES = -D_GNU_SOURCE -I. -I$(srcdir) -I../bfd -I$(BFDDIR) -I$(INCDIR) @HDEFINES@ -I$(srcdir)/../intl -I../intl -DLOCALEDIR="\"$(prefix)/share/locale\""
HFILES = arsup.h bucomm.h budbg.h coffgrok.h debug.h nlmconv.h dlltool.h \
- windres.h winduni.h
+ windres.h winduni.h binary.h
GENERATED_HFILES = arparse.h sysroff.h sysinfo.h defparse.h rcparse.h
@@ -84,7 +87,7 @@ CFILES = addr2line.c ar.c arsup.c bucomm
objcopy.c objdump.c prdbg.c rdcoff.c rddbg.c size.c srconv.c \
stabs.c strings.c sysdump.c version.c wrstabs.c \
windres.c resrc.c rescoff.c resbin.c winduni.c readelf.c \
- resres.c dllwrap.c rename.c
+ resres.c dllwrap.c rename.c binary.c
GENERATED_CFILES = \
underscore.c arparse.c arlex.c sysroff.c sysinfo.c syslex.c \
@@ -256,6 +259,8 @@ coffdump_SOURCES = coffdump.c coffgrok.c
sysdump_SOURCES = sysdump.c $(BULIBS)
+binary_SOURCES = binary.c
+
# coff/sym.h and coff/ecoff.h won't be found by the automatic dependency
# scripts, since they are only included conditionally.
nlmconv.o: nlmconv.c $(INCDIR)/coff/sym.h $(INCDIR)/coff/ecoff.h
@@ -336,6 +341,7 @@ CLEANFILES = dep.sed DEP DEPA DEP1 DEP2
install-exec-local: install-binPROGRAMS $(bin_PROGRAMS) $(noinst_PROGRAMS)
@list='$(noinst_PROGRAMS)'; for p in $$list; do \
+ test $$p = binary$(EXEEXT) && continue; \
if test -f $$p; then \
echo " $(LIBTOOL) --mode=install $(INSTALL_PROGRAM) $$p $(bindir)/`echo $$p|sed -e 's/$(EXEEXT)$$//' -e 's/-new//' -e 's/cxxfilt/$(DEMANGLER_NAME)/'|sed '$(transform)'|sed 's/$$/$(EXEEXT)/'`"; \
$(LIBTOOL) --mode=install $(INSTALL_PROGRAM) $$p $(bindir)/`echo $$p|sed -e 's/$(EXEEXT)$$//' -e 's/-new//' -e 's/cxxfilt/$(DEMANGLER_NAME)/'|sed '$(transform)'|sed 's/$$/$(EXEEXT)/'`; \
@@ -483,6 +489,9 @@ dllwrap.o: dllwrap.c ../bfd/bfd.h $(INCD
$(INCDIR)/fopen-same.h $(INCDIR)/dyn-string.h
rename.o: rename.c ../bfd/bfd.h $(INCDIR)/ansidecl.h \
bucomm.h config.h $(INCDIR)/bin-bugs.h $(INCDIR)/fopen-same.h
+binary.o: binary.c ../bfd/bfd.h $(INCDIR)/ansidecl.h \
+ $(INCDIR)/libiberty.h bucomm.h config.h $(INCDIR)/bin-bugs.h \
+ $(INCDIR)/fopen-same.h binary.h
underscore.o: underscore.c
arparse.o: arparse.c ../bfd/bfd.h $(INCDIR)/ansidecl.h \
bucomm.h config.h $(INCDIR)/bin-bugs.h $(INCDIR)/fopen-same.h \
--- /dev/null Fri Mar 23 20:37:44 2001
+++ binary.c Sat Aug 4 10:06:10 2001
@@ -0,0 +1,119 @@
+/* Copyright 2001 Free Software Foundation, Inc.
+
+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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+#include "bfd.h"
+#include "libiberty.h"
+#include "bucomm.h"
+#include "getopt.h"
+
+static void usage PARAMS ((FILE *, const char *, int));
+static void read_binary PARAMS ((const char *));
+static void write_binary PARAMS ((const char *));
+
+static unsigned char binary_data [] =
+{
+#include "binary.h"
+};
+
+static void
+write_binary (filename)
+ const char *filename;
+{
+ FILE *stream;
+
+ stream = fopen (filename, FOPEN_WB);
+ if (stream == NULL)
+ {
+ perror (filename);
+ xexit (1);
+ }
+
+ if (fwrite (binary_data, 1, sizeof (binary_data), stream)
+ != sizeof (binary_data))
+ {
+ perror (filename);
+ fclose (stream);
+ xexit (1);
+ }
+
+ fclose (stream);
+}
+
+static void
+read_binary (filename)
+ const char *filename;
+{
+ FILE *stream;
+ unsigned char buf [8192];
+ size_t len, i, count;
+
+ stream = fopen (filename, FOPEN_RB);
+ if (stream == NULL)
+ {
+ perror (filename);
+ xexit (1);
+ }
+
+ count = 0;
+ while ((len = fread (buf, 1, sizeof (buf), stream)) > 0)
+ {
+ for (i = 0; i < len; i++)
+ {
+ count++;
+ printf ("0x%.2x,", buf [i]);
+ putchar ((count % 8) ? ' ' : '\n');
+ }
+ }
+ if (count % 8)
+ putchar ('\n');
+
+ fclose (stream);
+}
+
+static void
+usage (stream, prog, status)
+ FILE *stream;
+ const char *prog;
+ int status;
+{
+ fprintf (stream, "Usage: %s [-i input] [-o output]\n", prog);
+ exit (status);
+}
+
+int
+main (argc, argv)
+ int argc;
+ char **argv;
+{
+ int c;
+
+ while ((c = getopt (argc, argv, "i:o:")) != EOF)
+ {
+ switch (c)
+ {
+ case 'i':
+ read_binary (optarg);
+ break;
+ case 'o':
+ write_binary (optarg);
+ break;
+ default:
+ usage (stderr, argv [0], 1);
+ }
+ }
+
+ return 0;
+}
--- /dev/null Fri Mar 23 20:37:44 2001
+++ binary.h Sat Aug 4 10:04:59 2001
@@ -0,0 +1,16 @@
+0x42, 0x4d, 0x7a, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x76, 0x00, 0x00, 0x00, 0x28, 0x00,
+0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00,
+0x00, 0x00, 0x01, 0x00, 0x04, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x80,
+0x00, 0x00, 0x00, 0x80, 0x80, 0x00, 0x80, 0x00,
+0x00, 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x80,
+0x00, 0x00, 0xc0, 0xc0, 0xc0, 0x00, 0x80, 0x80,
+0x80, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0xff,
+0x00, 0x00, 0x00, 0xff, 0xff, 0x00, 0xff, 0x00,
+0x00, 0x00, 0xff, 0x00, 0xff, 0x00, 0xff, 0xff,
+0x00, 0x00, 0xff, 0xff, 0xff, 0x00, 0x90, 0x00,
+0x00, 0x00,