]> granicus.if.org Git - file/commitdiff
Add FreeBSD-specific core file support (John Baldwin)
authorChristos Zoulas <christos@zoulas.com>
Tue, 11 Sep 2018 00:37:33 +0000 (00:37 +0000)
committerChristos Zoulas <christos@zoulas.com>
Tue, 11 Sep 2018 00:37:33 +0000 (00:37 +0000)
src/readelf.c

index c17297ec21c30def57b196aa243f05e6bab3f986..89a71a617a12f4d47f12485b65dc7d68c95cc86b 100644 (file)
@@ -27,7 +27,7 @@
 #include "file.h"
 
 #ifndef lint
-FILE_RCSID("@(#)$File: readelf.c,v 1.152 2018/09/09 20:33:28 christos Exp $")
+FILE_RCSID("@(#)$File: readelf.c,v 1.153 2018/09/11 00:37:33 christos Exp $")
 #endif
 
 #ifdef BUILTIN_ELF
@@ -772,6 +772,28 @@ do_core_note(struct magic_set *ms, unsigned char *nbuf, uint32_t type,
                }
                break;
 
+       case OS_STYLE_FREEBSD:
+               if (type == NT_PRPSINFO && *flags & FLAGS_IS_CORE) {
+                       size_t argoff, pidoff;
+
+                       if (clazz == ELFCLASS32)
+                               argoff = 4 + 4 + 17;
+                       else
+                               argoff = 4 + 4 + 8 + 17;
+                       if (file_printf(ms, ", from '%.80s'", nbuf + doff +
+                           argoff) == -1)
+                               return 1;
+                       pidoff = argoff + 81 + 2;
+                       if (doff + pidoff + 4 <= size) {
+                               if (file_printf(ms, ", pid=%u",
+                                   elf_getu32(swap, *(uint32_t *)(nbuf +
+                                   doff + pidoff))) == -1)
+                                       return 1;
+                       }
+                       *flags |= FLAGS_DID_CORE;
+               }                           
+               break;
+
        default:
                if (type == NT_PRPSINFO && *flags & FLAGS_IS_CORE) {
                        size_t i, j;