Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.bin/file Add support for recognising FreeBSD and OpenBSD...



details:   https://anonhg.NetBSD.org/src/rev/d7af10f191af
branches:  trunk
changeset: 525286:d7af10f191af
user:      bjh21 <bjh21%NetBSD.org@localhost>
date:      Tue Apr 09 15:10:17 2002 +0000

description:
Add support for recognising FreeBSD and OpenBSD executables.

diffstat:

 usr.bin/file/readelf.c |  36 ++++++++++++++++++++++++++++++++++--
 usr.bin/file/readelf.h |   4 +++-
 2 files changed, 37 insertions(+), 3 deletions(-)

diffs (75 lines):

diff -r 2e0d86539c1d -r d7af10f191af usr.bin/file/readelf.c
--- a/usr.bin/file/readelf.c    Tue Apr 09 14:54:40 2002 +0000
+++ b/usr.bin/file/readelf.c    Tue Apr 09 15:10:17 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: readelf.c,v 1.11 2002/03/30 16:21:28 bjh21 Exp $       */
+/*     $NetBSD: readelf.c,v 1.12 2002/04/09 15:10:17 bjh21 Exp $       */
 
 #include "file.h"
 
@@ -20,7 +20,7 @@
 #if 0
 FILE_RCSID("@(#)Id: readelf.c,v 1.17 2000/08/05 19:00:12 christos Exp ")
 #else
-__RCSID("$NetBSD: readelf.c,v 1.11 2002/03/30 16:21:28 bjh21 Exp $");
+__RCSID("$NetBSD: readelf.c,v 1.12 2002/04/09 15:10:17 bjh21 Exp $");
 #endif
 #endif
 
@@ -272,6 +272,38 @@
                                         * and hence is basically content-free.
                                         */
                                }
+
+                               if (nh_namesz == 8 &&
+                                   strcmp(&nbuf[nameoffset], "FreeBSD") == 0 &&
+                                   nh_type == NT_FREEBSD_VERSION &&
+                                   nh_descsz == 4) {
+                                       uint32_t desc = getu32(swap,
+                                           *(uint32_t *)&nbuf[offset]);
+                                       printf(", for FreeBSD");
+                                       /*
+                                        * Contents is __FreeBSD_version,
+                                        * whose relation to OS versions is
+                                        * defined by a huge table in the
+                                        * Porters' Handbook.  Happily, the
+                                        * first three digits are the version
+                                        * number, at least in versions of
+                                        * FreeBSD that use this note.
+                                        */
+
+                                       printf(" %d.%d", desc / 100000,
+                                           desc / 10000 % 10);
+                                       if (desc / 1000 % 10 > 0)
+                                               printf(".%d",
+                                                   desc / 1000 % 10);
+                               }
+
+                               if (nh_namesz == 8 &&
+                                   strcmp(&nbuf[nameoffset], "OpenBSD") == 0 &&
+                                   nh_type == NT_OPENBSD_VERSION &&
+                                   nh_descsz == 4) {
+                                       printf(", for OpenBSD");
+                                       /* Content of note is always 0 */
+                               }
                        }
                        break;
                }
diff -r 2e0d86539c1d -r d7af10f191af usr.bin/file/readelf.h
--- a/usr.bin/file/readelf.h    Tue Apr 09 14:54:40 2002 +0000
+++ b/usr.bin/file/readelf.h    Tue Apr 09 15:10:17 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: readelf.h,v 1.7 2002/03/30 17:54:51 bjh21 Exp $        */
+/*     $NetBSD: readelf.h,v 1.8 2002/04/09 15:10:18 bjh21 Exp $        */
 
 /*
  * readelf.h 
@@ -194,6 +194,8 @@
 /* NetBSD executables (name = "NetBSD") */
 #define NT_NETBSD_VERSION      1
 #define NT_NETBSD_EMULATION    2
+#define NT_FREEBSD_VERSION     1
+#define NT_OPENBSD_VERSION     1
 /* GNU executables (name = "GNU") */
 #define NT_GNU_VERSION         1
 



Home | Main Index | Thread Index | Old Index