From 23a7c9e84612a911883734b1b0a93092d114839f Mon Sep 17 00:00:00 2001
From: Sascha Wildner <saw@online.de>
Date: Thu, 9 Jul 2020 23:36:24 +0200
Subject: [PATCH 2/2] WIP -fno-common buildworld

---
 initrd/rescue/Makefile           |  3 ---
 lib/libc/x86_64/gen/qcontext.S   | 45 +++++++++++++++++++++++++++++++-
 lib/libc/x86_64/sys/getcontext.S | 45 +++++++++++++++++++++++++++++++-
 libexec/Makefile                 |  1 -
 sbin/Makefile                    |  5 ----
 usr.bin/Makefile                 |  4 ---
 6 files changed, 88 insertions(+), 15 deletions(-)

diff --git a/initrd/rescue/Makefile b/initrd/rescue/Makefile
index 08cb753eb8..030071c3bd 100644
--- a/initrd/rescue/Makefile
+++ b/initrd/rescue/Makefile
@@ -124,12 +124,10 @@ CRUNCH_PROGS_sbin=	\
 	disklabel32	\
 	disklabel64	\
 	dmesg		\
-	dump		\
 	dumpfs		\
 	dumpon		\
 	fdisk		\
 	ffsinfo		\
-	fsck		\
 	fsck_msdosfs	\
 	gpt		\
 	growfs		\
@@ -159,7 +157,6 @@ CRUNCH_PROGS_sbin=	\
 	rconfig		\
 	rcorder		\
 	reboot		\
-	restore		\
 	route		\
 	savecore	\
 	shutdown	\
diff --git a/lib/libc/x86_64/gen/qcontext.S b/lib/libc/x86_64/gen/qcontext.S
index 7a76b34424..f985d2ca58 100644
--- a/lib/libc/x86_64/gen/qcontext.S
+++ b/lib/libc/x86_64/gen/qcontext.S
@@ -32,7 +32,50 @@
  */
 #include <machine/asm.h>
 #include <cpu/specialreg.h>
-#include <asmcontext.h>
+
+#define	KUCSEL	0x2b
+#define	KUDSEL	0x23
+#define	MC_ADDR	0x90
+#define	MC_CS	0xb0
+#define	MC_ERR	0xa0
+#define	MC_FLAGS	0x98
+#define	MC_FPFORMAT	0xd4
+#define	MC_FPREGS	0x100
+#define	MC_LEN	0xd0
+#define	MC_ONSTACK	0x0
+#define	MC_OWNEDFP	0xd8
+#define	MC_R10	0x50
+#define	MC_R11	0x58
+#define	MC_R12	0x60
+#define	MC_R13	0x68
+#define	MC_R14	0x70
+#define	MC_R15	0x78
+#define	MC_R8	0x28
+#define	MC_R9	0x30
+#define	MC_RAX	0x38
+#define	MC_RBP	0x48
+#define	MC_RBX	0x40
+#define	MC_RCX	0x20
+#define	MC_RDI	0x8
+#define	MC_RDX	0x18
+#define	MC_RFLAGS	0xb8
+#define	MC_RIP	0xa8
+#define	MC_RSI	0x10
+#define	MC_RSP	0xc0
+#define	MC_SS	0xc8
+#define	MC_TRAPNO	0x88
+#define	SIG_BLOCK	0x1
+#define	SIG_SETMASK	0x3
+#define	SIZEOF_MCONTEXT_T	0x500
+#define	SIZEOF_UCONTEXT_T	0x580
+#define	UC_LINK	0x540
+#define	UC_MCONTEXT	0x40
+#define	UC_SIGMASK	0x0
+#define	_MC_FPFMT_387	0x10001
+#define	_MC_FPFMT_NODEV	0x10000
+#define	_MC_FPFMT_XMM	0x10002
+#define	_MC_FPFMT_YMM	0x10003
+#define	_MC_FPOWNED_NONE	0x20000
 
 	/*
 	 * void setcontext_quick(ucontext_t *ucp)
diff --git a/lib/libc/x86_64/sys/getcontext.S b/lib/libc/x86_64/sys/getcontext.S
index daa0ccd48c..532184af83 100644
--- a/lib/libc/x86_64/sys/getcontext.S
+++ b/lib/libc/x86_64/sys/getcontext.S
@@ -35,7 +35,50 @@
 
 #include <machine/asm.h>
 #include <cpu/specialreg.h>
-#include <asmcontext.h>
+
+#define	KUCSEL	0x2b
+#define	KUDSEL	0x23
+#define	MC_ADDR	0x90
+#define	MC_CS	0xb0
+#define	MC_ERR	0xa0
+#define	MC_FLAGS	0x98
+#define	MC_FPFORMAT	0xd4
+#define	MC_FPREGS	0x100
+#define	MC_LEN	0xd0
+#define	MC_ONSTACK	0x0
+#define	MC_OWNEDFP	0xd8
+#define	MC_R10	0x50
+#define	MC_R11	0x58
+#define	MC_R12	0x60
+#define	MC_R13	0x68
+#define	MC_R14	0x70
+#define	MC_R15	0x78
+#define	MC_R8	0x28
+#define	MC_R9	0x30
+#define	MC_RAX	0x38
+#define	MC_RBP	0x48
+#define	MC_RBX	0x40
+#define	MC_RCX	0x20
+#define	MC_RDI	0x8
+#define	MC_RDX	0x18
+#define	MC_RFLAGS	0xb8
+#define	MC_RIP	0xa8
+#define	MC_RSI	0x10
+#define	MC_RSP	0xc0
+#define	MC_SS	0xc8
+#define	MC_TRAPNO	0x88
+#define	SIG_BLOCK	0x1
+#define	SIG_SETMASK	0x3
+#define	SIZEOF_MCONTEXT_T	0x500
+#define	SIZEOF_UCONTEXT_T	0x580
+#define	UC_LINK	0x540
+#define	UC_MCONTEXT	0x40
+#define	UC_SIGMASK	0x0
+#define	_MC_FPFMT_387	0x10001
+#define	_MC_FPFMT_NODEV	0x10000
+#define	_MC_FPFMT_XMM	0x10002
+#define	_MC_FPFMT_YMM	0x10003
+#define	_MC_FPOWNED_NONE	0x20000
 
 	/*
 	 * This function is special-cased because the context it saves
diff --git a/libexec/Makefile b/libexec/Makefile
index 93603fe1ce..6d032432b5 100644
--- a/libexec/Makefile
+++ b/libexec/Makefile
@@ -26,7 +26,6 @@ SUBDIR=	atrun \
 	ssh-pkcs11-helper \
 	talkd \
 	tcpd \
-	telnetd \
 	tftpd \
 	utmp_update \
 	ypxfr
diff --git a/sbin/Makefile b/sbin/Makefile
index 7c277bb4f4..e3f72203a3 100644
--- a/sbin/Makefile
+++ b/sbin/Makefile
@@ -17,14 +17,11 @@ SUBDIR=	adjkerntz \
 	disklabel32 \
 	disklabel64 \
 	dmesg \
-	dump \
 	dumpfs \
 	dumpon \
 	ffsinfo \
-	fsck \
 	fsck_msdosfs \
 	fsck_hammer2 \
-	fsdb \
 	fsid \
 	fsirand \
 	getdevpath \
@@ -79,13 +76,11 @@ SUBDIR=	adjkerntz \
 	nvmectl \
 	ping \
 	ping6 \
-	quotacheck \
 	rconfig \
 	rcorder \
 	rcrun \
 	reboot \
 	resolvconf \
-	restore \
 	route \
 	routed \
 	rtsol \
diff --git a/usr.bin/Makefile b/usr.bin/Makefile
index 43660f29ca..6b70a72451 100644
--- a/usr.bin/Makefile
+++ b/usr.bin/Makefile
@@ -115,7 +115,6 @@ SUBDIR=	alias \
 	lt \
 	lzmainfo \
 	m4 \
-	mail \
 	man \
 	mandoc \
 	mesg \
@@ -195,11 +194,8 @@ SUBDIR=	alias \
 	tar \
 	tcopy \
 	tee \
-	telnet \
-	tftp \
 	time \
 	tic \
-	tip \
 	top \
 	touch \
 	tput \
-- 
2.26.2

