This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: "tail +140" no longer works.
- From: Alan Modra <amodra at bigpond dot net dot au>
- To: Dave Korn <dave dot korn dot cygwin at googlemail dot com>
- Cc: Nick Clifton <nickc at redhat dot com>, binutils at sourceware dot org
- Date: Mon, 16 Mar 2009 17:08:56 +1030
- Subject: Re: "tail +140" no longer works.
- References: <49A639A6.2070703@gmail.com> <20090227021634.GL6783@bubble.grove.modra.org> <49ABF409.7070801@redhat.com> <49B9E3DE.4000602@gmail.com>
On Fri, Mar 13, 2009 at 04:41:02AM +0000, Dave Korn wrote:
> Confirmed that "tail -c +140" fails and "tail -c +220" (note '+'
> accidentally omitted in Nick's post) works perfectly.
>
> How portable is this though? I'm a bit out of date but I seem to remember
> Solaris having a quirky set of command-line options. Should we consider an
> alternative solution using some/any/all of od/sed/grep-v maybe?
Why don't we leave someone else to worry about portability, and use
gcc's bootstrap compare? It isn't exactly easy to use, but after
quite some fiddling around I managed to get it all working. The
difficulty is that do_compare is intended for use as a shell command
and has embedded $f1 and $f2 variable expansions. I found these were
getting lost inside runtest or expect somewhere, so opted to simply
remove the '$' rather than trying to get quoting right to pass it down
unchanged to the ld testsuite tcl functions.
ld/
* configure.in: Invoke ACX_PROG_CMP_IGNORE_INITIAL.
* Makefile.am (check-DEJAGNU): Set DO_COMPARE.
* aclocal.m4: Regenerate.
* configure: Regenerate.
* Makefile.in: Regenerate.
ld/testsuite/
* ld-bootstrap/bootstrap.exp: Use DO_COMPARE. Remove unnecessary
cleanup and log output.
Index: ld/configure.in
===================================================================
RCS file: /cvs/src/src/ld/configure.in,v
retrieving revision 1.58
diff -u -p -r1.58 configure.in
--- ld/configure.in 3 Feb 2009 15:54:05 -0000 1.58
+++ ld/configure.in 16 Mar 2009 05:41:52 -0000
@@ -125,6 +125,7 @@ AM_PROG_LEX
AM_MAINTAINER_MODE
AM_CONDITIONAL(GENINSRC_NEVER, false)
+ACX_PROG_CMP_IGNORE_INITIAL
. ${srcdir}/configure.host
Index: ld/Makefile.am
===================================================================
RCS file: /cvs/src/src/ld/Makefile.am,v
retrieving revision 1.261
diff -u -p -r1.261 Makefile.am
--- ld/Makefile.am 3 Mar 2009 02:41:14 -0000 1.261
+++ ld/Makefile.am 16 Mar 2009 05:41:42 -0000
@@ -1767,6 +1767,7 @@ check-DEJAGNU: site.exp
CC_FOR_HOST="$(CC)" CFLAGS_FOR_HOST="$(CFLAGS)" \
OFILES="$(OFILES)" BFDLIB="$(TESTBFDLIB)" \
LIBIBERTY="$(LIBIBERTY) $(LIBINTL)" LIBS="$(LIBS)" \
+ DO_COMPARE="`echo '$(do_compare)' | sed -e 's,\\$$,,g'`" \
$(RUNTESTFLAGS); \
else echo "WARNING: could not find \`runtest'" 1>&2; :;\
fi
Index: ld/testsuite/ld-bootstrap/bootstrap.exp
===================================================================
RCS file: /cvs/src/src/ld/testsuite/ld-bootstrap/bootstrap.exp,v
retrieving revision 1.15
diff -u -p -r1.15 bootstrap.exp
--- ld/testsuite/ld-bootstrap/bootstrap.exp 6 Jul 2007 14:09:42 -0000 1.15
+++ ld/testsuite/ld-bootstrap/bootstrap.exp 16 Mar 2009 05:52:47 -0000
@@ -137,8 +137,6 @@ foreach flags {"" "strip" "--static" "--
}
}
- send_log "compare (tail of) tmpdir/ld2 tmpdir/ld3\n"
- verbose "compare (tail of) tmpdir/ld2 tmpdir/ld3"
if {[istarget "*-*-pe"]
|| [istarget "*-*-wince"]
|| [istarget "*-*-cygwin*"]
@@ -147,19 +145,19 @@ foreach flags {"" "strip" "--static" "--
|| [istarget "*-*-interix*"]
|| [istarget "*-*-beospe*"]
|| [istarget "*-*-netbsdpe*"]} {
- # Trim off the date present in PE binaries by only looking
- # at the ends of the files
- # Although this works, a way to set the date would be better.
- # Removing or zeroing the date stamp in the binary produced by
- # the linker is not possible as it is required by the target OS.
- exec tail +140 tmpdir/ld2 >tmpdir/ld2tail
- exec tail +140 tmpdir/ld3 >tmpdir/ld3tail
- catch "exec cmp tmpdir/ld2tail tmpdir/ld3tail" exec_output
- exec rm tmpdir/ld2tail tmpdir/ld3tail
+ # Trim off the date present in PE binaries by only looking
+ # at the ends of the files
+ # Although this works, a way to set the date would be better.
+ # Removing or zeroing the date stamp in the binary produced by
+ # the linker is not possible as it is required by the target OS.
+ set do_compare [string map {16 220 f1 tmpdir/ld2 f2 tmpdir/ld3 tmp-foo1 tmpdir/ld2tail tmp-foo2 tmpdir/ld3tail} $DO_COMPARE]
+ send_log "$do_compare\n"
+ verbose "$do_compare"
+ catch "exec [concat sh -c [list $do_compare]]" exec_output
} else {
- send_log "cmp tmpdir/ld2 tmpdir/ld3\n"
- verbose "cmp tmpdir/ld2 tmpdir/ld3"
- catch "exec cmp tmpdir/ld2 tmpdir/ld3" exec_output
+ send_log "cmp tmpdir/ld2 tmpdir/ld3\n"
+ verbose "cmp tmpdir/ld2 tmpdir/ld3"
+ catch "exec cmp tmpdir/ld2 tmpdir/ld3" exec_output
}
set exec_output [prune_warnings $exec_output]
@@ -174,4 +172,4 @@ foreach flags {"" "strip" "--static" "--
}
catch "exec rm -f tmpdir/ld-partial.o tmpdir/ld1 tmpdir/ld2 tmpdir/ld3" status
-catch "exec rm -f tmpdir/ld1tail tmpdir/ld2tail tmpdir/ld3tail" status
+catch "exec rm -f tmpdir/ld2tail tmpdir/ld3tail" status
--
Alan Modra
Australia Development Lab, IBM