From 66655be6e27f5937233479805826a804cdcac539 Mon Sep 17 00:00:00 2001 From: "warren.toomey" Date: Thu, 15 May 2008 03:21:46 +0000 Subject: [PATCH] I added the APOUT_UNIX_VERSION variable, so we can recompile/reassemble V2 source code and then run it, without having to muck with the magic.c. --- tools/apout/apout.1 | 15 +++++++++++++-- tools/apout/magic.c | 20 +++++++++++++++++--- 2 files changed, 30 insertions(+), 5 deletions(-) diff --git a/tools/apout/apout.1 b/tools/apout/apout.1 index 902365b..135e972 100644 --- a/tools/apout/apout.1 +++ b/tools/apout/apout.1 @@ -1,7 +1,7 @@ .\" Copyright Warren Toomey .\" -.\" $Revision: 1.9 $ -.\" $Date: 2002/06/10 12:08:27 $ +.\" $Revision: 1.10 $ +.\" $Date: 2008/05/15 03:20:52 $ .\" .Dd December, 2000 .Dt APOUT 1 @@ -104,6 +104,17 @@ Note that you must set .Ev APOUT_ROOT before you can run .Nm apout. +.Pp +There is one other optional environment variable: +.Ev APOUT_UNIX_VERSION. +This is mainly required for UNIX binaries that use the 0407 header, +which was used across several versions of UNIX, each with a different set +of system calls. If APOUT_UNIX_VERSION is set, +.Nm apout +will use the given version when it cannot determine which version of UNIX a +binary belongs to. The available values are "V1", "V2", "V3", "V4", "V5", "V6", +"V7", "2.9BSD" and "2.11BSD". +.Pp .Sh EMULATED ENVIRONMENT VARIABLES Initially, PDP-11 binaries run via .Nm apout diff --git a/tools/apout/magic.c b/tools/apout/magic.c index e326d56..7368240 100644 --- a/tools/apout/magic.c +++ b/tools/apout/magic.c @@ -6,8 +6,8 @@ * a.out header. If it matches any of the checksums below, it returns * the appropriate environment value. Otherwise, it returns IS_UNKNOWN. * - * $Revision: 1.14 $ - * $Date: 2008/05/06 23:31:53 $ + * $Revision: 1.15 $ + * $Date: 2008/05/15 03:20:52 $ */ #include "defines.h" @@ -118,6 +118,7 @@ int special_magic(u_int16_t *cptr) { u_int32_t cksum=0; int i; + char *unix_version; if (cptr==NULL) return(IS_UNKNOWN); /* Calculate the checksum */ @@ -129,7 +130,20 @@ int special_magic(u_int16_t *cptr) return(S[i].environment); } - /* None, return 0 */ + /* See if user tells us what version to use */ + if ((unix_version = getenv("APOUT_UNIX_VERSION"))) { + if (!strcmp(unix_version, "V1")) return(IS_V1); + if (!strcmp(unix_version, "V2")) return(IS_V2); + if (!strcmp(unix_version, "V3")) return(IS_V3); + if (!strcmp(unix_version, "V4")) return(IS_V4); + if (!strcmp(unix_version, "V5")) return(IS_V5); + if (!strcmp(unix_version, "V6")) return(IS_V6); + if (!strcmp(unix_version, "V7")) return(IS_V7); + if (!strcmp(unix_version, "2.9BSD")) return(IS_29BSD); + if (!strcmp(unix_version, "2.11BSD")) return(IS_211BSD); + } + + /* We can't tell what version of Unix, give up */ (void)printf("Apout - unknown magic in header: 0x%x\n",cksum); return(IS_UNKNOWN); }