summaryrefslogtreecommitdiffstats
path: root/usr.bin/file
diff options
context:
space:
mode:
authorjdp <jdp@FreeBSD.org>1998-10-03 04:38:58 +0000
committerjdp <jdp@FreeBSD.org>1998-10-03 04:38:58 +0000
commit590984c836f7b6807157d7a3ecc4061ee4a57088 (patch)
tree93b8f3ff2eb24c6df84e30f622ab519cfdcebc8a /usr.bin/file
parent263a0986b4ea534536832280e073f8e031948f5f (diff)
downloadFreeBSD-src-590984c836f7b6807157d7a3ecc4061ee4a57088.zip
FreeBSD-src-590984c836f7b6807157d7a3ecc4061ee4a57088.tar.gz
Fix "file" so that it prints the program names from core files
correctly.
Diffstat (limited to 'usr.bin/file')
-rw-r--r--usr.bin/file/readelf.c28
1 files changed, 16 insertions, 12 deletions
diff --git a/usr.bin/file/readelf.c b/usr.bin/file/readelf.c
index 350e602..fb87af7 100644
--- a/usr.bin/file/readelf.c
+++ b/usr.bin/file/readelf.c
@@ -1,7 +1,7 @@
#ifndef lint
static const char rcsid[] =
- "$Id: readelf.c,v 1.3 1998/01/28 07:36:25 charnier Exp $";
+ "$Id: readelf.c,v 1.4 1998/02/20 04:54:00 jb Exp $";
#endif /* not lint */
#ifdef BUILTIN_ELF
@@ -85,6 +85,7 @@ dophn_exec(fd, off, num, size, buf)
}
size_t prpsoffsets[] = {
+ 8, /* FreeBSD */
100, /* SunOS 5.x */
32, /* Linux */
};
@@ -93,14 +94,15 @@ size_t prpsoffsets[] = {
/*
* Look through the program headers of an executable image, searching
- * for a PT_NOTE section of type NT_PRPSINFO, with a name "CORE"; if one
- * is found, try looking in various places in its contents for a 16-character
- * string containing only printable characters - if found, that string
- * should be the name of the program that dropped core.
- * Note: right after that 16-character string is, at least in SunOS 5.x
- * (and possibly other SVR4-flavored systems) and Linux, a longer string
- * (80 characters, in 5.x, probably other SVR4-flavored systems, and Linux)
- * containing the start of the command line for that program.
+ * for a PT_NOTE section of type NT_PRPSINFO, with a name "CORE" or
+ * "FreeBSD"; if one is found, try looking in various places in its
+ * contents for a 16-character string containing only printable
+ * characters - if found, that string should be the name of the program
+ * that dropped core. Note: right after that 16-character string is,
+ * at least in SunOS 5.x (and possibly other SVR4-flavored systems) and
+ * Linux, a longer string (80 characters, in 5.x, probably other
+ * SVR4-flavored systems, and Linux) containing the start of the
+ * command line for that program.
*/
static void
dophn_core(fd, off, num, size, buf)
@@ -159,7 +161,8 @@ dophn_core(fd, off, num, size, buf)
}
/*
- * Make sure this note has the name "CORE".
+ * Make sure this note has the name "CORE" or
+ * "FreeBSD".
*/
if (offset + nh->n_namesz >= bufsize) {
/*
@@ -167,8 +170,9 @@ dophn_core(fd, off, num, size, buf)
*/
break;
}
- if (nh->n_namesz != 5
- || strcmp(&nbuf[offset], "CORE") != 0)
+ if (nbuf[offset + nh->n_namesz - 1] != '\0' ||
+ (strcmp(&nbuf[offset], "CORE") != 0 &&
+ strcmp(&nbuf[offset], "FreeBSD") != 0))
continue;
offset += nh->n_namesz;
offset = ((offset + 3)/4)*4;
OpenPOWER on IntegriCloud