In binutils 2.18, the 'srec' BFD file format does not handle EOF correctly.
This situation only comes up when the srec file does not contain an explicit
"end" record (S7, S8, or S9).

Here is a comparison of the native objdump on a RHEL system, which works OK on
such a file, and a host=i386-redhat-linux target=powerpc-linux cross objdump
built from binutils-2.18:


| $ cat test.srec
| S315000000000909090909090909444444444444444482
| S3150000001072727272727272724A4A4A4A4A4A4A4AFA
| $ objdump --version
| GNU objdump 2.14.90.0.4 20030523
| Copyright 2002 Free Software Foundation, Inc.
| This program is free software; you may redistribute it under the terms of
| the GNU General Public License.  This program has absolutely no warranty.
| $ xppc-objdump --version
| GNU objdump (GNU Binutils) 2.18
| Copyright 2007 Free Software Foundation, Inc.
| This program is free software; you may redistribute it under the terms of
| the GNU General Public License version 3 or (at your option) any later 
version.
| This program has absolutely no warranty.
| $ objdump -x test.srec
|
| test.srec:     file format srec
| test.srec
| architecture: UNKNOWN!, flags 0x00000000:
|
| start address 0x00000000
|
| Sections:
| Idx Name          Size      VMA       LMA       File off  Algn
|   0 .sec1         00000020  00000000  00000000  00000000  2**0
|                   CONTENTS, ALLOC, LOAD
| SYMBOL TABLE:
| no symbols
|
|
| $ xppc-objdump -x test.srec
| xppc-objdump: test.srec: File format not recognized

The problem appears to be caused by the function srec_get_byte assuming that
bfd_bread will set bfd_error to bfd_error_file_truncated when encountering EOF,
though bfd_bread does not always do that -- in some cases it leaves bfd_error
unchanged.

One fix, assuming that bfd_bread is correct and srec_get_byte is at fault, is
this:

*** binutils-2.18/bfd/ORIGsrec.c        2007-08-06 12:59:41.000000000 -0700
--- binutils-2.18/bfd/srec.c    2008-09-11 17:52:23.000000000 -0700
***************
*** 221,226 ****
--- 221,227 ----
  {
    bfd_byte c;

+   bfd_set_error (bfd_error_file_truncated);
    if (bfd_bread (&c, (bfd_size_type) 1, abfd) != 1)
      {
        if (bfd_get_error () != bfd_error_file_truncated)


--
                                        -=] Mike [=-


_______________________________________________
bug-binutils mailing list
bug-binutils@gnu.org
http://lists.gnu.org/mailman/listinfo/bug-binutils

Reply via email to