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 01:21:51 -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>
On Thu, Jul 26, 2001 at 06:17:56PM -0700, H . J . Lu wrote:
> On Thu, Jul 26, 2001 at 09:11:42PM -0400, DJ Delorie wrote:
> >
> > > FYI, this is NOT a patch for the FSF binutils, but something I will
> > > use for my next Linux binutils. It seems to work for me.
> >
> > If you're going to go through the trouble of fixing it, why not fix it
> > for everyone instead of just linux?
>
> That is only thing I could think of at that moment. I need a solution
> fast. I guess you can write a simple C program and run it to output
> bmp1.bmp. It should be easy enough to implement:
>
> 1. Read bmp1.bmp and print out each byte with %d.
> 2. Put them in a char array.
> 3. Write out the array with write ().
>
I wrote a small program with the existing portable code in binutils
to generate bmp1.bmp. It seems to work for me. Any comments?
H.J.
----
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 08:16:03
@@ -60,7 +60,8 @@ 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) binary
# Stuff that goes in tooldir/ if appropriate
TOOL_PROGS = nm-new strip-new ar ranlib dlltool
@@ -84,7 +85,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 +257,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 +339,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 && 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)/'`; \
@@ -355,6 +359,8 @@ install-exec-local: install-binPROGRAMS
fi; \
done
+windres: binary
+
# What appears below is generated by a hacked mkdep using gcc -MM.
# DO NOT DELETE THIS LINE -- mkdep uses it.
@@ -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
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 01:08:13 2001
@@ -0,0 +1,133 @@
+/* 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 [] =
+{
+ 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
+};
+
+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;
+}
Index: testsuite/binutils-all/windres/windres.exp
===================================================================
RCS file: /work/cvs/gnu/binutils/binutils/testsuite/binutils-all/windres/windres.exp,v
retrieving revision 1.1.1.3
diff -u -p -r1.1.1.3 windres.exp
--- testsuite/binutils-all/windres/windres.exp 2001/08/03 15:37:24 1.1.1.3
+++ testsuite/binutils-all/windres/windres.exp 2001/08/04 08:17:01
@@ -39,6 +39,10 @@ if {[which $WINDRES] == 0} then {
return
}
+if {![info exists $srcdir/$subdir/bmp1.bmp]} then {
+ exec $base_dir/binary -o $srcdir/$subdir/bmp1.bmp
+}
+
set wr "$WINDRES --include-dir $srcdir/$subdir"
if [file exists "$srcdir/../../winsup/w32api/include"] {