This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
A patch for bfd/format.c
- To: binutils at sourceware dot cygnus dot com
- Subject: A patch for bfd/format.c
- From: "H . J . Lu" <hjl at valinux dot com>
- Date: Fri, 17 Nov 2000 14:18:11 -0800
I have binutils configured as
# .../configure --enable-targets=all --enable-64-bit-bfd
For the file, foo.o, in a.out enclosed here, I got
# .../objdump -dw foo.o
lt-objdump: foo.o: Success
The problem is bfd_check_format_matches will call each target
to check if it matches with the .o file. pe_bfd_object_p in
bfd/peicode.h has
1293 offset = bfd_h_get_32 (abfd, buffer);
1294
1295 if (bfd_seek (abfd, offset, SEEK_SET) != 0
1296 || bfd_read (buffer, 1, 4, abfd) != 4)
1297 {
1298 if (bfd_get_error () != bfd_error_system_call)
1299 bfd_set_error (bfd_error_wrong_format);
1300 return NULL;
1301 }
The problem was it got a wild offset and bfd set error to
bfd_error_system_call. I don't know for sure when
bfd_check_format_matches () should stop checking the next target.
But bfd_error_system_call shouldn't stop it. With my patch, I got
# .../objdump -dw foo.o
lt-objdump: foo.o: File format is ambiguous
lt-objdump: Matching formats: a.out-cris a.out-i386 a.out-i386-bsd a.out-i386-lynx a.out-m88k-mach3 a.out-pc532-mach
--
H.J. Lu (hjl@valinux.com)
---
2000-11-17 H.J. Lu <hjl@gnu.org>
* format.c (bfd_check_format_matches): Don't return if get
bfd_error_system_call.
Index: format.c
===================================================================
RCS file: /work/cvs/gnu/binutils/bfd/format.c,v
retrieving revision 1.1.1.2
diff -u -p -r1.1.1.2 format.c
--- format.c 2000/07/20 03:27:55 1.1.1.2
+++ format.c 2000/11/17 22:08:00
@@ -254,13 +254,14 @@ bfd_check_format_matches (abfd, format,
break;
#endif
}
- else if (bfd_get_error () != bfd_error_wrong_format)
+ else if (bfd_get_error () != bfd_error_wrong_format
+ && bfd_get_error () != bfd_error_system_call)
{
abfd->xvec = save_targ;
abfd->format = bfd_unknown;
if (matching && bfd_get_error ()
- != bfd_error_file_ambiguously_recognized)
+ != bfd_error_file_ambiguously_recognized)
free (matching_vector);
return false;
foo.o