Index: corefile.c =================================================================== RCS file: /cvs/src/src/bfd/corefile.c,v retrieving revision 1.10 diff -u -p -r1.10 corefile.c --- corefile.c 5 Oct 2005 21:24:23 -0000 1.10 +++ corefile.c 25 Nov 2005 02:39:54 -0000 @@ -107,3 +107,59 @@ core_file_matches_executable_p (bfd *cor return BFD_SEND (core_bfd, _core_file_matches_executable_p, (core_bfd, exec_bfd)); } + +/* +FUNCTION + generic_core_file_matches_executable_p + +SYNOPSIS + bfd_boolean generic_core_file_matches_executable_p + (bfd *core_bfd, bfd *exec_bfd) + +DESCRIPTION + Return TRUE if the core file attached to @var{core_bfd} + was generated by a run of the executable file attached + to @var{exec_bfd}. The match is based on executable + basenames only. + + Note: When not able to determine the core file failing + command or the executable name, we still return TRUE even + though we're not sure that core file and executable match. + This is to avoid generating a false warning in situations + where we really don't know whether they match or not. +*/ + +bfd_boolean +generic_core_file_matches_executable_p (bfd *core_bfd, bfd *exec_bfd) +{ + char *exec; + char *core; + char *last_slash; + + if (exec_bfd == NULL || core_bfd == NULL) + return TRUE; + + /* The cast below is to avoid a compiler warning due to the assignment + of the const char * returned by bfd_core_file_failing_command to a + non-const char *. In this case, the assignement does not lead to + breaking the const, as we're only reading the string. */ + + core = (char *) bfd_core_file_failing_command (core_bfd); + if (core == NULL) + return TRUE; + + exec = bfd_get_filename (exec_bfd); + if (exec == NULL) + return TRUE; + + last_slash = strrchr (core, '/'); + if (last_slash != NULL) + core = last_slash + 1; + + last_slash = strrchr (exec, '/'); + if (last_slash != NULL) + exec = last_slash + 1; + + return (strcmp(exec, core) == 0); +} + Index: libbfd-in.h =================================================================== RCS file: /cvs/src/src/bfd/libbfd-in.h,v retrieving revision 1.59 diff -u -p -r1.59 libbfd-in.h --- libbfd-in.h 3 Nov 2005 16:06:11 -0000 1.59 +++ libbfd-in.h 25 Nov 2005 02:40:16 -0000 @@ -247,6 +247,12 @@ extern int _bfd_nocore_core_file_failing extern bfd_boolean _bfd_nocore_core_file_matches_executable_p (bfd *, bfd *); +/* A generic implementation of CORE_FILE_MATCHES_EXECUTABLE_P that + is independent of the target. */ + +extern bfd_boolean generic_core_file_matches_executable_p + (bfd *core_bfd, bfd *exec_bfd); + /* Routines to use for BFD_JUMP_TABLE_ARCHIVE when there is no archive file support. Use BFD_JUMP_TABLE_ARCHIVE (_bfd_noarchive). */ Index: libbfd.h =================================================================== RCS file: /cvs/src/src/bfd/libbfd.h,v retrieving revision 1.164 diff -u -p -r1.164 libbfd.h --- libbfd.h 8 Nov 2005 11:15:11 -0000 1.164 +++ libbfd.h 25 Nov 2005 02:40:16 -0000 @@ -252,6 +252,12 @@ extern int _bfd_nocore_core_file_failing extern bfd_boolean _bfd_nocore_core_file_matches_executable_p (bfd *, bfd *); +/* A generic implementation of CORE_FILE_MATCHES_EXECUTABLE_P that + is independent of the target. */ + +extern bfd_boolean generic_core_file_matches_executable_p + (bfd *core_bfd, bfd *exec_bfd); + /* Routines to use for BFD_JUMP_TABLE_ARCHIVE when there is no archive file support. Use BFD_JUMP_TABLE_ARCHIVE (_bfd_noarchive). */ Index: hpux-core.c =================================================================== RCS file: /cvs/src/src/bfd/hpux-core.c,v retrieving revision 1.18 diff -u -p -r1.18 hpux-core.c --- hpux-core.c 29 Oct 2005 23:00:12 -0000 1.18 +++ hpux-core.c 25 Nov 2005 02:40:16 -0000 @@ -101,29 +101,19 @@ struct hpux_core_struct #define core_command(bfd) (core_hdr(bfd)->cmd) #define core_kernel_thread_id(bfd) (core_hdr(bfd)->lwpid) #define core_user_thread_id(bfd) (core_hdr(bfd)->user_tid) +#define hpux_core_core_file_matches_executable_p generic_core_file_matches_executable_p -static asection *make_bfd_asection - PARAMS ((bfd *, const char *, flagword, bfd_size_type, bfd_vma, - unsigned int)); -static const bfd_target *hpux_core_core_file_p - PARAMS ((bfd *)); -static char *hpux_core_core_file_failing_command - PARAMS ((bfd *)); -static int hpux_core_core_file_failing_signal - PARAMS ((bfd *)); -static bfd_boolean hpux_core_core_file_matches_executable_p - PARAMS ((bfd *, bfd *)); -static void swap_abort - PARAMS ((void)); +static asection *make_bfd_asection (bfd *, const char *, flagword, + bfd_size_type, bfd_vma, unsigned int); +static const bfd_target *hpux_core_core_file_p (bfd *); +static char *hpux_core_core_file_failing_command (bfd *); +static int hpux_core_core_file_failing_signal (bfd *); +static void swap_abort (void); static asection * -make_bfd_asection (abfd, name, flags, size, vma, alignment_power) - bfd *abfd; - const char *name; - flagword flags; - bfd_size_type size; - bfd_vma vma; - unsigned int alignment_power; +make_bfd_asection (bfd *abfd, const char *name, flagword flags, + bfd_size_type size, bfd_vma vma, + unsigned int alignment_power) { asection *asect; char *newname; @@ -155,7 +145,7 @@ thread_section_p (bfd *abfd ATTRIBUTE_UN asection *sect, void *obj ATTRIBUTE_UNUSED) { - return (strncmp (bfd_section_name (abfd, sect), ".reg/", 5) == 0); + return (strncmp (sect->name, ".reg/", 5) == 0); } /* this function builds a bfd target if the file is a corefile. @@ -168,8 +158,7 @@ thread_section_p (bfd *abfd ATTRIBUTE_UN (I am just guessing here!) */ static const bfd_target * -hpux_core_core_file_p (abfd) - bfd *abfd; +hpux_core_core_file_p (bfd *abfd) { int good_sections = 0; int unknown_sections = 0; @@ -361,30 +350,21 @@ hpux_core_core_file_p (abfd) } static char * -hpux_core_core_file_failing_command (abfd) - bfd *abfd; +hpux_core_core_file_failing_command (bfd *abfd) { return core_command (abfd); } static int -hpux_core_core_file_failing_signal (abfd) - bfd *abfd; +hpux_core_core_file_failing_signal (bfd *abfd) { return core_signal (abfd); } -static bfd_boolean -hpux_core_core_file_matches_executable_p (core_bfd, exec_bfd) - bfd *core_bfd ATTRIBUTE_UNUSED; - bfd *exec_bfd ATTRIBUTE_UNUSED; -{ - return TRUE; /* FIXME, We have no way of telling at this point */ -} /* If somebody calls any byte-swapping routines, shoot them. */ static void -swap_abort () +swap_abort (void) { abort(); /* This way doesn't require any declaration for ANSI to fuck up */ } Index: aix386-core.c =================================================================== RCS file: /cvs/src/src/bfd/aix386-core.c,v retrieving revision 1.14 diff -u -p -r1.14 aix386-core.c --- aix386-core.c 4 May 2005 15:52:59 -0000 1.14 +++ aix386-core.c 25 Nov 2005 02:39:45 -0000 @@ -204,14 +204,7 @@ aix386_core_file_failing_signal (abfd) return core_hdr (abfd)->cd_cursig; } -static bfd_boolean -aix386_core_file_matches_executable_p (core_bfd, exec_bfd) - bfd *core_bfd; - bfd *exec_bfd; -{ - /* FIXME: We have no way of telling at this point. */ - return TRUE; -} +#define aix386_core_file_matches_executable_p generic_core_file_matches_executable_p /* If somebody calls any byte-swapping routines, shoot them. */ Index: aix5ppc-core.c =================================================================== RCS file: /cvs/src/src/bfd/aix5ppc-core.c,v retrieving revision 1.12 diff -u -p -r1.12 aix5ppc-core.c --- aix5ppc-core.c 9 Aug 2005 08:56:36 -0000 1.12 +++ aix5ppc-core.c 25 Nov 2005 02:39:45 -0000 @@ -319,7 +319,7 @@ xcoff64_core_file_failing_signal (bfd *a #else /* AIX_5_CORE */ const bfd_target *xcoff64_core_p (bfd *); -bfd_boolean xcoff64_core_file_matches_executable_p (bfd *, bfd *); +#define xcoff64_core_file_matches_executable_p generic_core_file_matches_executable_p char *xcoff64_core_file_failing_command (bfd *); int xcoff64_core_file_failing_signal (bfd *); @@ -330,13 +330,6 @@ xcoff64_core_p (bfd *abfd ATTRIBUTE_UNUS return 0; } -bfd_boolean -xcoff64_core_file_matches_executable_p (bfd *core_bfd ATTRIBUTE_UNUSED, - bfd *exec_bfd ATTRIBUTE_UNUSED) -{ - return FALSE; -} - char * xcoff64_core_file_failing_command (bfd *abfd ATTRIBUTE_UNUSED) { Index: cisco-core.c =================================================================== RCS file: /cvs/src/src/bfd/cisco-core.c,v retrieving revision 1.11 diff -u -p -r1.11 cisco-core.c --- cisco-core.c 4 May 2005 15:53:01 -0000 1.11 +++ cisco-core.c 25 Nov 2005 02:39:48 -0000 @@ -75,7 +75,7 @@ static const bfd_target *cisco_core_file static const bfd_target *cisco_core_file_p PARAMS ((bfd *)); char *cisco_core_file_failing_command PARAMS ((bfd *)); int cisco_core_file_failing_signal PARAMS ((bfd *)); -bfd_boolean cisco_core_file_matches_executable_p PARAMS ((bfd *, bfd *)); +#define cisco_core_file_matches_executable_p generic_core_file_matches_executable_p /* Examine the file for a crash info struct at the offset given by CRASH_INFO_LOC. */ @@ -317,14 +317,6 @@ cisco_core_file_failing_signal (abfd) { return abfd->tdata.cisco_core_data->sig; } - -bfd_boolean -cisco_core_file_matches_executable_p (core_bfd, exec_bfd) - bfd *core_bfd ATTRIBUTE_UNUSED; - bfd *exec_bfd ATTRIBUTE_UNUSED; -{ - return TRUE; -} extern const bfd_target cisco_core_little_vec; Index: hppabsd-core.c =================================================================== RCS file: /cvs/src/src/bfd/hppabsd-core.c,v retrieving revision 1.17 diff -u -p -r1.17 hppabsd-core.c --- hppabsd-core.c 27 Oct 2005 03:35:30 -0000 1.17 +++ hppabsd-core.c 25 Nov 2005 02:40:15 -0000 @@ -57,8 +57,7 @@ static char *hppabsd_core_core_file_fail PARAMS ((bfd *)); static int hppabsd_core_core_file_failing_signal PARAMS ((bfd *)); -static bfd_boolean hppabsd_core_core_file_matches_executable_p - PARAMS ((bfd *, bfd *)); +#define hppabsd_core_core_file_matches_executable_p generic_core_file_matches_executable_p static void swap_abort PARAMS ((void)); @@ -217,14 +216,6 @@ hppabsd_core_core_file_failing_signal (a { return core_signal (abfd); } - -static bfd_boolean -hppabsd_core_core_file_matches_executable_p (core_bfd, exec_bfd) - bfd *core_bfd, *exec_bfd; -{ - /* There's no way to know this... */ - return TRUE; -} /* If somebody calls any byte-swapping routines, shoot them. */ static void Index: irix-core.c =================================================================== RCS file: /cvs/src/src/bfd/irix-core.c,v retrieving revision 1.17 diff -u -p -r1.17 irix-core.c --- irix-core.c 4 May 2005 15:53:33 -0000 1.17 +++ irix-core.c 25 Nov 2005 02:40:16 -0000 @@ -41,6 +41,8 @@ struct sgi_core_struct #define core_signal(bfd) (core_hdr(bfd)->sig) #define core_command(bfd) (core_hdr(bfd)->cmd) +#define irix_core_core_file_matches_executable_p generic_core_file_matches_executable_p + static asection *make_bfd_asection (bfd *, const char *, flagword, bfd_size_type, bfd_vma, file_ptr); @@ -262,13 +264,6 @@ irix_core_core_file_failing_signal (bfd return core_signal (abfd); } -static bfd_boolean -irix_core_core_file_matches_executable_p (bfd *core_bfd ATTRIBUTE_UNUSED, - bfd *exec_bfd ATTRIBUTE_UNUSED) -{ - return TRUE; /* XXX - FIXME */ -} - /* If somebody calls any byte-swapping routines, shoot them. */ static void swap_abort(void) Index: lynx-core.c =================================================================== RCS file: /cvs/src/src/bfd/lynx-core.c,v retrieving revision 1.9 diff -u -p -r1.9 lynx-core.c --- lynx-core.c 4 May 2005 15:53:35 -0000 1.9 +++ lynx-core.c 25 Nov 2005 02:40:17 -0000 @@ -51,6 +51,8 @@ struct lynx_core_struct #define core_signal(bfd) (core_hdr(bfd)->sig) #define core_command(bfd) (core_hdr(bfd)->cmd) +#define lynx_core_file_matches_executable_p generic_core_file_matches_executable_p + /* Handle Lynx core dump file. */ static asection * @@ -225,11 +227,4 @@ lynx_core_file_failing_signal (abfd) return core_signal (abfd); } -bfd_boolean -lynx_core_file_matches_executable_p (core_bfd, exec_bfd) - bfd *core_bfd, *exec_bfd; -{ - return TRUE; /* FIXME, We have no way of telling at this point */ -} - #endif /* LYNX_CORE */ Index: mach-o.c =================================================================== RCS file: /cvs/src/src/bfd/mach-o.c,v retrieving revision 1.19 diff -u -p -r1.19 mach-o.c --- mach-o.c 23 May 2005 17:44:55 -0000 1.19 +++ mach-o.c 25 Nov 2005 02:40:17 -0000 @@ -75,6 +75,7 @@ #define bfd_mach_o_bfd_discard_group bfd_generic_discard_group #define bfd_mach_o_section_already_linked _bfd_generic_section_already_linked #define bfd_mach_o_bfd_copy_private_header_data _bfd_generic_bfd_copy_private_header_data +#define bfd_mach_o_core_file_matches_executable_p generic_core_file_matches_executable_p /* The flags field of a section structure is separated into two parts a section @@ -1993,13 +1994,6 @@ bfd_mach_o_core_file_failing_signal (bfd return 0; } -bfd_boolean -bfd_mach_o_core_file_matches_executable_p (bfd *core_bfd ATTRIBUTE_UNUSED, - bfd *exec_bfd ATTRIBUTE_UNUSED) -{ - return TRUE; -} - #define TARGET_NAME mach_o_be_vec #define TARGET_STRING "mach-o-be" #define TARGET_BIG_ENDIAN 1 Index: netbsd-core.c =================================================================== RCS file: /cvs/src/src/bfd/netbsd-core.c,v retrieving revision 1.23 diff -u -p -r1.23 netbsd-core.c --- netbsd-core.c 4 May 2005 15:53:35 -0000 1.23 +++ netbsd-core.c 25 Nov 2005 02:40:18 -0000 @@ -42,6 +42,8 @@ OpenBSD/sparc64. */ #define SPARC64_WCOOKIE_OFFSET 832 +#define netbsd_core_file_matches_executable_p generic_core_file_matches_executable_p + struct netbsd_core_struct { struct core core; @@ -246,14 +248,6 @@ netbsd_core_file_failing_signal (bfd *ab /*return core_signal (abfd);*/ return abfd->tdata.netbsd_core_data->core.c_signo; } - -static bfd_boolean -netbsd_core_file_matches_executable_p (bfd *core_bfd ATTRIBUTE_UNUSED, - bfd *exec_bfd ATTRIBUTE_UNUSED) -{ - /* FIXME, We have no way of telling at this point. */ - return TRUE; -} /* If somebody calls any byte-swapping routines, shoot them. */ Index: osf-core.c =================================================================== RCS file: /cvs/src/src/bfd/osf-core.c,v retrieving revision 1.15 diff -u -p -r1.15 osf-core.c --- osf-core.c 29 Oct 2005 23:00:12 -0000 1.15 +++ osf-core.c 25 Nov 2005 02:40:19 -0000 @@ -40,8 +40,7 @@ static char *osf_core_core_file_failing_ PARAMS ((bfd *)); static int osf_core_core_file_failing_signal PARAMS ((bfd *)); -static bfd_boolean osf_core_core_file_matches_executable_p - PARAMS ((bfd *, bfd *)); +#define osf_core_core_file_matches_executable_p generic_core_file_matches_executable_p static void swap_abort PARAMS ((void)); @@ -172,14 +171,6 @@ osf_core_core_file_failing_signal (abfd) { return core_signal (abfd); } - -static bfd_boolean -osf_core_core_file_matches_executable_p (core_bfd, exec_bfd) - bfd *core_bfd ATTRIBUTE_UNUSED; - bfd *exec_bfd ATTRIBUTE_UNUSED; -{ - return TRUE; /* FIXME, We have no way of telling at this point */ -} /* If somebody calls any byte-swapping routines, shoot them. */ static void Index: ptrace-core.c =================================================================== RCS file: /cvs/src/src/bfd/ptrace-core.c,v retrieving revision 1.13 diff -u -p -r1.13 ptrace-core.c --- ptrace-core.c 4 May 2005 15:53:37 -0000 1.13 +++ ptrace-core.c 25 Nov 2005 02:40:20 -0000 @@ -51,8 +51,7 @@ struct trad_core_struct const bfd_target *ptrace_unix_core_file_p PARAMS ((bfd *abfd)); char * ptrace_unix_core_file_failing_command PARAMS ((bfd *abfd)); int ptrace_unix_core_file_failing_signal PARAMS ((bfd *abfd)); -bfd_boolean ptrace_unix_core_file_matches_executable_p - PARAMS ((bfd *core_bfd, bfd *exec_bfd)); +#define ptrace_unix_core_file_matches_executable_p generic_core_file_matches_executable_p static void swap_abort PARAMS ((void)); const bfd_target * @@ -151,15 +150,6 @@ ptrace_unix_core_file_failing_signal (ab { return abfd->tdata.trad_core_data->u.pt_sigframe.sig_num; } - -bfd_boolean -ptrace_unix_core_file_matches_executable_p (core_bfd, exec_bfd) - bfd *core_bfd, *exec_bfd; -{ - /* FIXME: Use pt_timdat field of the ptrace_user structure to match - the date of the executable */ - return TRUE; -} /* If somebody calls any byte-swapping routines, shoot them. */ static void Index: sco5-core.c =================================================================== RCS file: /cvs/src/src/bfd/sco5-core.c,v retrieving revision 1.18 diff -u -p -r1.18 sco5-core.c --- sco5-core.c 29 Oct 2005 23:00:12 -0000 1.18 +++ sco5-core.c 25 Nov 2005 02:40:21 -0000 @@ -49,8 +49,7 @@ static struct user *read_uarea PARAMS (( const bfd_target *sco5_core_file_p PARAMS ((bfd *abfd)); char *sco5_core_file_failing_command PARAMS ((bfd *abfd)); int sco5_core_file_failing_signal PARAMS ((bfd *abfd)); -bfd_boolean sco5_core_file_matches_executable_p - PARAMS ((bfd *core_bfd, bfd *exec_bfd)); +#define sco5_core_file_matches_executable_p generic_core_file_matches_executable_p static void swap_abort PARAMS ((void)); static asection * @@ -345,14 +344,6 @@ sco5_core_file_failing_signal (ignore_ab : -1); } -bfd_boolean -sco5_core_file_matches_executable_p (core_bfd, exec_bfd) - bfd *core_bfd ATTRIBUTE_UNUSED; - bfd *exec_bfd ATTRIBUTE_UNUSED; -{ - return TRUE; /* FIXME, We have no way of telling at this point */ -} - /* If somebody calls any byte-swapping routines, shoot them. */ static void swap_abort () Index: trad-core.c =================================================================== RCS file: /cvs/src/src/bfd/trad-core.c,v retrieving revision 1.22 diff -u -p -r1.22 trad-core.c --- trad-core.c 27 Oct 2005 03:35:30 -0000 1.22 +++ trad-core.c 25 Nov 2005 02:40:22 -0000 @@ -65,8 +65,7 @@ struct trad_core_struct const bfd_target *trad_unix_core_file_p PARAMS ((bfd *abfd)); char * trad_unix_core_file_failing_command PARAMS ((bfd *abfd)); int trad_unix_core_file_failing_signal PARAMS ((bfd *abfd)); -bfd_boolean trad_unix_core_file_matches_executable_p - PARAMS ((bfd *core_bfd, bfd *exec_bfd)); +#define trad_unix_core_file_matches_executable_p generic_core_file_matches_executable_p static void swap_abort PARAMS ((void)); /* Handle 4.2-style (and perhaps also sysV-style) core dump file. */ @@ -253,14 +252,6 @@ trad_unix_core_file_failing_signal (igno return -1; /* FIXME, where is it? */ #endif } - -bfd_boolean -trad_unix_core_file_matches_executable_p (core_bfd, exec_bfd) - bfd *core_bfd ATTRIBUTE_UNUSED; - bfd *exec_bfd ATTRIBUTE_UNUSED; -{ - return TRUE; /* FIXME, We have no way of telling at this point */ -} /* If somebody calls any byte-swapping routines, shoot them. */ static void