From 241ca2287a912d85c19332b44ab94166a9b2f8ee Mon Sep 17 00:00:00 2001 From: Peter Wemm Date: Fri, 24 Aug 2001 09:26:17 +0000 Subject: [PATCH] Banish hard-coded KERNBASE references from savecore. Dynamically adjust to whatever kernbase is in the kernel that we are dumping. --- sbin/savecore/savecore.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/sbin/savecore/savecore.c b/sbin/savecore/savecore.c index 2d33858c0f52..5e1a00184ae1 100644 --- a/sbin/savecore/savecore.c +++ b/sbin/savecore/savecore.c @@ -70,7 +70,7 @@ static const char rcsid[] = #endif #ifdef __i386__ -#define ok(number) ((number) - KERNBASE) +#define ok(number) ((number) - kernbase) #endif struct nlist current_nl[] = { /* Namelist for currently running system. */ @@ -86,6 +86,8 @@ struct nlist current_nl[] = { /* Namelist for currently running system. */ { "_panicstr" }, #define X_DUMPMAG 5 { "_dumpmag" }, +#define X_KERNBASE 6 + { "_kernbase" }, { "" }, }; int cursyms[] = { X_DUMPLO, X_VERSION, X_DUMPMAG, -1 }; @@ -98,6 +100,7 @@ struct nlist dump_nl[] = { /* Name list for dumped system. */ { "_version" }, { "_panicstr" }, { "_dumpmag" }, + { "_kernbase" }, { "" }, }; @@ -118,6 +121,10 @@ char panic_mesg[1024]; /* panic message */ int panicstr; /* flag: dump was caused by panic */ char vers[1024]; /* version of kernel that crashed */ +#ifdef __i386__ +u_long kernbase; /* offset of kvm to core file */ +#endif + int clear, compress, force, verbose; /* flags */ int keep; /* keep dump on device */ @@ -251,6 +258,13 @@ kmem_setup() exit(1); } +#ifdef __i386__ + if (dump_nl[X_KERNBASE].n_value != 0) + kernbase = dump_nl[X_KERNBASE].n_value; + else + kernbase = KERNBASE; +#endif + len = sizeof dumpdev; if (sysctlbyname("kern.dumpdev", &dumpdev, &len, NULL, 0) == -1) { syslog(LOG_ERR, "sysctl: kern.dumpdev: %m");