aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--bfd/ChangeLog27
-rw-r--r--bfd/aix386-core.c9
-rw-r--r--bfd/aix5ppc-core.c9
-rw-r--r--bfd/cisco-core.c10
-rw-r--r--bfd/corefile.c56
-rw-r--r--bfd/hppabsd-core.c11
-rw-r--r--bfd/hpux-core.c50
-rw-r--r--bfd/irix-core.c9
-rw-r--r--bfd/libbfd-in.h6
-rw-r--r--bfd/libbfd.h6
-rw-r--r--bfd/lynx-core.c9
-rw-r--r--bfd/mach-o.c8
-rw-r--r--bfd/netbsd-core.c10
-rw-r--r--bfd/osf-core.c11
-rw-r--r--bfd/ptrace-core.c12
-rw-r--r--bfd/sco5-core.c11
-rw-r--r--bfd/trad-core.c11
17 files changed, 125 insertions, 140 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index 075895e..a7efbca 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,3 +1,30 @@
+2005-12-23 Joel Brobecker <brobecker@adacore.com>
+
+ * corefile.c (generic_core_file_matches_executable_p): New function.
+ * libbfd-in.h (generic_core_file_matches_executable_p): Add
+ declaration.
+ * libbfd.h: Regenerate.
+ * hpux-core.c: ANSIfy function declarations and prototypes.
+ (thread_section_p): Manually expand bfd_section_name macro
+ to make it clear that parameter ABFD is not used.
+ (hpux_core_core_file_matches_executable_p): Delete, replaced
+ by macro pointing to generic_core_file_matches_executable_p.
+
+ * aix386-core.c: Replace core_file_matches_executable_p null
+ implementation by generic_core_file_matches_executable_p by
+ using a macro.
+ * aix5ppc-core.c: Likewise.
+ * cisco-core.c: Likewise.
+ * hppabsd-core.c: Likewise.
+ * irix-core.c: Likewise.
+ * lynx-core.c: Likewise.
+ * mach-o.c: Likewise.
+ * netbsd-core.c: Likewise.
+ * osf-core.c: Likewise.
+ * ptrace-core.c: Likewise.
+ * sco5-core.c: Likewise.
+ * trad-core.c: Likewise.
+
2005-12-19 David Heine <dlheine@tensilica.com>
* elf32-xtensa.c (action_list_count, xlate_map_entry, xlate_map,
diff --git a/bfd/aix386-core.c b/bfd/aix386-core.c
index 3f0a27d..17a0290 100644
--- a/bfd/aix386-core.c
+++ b/bfd/aix386-core.c
@@ -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. */
diff --git a/bfd/aix5ppc-core.c b/bfd/aix5ppc-core.c
index 6b588ba..ff58bf3 100644
--- a/bfd/aix5ppc-core.c
+++ b/bfd/aix5ppc-core.c
@@ -319,7 +319,7 @@ xcoff64_core_file_failing_signal (bfd *abfd)
#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_UNUSED)
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)
{
diff --git a/bfd/cisco-core.c b/bfd/cisco-core.c
index 56129e9..b7f735b 100644
--- a/bfd/cisco-core.c
+++ b/bfd/cisco-core.c
@@ -75,7 +75,7 @@ static const bfd_target *cisco_core_file_validate PARAMS ((bfd *, int));
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;
diff --git a/bfd/corefile.c b/bfd/corefile.c
index adc5b4a..aaf888bc 100644
--- a/bfd/corefile.c
+++ b/bfd/corefile.c
@@ -107,3 +107,59 @@ core_file_matches_executable_p (bfd *core_bfd, bfd *exec_bfd)
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;
+}
+
diff --git a/bfd/hppabsd-core.c b/bfd/hppabsd-core.c
index 894d244..67627e7 100644
--- a/bfd/hppabsd-core.c
+++ b/bfd/hppabsd-core.c
@@ -57,8 +57,7 @@ static char *hppabsd_core_core_file_failing_command
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 (abfd)
{
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
diff --git a/bfd/hpux-core.c b/bfd/hpux-core.c
index 9a97531..08adcd3 100644
--- a/bfd/hpux-core.c
+++ b/bfd/hpux-core.c
@@ -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_UNUSED,
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_UNUSED,
(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 */
}
diff --git a/bfd/irix-core.c b/bfd/irix-core.c
index 954d553..e633145 100644
--- a/bfd/irix-core.c
+++ b/bfd/irix-core.c
@@ -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 *abfd)
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)
diff --git a/bfd/libbfd-in.h b/bfd/libbfd-in.h
index e3468c1..c838d90 100644
--- a/bfd/libbfd-in.h
+++ b/bfd/libbfd-in.h
@@ -247,6 +247,12 @@ extern int _bfd_nocore_core_file_failing_signal
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). */
diff --git a/bfd/libbfd.h b/bfd/libbfd.h
index 5a8c216..48a8b9b 100644
--- a/bfd/libbfd.h
+++ b/bfd/libbfd.h
@@ -252,6 +252,12 @@ extern int _bfd_nocore_core_file_failing_signal
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). */
diff --git a/bfd/lynx-core.c b/bfd/lynx-core.c
index 470cb50..ef243fb 100644
--- a/bfd/lynx-core.c
+++ b/bfd/lynx-core.c
@@ -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 */
diff --git a/bfd/mach-o.c b/bfd/mach-o.c
index 6991612..03a7144 100644
--- a/bfd/mach-o.c
+++ b/bfd/mach-o.c
@@ -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 *abfd ATTRIBUTE_UNUSED)
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
diff --git a/bfd/netbsd-core.c b/bfd/netbsd-core.c
index 948423d..e9111a9 100644
--- a/bfd/netbsd-core.c
+++ b/bfd/netbsd-core.c
@@ -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 *abfd)
/*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. */
diff --git a/bfd/osf-core.c b/bfd/osf-core.c
index 35aa82d..cc6c4dc 100644
--- a/bfd/osf-core.c
+++ b/bfd/osf-core.c
@@ -40,8 +40,7 @@ static char *osf_core_core_file_failing_command
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
diff --git a/bfd/ptrace-core.c b/bfd/ptrace-core.c
index 4ddd54c..4ac28aa 100644
--- a/bfd/ptrace-core.c
+++ b/bfd/ptrace-core.c
@@ -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 (abfd)
{
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
diff --git a/bfd/sco5-core.c b/bfd/sco5-core.c
index d10dbfa..9a06b88 100644
--- a/bfd/sco5-core.c
+++ b/bfd/sco5-core.c
@@ -49,8 +49,7 @@ static struct user *read_uarea PARAMS ((bfd *, int));
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_abfd)
: -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 ()
diff --git a/bfd/trad-core.c b/bfd/trad-core.c
index 2f8c9f9..cb4111f 100644
--- a/bfd/trad-core.c
+++ b/bfd/trad-core.c
@@ -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 (ignore_abfd)
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