aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ObsoleteFiles.inc5
-rw-r--r--stand/i386/Makefile4
-rw-r--r--stand/i386/kgzldr/Makefile20
-rw-r--r--stand/i386/kgzldr/Makefile.depend12
-rw-r--r--stand/i386/kgzldr/boot.c129
-rw-r--r--stand/i386/kgzldr/crt.S83
-rw-r--r--stand/i386/kgzldr/kgzldr.h41
-rw-r--r--stand/i386/kgzldr/lib.c88
-rw-r--r--stand/i386/kgzldr/sio.S44
-rw-r--r--stand/i386/kgzldr/start.S45
-rw-r--r--targets/pseudo/userland/Makefile.depend1
-rw-r--r--targets/pseudo/userland/misc/Makefile.depend2
-rw-r--r--usr.sbin/Makefile.amd641
-rw-r--r--usr.sbin/Makefile.i3861
-rw-r--r--usr.sbin/kgzip/Makefile9
-rw-r--r--usr.sbin/kgzip/Makefile.depend15
-rw-r--r--usr.sbin/kgzip/aouthdr.c81
-rw-r--r--usr.sbin/kgzip/aouthdr.h61
-rw-r--r--usr.sbin/kgzip/elfhdr.c166
-rw-r--r--usr.sbin/kgzip/elfhdr.h86
-rw-r--r--usr.sbin/kgzip/kgz.h59
-rw-r--r--usr.sbin/kgzip/kgzcmp.c239
-rw-r--r--usr.sbin/kgzip/kgzip.8156
-rw-r--r--usr.sbin/kgzip/kgzip.c178
-rw-r--r--usr.sbin/kgzip/kgzip.h53
-rw-r--r--usr.sbin/kgzip/kgzld.c103
-rw-r--r--usr.sbin/kgzip/xio.c123
27 files changed, 6 insertions, 1799 deletions
diff --git a/ObsoleteFiles.inc b/ObsoleteFiles.inc
index 632139c911c4..4a54cd193f27 100644
--- a/ObsoleteFiles.inc
+++ b/ObsoleteFiles.inc
@@ -38,6 +38,11 @@
# xargs -n1 | sort | uniq -d;
# done
+# 20190523: Remove obsolete kgzip and support files
+OLD_FILES+=usr/sbin/kgzip
+OLD_FILES+=usr/lib/kgzldr.o
+OLD_FILES+=usr/share/man/man8/kgzip.8.gz
+
# 20190517: Remove obsolete 10 and 10/100 ethernet drivers.
OLD_FILES+=usr/share/man/man4/bm.4.gz
OLD_FILES+=usr/share/man/man4/cs.4.gz
diff --git a/stand/i386/Makefile b/stand/i386/Makefile
index 2a9ead4c8e72..a9d402acf609 100644
--- a/stand/i386/Makefile
+++ b/stand/i386/Makefile
@@ -16,10 +16,6 @@ SUBDIR.yes+= loader_simp
# special boot programs, 'self-extracting boot2+loader'
SUBDIR.yes+= pxeldr
-.if ${MACHINE_CPUARCH} == "i386"
-SUBDIR.yes+= kgzldr
-.endif
-
SUBDIR.${MK_LOADER_ZFS}+= zfsboot gptzfsboot
.include <bsd.subdir.mk>
diff --git a/stand/i386/kgzldr/Makefile b/stand/i386/kgzldr/Makefile
deleted file mode 100644
index 96ba94ee535f..000000000000
--- a/stand/i386/kgzldr/Makefile
+++ /dev/null
@@ -1,20 +0,0 @@
-# $FreeBSD$
-
-.include <bsd.init.mk>
-
-PROG= kgzldr.o
-STRIP=
-BINMODE=${LIBMODE}
-BINDIR= ${LIBDIR}
-
-SRCS= start.S boot.c subr_inflate.c lib.c crt.S sio.S
-CFLAGS= -Os
-CFLAGS+=-DKZIP
-NO_SHARED=
-LDFLAGS+=-Wl,-r
-.PATH: ${SYSDIR}/kern
-
-BOOT_COMCONSOLE_PORT?= 0x3f8
-ACFLAGS+=-Wa,-defsym,SIO_PRT=${BOOT_COMCONSOLE_PORT}
-
-.include <bsd.prog.mk>
diff --git a/stand/i386/kgzldr/Makefile.depend b/stand/i386/kgzldr/Makefile.depend
deleted file mode 100644
index 79506ce16b79..000000000000
--- a/stand/i386/kgzldr/Makefile.depend
+++ /dev/null
@@ -1,12 +0,0 @@
-# $FreeBSD$
-# Autogenerated - do NOT edit!
-
-DIRDEPS = \
- include \
-
-
-.include <dirdeps.mk>
-
-.if ${DEP_RELDIR} == ${_DEP_RELDIR}
-# local dependencies - needed for -jN in clean tree
-.endif
diff --git a/stand/i386/kgzldr/boot.c b/stand/i386/kgzldr/boot.c
deleted file mode 100644
index 45ed2ee62e16..000000000000
--- a/stand/i386/kgzldr/boot.c
+++ /dev/null
@@ -1,129 +0,0 @@
-/*-
- * Copyright (c) 1999 Global Technology Associates, Inc.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
- * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
-#include <sys/types.h>
-#include <sys/reboot.h>
-#include <sys/inflate.h>
-
-#include "kgzldr.h"
-
-#define KGZ_HEAD 0xa /* leading bytes to ignore */
-#define KGZ_TAIL 0x8 /* trailing bytes to ignore */
-
-#define E_FMT 1 /* Error: Invalid format */
-#define E_MEM 2 /* Error: Out of memory */
-
-struct kgz_hdr {
- char ident[4]; /* identification */
- uint32_t dload; /* decoded image load address */
- uint32_t dsize; /* decoded image size */
- uint32_t isize; /* image size in memory */
- uint32_t entry; /* program entry point */
- uint32_t nsize; /* encoded image size */
-};
-extern struct kgz_hdr kgz; /* header */
-extern uint8_t kgz_ndata[]; /* encoded image */
-
-static const char *const msg[] = {
- "done",
- "invalid format",
- "out of memory"
-};
-
-static const u_char *ip; /* input pointer */
-static u_char *op; /* output pointer */
-
-static struct inflate infl; /* inflate() parameters */
-
-static int decode(void);
-static int input(void *);
-static int output(void *, u_char *, u_long);
-
-/*
- * Uncompress and boot a kernel.
- */
-int
-boot(int howto)
-{
- int err;
-
- kgz_con = howto & RB_SERIAL ? KGZ_SIO : KGZ_CRT;
- putstr("Uncompressing ... ");
- err = decode();
- putstr(msg[err]);
- putstr("\n");
- if (err) {
- putstr("System halted");
- for (;;)
- ;
- }
- return err;
-}
-
-/*
- * Interface with inflate() to uncompress the data.
- */
-static int
-decode(void)
-{
- static u_char slide[GZ_WSIZE];
- int err;
-
- ip = kgz_ndata + KGZ_HEAD;
- op = (u_char *)kgz.dload;
- infl.gz_input = input;
- infl.gz_output = output;
- infl.gz_slide = slide;
- err = inflate(&infl);
- return err ? err == 3 ? E_MEM : E_FMT : 0;
-}
-
-/*
- * Read a byte.
- */
-static int
-input(void *dummy)
-{
- if ((size_t)(ip - kgz_ndata) + KGZ_TAIL > kgz.nsize)
- return GZ_EOF;
- return *ip++;
-}
-
-/*
- * Write some bytes.
- */
-static int
-output(void *dummy, u_char * ptr, u_long len)
-{
- if (op - (u_char *)kgz.dload + len > kgz.dsize)
- return -1;
- while (len--)
- *op++ = *ptr++;
- return 0;
-}
diff --git a/stand/i386/kgzldr/crt.S b/stand/i386/kgzldr/crt.S
deleted file mode 100644
index cfb479fd2d84..000000000000
--- a/stand/i386/kgzldr/crt.S
+++ /dev/null
@@ -1,83 +0,0 @@
-#
-# Copyright (c) 1999 Global Technology Associates, Inc.
-# All rights reserved.
-#
-# Redistribution and use in source and binary forms, with or without
-# modification, are permitted provided that the following conditions
-# are met:
-# 1. Redistributions of source code must retain the above copyright
-# notice, this list of conditions and the following disclaimer.
-# 2. Redistributions in binary form must reproduce the above copyright
-# notice, this list of conditions and the following disclaimer in the
-# documentation and/or other materials provided with the distribution.
-#
-# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS``AS IS'' AND
-# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS
-# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
-# OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
-# OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
-# BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
-# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
-# OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
-# EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-#
-# From: btx.s 1.10 1999/02/25 16:27:41 rnordier
-# $FreeBSD$
-#
-
-# Screen defaults and assumptions.
-
- .set SCR_MAT,0x7 # Mode/attribute
- .set SCR_COL,0x50 # Columns per row
- .set SCR_ROW,0x19 # Rows per screen
-
-# BIOS Data Area locations.
-
- .set BDA_SCR,0x449 # Video mode
- .set BDA_POS,0x450 # Cursor position
-
- .globl crt_putchr
-
-# void crt_putchr(int c)
-
-crt_putchr: movb 0x4(%esp,1),%al # Get character
- pusha # Save
- xorl %ecx,%ecx # Zero for loops
- movb $SCR_MAT,%ah # Mode/attribute
- movl $BDA_POS,%ebx # BDA pointer
- movw (%ebx),%dx # Cursor position
- movl $0xb8000,%edi # Regen buffer (color)
- cmpb %ah,BDA_SCR-BDA_POS(%ebx) # Mono mode?
- jne crt_putchr.1 # No
- xorw %di,%di # Regen buffer (mono)
-crt_putchr.1: cmpb $0xa,%al # New line?
- je crt_putchr.2 # Yes
- xchgl %eax,%ecx # Save char
- movb $SCR_COL,%al # Columns per row
- mulb %dh # * row position
- addb %dl,%al # + column
- adcb $0x0,%ah # position
- shll %eax # * 2
- xchgl %eax,%ecx # Swap char, offset
- movw %ax,(%edi,%ecx,1) # Write attr:char
- incl %edx # Bump cursor
- cmpb $SCR_COL,%dl # Beyond row?
- jb crt_putchr.3 # No
-crt_putchr.2: xorb %dl,%dl # Zero column
- incb %dh # Bump row
-crt_putchr.3: cmpb $SCR_ROW,%dh # Beyond screen?
- jb crt_putchr.4 # No
- leal 2*SCR_COL(%edi),%esi # New top line
- movw $(SCR_ROW-1)*SCR_COL/2,%cx # Words to move
- rep # Scroll
- movsl # screen
- movb $' ',%al # Space
- movb $SCR_COL,%cl # Columns to clear
- rep # Clear
- stosw # line
- movb $SCR_ROW-1,%dh # Bottom line
-crt_putchr.4: movw %dx,(%ebx) # Update position
- popa # Restore
- ret # To caller
diff --git a/stand/i386/kgzldr/kgzldr.h b/stand/i386/kgzldr/kgzldr.h
deleted file mode 100644
index 5cd5b44b6005..000000000000
--- a/stand/i386/kgzldr/kgzldr.h
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Copyright (c) 1999 Global Technology Associates, Inc.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
- * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * $FreeBSD$
- */
-
-#define KGZ_CRT 0x1 /* Video console */
-#define KGZ_SIO 0x2 /* Serial console */
-
-extern int kgz_con;
-
-int boot(int);
-
-unsigned char *kzipmalloc(int);
-void kzipfree(void *);
-void putstr(const char *);
-
-void crt_putchr(int);
-void sio_putchr(int);
diff --git a/stand/i386/kgzldr/lib.c b/stand/i386/kgzldr/lib.c
deleted file mode 100644
index 538875b510e5..000000000000
--- a/stand/i386/kgzldr/lib.c
+++ /dev/null
@@ -1,88 +0,0 @@
-/*-
- * Copyright (c) 1999 Global Technology Associates, Inc.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
- * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
-#include <sys/types.h>
-#include <stddef.h>
-
-#include "kgzldr.h"
-
-#define MEMSIZ 0x8000 /* Memory pool size */
-
-int kgz_con; /* Console control */
-
-static size_t memtot; /* Memory allocated: bytes */
-static u_int memcnt; /* Memory allocated: blocks */
-
-/*
- * Library functions required by inflate().
- */
-
-/*
- * Allocate memory block.
- */
-unsigned char *
-kzipmalloc(int size)
-{
- static u_char mem[MEMSIZ];
- void *ptr;
-
- if (memtot + size > MEMSIZ)
- return NULL;
- ptr = mem + memtot;
- memtot += size;
- memcnt++;
- return ptr;
-}
-
-/*
- * Free allocated memory block.
- */
-void
-kzipfree(void *ptr)
-{
- memcnt--;
- if (!memcnt)
- memtot = 0;
-}
-
-/*
- * Write a string to the console.
- */
-void
-putstr(const char *str)
-{
- int c;
-
- while ((c = *str++)) {
- if (kgz_con & KGZ_CRT)
- crt_putchr(c);
- if (kgz_con & KGZ_SIO)
- sio_putchr(c);
- }
-}
diff --git a/stand/i386/kgzldr/sio.S b/stand/i386/kgzldr/sio.S
deleted file mode 100644
index ff174eb0b71b..000000000000
--- a/stand/i386/kgzldr/sio.S
+++ /dev/null
@@ -1,44 +0,0 @@
-#
-# Copyright (c) 1999 Global Technology Associates, Inc.
-# All rights reserved.
-#
-# Redistribution and use in source and binary forms, with or without
-# modification, are permitted provided that the following conditions
-# are met:
-# 1. Redistributions of source code must retain the above copyright
-# notice, this list of conditions and the following disclaimer.
-# 2. Redistributions in binary form must reproduce the above copyright
-# notice, this list of conditions and the following disclaimer in the
-# documentation and/or other materials provided with the distribution.
-#
-# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS``AS IS'' AND
-# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS
-# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
-# OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
-# OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
-# BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
-# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
-# OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
-# EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-#
-# From: sio.s 1.3 1999/01/10 14:48:03 rnordier
-# $FreeBSD$
-#
-
- .globl sio_putchr
-
-# void sio_putchr(int c)
-
-sio_putchr: movw $SIO_PRT+0x5,%dx # Line status reg
- xor %ecx,%ecx # Timeout
- movb $0x40,%ch # counter
-sio_putchr.1: inb %dx,%al # Transmitter
- testb $0x20,%al # buffer empty?
- loopz sio_putchr.1 # No
- jz sio_putchr.2 # If timeout
- movb 0x4(%esp,1),%al # Get character
- subb $0x5,%dl # Transmitter hold reg
- outb %al,%dx # Write character
-sio_putchr.2: ret # To caller
diff --git a/stand/i386/kgzldr/start.S b/stand/i386/kgzldr/start.S
deleted file mode 100644
index 550fa526d946..000000000000
--- a/stand/i386/kgzldr/start.S
+++ /dev/null
@@ -1,45 +0,0 @@
-#
-# Copyright (c) 1999 Global Technology Associates, Inc.
-# All rights reserved.
-#
-# Redistribution and use in source and binary forms, with or without
-# modification, are permitted provided that the following conditions
-# are met:
-# 1. Redistributions of source code must retain the above copyright
-# notice, this list of conditions and the following disclaimer.
-# 2. Redistributions in binary form must reproduce the above copyright
-# notice, this list of conditions and the following disclaimer in the
-# documentation and/or other materials provided with the distribution.
-#
-# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS``AS IS'' AND
-# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS
-# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
-# OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
-# OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
-# BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
-# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
-# OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
-# EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-#
-# $FreeBSD$
-#
-
- .set entry,0x10 # kgz.entry
-
- .globl _start
-
-# C startup code for kgzldr.
-
-_start: cld # String ops inc
- movl $_edata,%edi # Start of bss
- movl $_end,%ecx # Compute
- subl %edi,%ecx # size
- xorl %eax,%eax # Zero
- rep # Clear
- stosb # bss
- pushl 0x4(%esp) # Pass howto flags
- call boot # Call C code
- popl %ecx # Clear stack
- jmp *kgz+entry # To loaded code
diff --git a/targets/pseudo/userland/Makefile.depend b/targets/pseudo/userland/Makefile.depend
index 28493b3c9cd6..934d7be54ed7 100644
--- a/targets/pseudo/userland/Makefile.depend
+++ b/targets/pseudo/userland/Makefile.depend
@@ -827,7 +827,6 @@ DIRDEPS.i386= \
usr.sbin/hyperv/tools/kvp \
usr.sbin/hyperv/tools/vss \
usr.sbin/kgmon \
- usr.sbin/kgzip \
usr.sbin/lptcontrol \
usr.sbin/mptable \
usr.sbin/ndiscvt \
diff --git a/targets/pseudo/userland/misc/Makefile.depend b/targets/pseudo/userland/misc/Makefile.depend
index 7b4700a5d201..a4723e8dff1b 100644
--- a/targets/pseudo/userland/misc/Makefile.depend
+++ b/targets/pseudo/userland/misc/Makefile.depend
@@ -83,7 +83,7 @@ DIRDEPS+= \
DIRDEPS.arm= ${_sys_boot_fdt} ${_sys_boot_efi}
DIRDEPS.arm64= ${_sys_boot_fdt} ${_sys_boot_efi}
-DIRDEPS.i386= ${DIRDEPS.x86sys} ${_sys_boot_efi} stand/i386/kgzldr
+DIRDEPS.i386= ${DIRDEPS.x86sys} ${_sys_boot_efi}
DIRDEPS.powerpc= ${_sys_boot_fdt} stand/libsa32 stand/ofw stand/uboot
DIRDEPS.sparc64= stand/ofw ${_sys_boot_zfs}
.endif
diff --git a/usr.sbin/Makefile.amd64 b/usr.sbin/Makefile.amd64
index c44b4401c89e..fca60eae07e1 100644
--- a/usr.sbin/Makefile.amd64
+++ b/usr.sbin/Makefile.amd64
@@ -1,6 +1,5 @@
# $FreeBSD$
-# kgzip: builds, but missing support files
# mptable: broken (not 64 bit clean)
# pnpinfo: crashes (not really useful anyway)
.if ${MK_ACPI} != "no"
diff --git a/usr.sbin/Makefile.i386 b/usr.sbin/Makefile.i386
index 4a4dcbea9558..6724115b8217 100644
--- a/usr.sbin/Makefile.i386
+++ b/usr.sbin/Makefile.i386
@@ -16,7 +16,6 @@ SUBDIR+= cpucontrol
SUBDIR+= hyperv
.endif
SUBDIR+= kgmon
-SUBDIR+= kgzip
SUBDIR+= lptcontrol
SUBDIR+= mptable
.if ${MK_NDIS} != "no"
diff --git a/usr.sbin/kgzip/Makefile b/usr.sbin/kgzip/Makefile
deleted file mode 100644
index 013c65fe33c9..000000000000
--- a/usr.sbin/kgzip/Makefile
+++ /dev/null
@@ -1,9 +0,0 @@
-# $FreeBSD$
-
-PROG= kgzip
-MAN= kgzip.8
-SRCS= kgzip.c aouthdr.c elfhdr.c kgzcmp.c kgzld.c xio.c
-
-WARNS?= 3
-
-.include <bsd.prog.mk>
diff --git a/usr.sbin/kgzip/Makefile.depend b/usr.sbin/kgzip/Makefile.depend
deleted file mode 100644
index c729e17c52db..000000000000
--- a/usr.sbin/kgzip/Makefile.depend
+++ /dev/null
@@ -1,15 +0,0 @@
-# $FreeBSD$
-# Autogenerated - do NOT edit!
-
-DIRDEPS = \
- include \
- include/xlocale \
- lib/${CSU_DIR} \
- lib/libc \
-
-
-.include <dirdeps.mk>
-
-.if ${DEP_RELDIR} == ${_DEP_RELDIR}
-# local dependencies - needed for -jN in clean tree
-.endif
diff --git a/usr.sbin/kgzip/aouthdr.c b/usr.sbin/kgzip/aouthdr.c
deleted file mode 100644
index 5ebd199261b4..000000000000
--- a/usr.sbin/kgzip/aouthdr.c
+++ /dev/null
@@ -1,81 +0,0 @@
-/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
- *
- * Copyright (c) 2000 Robert Nordier
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS
- * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
- * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
- * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
- * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * $FreeBSD$
- */
-
-#include <stddef.h>
-#include "aouthdr.h"
-
-#define KGZ_FIX_NSIZE 0 /* Run-time fixup */
-
-const struct kgz_aouthdr0 aouthdr0 = {
- /* a.out header */
- {
- MID_I386 << 020 | OMAGIC, /* a_midmag */
- 0, /* a_text */
- sizeof(struct kgz_hdr) + KGZ_FIX_NSIZE, /* a_data */
- 0, /* a_bss */
- sizeof(struct nlist) * KGZ__STNUM, /* a_syms */
- 0, /* a_entry */
- 0, /* a_trsize */
- 0 /* a_drsize */
- }
-};
-
-const struct kgz_aouthdr1 aouthdr1 = {
- /* Symbol table */
- {
- {
- {
- (char *)offsetof(struct kgz__strtab,
- kgz) /* n_un */
- },
- N_DATA | N_EXT, /* n_type */
- AUX_OBJECT, /* n_other */
- 0, /* n_desc */
- 0 /* n_value */
- },
- {
- {
- (char *)offsetof(struct kgz__strtab,
- kgz_ndata) /* n_un */
- },
- N_DATA | N_EXT, /* n_type */
- AUX_OBJECT, /* n_other */
- 0, /* n_desc */
- sizeof(struct kgz_hdr) /* n_value */
- }
- },
- /* String table */
- {
- sizeof(struct kgz__strtab), /* length */
- KGZ__STR_KGZ, /* kgz */
- KGZ__STR_KGZ_NDATA /* kgz_ndata */
- }
-};
diff --git a/usr.sbin/kgzip/aouthdr.h b/usr.sbin/kgzip/aouthdr.h
deleted file mode 100644
index 2fd990db0a21..000000000000
--- a/usr.sbin/kgzip/aouthdr.h
+++ /dev/null
@@ -1,61 +0,0 @@
-/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
- *
- * Copyright (c) 2000 Robert Nordier
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS
- * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
- * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
- * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
- * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * $FreeBSD$
- */
-
-#include <a.out.h>
-#include "kgz.h"
-
-/* Relocatable header: part 0 */
-struct kgz_aouthdr0 {
- struct exec a;
-};
-
-/* Symbol table entries */
-#define KGZ__STNUM 2
-
-/* Symbol table strings */
-#define KGZ__STR_KGZ "_kgz"
-#define KGZ__STR_KGZ_NDATA "_kgz_ndata"
-
-/* String table */
-struct kgz__strtab {
- unsigned long length;
- char kgz[sizeof(KGZ__STR_KGZ)];
- char kgz_ndata[sizeof(KGZ__STR_KGZ_NDATA)];
-};
-
-/* Relocatable header: part 1 */
-struct kgz_aouthdr1 {
- struct nlist st[KGZ__STNUM];
- struct kgz__strtab strtab;
-};
-
-extern const struct kgz_aouthdr0 aouthdr0;
-extern const struct kgz_aouthdr1 aouthdr1;
diff --git a/usr.sbin/kgzip/elfhdr.c b/usr.sbin/kgzip/elfhdr.c
deleted file mode 100644
index 9d5dab2e88a6..000000000000
--- a/usr.sbin/kgzip/elfhdr.c
+++ /dev/null
@@ -1,166 +0,0 @@
-/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
- *
- * Copyright (c) 1999 Global Technology Associates, Inc.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
- * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * $FreeBSD$
- */
-
-#include <sys/endian.h>
-#include <stddef.h>
-#include "elfhdr.h"
-
-#define KGZ_FIX_NSIZE 0 /* Run-time fixup */
-
-/*
- * Relocatable header template.
- */
-const struct kgz_elfhdr elfhdr = {
- /* ELF header */
- {
- {
- ELFMAG0, ELFMAG1, ELFMAG2, ELFMAG3, /* e_ident */
- ELFCLASS32, ELFDATA2LSB, EV_CURRENT, 0,
- 'F', 'r', 'e', 'e', 'B', 'S', 'D', 0
- },
- htole16(ET_EXEC), /* e_type */
- htole16(EM_386), /* e_machine */
- htole32(EV_CURRENT), /* e_version */
- 0, /* e_entry */
- 0, /* e_phoff */
- htole32(offsetof(struct kgz_elfhdr, sh)), /* e_shoff */
- 0, /* e_flags */
- htole16(sizeof(Elf32_Ehdr)), /* e_ehsize */
- 0, /* e_phentsize */
- 0, /* e_phnum */
- htole16(sizeof(Elf32_Shdr)), /* e_shentsize */
- htole16(KGZ_SHNUM), /* e_shnum */
- htole16(KGZ_SH_SHSTRTAB) /* e_shstrndx */
- },
- /* Section header */
- {
- {
- 0, /* sh_name */
- htole32(SHT_NULL), /* sh_type */
- 0, /* sh_flags */
- 0, /* sh_addr */
- 0, /* sh_offset */
- 0, /* sh_size */
- htole32(SHN_UNDEF), /* sh_link */
- 0, /* sh_info */
- 0, /* sh_addralign */
- 0 /* sh_entsize */
- },
- {
- htole32(offsetof(struct kgz_shstrtab, symtab)), /* sh_name */
- htole32(SHT_SYMTAB), /* sh_type */
- 0, /* sh_flags */
- 0, /* sh_addr */
- htole32(offsetof(struct kgz_elfhdr, st)), /* sh_offset */
- htole32(sizeof(Elf32_Sym) * KGZ_STNUM), /* sh_size */
- htole32(KGZ_SH_STRTAB), /* sh_link */
- htole32(1), /* sh_info */
- htole32(4), /* sh_addralign */
- htole32(sizeof(Elf32_Sym)) /* sh_entsize */
- },
- {
- htole32(offsetof(struct kgz_shstrtab, shstrtab)), /* sh_name */
- htole32(SHT_STRTAB), /* sh_type */
- 0, /* sh_flags */
- 0, /* sh_addr */
- htole32(offsetof(struct kgz_elfhdr, shstrtab)), /* sh_offset */
- htole32(sizeof(struct kgz_shstrtab)), /* sh_size */
- htole32(SHN_UNDEF), /* sh_link */
- 0, /* sh_info */
- htole32(1), /* sh_addralign */
- 0 /* sh_entsize */
- },
- {
- htole32(offsetof(struct kgz_shstrtab, strtab)), /* sh_name */
- htole32(SHT_STRTAB), /* sh_type */
- 0, /* sh_flags */
- 0, /* sh_addr */
- htole32(offsetof(struct kgz_elfhdr, strtab)), /* sh_offset */
- htole32(sizeof(struct kgz_strtab)), /* sh_size */
- htole32(SHN_UNDEF), /* sh_link */
- 0, /* sh_info */
- htole32(1), /* sh_addralign */
- 0 /* sh_entsize */
- },
- {
- htole32(offsetof(struct kgz_shstrtab, data)), /* sh_name */
- htole32(SHT_PROGBITS), /* sh_type */
- htole32(SHF_ALLOC | SHF_WRITE), /* sh_flags */
- 0, /* sh_addr */
- htole32(sizeof(struct kgz_elfhdr)), /* sh_offset */
- htole32(sizeof(struct kgz_hdr) + KGZ_FIX_NSIZE), /* sh_size */
- htole32(SHN_UNDEF), /* sh_link */
- 0, /* sh_info */
- htole32(4), /* sh_addralign */
- 0 /* sh_entsize */
- }
- },
- /* Symbol table */
- {
- {
- 0, /* st_name */
- 0, /* st_value */
- 0, /* st_size */
- 0, /* st_info */
- 0, /* st_other */
- htole16(SHN_UNDEF) /* st_shndx */
- },
- {
- htole32(offsetof(struct kgz_strtab, kgz)), /* st_name */
- 0, /* st_value */
- htole32(sizeof(struct kgz_hdr)), /* st_size */
- ELF32_ST_INFO(STB_GLOBAL, STT_OBJECT), /* st_info */
- 0, /* st_other */
- htole16(KGZ_SH_DATA) /* st_shndx */
- },
- {
- htole32(offsetof(struct kgz_strtab, kgz_ndata)), /* st_name */
- htole32(sizeof(struct kgz_hdr)), /* st_value */
- htole32(KGZ_FIX_NSIZE), /* st_size */
- ELF32_ST_INFO(STB_GLOBAL, STT_OBJECT), /* st_info */
- 0, /* st_other */
- htole16(KGZ_SH_DATA) /* st_shndx */
- }
- },
- /* Section header string table */
- {
- KGZ_SHSTR_ZERO, /* zero */
- KGZ_SHSTR_SYMTAB, /* symtab */
- KGZ_SHSTR_SHSTRTAB, /* shstrtab */
- KGZ_SHSTR_STRTAB, /* strtab */
- KGZ_SHSTR_DATA /* data */
- },
- /* String table */
- {
- KGZ_STR_ZERO, /* zero */
- KGZ_STR_KGZ, /* kgz */
- KGZ_STR_KGZ_NDATA /* kgz_ndata */
- }
-};
diff --git a/usr.sbin/kgzip/elfhdr.h b/usr.sbin/kgzip/elfhdr.h
deleted file mode 100644
index de57ce476517..000000000000
--- a/usr.sbin/kgzip/elfhdr.h
+++ /dev/null
@@ -1,86 +0,0 @@
-/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
- *
- * Copyright (c) 1999 Global Technology Associates, Inc.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
- * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * $FreeBSD$
- */
-
-#include <sys/types.h>
-#define __ELF_WORD_SIZE 32
-#include <sys/elf32.h>
-#include <sys/elf_generic.h>
-#include "kgz.h"
-
-/* Section header indices */
-#define KGZ_SH_SYMTAB 1
-#define KGZ_SH_SHSTRTAB 2
-#define KGZ_SH_STRTAB 3
-#define KGZ_SH_DATA 4
-#define KGZ_SHNUM 5
-
-/* Section header strings */
-#define KGZ_SHSTR_ZERO ""
-#define KGZ_SHSTR_SYMTAB ".symtab"
-#define KGZ_SHSTR_SHSTRTAB ".shstrtab"
-#define KGZ_SHSTR_STRTAB ".strtab"
-#define KGZ_SHSTR_DATA ".data"
-
-/* Section header string table */
-struct kgz_shstrtab {
- char zero[sizeof(KGZ_SHSTR_ZERO)];
- char symtab[sizeof(KGZ_SHSTR_SYMTAB)];
- char shstrtab[sizeof(KGZ_SHSTR_SHSTRTAB)];
- char strtab[sizeof(KGZ_SHSTR_STRTAB)];
- char data[sizeof(KGZ_SHSTR_DATA)];
-};
-
-/* Symbol table indices */
-#define KGZ_ST_KGZ 1
-#define KGZ_ST_KGZ_NDATA 2
-#define KGZ_STNUM 3
-
-/* Symbol table strings */
-#define KGZ_STR_ZERO ""
-#define KGZ_STR_KGZ "kgz"
-#define KGZ_STR_KGZ_NDATA "kgz_ndata"
-
-/* String table */
-struct kgz_strtab {
- char zero[sizeof(KGZ_STR_ZERO)];
- char kgz[sizeof(KGZ_STR_KGZ)];
- char kgz_ndata[sizeof(KGZ_STR_KGZ_NDATA)];
-};
-
-/* Relocatable header format */
-struct kgz_elfhdr {
- Elf32_Ehdr e;
- Elf32_Shdr sh[KGZ_SHNUM];
- Elf32_Sym st[KGZ_STNUM];
- struct kgz_shstrtab shstrtab;
- struct kgz_strtab strtab;
-};
-
-extern const struct kgz_elfhdr elfhdr;
diff --git a/usr.sbin/kgzip/kgz.h b/usr.sbin/kgzip/kgz.h
deleted file mode 100644
index 54d37f719d56..000000000000
--- a/usr.sbin/kgzip/kgz.h
+++ /dev/null
@@ -1,59 +0,0 @@
-/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
- *
- * Copyright (c) 1999 Global Technology Associates, Inc.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
- * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * $FreeBSD$
- */
-
-#ifndef _KGZ_H_
-#define _KGZ_H_
-
-#include <sys/types.h>
-
-/*
- * KGZ definitions: kgzip(8) output.
- */
-
-/* Values for ident[]. */
-#define KGZ_ID0 'K'
-#define KGZ_ID1 'G'
-#define KGZ_ID2 'Z'
-#define KGZ_ID3 '\0'
-
-/* KGZ header. */
-struct kgz_hdr {
- char ident[4]; /* identification */
- uint32_t dload; /* decoded image load address */
- uint32_t dsize; /* decoded image size */
- uint32_t isize; /* image size in memory */
- uint32_t entry; /* program entry point */
- uint32_t nsize; /* encoded image size */
-};
-
-extern struct kgz_hdr kgz; /* header */
-extern uint8_t kgz_ndata[]; /* encoded image */
-
-#endif /* !_KGZ_H_ */
diff --git a/usr.sbin/kgzip/kgzcmp.c b/usr.sbin/kgzip/kgzcmp.c
deleted file mode 100644
index b9d59a0ea8b0..000000000000
--- a/usr.sbin/kgzip/kgzcmp.c
+++ /dev/null
@@ -1,239 +0,0 @@
-/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
- *
- * Copyright (c) 1999 Global Technology Associates, Inc.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
- * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * $FreeBSD$
- */
-
-#define _KERNEL
-#include <sys/param.h>
-#undef _KERNEL
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <sys/wait.h>
-
-#include <err.h>
-#include <fcntl.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-
-#include <a.out.h>
-
-#include "aouthdr.h"
-#include "elfhdr.h"
-#include "kgzip.h"
-
-static void mk_data(const struct iodesc *i, const struct iodesc *,
- struct kgz_hdr *, size_t);
-static int ld_elf(const struct iodesc *, const struct iodesc *,
- struct kgz_hdr *, const Elf32_Ehdr *);
-static int ld_aout(const struct iodesc *, const struct iodesc *,
- struct kgz_hdr *, const struct exec *);
-
-/*
- * Compress executable and output it in relocatable object format.
- */
-void
-kgzcmp(struct kgz_hdr *kh, const char *f1, const char *f2)
-{
- struct iodesc idi, ido;
- struct kgz_hdr khle;
-
- if ((idi.fd = open(idi.fname = f1, O_RDONLY)) == -1)
- err(1, "%s", idi.fname);
- if ((ido.fd = open(ido.fname = f2, O_CREAT | O_TRUNC | O_WRONLY,
- 0666)) == -1)
- err(1, "%s", ido.fname);
- kh->ident[0] = KGZ_ID0;
- kh->ident[1] = KGZ_ID1;
- kh->ident[2] = KGZ_ID2;
- kh->ident[3] = KGZ_ID3;
- mk_data(&idi, &ido, kh,
- (format == F_AOUT ? sizeof(struct kgz_aouthdr0) :
- sizeof(struct kgz_elfhdr)) +
- sizeof(struct kgz_hdr));
- kh->dload &= 0xffffff;
- kh->entry &= 0xffffff;
- if (format == F_AOUT) {
- struct kgz_aouthdr0 ahdr0 = aouthdr0;
- struct kgz_aouthdr1 ahdr1 = aouthdr1;
- unsigned x = (sizeof(struct kgz_hdr) + kh->nsize) & (16 - 1);
- if (x) {
- x = 16 - x;
- xzero(&ido, x);
- }
- xwrite(&ido, &ahdr1, sizeof(ahdr1));
- ahdr0.a.a_data += kh->nsize + x;
- xseek(&ido, 0);
- xwrite(&ido, &ahdr0, sizeof(ahdr0));
- } else {
- struct kgz_elfhdr ehdr = elfhdr;
- ehdr.st[KGZ_ST_KGZ_NDATA].st_size = htole32(kh->nsize);
- ehdr.sh[KGZ_SH_DATA].sh_size =
- htole32(le32toh(ehdr.sh[KGZ_SH_DATA].sh_size) + kh->nsize);
- xseek(&ido, 0);
- xwrite(&ido, &ehdr, sizeof(ehdr));
- }
- khle = *kh;
- khle.dload = htole32(khle.dload);
- khle.dsize = htole32(khle.dsize);
- khle.isize = htole32(khle.isize);
- khle.entry = htole32(khle.entry);
- khle.nsize = htole32(khle.nsize);
- xwrite(&ido, &khle, sizeof(khle));
- xclose(&ido);
- xclose(&idi);
-}
-
-/*
- * Make encoded (compressed) data.
- */
-static void
-mk_data(const struct iodesc * idi, const struct iodesc * ido,
- struct kgz_hdr * kh, size_t off)
-{
- union {
- struct exec ex;
- Elf32_Ehdr ee;
- } hdr;
- struct stat sb;
- struct iodesc idp;
- int fd[2];
- pid_t pid;
- size_t n;
- int fmt, status, e;
-
- n = xread(idi, &hdr, sizeof(hdr), 0);
- fmt = 0;
- if (n >= sizeof(hdr.ee) && IS_ELF(hdr.ee))
- fmt = F_ELF;
- else if (n >= sizeof(hdr.ex) && N_GETMAGIC(hdr.ex) == ZMAGIC)
- fmt = F_AOUT;
- if (!fmt)
- errx(1, "%s: Format not supported", idi->fname);
- xseek(ido, off);
- if (pipe(fd))
- err(1, NULL);
- switch (pid = fork()) {
- case -1:
- err(1, NULL);
- case 0:
- close(fd[1]);
- dup2(fd[0], STDIN_FILENO);
- close(fd[0]);
- close(idi->fd);
- dup2(ido->fd, STDOUT_FILENO);
- close(ido->fd);
- execlp("gzip", "gzip", "-9n", (char *)NULL);
- warn(NULL);
- _exit(1);
- default:
- close(fd[0]);
- idp.fname = "(pipe)";
- idp.fd = fd[1];
- e = fmt == F_ELF ? ld_elf(idi, &idp, kh, &hdr.ee) :
- fmt == F_AOUT ? ld_aout(idi, &idp, kh, &hdr.ex) : -1;
- close(fd[1]);
- if ((pid = waitpid(pid, &status, 0)) == -1)
- err(1, NULL);
- if (WIFSIGNALED(status) || WEXITSTATUS(status))
- exit(1);
- }
- if (e)
- errx(1, "%s: Invalid format", idi->fname);
- if (fstat(ido->fd, &sb))
- err(1, "%s", ido->fname);
- kh->nsize = sb.st_size - off;
-}
-
-/*
- * "Load" an ELF-format executable.
- */
-static int
-ld_elf(const struct iodesc * idi, const struct iodesc * ido,
- struct kgz_hdr * kh, const Elf32_Ehdr * e)
-{
- Elf32_Phdr p;
- size_t load, addr, n;
- unsigned x, i;
-
- load = addr = n = 0;
- for (x = i = 0; i < e->e_phnum; i++) {
- if (xread(idi, &p, sizeof(p),
- e->e_phoff + i * e->e_phentsize) != e->e_phentsize)
- return -1;
- if (p.p_type != PT_LOAD)
- continue;
- if (!x)
- load = addr = p.p_vaddr;
- else {
- if (p.p_vaddr < addr)
- return -1;
- n = p.p_vaddr - addr;
- if (n) {
- xzero(ido, n);
- addr += n;
- }
- }
- if (p.p_memsz < p.p_filesz)
- return -1;
- n = p.p_memsz - p.p_filesz;
- xcopy(idi, ido, p.p_filesz, p.p_offset);
- addr += p.p_filesz;
- x++;
- }
- if (!x)
- return -1;
- kh->dload = load;
- kh->dsize = addr - load;
- kh->isize = kh->dsize + n;
- kh->entry = e->e_entry;
- return 0;
-}
-
-/*
- * "Load" an a.out-format executable.
- */
-static int
-ld_aout(const struct iodesc * idi, const struct iodesc * ido,
- struct kgz_hdr * kh, const struct exec * a)
-{
- size_t load, addr;
-
- load = addr = N_TXTADDR(*a);
- xcopy(idi, ido, le32toh(a->a_text), N_TXTOFF(*a));
- addr += le32toh(a->a_text);
- if (N_DATADDR(*a) != addr)
- return -1;
- xcopy(idi, ido, le32toh(a->a_data), N_DATOFF(*a));
- addr += le32toh(a->a_data);
- kh->dload = load;
- kh->dsize = addr - load;
- kh->isize = kh->dsize + le32toh(a->a_bss);
- kh->entry = le32toh(a->a_entry);
- return 0;
-}
diff --git a/usr.sbin/kgzip/kgzip.8 b/usr.sbin/kgzip/kgzip.8
deleted file mode 100644
index fd7b4e3e6250..000000000000
--- a/usr.sbin/kgzip/kgzip.8
+++ /dev/null
@@ -1,156 +0,0 @@
-.\" Copyright (c) 1999 Global Technology Associates, Inc.
-.\" All rights reserved.
-.\"
-.\" Redistribution and use in source and binary forms, with or without
-.\" modification, are permitted provided that the following conditions
-.\" are met:
-.\" 1. Redistributions of source code must retain the above copyright
-.\" notice, this list of conditions and the following disclaimer.
-.\" 2. Redistributions in binary form must reproduce the above copyright
-.\" notice, this list of conditions and the following disclaimer in the
-.\" documentation and/or other materials provided with the distribution.
-.\"
-.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS``AS IS'' AND
-.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS
-.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
-.\" OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
-.\" OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
-.\" BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
-.\" WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
-.\" OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
-.\" EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-.\"
-.\" $FreeBSD$
-.\"
-.Dd August 2, 2016
-.Dt KGZIP 8
-.Os
-.Sh NAME
-.Nm kgzip
-.Nd compress a kernel
-.Sh SYNOPSIS
-.Nm
-.Op Fl cv
-.Op Fl f Ar format
-.Op Fl l Ar loader
-.Op Fl o Ar output
-.Ar file
-.Sh DESCRIPTION
-.Bf -symbolic
-This utility is deprecated.
-Users are advised to use
-.Xr loader 8
-and compress the kernel with
-.Xr gzip 1 .
-.Ef
-.Pp
-The
-.Nm
-utility compresses a kernel or some other bootable binary.
-Operation
-is in two phases as follows:
-.Bl -enum
-.It
-A load image of the executable file is built which omits all but
-the
-.Sq text
-and
-.Sq data
-segments.
-This image is compressed using
-.Xr gzip 1
-and output as data in relocatable object format.
-.It
-The object file is linked with a special self-hosting loader, producing
-an executable suitable for booting with either the second- or
-third-level bootstraps.
-.El
-.Pp
-Supported object formats are 32-bit ELF and a.out ZMAGIC.
-.Pp
-If the
-.Ar file
-operand has a
-.Sq .o
-suffix, input is assumed to be for the link phase, and the first phase
-is omitted.
-.Pp
-The options are:
-.Bl -tag -width Fl
-.It Fl c
-Omit the link phase.
-.It Fl v
-Display object file information.
-.It Fl f Ar format
-Use
-.Ar format
-as the output format, where
-.Ar format
-is
-.Sq aout
-or
-.Sq elf .
-The default format is ELF.
-.It Fl l Ar loader
-Link
-.Ar loader
-as the loader.
-.It Fl o Ar output
-Name the output file
-.Ar output .
-The default is to use the input name with the suffix
-.Sq .o
-(for relocatables) or
-.Sq .kgz
-(for executables).
-.El
-.Sh NOTES
-Global variables equivalent to the following are defined in the output:
-.Bd -literal
-struct kgz_hdr {
- char ident[4]; /* identification: "KGZ" */
- uint32_t dload; /* decoded image load address */
- uint32_t dsize; /* decoded image size */
- uint32_t isize; /* image size in memory */
- uint32_t entry; /* entry point */
- uint32_t nsize; /* encoded image size */
-} kgz;
-
-uint8_t kgz_ndata[]; /* encoded data */
-.Ed
-.Pp
-The encoded data is simply
-.Xr gzip 1
-output: a header (with no optional fields); compressed data; and 32-bit
-CRC and size values.
-.Sh FILES
-.Bl -tag -width /usr/lib/kgzldr.o -compact
-.It Pa /usr/lib/kgzldr.o
-The default loader
-.El
-.Sh EXIT STATUS
-.Ex -std
-.Sh SEE ALSO
-.Xr gzip 1 ,
-.Xr ld 1 ,
-.Xr a.out 5 ,
-.Xr elf 5 ,
-.Xr boot 8 ,
-.Xr loader 8
-.Sh AUTHORS
-.An Robert Nordier Aq Mt rnordier@FreeBSD.org
-.Sh BUGS
-As symbols are lost, the usefulness of this utility for compressing
-kernels is limited to situations where
-.Xr loader 8
-cannot be used.
-.Pp
-.Pa kgzldr.o
-is only available for the i386 architecture.
-.Pp
-The preferred method of compressing a kernel
-is simply to
-.Xr gzip 1
-it.
diff --git a/usr.sbin/kgzip/kgzip.c b/usr.sbin/kgzip/kgzip.c
deleted file mode 100644
index 7c11ffffe038..000000000000
--- a/usr.sbin/kgzip/kgzip.c
+++ /dev/null
@@ -1,178 +0,0 @@
-/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
- *
- * Copyright (c) 1999 Global Technology Associates, Inc.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
- * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef lint
-static const char rcsid[] =
- "$FreeBSD$";
-#endif /* not lint */
-
-#include <sys/types.h>
-#include <err.h>
-#include <paths.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-
-#include "kgzip.h"
-
-#define FN_SRC 0 /* Filename: source */
-#define FN_OBJ 1 /* Filename: relocatable */
-#define FN_KGZ 2 /* Filename: executable */
-#define FN_CNT 3 /* Number of filenames */
-
-#define SFX_OBJ ".o" /* Filename suffix: relocatable */
-#define SFX_KGZ ".kgz" /* Filename suffix: executable */
-#define SFX_MAX 5 /* Size of larger filename suffix */
-
-const char *loader = "/usr/lib/kgzldr.o"; /* Default loader */
-int format; /* Output format */
-
-char *tname; /* Name of temporary file */
-
-static void cleanup(void);
-static void mk_fn(int, const char *, const char *, char *[]);
-static void usage(void);
-
-/*
- * Compress a kernel.
- */
-int
-main(int argc, char *argv[])
-{
- static char *fn[FN_CNT];
- struct kgz_hdr kh;
- const char *output;
- char *tmpdir;
- int cflag, vflag, c;
-
- tmpdir = getenv("TMPDIR");
- if (asprintf(&tname, "%s/kgzXXXXXXXXXX",
- tmpdir == NULL ? _PATH_TMP : tmpdir) == -1)
- errx(1, "Out of memory");
- output = NULL;
- cflag = vflag = 0;
- while ((c = getopt(argc, argv, "cvf:l:o:")) != -1)
- switch (c) {
- case 'c':
- cflag = 1;
- break;
- case 'v':
- vflag = 1;
- break;
- case 'f':
- if (!strcmp(optarg, "aout"))
- format = F_AOUT;
- else if (!strcmp(optarg, "elf"))
- format = F_ELF;
- else
- errx(1, "%s: Unknown format", optarg);
- break;
- case 'l':
- loader = optarg;
- break;
- case 'o':
- output = optarg;
- break;
- default:
- usage();
- }
- argc -= optind;
- argv += optind;
- if (argc != 1)
- usage();
- atexit(cleanup);
- mk_fn(cflag, *argv, output, fn);
- memset(&kh, 0, sizeof(kh));
- if (fn[FN_SRC]) {
- if (!format)
- format = F_ELF;
- kgzcmp(&kh, fn[FN_SRC], fn[FN_OBJ]);
- }
- if (!cflag)
- kgzld(&kh, fn[FN_OBJ], fn[FN_KGZ]);
- if (vflag)
- printf("dload=%#x dsize=%#x isize=%#x entry=%#x nsize=%#x\n",
- kh.dload, kh.dsize, kh.isize, kh.entry, kh.nsize);
- return 0;
-}
-
-/*
- * Clean up after processing.
- */
-static void
-cleanup(void)
-{
- if (tname)
- unlink(tname);
-}
-
-/*
- * Make the required filenames.
- */
-static void
-mk_fn(int cflag, const char *f1, const char *f2, char *fn[])
-{
- const char *p, *s;
- size_t n;
- int i, fd;
-
- i = 0;
- s = strrchr(f1, 0);
- n = sizeof(SFX_OBJ) - 1;
- if ((size_t)(s - f1) > n && !memcmp(s - n, SFX_OBJ, n)) {
- s -= n;
- i++;
- }
- fn[i++] = (char *)f1;
- if (i == FN_OBJ && !cflag) {
- if ((fd = mkstemp(tname)) == -1)
- err(1, NULL);
- close(fd);
- fn[i++] = tname;
- }
- if (!(fn[i] = (char *)f2)) {
- p = (p = strrchr(f1, '/')) ? p + 1 : f1;
- n = (size_t)(s - p);
- if (!(fn[i] = malloc(n + SFX_MAX)))
- err(1, NULL);
- memcpy(fn[i], p, n);
- strcpy(fn[i] + n, i == FN_OBJ ? SFX_OBJ : SFX_KGZ);
- }
-}
-
-/*
- * Display usage information.
- */
-static void
-usage(void)
-{
- fprintf(stderr,
- "usage: kgzip [-cv] [-f format] [-l loader] [-o output] file\n");
- exit(1);
-}
diff --git a/usr.sbin/kgzip/kgzip.h b/usr.sbin/kgzip/kgzip.h
deleted file mode 100644
index 3151a1299d3e..000000000000
--- a/usr.sbin/kgzip/kgzip.h
+++ /dev/null
@@ -1,53 +0,0 @@
-/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
- *
- * Copyright (c) 1999 Global Technology Associates, Inc.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
- * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * $FreeBSD$
- */
-
-#include "kgz.h"
-
-#define F_AOUT 1 /* Format: a.out */
-#define F_ELF 2 /* Format: ELF32 */
-
-/* Used by I/O routines */
-struct iodesc {
- const char *fname; /* File name */
- int fd; /* File descriptor */
-};
-
-extern const char *loader; /* Default loader */
-extern int format; /* Output format */
-
-void kgzcmp(struct kgz_hdr *, const char *, const char *);
-void kgzld(struct kgz_hdr *, const char *, const char *);
-
-void xclose(const struct iodesc *);
-void xcopy(const struct iodesc *, const struct iodesc *, size_t, off_t);
-void xzero(const struct iodesc *, size_t);
-size_t xread(const struct iodesc *, void *, size_t, off_t);
-void xwrite(const struct iodesc *, const void *, size_t);
-void xseek(const struct iodesc *, off_t);
diff --git a/usr.sbin/kgzip/kgzld.c b/usr.sbin/kgzip/kgzld.c
deleted file mode 100644
index f717a90aa385..000000000000
--- a/usr.sbin/kgzip/kgzld.c
+++ /dev/null
@@ -1,103 +0,0 @@
-/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
- *
- * Copyright (c) 1999 Global Technology Associates, Inc.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
- * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * $FreeBSD$
- */
-
-#include <sys/types.h>
-#include <sys/endian.h>
-#include <sys/wait.h>
-
-#include <err.h>
-#include <fcntl.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-
-#include "aouthdr.h"
-#include "elfhdr.h"
-#include "kgzip.h"
-
-#define align(x, y) (((x) + (y) - 1) & ~((y) - 1))
-
-/*
- * Link KGZ file and loader.
- */
-void
-kgzld(struct kgz_hdr * kh, const char *f1, const char *f2)
-{
- char addr[16];
- struct iodesc idi;
- pid_t pid;
- size_t n;
- int status;
-
- if (strcmp(kh->ident, "KGZ")) {
- if ((idi.fd = open(idi.fname = f1, O_RDONLY)) == -1)
- err(1, "%s", idi.fname);
- if (!format) {
- union {
- struct exec ex;
- Elf32_Ehdr ee;
- } hdr;
- n = xread(&idi, &hdr, sizeof(hdr), 0);
- if (n >= sizeof(hdr.ee) && IS_ELF(hdr.ee))
- format = F_ELF;
- else if (n >= sizeof(hdr.ex) &&
- N_GETMAGIC(hdr.ex) == OMAGIC)
- format = F_AOUT;
- if (!format)
- errx(1, "%s: Format not supported", idi.fname);
- }
- n = xread(&idi, kh, sizeof(*kh),
- format == F_AOUT ? sizeof(struct kgz_aouthdr0)
- : sizeof(struct kgz_elfhdr));
- xclose(&idi);
- if (n != sizeof(*kh) || strcmp(kh->ident, "KGZ"))
- errx(1, "%s: Invalid format", idi.fname);
- }
- sprintf(addr, "%#x", align(kh->dload + kh->dsize, 0x1000));
- switch (pid = fork()) {
- case -1:
- err(1, NULL);
- case 0:
- if (format == F_AOUT)
- execlp("ld", "ld", "-aout", "-Z", "-T", addr, "-o", f2,
- loader, f1, (char *)NULL);
- else
- execlp("ld", "ld", "-Ttext", addr, "-o", f2, loader, f1,
- (char *)NULL);
- warn(NULL);
- _exit(1);
- default:
- if ((pid = waitpid(pid, &status, 0)) == -1)
- err(1, NULL);
- if (WIFSIGNALED(status) || WEXITSTATUS(status))
- exit(1);
- }
-}
diff --git a/usr.sbin/kgzip/xio.c b/usr.sbin/kgzip/xio.c
deleted file mode 100644
index d72f0ec8df3d..000000000000
--- a/usr.sbin/kgzip/xio.c
+++ /dev/null
@@ -1,123 +0,0 @@
-/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
- *
- * Copyright (c) 1999 Global Technology Associates, Inc.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
- * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
- * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * $FreeBSD$
- */
-
-#include <err.h>
-#include <string.h>
-#include <unistd.h>
-
-#include "kgzip.h"
-
-/*
- * Close a file.
- */
-void
-xclose(const struct iodesc *id)
-{
- if (close(id->fd))
- err(1, "%s", id->fname);
-}
-
-/*
- * Copy bytes from one file to another.
- */
-void
-xcopy(const struct iodesc * idi, const struct iodesc * ido,
- size_t nbyte, off_t offset)
-{
- char buf[8192];
- size_t n;
-
- while (nbyte) {
- if ((n = sizeof(buf)) > nbyte)
- n = nbyte;
- if (xread(idi, buf, n, offset) != n)
- errx(1, "%s: Short read", idi->fname);
- xwrite(ido, buf, n);
- nbyte -= n;
- offset = -1;
- }
-}
-
-/*
- * Write binary zeroes to a file.
- */
-void
-xzero(const struct iodesc * id, size_t nbyte)
-{
- char buf[8192];
- size_t n;
-
- memset(buf, 0, sizeof(buf));
- while (nbyte) {
- if ((n = sizeof(buf)) > nbyte)
- n = nbyte;
- xwrite(id, buf, n);
- nbyte -= n;
- }
-}
-
-/*
- * Read from a file.
- */
-size_t
-xread(const struct iodesc * id, void *buf, size_t nbyte, off_t offset)
-{
- ssize_t n;
-
- if (offset != -1 && lseek(id->fd, offset, SEEK_SET) != offset)
- err(1, "%s", id->fname);
- if ((n = read(id->fd, buf, nbyte)) == -1)
- err(1, "%s", id->fname);
- return (size_t)n;
-}
-
-/*
- * Write to a file.
- */
-void
-xwrite(const struct iodesc * id, const void *buf, size_t nbyte)
-{
- ssize_t n;
-
- if ((n = write(id->fd, buf, nbyte)) == -1)
- err(1, "%s", id->fname);
- if ((size_t)n != nbyte)
- errx(1, "%s: Short write", id->fname);
-}
-
-/*
- * Reposition within a file.
- */
-void
-xseek(const struct iodesc *id, off_t offset)
-{
- if (lseek(id->fd, offset, SEEK_SET) != offset)
- err(1, "%s", id->fname);
-}