Module Name:    src
Committed By:   rin
Date:           Mon Nov  6 06:53:52 UTC 2023

Modified Files:
        src/sys/arch/i386/stand/dosboot: Makefile

Log Message:
x86/dosboot: Allow NULL dereference to fetch command line arguments

DOS command line arguments are provided as struct psp at 0x0000;
see doscommain.c.

Recent versions of gcc and clang are clever enough to optimize code
block involving NULL dereference into ud2 insn.

Sprinkle -fno-delete-null-pointer-checks to doscommain.c to
prevent this behavior.

Note that dosboot.com for netbsd-9 and later was broken due to
this ``over optimization''. gcc 5.5.0 and clang 4.0.0 in netbsd-8
generate correct codes without this workaround.

XXX
Are there still use cases for dosboot.com? Does anyone want to
boot NetBSD from real-mode DOS in 2023?


To generate a diff of this commit:
cvs rdiff -u -r1.33 -r1.34 src/sys/arch/i386/stand/dosboot/Makefile

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/i386/stand/dosboot/Makefile
diff -u src/sys/arch/i386/stand/dosboot/Makefile:1.33 src/sys/arch/i386/stand/dosboot/Makefile:1.34
--- src/sys/arch/i386/stand/dosboot/Makefile:1.33	Mon Sep 23 13:42:36 2019
+++ src/sys/arch/i386/stand/dosboot/Makefile	Mon Nov  6 06:53:52 2023
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.33 2019/09/23 13:42:36 christos Exp $
+#	$NetBSD: Makefile,v 1.34 2023/11/06 06:53:52 rin Exp $
 
 S=	${.CURDIR}/../../../..
 
@@ -31,6 +31,9 @@ SAMISCCPPFLAGS+= -DHEAP_START=0x20000 -D
 SAMISCMAKEFLAGS= SA_USE_CREAD=yes SA_INCLUDE_NET=no SA_ENABLE_LS_OP=yes
 I386MISCMAKEFLAGS= I386_INCLUDE_DOS=yes
 
+# DOS command line arguments are located at 0x0000.
+COPTS.doscommain.c+= -fno-delete-null-pointer-checks
+
 VERSIONFILE= ${.CURDIR}/version
 
 .include <bsd.init.mk>

Reply via email to