This is the mail archive of the
binutils@sourceware.cygnus.com
mailing list for the binutils project.
revised patch for objdump'ing core files
- To: binutils at sourceware dot cygnus dot com
- Subject: revised patch for objdump'ing core files
- From: fnf at toadfish dot ninemoons dot com
- Date: Tue, 26 Oct 1999 16:54:38 -0700 (MST)
Some time back, I submitted a patch that allowed objdump to recognize
and dump core files. However that patch had a couple of problems with
properly handling ambiguously recognized files, particularly
bfd_object files.
I believe this patch fixes that. This patch is modeled after how
display_bfd works in size.c, by moving the actual code to process the
bfd out of display_bfd and into a separate function called by
display_bfd, once a match is found.
Could someone please review this and check it in if it looks OK now?
Thanks!
-Fred
1999-10-26 Fred Fish <fnf@cygnus.com>
* objdump.c (display_bfd): Break into two functions. The
actual dumping code moves to dump_bfd. If bfd is not
unambiguously recognized as a bfd_object, attempt to dump
it as a bfd_core.
(dump_bfd): New function.
Index: objdump.c
===================================================================
RCS file: /cvs/binutils/binutils/binutils/objdump.c,v
retrieving revision 1.12
diff -c -p -r1.12 objdump.c
*** objdump.c 1999/09/19 22:39:49 1.12
--- objdump.c 1999/10/26 23:33:50
*************** bfd *abfd;
*** 2042,2064 ****
bfd_print_private_bfd_data (abfd, stdout);
}
static void
! display_bfd (abfd)
bfd *abfd;
{
- char **matching;
-
- if (!bfd_check_format_matches (abfd, bfd_object, &matching))
- {
- nonfatal (bfd_get_filename (abfd));
- if (bfd_get_error () == bfd_error_file_ambiguously_recognized)
- {
- list_matching_formats (matching);
- free (matching);
- }
- return;
- }
-
/* If we are adjusting section VMA's, change them all now. Changing
the BFD information is a hack. However, we must do it, or
bfd_find_nearest_line will not do the right thing. */
--- 2042,2053 ----
bfd_print_private_bfd_data (abfd, stdout);
}
+ /* Dump selected contents of ABFD */
+
static void
! dump_bfd (abfd)
bfd *abfd;
{
/* If we are adjusting section VMA's, change them all now. Changing
the BFD information is a hack. However, we must do it, or
bfd_find_nearest_line will not do the right thing. */
*************** display_bfd (abfd)
*** 2131,2136 ****
--- 2120,2160 ----
{
free (dynsyms);
dynsyms = NULL;
+ }
+ }
+
+ static void
+ display_bfd (abfd)
+ bfd *abfd;
+ {
+ char **matching;
+
+ if (bfd_check_format_matches (abfd, bfd_object, &matching))
+ {
+ dump_bfd (abfd);
+ return;
+ }
+
+ if (bfd_get_error () == bfd_error_file_ambiguously_recognized)
+ {
+ nonfatal (bfd_get_filename (abfd));
+ list_matching_formats (matching);
+ free (matching);
+ return;
+ }
+
+ if (bfd_check_format_matches (abfd, bfd_core, &matching))
+ {
+ dump_bfd (abfd);
+ return;
+ }
+
+ nonfatal (bfd_get_filename (abfd));
+
+ if (bfd_get_error () == bfd_error_file_ambiguously_recognized)
+ {
+ list_matching_formats (matching);
+ free (matching);
}
}