shithub: plan9front

Download patch

ref: 235ef367d793db705b1b4ef20913c697eccd13a6
parent: 6e8b8c8f1a34f5229075fa06eff5f22ab25eb901
author: Ori Bernstein <ori@eigenstate.org>
date: Sat Sep 25 12:57:58 EDT 2021

vmx: update openbsd kernel heuristics

in OpenBSD 6.9 and up, the kernel (bsd, bsd.mp) still has
the ostype symbols, but bsd.rd appears to have lost them,
even when decompressed.

so, as a result, we should use what we have, which isn't
much.

--- a/sys/src/cmd/vmx/ksetup.c	Sat Sep 25 10:51:23 2021
+++ b/sys/src/cmd/vmx/ksetup.c	Sat Sep 25 12:57:58 2021
@@ -728,13 +728,18 @@
 static int
 tryelf(void)
 {
-	char *s;
+	char *s, *t;
 
 	if(!elfheaders()) return 0;
 	elfdata();
 	if(!elfsymbols()) return 0;
 	s = symaddr(elfsym("ostype"));
 	if(s != nil && strcmp(s, "OpenBSD") == 0)
+		return obsdload();
+	/* from 6.9 up, bsd.rd has just these syms */
+	s = symaddr(elfsym("rd_root_image"));
+	t = symaddr(elfsym("rd_root_size"));
+	if(s != nil && t != nil)
 		return obsdload();
 	return 0;
 }