diff options
25 files changed, 75 insertions, 813 deletions
diff --git a/distrib/alpha/bsd.rd/Makefile b/distrib/alpha/bsd.rd/Makefile index cf2997c02ec..39168a4e9bd 100644 --- a/distrib/alpha/bsd.rd/Makefile +++ b/distrib/alpha/bsd.rd/Makefile @@ -1,4 +1,4 @@ -# $OpenBSD: Makefile,v 1.30 2017/09/18 20:13:52 jasper Exp $ +# $OpenBSD: Makefile,v 1.31 2019/04/05 21:08:00 deraadt Exp $ TOP= ${.CURDIR}/.. @@ -24,9 +24,9 @@ bsd.rd: bsd.rd_unz strip ${STRIPOPTS} bsd.strip gzip -c ${GZIPFLAGS} bsd.strip > bsd.rd -bsd.rd_unz: bsd ${IMAGE} rdsetroot +bsd.rd_unz: bsd ${IMAGE} cp bsd bsd.rd_unz - ${.OBJDIR}/rdsetroot bsd.rd_unz ${IMAGE} + rdsetroot bsd.rd_unz ${IMAGE} strip -R .SUNW_ctf -R .shstrtab bsd.rd_unz bsd: @@ -44,11 +44,6 @@ ${IMAGE}: ${CBIN} rm $@.d/${CBIN} makefs ${MAKEFSARGS_RD} $@ $@.d -rdsetroot: ${TOP}/../common/elfrdsetroot.c - ${HOSTCC} ${HOSTCFLAGS} -o rdsetroot \ - ${TOP}/../common/elfrdsetroot.c ${TOP}/../common/elf32.c \ - ${TOP}/../common/elf64.c - .ifdef RELEASEDIR beforeinstall: cp bsd.rd ${RELEASEDIR} diff --git a/distrib/alpha/common/Makefile.inc b/distrib/alpha/common/Makefile.inc index 6e463a60a31..162759f90fa 100644 --- a/distrib/alpha/common/Makefile.inc +++ b/distrib/alpha/common/Makefile.inc @@ -1,4 +1,4 @@ -# $OpenBSD: Makefile.inc,v 1.35 2017/09/18 20:13:52 jasper Exp $ +# $OpenBSD: Makefile.inc,v 1.36 2019/04/05 21:08:00 deraadt Exp $ TOP= ${.CURDIR}/.. @@ -66,9 +66,9 @@ bsd.gz: bsd.rd strip bsd.strip gzip -c ${GZIPFLAGS} bsd.strip > bsd.gz -bsd.rd: bsd ${IMAGE} rdsetroot +bsd.rd: bsd ${IMAGE} cp bsd bsd.rd - ${.OBJDIR}/rdsetroot bsd.rd ${IMAGE} + rdsetroot bsd.rd ${IMAGE} bsd: cd ${.CURDIR}/../../../sys/arch/alpha/compile/${RAMDISK} && \ @@ -85,11 +85,6 @@ ${IMAGE}: ${CBIN} rm $@.d/${CBIN} makefs ${MAKEFSARGS_RD} $@ $@.d -rdsetroot: ${TOP}/../common/elfrdsetroot.c - ${HOSTCC} ${HOSTCFLAGS} -o rdsetroot \ - ${TOP}/../common/elfrdsetroot.c ${TOP}/../common/elf32.c \ - ${TOP}/../common/elf64.c - unconfig: -umount ${MOUNT_POINT} -vnconfig -u ${VND} diff --git a/distrib/amd64/ramdiskA/Makefile.inc b/distrib/amd64/ramdiskA/Makefile.inc index 5248f4d1264..d623deb07ef 100644 --- a/distrib/amd64/ramdiskA/Makefile.inc +++ b/distrib/amd64/ramdiskA/Makefile.inc @@ -1,4 +1,4 @@ -# $OpenBSD: Makefile.inc,v 1.7 2018/06/06 00:14:29 mortimer Exp $ +# $OpenBSD: Makefile.inc,v 1.8 2019/04/05 21:08:00 deraadt Exp $ TOP= ${.CURDIR}/.. @@ -68,10 +68,9 @@ bsd.gz: bsd.rd strip -R .comment -R .SUNW_ctf bsd.strip gzip -c9n bsd.strip > bsd.gz -bsd.rd: mr.fs bsd rdsetroot +bsd.rd: mr.fs bsd cp bsd bsd.rd - ${.OBJDIR}/rdsetroot bsd.rd mr.fs - + rdsetroot bsd.rd mr.fs bsd: cd ${.CURDIR}/../../../sys/arch/amd64/compile/${RAMDISK} && \ @@ -88,11 +87,6 @@ mr.fs: instbin rm $@.d/instbin makefs ${MAKEFSARGS_RD} $@ $@.d -rdsetroot: ${TOP}/../common/elfrdsetroot.c - ${HOSTCC} ${HOSTCFLAGS} -o rdsetroot \ - ${TOP}/../common/elfrdsetroot.c ${TOP}/../common/elf32.c \ - ${TOP}/../common/elf64.c - .ifdef RELEASEDIR install: .ifndef NOBSDRD @@ -118,8 +112,7 @@ instbin.conf: ${LISTS} clean cleandir: /bin/rm -f *.core mr.fs instbin instbin.mk instbin*.cache \ *.o *.lo *.c bsd bsd.rd bsd.gz bsd.strip floppy*.fs \ - lib*.a lib*.olist instbin.map \ - rdsetroot boot instbin.conf ${FS} + lib*.a lib*.olist instbin.map boot instbin.conf ${FS} /bin/rm -rf mr.fs.d .include <bsd.obj.mk> diff --git a/distrib/amd64/ramdisk_cd/Makefile.inc b/distrib/amd64/ramdisk_cd/Makefile.inc index aa359a76bbe..a4ad30a640d 100644 --- a/distrib/amd64/ramdisk_cd/Makefile.inc +++ b/distrib/amd64/ramdisk_cd/Makefile.inc @@ -1,4 +1,4 @@ -# $OpenBSD: Makefile.inc,v 1.7 2017/08/13 15:41:30 jasper Exp $ +# $OpenBSD: Makefile.inc,v 1.8 2019/04/05 21:08:00 deraadt Exp $ TOP= ${.CURDIR}/.. @@ -71,10 +71,9 @@ bsd.gz: bsd.rd strip -R .comment -R .SUNW_ctf bsd.strip gzip -c9n bsd.strip > bsd.gz -bsd.rd: mr.fs bsd rdsetroot +bsd.rd: mr.fs bsd cp bsd bsd.rd - ${.OBJDIR}/rdsetroot bsd.rd mr.fs - + rdsetroot bsd.rd mr.fs bsd: cd ${.CURDIR}/../../../sys/arch/amd64/compile/${RAMDISK} && \ @@ -94,11 +93,6 @@ mr.fs: instbin df -i /dev/${VND}a vnconfig -u ${VND} -rdsetroot: ${TOP}/../common/elfrdsetroot.c - ${HOSTCC} ${HOSTCFLAGS} -o rdsetroot \ - ${TOP}/../common/elfrdsetroot.c ${TOP}/../common/elf32.c \ - ${TOP}/../common/elf64.c - .ifdef RELEASEDIR install: .ifndef NOBSDRD @@ -124,8 +118,7 @@ instbin.conf: ${LISTS} clean cleandir: /bin/rm -f *.core mr.fs instbin instbin.mk instbin*.cache \ *.o *.lo *.c bsd bsd.rd bsd.gz bsd.strip floppy*.fs \ - lib*.a lib*.olist instbin.map \ - rdsetroot boot instbin.conf ${FS} + lib*.a lib*.olist instbin.map boot instbin.conf ${FS} /bin/rm -rf mr.fs.d .include <bsd.obj.mk> diff --git a/distrib/arm64/ramdisk/Makefile b/distrib/arm64/ramdisk/Makefile index 2f22ce6d087..fa6cc53222e 100644 --- a/distrib/arm64/ramdisk/Makefile +++ b/distrib/arm64/ramdisk/Makefile @@ -1,4 +1,4 @@ -# $OpenBSD: Makefile,v 1.4 2019/01/24 23:27:16 naddy Exp $ +# $OpenBSD: Makefile,v 1.5 2019/04/05 21:08:00 deraadt Exp $ REV= ${OSrev} @@ -36,9 +36,9 @@ bsd: su ${BUILDUSER} -c '${MAKE} config && ${MAKE} clean && exec ${MAKE}' cp -p ${TOP}/../../sys/arch/arm64/compile/RAMDISK/obj/bsd bsd -${BSD_RD}: ${IMAGE} bsd rdsetroot +${BSD_RD}: ${IMAGE} bsd cp bsd ${BSD_RD} - ${.OBJDIR}/rdsetroot ${BSD_RD} ${IMAGE} + rdsetroot ${BSD_RD} ${IMAGE} ${IMAGE}: ${CBIN} rm -rf $@.d @@ -55,11 +55,6 @@ ${IMAGE}: ${CBIN} .endif -rdsetroot: ${TOP}/../common/elfrdsetroot.c - ${HOSTCC} ${HOSTCFLAGS} -o rdsetroot \ - ${TOP}/../common/elfrdsetroot.c ${TOP}/../common/elf32.c \ - ${TOP}/../common/elf64.c - ${CBIN}.mk ${CBIN}.cache ${CBIN}.c: ${CRUNCHCONF} crunchgen -E -D ${.CURDIR}/../../.. -L ${DESTDIR}/usr/lib ${.ALLSRC} @@ -71,8 +66,7 @@ ${CRUNCHCONF}: ${LISTS} clean cleandir: /bin/rm -f *.core ${IMAGE} ${CBIN} ${CBIN}.mk ${CBIN}.cache \ - lib*.a lib*.olist ${CBIN}.map \ - *.o *.lo *.c ${ALLBSD} ${ALLBSDRD} rdsetroot + lib*.a lib*.olist ${CBIN}.map *.o *.lo *.c ${ALLBSD} ${ALLBSDRD} rm -f instbin.conf rm -rf cd-dir ${IMAGE}.d diff --git a/distrib/armv7/ramdisk/Makefile b/distrib/armv7/ramdisk/Makefile index 09deb22e836..eacb92f7170 100644 --- a/distrib/armv7/ramdisk/Makefile +++ b/distrib/armv7/ramdisk/Makefile @@ -1,4 +1,4 @@ -# $OpenBSD: Makefile,v 1.18 2019/01/24 23:27:16 naddy Exp $ +# $OpenBSD: Makefile,v 1.19 2019/04/05 21:08:00 deraadt Exp $ REV= ${OSrev} @@ -40,9 +40,9 @@ bsd: su ${BUILDUSER} -c '${MAKE} config && ${MAKE} clean && exec ${MAKE}' cp -p ${TOP}/../../sys/arch/armv7/compile/RAMDISK/obj/bsd bsd -${BSD_RD}: ${IMAGE} bsd rdsetroot +${BSD_RD}: ${IMAGE} bsd cp bsd ${BSD_RD} - ${.OBJDIR}/rdsetroot ${BSD_RD} ${IMAGE} + rdsetroot ${BSD_RD} ${IMAGE} ${IMAGE}: ${CBIN} rm -rf $@.d @@ -59,11 +59,6 @@ ${IMAGE}: ${CBIN} .endif -rdsetroot: ${TOP}/../common/elfrdsetroot.c - ${HOSTCC} ${HOSTCFLAGS} -o rdsetroot \ - ${TOP}/../common/elfrdsetroot.c ${TOP}/../common/elf32.c \ - ${TOP}/../common/elf64.c - ${CBIN}.mk ${CBIN}.cache ${CBIN}.c: ${CRUNCHCONF} crunchgen -E -D ${.CURDIR}/../../.. -L ${DESTDIR}/usr/lib ${.ALLSRC} @@ -75,8 +70,7 @@ ${CRUNCHCONF}: ${LISTS} clean cleandir: /bin/rm -f *.core ${IMAGE} ${CBIN} ${CBIN}.mk ${CBIN}.cache \ - lib*.a lib*.olist ${CBIN}.map \ - *.o *.lo *.c ${ALLBSD} ${ALLBSDRD} rdsetroot + lib*.a lib*.olist ${CBIN}.map *.o *.lo *.c ${ALLBSD} ${ALLBSDRD} rm -f instbin.conf rm -rf cd-dir ${IMAGE}.d diff --git a/distrib/common/elf32.c b/distrib/common/elf32.c deleted file mode 100644 index f286eef4ae3..00000000000 --- a/distrib/common/elf32.c +++ /dev/null @@ -1,3 +0,0 @@ -/* $OpenBSD: elf32.c,v 1.2 2015/01/20 04:41:01 krw Exp $ */ -#define ELFSIZE 32 -#include "elfrd_size.c" diff --git a/distrib/common/elf64.c b/distrib/common/elf64.c deleted file mode 100644 index 6c093bf53a7..00000000000 --- a/distrib/common/elf64.c +++ /dev/null @@ -1,3 +0,0 @@ -/* $OpenBSD: elf64.c,v 1.2 2015/01/20 04:41:01 krw Exp $ */ -#define ELFSIZE 64 -#include "elfrd_size.c" diff --git a/distrib/common/elfrd_size.c b/distrib/common/elfrd_size.c deleted file mode 100644 index 1590312677b..00000000000 --- a/distrib/common/elfrd_size.c +++ /dev/null @@ -1,381 +0,0 @@ -/* $OpenBSD: elfrd_size.c,v 1.10 2018/06/01 21:20:13 mortimer Exp $ */ - -#include <sys/types.h> -#include <sys/mman.h> -#include <sys/stat.h> - -#include <elf.h> -#include <stdint.h> -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <unistd.h> -#include <nlist.h> - -#include <errno.h> -#include <limits.h> - -#include "elfrdsetroot.h" - -void -ELFNAME(locate_image)(int, struct elfhdr *, char *, long *, long *, off_t *, - size_t *); -int -ELFNAME(find_rd_root_image)(char *, int, Elf_Phdr *, int, long *, long *, - off_t *, size_t *); -int -ELFNAME(nlist)(int, struct nlist *); - -struct elf_fn ELFDEFNNAME(fn) = -{ - ELFNAME(locate_image), - ELFNAME(find_rd_root_image) -}; - -void -ELFNAME(locate_image)(int fd, struct elfhdr *ghead, char *file, - long *prd_root_size_off, long *prd_root_image_off, off_t *pmmap_off, - size_t *pmmap_size) -{ - int n; - int found = 0; - size_t phsize; - Elf_Ehdr head; - - Elf_Phdr *ph; - - /* elfhdr may not have the full header? */ - lseek(fd, 0, SEEK_SET); - - if (read(fd, &head, sizeof(head)) != sizeof(head)) { - fprintf(stderr, "%s: can't read phdr area\n", file); - exit(1); - } - - phsize = head.e_phnum * sizeof(Elf_Phdr); - if ((ph = malloc(phsize)) == NULL) { - perror("malloc"); - exit(1); - } - - lseek(fd, head.e_phoff, SEEK_SET); - - if (read(fd, ph, phsize) != phsize) { - fprintf(stderr, "%s: can't read phdr area\n", file); - exit(1); - } - - for (n = 0; n < head.e_phnum && !found; n++) { - if (ph[n].p_type == PT_LOAD) - found = ELFNAME(find_rd_root_image)(file, fd, &ph[n], - n, prd_root_size_off, prd_root_image_off, - pmmap_off, pmmap_size); - } - if (!found) { - fprintf(stderr, "%s: can't locate space for rd_root_image!\n", - file); - exit(1); - } - free(ph); -} - -struct nlist ELFNAME(wantsyms)[] = { - { "_rd_root_size", 0 }, - { "_rd_root_image", 0 }, - { NULL, 0 } -}; - -int -ELFNAME(find_rd_root_image)(char *file, int fd, Elf_Phdr *ph, int segment, - long *prd_root_size_off, long *prd_root_image_off, off_t *pmmap_off, - size_t *pmmap_size) -{ - unsigned long kernel_start, kernel_size; - uint64_t rd_root_size_off, rd_root_image_off; - - if (ELFNAME(nlist)(fd, ELFNAME(wantsyms))) { - fprintf(stderr, "%s: no rd_root_image symbols?\n", file); - exit(1); - } - kernel_start = ph->p_paddr; - kernel_size = ph->p_filesz; - - rd_root_size_off = ELFNAME(wantsyms)[0].n_value - kernel_start; - if (rd_root_size_off < (ph->p_vaddr - ph->p_paddr)) - return (0); - rd_root_size_off -= (ph->p_vaddr - ph->p_paddr); - - rd_root_image_off = ELFNAME(wantsyms)[1].n_value - kernel_start; - if (rd_root_image_off < (ph->p_vaddr - ph->p_paddr)) - return (0); - rd_root_image_off -= (ph->p_vaddr - ph->p_paddr); - - if (debug) { - fprintf(stderr, "segment %d rd_root_size_off = 0x%llx\n", segment, - rd_root_size_off); - if ((ph->p_vaddr - ph->p_paddr) != 0) - fprintf(stderr, "root_off v %zx p %zx, diff %zx altered %llx\n", - (size_t)ph->p_vaddr, (size_t)ph->p_paddr, - (size_t)(ph->p_vaddr - ph->p_paddr), - rd_root_size_off - (ph->p_vaddr - ph->p_paddr)); - fprintf(stderr, "rd_root_image_off = 0x%llx\n", rd_root_image_off); - } - - /* - * Sanity check locations of db_* symbols - */ - if (rd_root_image_off >= kernel_size) - return (0); - if (rd_root_size_off >= kernel_size) { - fprintf(stderr, "%s: rd_root_size not in data segment?\n", - file); - return (0); - } - *pmmap_off = ph->p_offset; - *pmmap_size = kernel_size; - *prd_root_size_off = rd_root_size_off; - *prd_root_image_off = rd_root_image_off; - return (1); -} - -/* - * __elf_is_okay__ - Determine if ehdr really - * is ELF and valid for the target platform. - * - * WARNING: This is NOT a ELF ABI function and - * as such its use should be restricted. - */ -int -ELFNAME(__elf_is_okay__)(Elf_Ehdr *ehdr) -{ - int retval = 0; - /* - * We need to check magic, class size, endianess, - * and version before we look at the rest of the - * Elf_Ehdr structure. These few elements are - * represented in a machine independent fashion. - */ - if (IS_ELF(*ehdr) && - ehdr->e_ident[EI_DATA] == ELF_TARG_DATA && - ehdr->e_ident[EI_VERSION] == ELF_TARG_VER) { - -#if 0 /* allow cross, no arch check */ - /* Now check the machine dependent header */ - if (ehdr->e_machine == ELF_TARG_MACH && - ehdr->e_version == ELF_TARG_VER) -#endif - retval = 1; - } - - return retval; -} - -#define ISLAST(p) (p->n_name == 0 || p->n_name[0] == 0) -#define MIN(x, y) ((x)<(y)? (x) : (y)) - - -int -ELFNAME(nlist)(int fd, struct nlist *list) -{ - struct nlist *p; - caddr_t strtab; - Elf_Off symoff = 0, symstroff = 0; - Elf_Word symsize = 0; - long symstrsize = 0; - Elf_Sword nent, cc, i; - Elf_Sym sbuf[1024]; - Elf_Sym *s; - Elf_Ehdr ehdr; - Elf_Shdr *shdr = NULL; - size_t shdr_size; - struct stat st; - int usemalloc = 0; - size_t left, len; - - /* Make sure obj is OK */ - if (pread(fd, &ehdr, sizeof(Elf_Ehdr), (off_t)0) != sizeof(Elf_Ehdr) || - !ELFNAME(__elf_is_okay__)(&ehdr) || fstat(fd, &st) < 0) - return (-1); - - /* calculate section header table size */ - shdr_size = ehdr.e_shentsize * ehdr.e_shnum; - - /* Make sure it's not too big to mmap */ - if (SIZE_MAX - ehdr.e_shoff < shdr_size || - (S_ISREG(st.st_mode) && ehdr.e_shoff + shdr_size > st.st_size)) { - errno = EFBIG; - return (-1); - } - - /* mmap section header table */ - shdr = (Elf_Shdr *)mmap(NULL, (size_t)shdr_size, PROT_READ, - MAP_SHARED|MAP_FILE, fd, (off_t) ehdr.e_shoff); - if (shdr == MAP_FAILED) { - usemalloc = 1; - if ((shdr = malloc(shdr_size)) == NULL) - return (-1); - - if (pread(fd, shdr, shdr_size, (off_t)ehdr.e_shoff) != - shdr_size) { - free(shdr); - return (-1); - } - } - - /* - * Find the symbol table entry and its corresponding - * string table entry. Version 1.1 of the ABI states - * that there is only one symbol table but that this - * could change in the future. - */ - for (i = 0; i < ehdr.e_shnum; i++) { - if (shdr[i].sh_type == SHT_SYMTAB) { - if (shdr[i].sh_link >= ehdr.e_shnum) - continue; - symoff = shdr[i].sh_offset; - symsize = shdr[i].sh_size; - symstroff = shdr[shdr[i].sh_link].sh_offset; - symstrsize = shdr[shdr[i].sh_link].sh_size; - break; - } - } - - /* Flush the section header table */ - if (usemalloc) - free(shdr); - else - munmap((caddr_t)shdr, shdr_size); - - /* - * clean out any left-over information for all valid entries. - * Type and value defined to be 0 if not found; historical - * versions cleared other and desc as well. Also figure out - * the largest string length so don't read any more of the - * string table than we have to. - * - * XXX clearing anything other than n_type and n_value violates - * the semantics given in the man page. - */ - nent = 0; - for (p = list; !ISLAST(p); ++p) { - p->n_type = 0; - p->n_other = 0; - p->n_desc = 0; - p->n_value = 0; - ++nent; - } - - /* Don't process any further if object is stripped. */ - /* ELFism - dunno if stripped by looking at header */ - if (symoff == 0) - return nent; - - /* Check for files too large to mmap. */ - if (SIZE_MAX - symstrsize < symstroff || - (S_ISREG(st.st_mode) && symstrsize + symstroff > st.st_size)) { - errno = EFBIG; - return (-1); - } - - /* - * Map string table into our address space. This gives us - * an easy way to randomly access all the strings, without - * making the memory allocation permanent as with malloc/free - * (i.e., munmap will return it to the system). - */ - if (usemalloc) { - if ((strtab = malloc(symstrsize)) == NULL) - return (-1); - if (pread(fd, strtab, symstrsize, (off_t)symstroff) != - symstrsize) { - free(strtab); - return (-1); - } - } else { - strtab = mmap(NULL, (size_t)symstrsize, PROT_READ, - MAP_SHARED|MAP_FILE, fd, (off_t) symstroff); - if (strtab == MAP_FAILED) - return (-1); - } - - while (symsize >= sizeof(Elf_Sym)) { - cc = MIN(symsize, sizeof(sbuf)); - if (pread(fd, sbuf, cc, (off_t)symoff) != cc) - break; - symsize -= cc; - symoff += cc; - for (s = sbuf; cc > 0; ++s, cc -= sizeof(*s)) { - Elf_Word soff = s->st_name; - - if (soff == 0 || soff >= symstrsize) - continue; - left = symstrsize - soff; - - for (p = list; !ISLAST(p); p++) { - char *sym; - - /* - * First we check for the symbol as it was - * provided by the user. If that fails - * and the first char is an '_', skip over - * the '_' and try again. - * XXX - What do we do when the user really - * wants '_foo' and there are symbols - * for both 'foo' and '_foo' in the - * table and 'foo' is first? - */ - sym = p->n_name; - len = strlen(sym); - - if ((len >= left || - strcmp(&strtab[soff], sym) != 0) && - (sym[0] != '_' || len - 1 >= left || - strcmp(&strtab[soff], sym + 1) != 0)) - continue; - - p->n_value = s->st_value; - - /* XXX - type conversion */ - /* is pretty rude. */ - switch(ELF_ST_TYPE(s->st_info)) { - case STT_NOTYPE: - switch (s->st_shndx) { - case SHN_UNDEF: - p->n_type = N_UNDF; - break; - case SHN_ABS: - p->n_type = N_ABS; - break; - case SHN_COMMON: - p->n_type = N_COMM; - break; - default: - p->n_type = N_COMM | N_EXT; - break; - } - break; - case STT_OBJECT: - p->n_type = N_DATA; - break; - case STT_FUNC: - p->n_type = N_TEXT; - break; - case STT_FILE: - p->n_type = N_FN; - break; - } - if (ELF_ST_BIND(s->st_info) == STB_LOCAL) - p->n_type = N_EXT; - p->n_desc = 0; - p->n_other = 0; - if (--nent <= 0) - break; - } - } - } - if (usemalloc) - free(strtab); - else - munmap(strtab, symstrsize); - return (nent); -} diff --git a/distrib/common/elfrdsetroot.c b/distrib/common/elfrdsetroot.c deleted file mode 100644 index 42db343da03..00000000000 --- a/distrib/common/elfrdsetroot.c +++ /dev/null @@ -1,223 +0,0 @@ -/* $OpenBSD: elfrdsetroot.c,v 1.26 2018/04/26 12:42:50 guenther Exp $ */ -/* $NetBSD: rdsetroot.c,v 1.2 1995/10/13 16:38:39 gwr Exp $ */ - -/* - * Copyright (c) 1994 Gordon W. Ross - * Copyright (c) 1997 Per Fogelstrom. (ELF modifications) - * 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. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 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. - */ - -/* - * Copy a ramdisk image into the space reserved for it. - * Kernel variables: rd_root_size, rd_root_image - */ - -#include <sys/types.h> -#include <sys/mman.h> -#include <sys/stat.h> - -#include <elf.h> -#include <fcntl.h> -#include <stdio.h> -#include <stdlib.h> -#include <unistd.h> - -#include "elfrdsetroot.h" - -struct elfhdr head; - -/* Offsets relative to start of data segment. */ -long rd_root_image_off, rd_root_size_off; - -/* value in the location at rd_root_size_off */ -off_t rd_root_size_val; - -/* pointers to pieces of mapped file */ -char *dataseg; - -/* parameters to mmap digged out from program header */ -off_t mmap_off; -size_t mmap_size; - -__dead void usage(void); - -int debug; - -struct elf_fn *elf_fn; - -int -main(int argc, char *argv[]) -{ - int ch, fd, n, xflag = 0, fsd; - char *fs = NULL; - char *file; - u_int32_t *ip; - - while ((ch = getopt(argc, argv, "dx")) != -1) { - switch (ch) { - case 'd': - debug = 1; - break; - case 'x': - xflag = 1; - break; - default: - usage(); - } - } - argc -= optind; - argv += optind; - - if (argc == 1) - file = argv[0]; - else if (argc == 2) { - file = argv[0]; - fs = argv[1]; - } else - usage(); - - fd = open(file, xflag ? O_RDONLY : O_RDWR, 0644); - if (fd < 0) { - perror(file); - exit(1); - } - - if (fs) { - if (xflag) - fsd = open(fs, O_RDWR | O_CREAT | O_TRUNC, 0644); - else - fsd = open(fs, O_RDONLY, 0644); - } else { - if (xflag) - fsd = dup(STDOUT_FILENO); - else - fsd = dup(STDIN_FILENO); - } - if (fsd < 0) { - perror(fs); - exit(1); - } - - if (pledge("stdio", NULL) == -1) { - perror("pledge"); - exit(1); - } - - n = read(fd, &head, sizeof(head)); - if (n < sizeof(head)) { - fprintf(stderr, "%s: reading header\n", file); - exit(1); - } - - if (!IS_ELF(head)) { - fprintf(stderr, "%s: bad magic number\n", file); - exit(1); - } - - if (head.e_ident[EI_CLASS] == ELFCLASS32) { - elf_fn = &ELF32_fn; - } else if (head.e_ident[EI_CLASS] == ELFCLASS64) { - elf_fn = &ELF64_fn; - } else { - fprintf(stderr, "%s: invalid elf, not 32 or 64 bit", file); - exit(1); - } - - elf_fn->locate_image(fd, &head, file, &rd_root_size_off, - &rd_root_image_off, &mmap_off, &mmap_size); - - /* - * Map in the whole data segment. - * The file offset needs to be page aligned. - */ - dataseg = mmap(NULL, mmap_size, - xflag ? PROT_READ : PROT_READ | PROT_WRITE, - MAP_SHARED, fd, mmap_off); - if (dataseg == MAP_FAILED) { - fprintf(stderr, "%s: can not map data seg\n", file); - perror(file); - exit(1); - } - - /* - * Find value in the location: rd_root_size - */ - ip = (u_int32_t *) (dataseg + rd_root_size_off); - rd_root_size_val = *ip; - if (debug) - fprintf(stderr, "rd_root_size val: 0x%llx (%lld blocks)\n", - (unsigned long long)rd_root_size_val, - (unsigned long long)rd_root_size_val >> 9); - - /* - * Copy the symbol table and string table. - */ - if (debug) - fprintf(stderr, "copying root image...\n"); - - if (xflag) { - n = write(fsd, dataseg + rd_root_image_off, - (size_t)rd_root_size_val); - if (n != rd_root_size_val) { - perror("write"); - exit(1); - } - } else { - struct stat sstat; - - if (fstat(fsd, &sstat) == -1) { - perror("fstat"); - exit(1); - } - if (S_ISREG(sstat.st_mode) && - sstat.st_size > rd_root_size_val) { - fprintf(stderr, "ramdisk too small 0x%llx 0x%llx\n", - (unsigned long long)sstat.st_size, - (unsigned long long)rd_root_size_val); - exit(1); - } - n = read(fsd, dataseg + rd_root_image_off, - (size_t)rd_root_size_val); - if (n < 0) { - perror("read"); - exit(1); - } - - msync(dataseg, mmap_size, 0); - } - - if (debug) - fprintf(stderr, "...copied %d bytes\n", n); - exit(0); -} - -__dead void -usage(void) -{ - extern char *__progname; - - fprintf(stderr, "usage: %s [-dx] bsd [fs]\n", __progname); - exit(1); -} diff --git a/distrib/common/elfrdsetroot.h b/distrib/common/elfrdsetroot.h deleted file mode 100644 index e32391aaadc..00000000000 --- a/distrib/common/elfrdsetroot.h +++ /dev/null @@ -1,13 +0,0 @@ -/* $OpenBSD: elfrdsetroot.h,v 1.3 2017/12/03 19:32:19 tb Exp $ */ - -struct elf_fn { - void (*locate_image)(int, struct elfhdr *, char *, long *, long *, - off_t *, size_t *); - int (*find_rd_root_image)(char *, int, Elf_Phdr *, int, long *, long *, - off_t *, size_t *); - -}; - -extern int debug; -extern struct elf_fn ELF32_fn; -extern struct elf_fn ELF64_fn; diff --git a/distrib/hppa/ramdisk/Makefile b/distrib/hppa/ramdisk/Makefile index f11c8b5f399..e775f740c5e 100644 --- a/distrib/hppa/ramdisk/Makefile +++ b/distrib/hppa/ramdisk/Makefile @@ -1,4 +1,4 @@ -# $OpenBSD: Makefile,v 1.35 2017/09/18 20:13:52 jasper Exp $ +# $OpenBSD: Makefile,v 1.36 2019/04/05 21:08:00 deraadt Exp $ CBIN= instbin ARCHDIR= ${.CURDIR}/.. @@ -52,20 +52,14 @@ obsd: su ${BUILDUSER} -c '${MAKE} config && ${MAKE} clean && exec ${MAKE}' cp -p ${SRCDIR}/sys/arch/${MACHINE}/compile/${KERNEL}/obj/bsd obsd -bsd.rd: obsd ${IMAGE} rdsetroot +bsd.rd: obsd ${IMAGE} cp obsd bsd.rd - ${.OBJDIR}/rdsetroot bsd.rd ${IMAGE} + rdsetroot bsd.rd ${IMAGE} strip ${STRIPOPTS} bsd.rd bsd: bsd.rd (cat bsd.rd ; dd if=/dev/zero count=1) | gzip ${GZIPFLAGS} > bsd -rdsetroot: ${.CURDIR}/../../common/elfrdsetroot.c \ - ${.CURDIR}/../../common/elf32.c ${.CURDIR}/../../common/elf64.c - ${HOSTCC} ${HOSTCCFLAGS} -o rdsetroot \ - ${.CURDIR}/../../common/elfrdsetroot.c \ - ${.CURDIR}/../../common/elf32.c ${.CURDIR}/../../common/elf64.c - ${IMAGE}: ${CBIN} rm -rf $@.d install -d -o root -g wheel $@.d diff --git a/distrib/i386/common/Makefile.inc b/distrib/i386/common/Makefile.inc index 8823497eb10..e755d39c92c 100644 --- a/distrib/i386/common/Makefile.inc +++ b/distrib/i386/common/Makefile.inc @@ -1,4 +1,4 @@ -# $OpenBSD: Makefile.inc,v 1.44 2017/08/13 15:41:30 jasper Exp $ +# $OpenBSD: Makefile.inc,v 1.45 2019/04/05 21:08:00 deraadt Exp $ TOP= ${.CURDIR}/.. @@ -65,10 +65,9 @@ bsd.gz: bsd.rd strip -R .comment -R .SUNW_ctf bsd.strip gzip -c9n bsd.strip > bsd.gz -bsd.rd: ${IMAGE} bsd rdsetroot +bsd.rd: ${IMAGE} bsd cp bsd bsd.rd - ${.OBJDIR}/rdsetroot bsd.rd ${IMAGE} - + rdsetroot bsd.rd ${IMAGE} bsd: cd ${.CURDIR}/../../../sys/arch/i386/compile/${RAMDISK} && \ @@ -88,11 +87,6 @@ ${IMAGE}: ${CBIN} df -i /dev/${VND}a vnconfig -u ${VND} -rdsetroot: ${TOP}/../common/elfrdsetroot.c - ${HOSTCC} ${HOSTCFLAGS} -o rdsetroot \ - ${TOP}/../common/elfrdsetroot.c ${TOP}/../common/elf32.c \ - ${TOP}/../common/elf64.c - .ifdef RELEASEDIR install: .ifndef NOBSDRD @@ -118,8 +112,7 @@ ${CRUNCHCONF}: ${LISTS} clean cleandir: /bin/rm -f *.core ${IMAGE} ${CBIN} ${CBIN}.mk ${CBIN}*.cache \ *.o *.lo *.c bsd bsd.rd bsd.gz bsd.strip floppy*.fs \ - lib*.a lib*.olist ${CBIN}.map \ - rdsetroot boot ${CRUNCHCONF} ${FS} + lib*.a lib*.olist ${CBIN}.map boot ${CRUNCHCONF} ${FS} /bin/rm -rf ${IMAGE}.d .include <bsd.obj.mk> diff --git a/distrib/landisk/ramdisk/Makefile b/distrib/landisk/ramdisk/Makefile index b8cd8f4bdfa..ef257130c32 100644 --- a/distrib/landisk/ramdisk/Makefile +++ b/distrib/landisk/ramdisk/Makefile @@ -1,4 +1,4 @@ -# $OpenBSD: Makefile,v 1.20 2017/01/08 14:42:12 natano Exp $ +# $OpenBSD: Makefile,v 1.21 2019/04/05 21:08:00 deraadt Exp $ REV= ${OSrev} @@ -26,9 +26,9 @@ all ${IMAGE}: # mix config is not needed. all: ${BSD_RD} -${BSD_RD}: ${IMAGE} bsd rdsetroot +${BSD_RD}: ${IMAGE} bsd cp bsd ${BSD_RD} - ${.OBJDIR}/rdsetroot ${BSD_RD} ${IMAGE} + rdsetroot ${BSD_RD} ${IMAGE} ${IMAGE}: ${CBIN} rm -rf $@.d @@ -47,11 +47,6 @@ bsd: su ${BUILDUSER} -c '${MAKE} config && ${MAKE} clean && exec ${MAKE}' cp -p ${TOP}/../../sys/arch/landisk/compile/RAMDISK/obj/bsd bsd -rdsetroot: ${TOP}/../common/elfrdsetroot.c - ${HOSTCC} ${HOSTCFLAGS} -o rdsetroot \ - ${TOP}/../common/elfrdsetroot.c ${TOP}/../common/elf32.c \ - ${TOP}/../common/elf64.c - .ifdef RELEASEDIR install: cp ${BSD_RD} ${RELEASEDIR} @@ -68,8 +63,7 @@ ${CRUNCHCONF}: ${LISTS} clean cleandir: /bin/rm -f *.core ${IMAGE} ${CBIN} ${CBIN}.mk ${CBIN}.cache \ - lib*.a lib*.olist ${CBIN}.map \ - *.o *.lo *.c bsd ${BSD_RD} rdsetroot + lib*.a lib*.olist ${CBIN}.map *.o *.lo *.c bsd ${BSD_RD} rm -f instbin.conf rm -rf cd-dir ${IMAGE}.d diff --git a/distrib/loongson/ramdisk/Makefile b/distrib/loongson/ramdisk/Makefile index c2a2b553cfe..b5942266a35 100644 --- a/distrib/loongson/ramdisk/Makefile +++ b/distrib/loongson/ramdisk/Makefile @@ -1,4 +1,4 @@ -# $OpenBSD: Makefile,v 1.12 2016/12/11 10:01:01 natano Exp $ +# $OpenBSD: Makefile,v 1.13 2019/04/05 21:08:00 deraadt Exp $ REV= ${OSrev} @@ -26,9 +26,9 @@ all ${IMAGE}: # mix config is not needed. all: ${BSD_RD} -${BSD_RD}: ${IMAGE} bsd rdsetroot +${BSD_RD}: ${IMAGE} bsd cp bsd ${BSD_RD} - ${.OBJDIR}/rdsetroot ${BSD_RD} ${IMAGE} + rdsetroot ${BSD_RD} ${IMAGE} ${IMAGE}: ${CBIN} rm -rf $@.d @@ -47,11 +47,6 @@ bsd: su ${BUILDUSER} -c '${MAKE} config && ${MAKE} clean && exec ${MAKE}' cp -p ${TOP}/../../sys/arch/loongson/compile/RAMDISK/obj/bsd bsd -rdsetroot: ${TOP}/../common/elfrdsetroot.c - ${HOSTCC} ${HOSTCFLAGS} -o rdsetroot \ - ${TOP}/../common/elfrdsetroot.c ${TOP}/../common/elf32.c \ - ${TOP}/../common/elf64.c - ${CBIN}.mk ${CBIN}.cache ${CBIN}.c: ${CRUNCHCONF} crunchgen -EM -D ${.CURDIR}/../../.. -L ${DESTDIR}/usr/lib ${.ALLSRC} @@ -63,8 +58,7 @@ ${CRUNCHCONF}: ${LISTS} clean cleandir: /bin/rm -f *.core ${IMAGE} ${CBIN} ${CBIN}.mk ${CBIN}.cache \ - lib*.a lib*.olist ${CBIN}.map \ - *.o *.lo *.c bsd ${BSD_RD} cd${REV}.iso rdsetroot + lib*.a lib*.olist ${CBIN}.map *.o *.lo *.c bsd ${BSD_RD} cd${REV}.iso rm -rf cd-dir ${IMAGE}.d .ifdef RELEASEDIR diff --git a/distrib/luna88k/ramdisk/Makefile b/distrib/luna88k/ramdisk/Makefile index bcac913eaf4..9e2e1ed05ff 100644 --- a/distrib/luna88k/ramdisk/Makefile +++ b/distrib/luna88k/ramdisk/Makefile @@ -1,4 +1,4 @@ -# $OpenBSD: Makefile,v 1.19 2017/01/27 17:59:09 natano Exp $ +# $OpenBSD: Makefile,v 1.20 2019/04/05 21:08:00 deraadt Exp $ TOP= ${.CURDIR}/.. @@ -15,9 +15,9 @@ MAKEFSARGS_RD= -o disklabel=${DISKTYPE},minfree=0 all: ${BSD_RD} -${BSD_RD}: ${IMAGE} bsd rdsetroot +${BSD_RD}: ${IMAGE} bsd cp bsd ${BSD_RD} - ${.OBJDIR}/rdsetroot ${BSD_RD} ${IMAGE} + rdsetroot ${BSD_RD} ${IMAGE} ${IMAGE}: ${CBIN} rm -rf $@.d @@ -36,11 +36,6 @@ bsd: .endif cp -p ${.CURDIR}/../../../sys/arch/luna88k/compile/RAMDISK/obj/bsd bsd -rdsetroot: ${TOP}/../common/elfrdsetroot.c - ${HOSTCC} -o rdsetroot \ - ${TOP}/../common/elfrdsetroot.c ${TOP}/../common/elf32.c \ - ${TOP}/../common/elf64.c - .ifdef RELEASEDIR install: cp ${BSD_RD} ${RELEASEDIR} @@ -57,8 +52,7 @@ ${CBIN}: ${CBIN}.mk ${CBIN}.cache ${CBIN}.c clean cleandir: /bin/rm -f *.core ${IMAGE} ${CBIN} ${CBIN}.conf ${CBIN}.mk ${CBIN}.cache \ - lib*.a lib*.olist ${CBIN}.map \ - *.o *.lo *.c bsd ${BSD_RD} rdsetroot + lib*.a lib*.olist ${CBIN}.map *.o *.lo *.c bsd ${BSD_RD} /bin/rm -rf ${IMAGE}.d .include <bsd.obj.mk> diff --git a/distrib/macppc/ramdisk/Makefile b/distrib/macppc/ramdisk/Makefile index e982f38e7b4..0f1ea7f2845 100644 --- a/distrib/macppc/ramdisk/Makefile +++ b/distrib/macppc/ramdisk/Makefile @@ -1,4 +1,4 @@ -# $OpenBSD: Makefile,v 1.34 2017/08/13 15:41:30 jasper Exp $ +# $OpenBSD: Makefile,v 1.35 2019/04/05 21:08:00 deraadt Exp $ REV= ${OSrev} @@ -26,9 +26,9 @@ all ${IMAGE}: # mix config is not needed. all: ${BSD_RD} cd -${BSD_RD}: ${IMAGE} bsd rdsetroot +${BSD_RD}: ${IMAGE} bsd cp bsd ${BSD_RD} - ${.OBJDIR}/rdsetroot ${BSD_RD} ${IMAGE} + rdsetroot ${BSD_RD} ${IMAGE} cd: ${BSD_RD} -rm -rf ${.OBJDIR}/cd-dir/ @@ -73,11 +73,6 @@ bsd: su ${BUILDUSER} -c '${MAKE} config && ${MAKE} clean && exec ${MAKE}' cp -p ${TOP}/../../sys/arch/macppc/compile/RAMDISK/obj/bsd bsd -rdsetroot: ${TOP}/../common/elfrdsetroot.c - ${HOSTCC} ${HOSTCFLAGS} -o rdsetroot \ - ${TOP}/../common/elfrdsetroot.c ${TOP}/../common/elf32.c \ - ${TOP}/../common/elf64.c - ${CBIN}.mk ${CBIN}.cache ${CBIN}.c: ${CRUNCHCONF} crunchgen -E -D ${.CURDIR}/../../.. -L ${DESTDIR}/usr/lib ${.ALLSRC} @@ -89,8 +84,7 @@ ${CRUNCHCONF}: ${LISTS} clean cleandir: /bin/rm -f *.core ${IMAGE} ${CBIN} ${CBIN}.mk ${CBIN}.cache \ - lib*.a lib*.olist ${CBIN}.map \ - *.o *.lo *.c bsd ${BSD_RD} cd${REV}.iso rdsetroot + lib*.a lib*.olist ${CBIN}.map *.o *.lo *.c bsd ${BSD_RD} cd${REV}.iso rm -rf cd-dir ${IMAGE}.d .ifdef RELEASEDIR diff --git a/distrib/octeon/ramdisk/Makefile b/distrib/octeon/ramdisk/Makefile index 9752eb8f889..26b6b1b95f5 100644 --- a/distrib/octeon/ramdisk/Makefile +++ b/distrib/octeon/ramdisk/Makefile @@ -1,4 +1,4 @@ -# $OpenBSD: Makefile,v 1.5 2016/12/05 20:08:34 natano Exp $ +# $OpenBSD: Makefile,v 1.6 2019/04/05 21:08:00 deraadt Exp $ REV= ${OSrev} @@ -20,9 +20,9 @@ MAKEFSARGS_RD= -o disklabel=${DISKTYPE},minfree=0,density=4096 # mix config is not needed. all: ${BSD_RD} -${BSD_RD}: ${IMAGE} bsd rdsetroot +${BSD_RD}: ${IMAGE} bsd cp bsd ${BSD_RD} - ${.OBJDIR}/rdsetroot ${BSD_RD} ${IMAGE} + rdsetroot ${BSD_RD} ${IMAGE} ${IMAGE}: ${CBIN} rm -rf $@.d @@ -39,11 +39,6 @@ bsd: su ${BUILDUSER} -c '${MAKE} config && ${MAKE} clean && exec ${MAKE}' cp -p ${TOP}/../../sys/arch/octeon/compile/RAMDISK/obj/bsd bsd -rdsetroot: ${TOP}/../common/elfrdsetroot.c - ${HOSTCC} ${HOSTCFLAGS} -o rdsetroot \ - ${TOP}/../common/elfrdsetroot.c ${TOP}/../common/elf32.c \ - ${TOP}/../common/elf64.c - ${CBIN}.mk ${CBIN}.cache ${CBIN}.c: ${CRUNCHCONF} crunchgen -M -E -D ${.CURDIR}/../../.. -L ${DESTDIR}/usr/lib ${.ALLSRC} @@ -55,8 +50,7 @@ ${CRUNCHCONF}: ${LISTS} clean cleandir: /bin/rm -f *.core ${IMAGE} ${CBIN} ${CBIN}.mk ${CBIN}.cache \ - lib*.a lib*.olist ${CBIN}.map \ - *.o *.lo *.c bsd ${BSD_RD} rdsetroot + lib*.a lib*.olist ${CBIN}.map *.o *.lo *.c bsd ${BSD_RD} rm -rf cd-dir ${IMAGE}.d .ifdef RELEASEDIR diff --git a/distrib/ramdisk/Makefile b/distrib/ramdisk/Makefile index 6cd91b6cd26..a610b4292d5 100644 --- a/distrib/ramdisk/Makefile +++ b/distrib/ramdisk/Makefile @@ -1,4 +1,4 @@ -# $OpenBSD: Makefile,v 1.52 2017/09/18 20:13:52 jasper Exp $ +# $OpenBSD: Makefile,v 1.53 2019/04/05 21:08:01 deraadt Exp $ REV= ${OSrev} @@ -21,7 +21,6 @@ REALIMAGE!= echo /var/tmp/image.${PID} IMAGE?= ramdisk${REV}.fs IMAGESIZE?= 8192 # 4MB in 512 byte blocks NEWFS_WILL_FAIL?=false -RDSETROOT_EXT_SRC=${.CURDIR}/../common/elf32.c ${.CURDIR}/../common/elf64.c CRUNCHGENOPTS?=-E KERNEL?= RAMDISK UTILS?= ${.CURDIR}/../miniroot @@ -76,18 +75,14 @@ bsd: su ${BUILDUSER} -c '${MAKE} config && ${MAKE} clean && env COPTS=-Oz ${MAKE}' cp -p ${.CURDIR}/../../sys/arch/${MACHINE}/compile/${KERNEL}/obj/bsd bsd -bsd.rd: bsd ${IMAGE} rdsetroot +bsd.rd: bsd ${IMAGE} cp bsd bsd.rd - ${.OBJDIR}/rdsetroot bsd.rd ${IMAGE} + rdsetroot bsd.rd ${IMAGE} strip -R .SUNW_ctf bsd.rd bsd.gz: bsd.rd gzip ${GZIPFLAGS} < bsd.rd > bsd.gz -rdsetroot: ${.CURDIR}/../common/elfrdsetroot.c ${RDSETROOT_EXT_SRC} - ${HOSTCC} ${HOSTCCFLAGS} -o rdsetroot ${RDSETROOT_EXT_SRC} \ - ${.CURDIR}/../common/elfrdsetroot.c - ${IMAGE}: ${CBIN} dd if=/dev/zero of=${REALIMAGE} count=${IMAGESIZE} vnconfig -v -c ${VND} ${REALIMAGE} @@ -119,8 +114,7 @@ ${CBIN}: ${CBIN}.mk ${CBIN}.cache ${CBIN}.c clean cleandir: /bin/rm -f *.core ${IMAGE} ${CBIN} ${CBIN}.mk ${CBIN}.cache \ - lib*.a lib*.olist ${CBIN}.map \ - ${CBIN}.conf *.o *.lo *.c bsd bsd.* + lib*.a lib*.olist ${CBIN}.map ${CBIN}.conf *.o *.lo *.c bsd bsd.* .endif # DESTDIR check diff --git a/distrib/sgi/ramdisk/Makefile b/distrib/sgi/ramdisk/Makefile index 25b4c4f6440..a1d91543e08 100644 --- a/distrib/sgi/ramdisk/Makefile +++ b/distrib/sgi/ramdisk/Makefile @@ -1,4 +1,4 @@ -# $OpenBSD: Makefile,v 1.23 2016/12/06 19:46:11 natano Exp $ +# $OpenBSD: Makefile,v 1.24 2019/04/05 21:08:01 deraadt Exp $ REV= ${OSrev} @@ -40,9 +40,9 @@ bsd.IP${IP}: .endif cp -p ${.TOP}/../../sys/arch/sgi/compile/RAMDISK-IP${IP}/obj/bsd bsd.IP${IP} -${BSD_RD}.IP${IP}: ${IMAGE} bsd.IP${IP} rdsetroot +${BSD_RD}.IP${IP}: ${IMAGE} bsd.IP${IP} cp bsd.IP${IP} ${BSD_RD}.IP${IP} - ${.OBJDIR}/rdsetroot ${BSD_RD}.IP${IP} ${IMAGE} + rdsetroot ${BSD_RD}.IP${IP} ${IMAGE} .endfor ${IMAGE}: ${CBIN} @@ -57,11 +57,6 @@ ${IMAGE}: ${CBIN} .endif -rdsetroot: ${TOP}/../common/elfrdsetroot.c - ${HOSTCC} ${HOSTCFLAGS} -o rdsetroot \ - ${TOP}/../common/elfrdsetroot.c ${TOP}/../common/elf32.c \ - ${TOP}/../common/elf64.c - ${CBIN}.mk ${CBIN}.cache ${CBIN}.c: ${CRUNCHCONF} crunchgen -M -E -D ${.CURDIR}/../../.. -L ${DESTDIR}/usr/lib ${.ALLSRC} @@ -73,8 +68,7 @@ ${CRUNCHCONF}: ${LISTS} clean cleandir: /bin/rm -f *.core ${IMAGE} ${CBIN} ${CBIN}.mk ${CBIN}.cache \ - lib*.a lib*.olist ${CBIN}.map \ - ${ALLBSD} ${ALLBSDRD} *.o *.lo *.c rdsetroot + lib*.a lib*.olist ${CBIN}.map ${ALLBSD} ${ALLBSDRD} *.o *.lo *.c /bin/rm -rf ${IMAGE}.d .ifdef RELEASEDIR diff --git a/distrib/socppc/ramdisk/Makefile b/distrib/socppc/ramdisk/Makefile index b4e9bb3ed71..3805c198427 100644 --- a/distrib/socppc/ramdisk/Makefile +++ b/distrib/socppc/ramdisk/Makefile @@ -1,4 +1,4 @@ -# $OpenBSD: Makefile,v 1.17 2017/07/25 13:32:14 robert Exp $ +# $OpenBSD: Makefile,v 1.18 2019/04/05 21:08:01 deraadt Exp $ REV= ${OSrev} @@ -27,9 +27,9 @@ all ${IMAGE}: # mix config is not needed. all: ${BSD_RD} ${BSD_BIN} -${BSD_RD}: ${IMAGE} bsd rdsetroot +${BSD_RD}: ${IMAGE} bsd cp bsd ${BSD_RD} - ${.OBJDIR}/rdsetroot ${BSD_RD} ${IMAGE} + rdsetroot ${BSD_RD} ${IMAGE} ${BSD_BIN}: ${BSD_RD} objcopy -O binary ${BSD_RD} ${BSD_BIN} @@ -51,11 +51,6 @@ bsd: su ${BUILDUSER} -c '${MAKE} config && ${MAKE} clean && env COPTS=-Oz ${MAKE}' cp -p ${TOP}/../../sys/arch/socppc/compile/RAMDISK/obj/bsd bsd -rdsetroot: ${TOP}/../common/elfrdsetroot.c - ${HOSTCC} ${HOSTCFLAGS} -o rdsetroot \ - ${TOP}/../common/elfrdsetroot.c ${TOP}/../common/elf32.c \ - ${TOP}/../common/elf64.c - ${CBIN}.mk ${CBIN}.cache ${CBIN}.c: ${CRUNCHCONF} crunchgen -E -D ${.CURDIR}/../../.. -L ${DESTDIR}/usr/lib ${.ALLSRC} @@ -67,8 +62,7 @@ ${CRUNCHCONF}: ${LISTS} clean cleandir: /bin/rm -f *.core ${IMAGE} ${CBIN} ${CBIN}.mk ${CBIN}.cache \ - lib*.a lib*.olist ${CBIN}.map \ - *.o *.lo *.c bsd ${BSD_RD} cd${REV}.iso rdsetroot + lib*.a lib*.olist ${CBIN}.map *.o *.lo *.c bsd ${BSD_RD} cd${REV}.iso rm -rf cd-dir ${IMAGE}.d .ifdef RELEASEDIR diff --git a/distrib/sparc64/bsd.rd/Makefile b/distrib/sparc64/bsd.rd/Makefile index 317485d68e1..15b60a0ad2c 100644 --- a/distrib/sparc64/bsd.rd/Makefile +++ b/distrib/sparc64/bsd.rd/Makefile @@ -1,4 +1,4 @@ -# $OpenBSD: Makefile,v 1.35 2017/09/18 20:13:53 jasper Exp $ +# $OpenBSD: Makefile,v 1.36 2019/04/05 21:08:01 deraadt Exp $ TOP= ${.CURDIR}/.. @@ -24,9 +24,9 @@ bsd.rd: bsd.rd_unz strip ${STRIPOPTS} bsd.strip gzip -c ${GZIPFLAGS} bsd.strip > bsd.rd -bsd.rd_unz: bsd ${IMAGE} rdsetroot +bsd.rd_unz: bsd ${IMAGE} cp bsd bsd.rd_unz - ${.OBJDIR}/rdsetroot bsd.rd_unz ${IMAGE} + rdsetroot bsd.rd_unz ${IMAGE} bsd: cd ${.CURDIR}/../../../sys/arch/sparc64/compile/${RAMDISK} && \ @@ -43,11 +43,6 @@ ${IMAGE}: ${CBIN} rm $@.d/${CBIN} makefs ${MAKEFSARGS_RD} $@ $@.d -rdsetroot: ${TOP}/../common/elfrdsetroot.c - ${HOSTCC} ${HOSTCFLAGS} -o rdsetroot \ - ${TOP}/../common/elfrdsetroot.c ${TOP}/../common/elf32.c \ - ${TOP}/../common/elf64.c - .ifdef RELEASEDIR install: .ifndef NOBSDRD @@ -69,7 +64,7 @@ ${CBIN}: ${CBIN}.mk ${CBIN}.cache ${CBIN}.c clean cleandir: /bin/rm -f *.core ${IMAGE} ${CBIN} ${CBIN}.mk ${CBIN}*.cache \ lib*.a lib*.olist ${CBIN}.map \ - *.o *.lo *.c bsd bsd.rd{,_unz} bsd.gz bsd.strip floppy*.fs rdsetroot + *.o *.lo *.c bsd bsd.rd{,_unz} bsd.gz bsd.strip floppy*.fs /bin/rm -rf ${IMAGE}.d .include <bsd.obj.mk> diff --git a/distrib/sparc64/common/Makefile.inc b/distrib/sparc64/common/Makefile.inc index 8f46729c38b..2daadf3527d 100644 --- a/distrib/sparc64/common/Makefile.inc +++ b/distrib/sparc64/common/Makefile.inc @@ -1,4 +1,4 @@ -# $OpenBSD: Makefile.inc,v 1.17 2017/06/03 22:25:19 deraadt Exp $ +# $OpenBSD: Makefile.inc,v 1.18 2019/04/05 21:08:01 deraadt Exp $ TOP= ${.CURDIR}/.. @@ -67,9 +67,6 @@ rd_teardown: cp ${REALIMAGE} ${IMAGE} rm ${REALIMAGE} -rdsetroot: ${TOP}/../../common/elfrdsetroot.c - ${HOSTCC} -o rdsetroot ${TOP}/../../common/elfrdsetroot.c - unconfig: -umount -f ${MOUNT_POINT} -vnconfig -u ${VND} @@ -103,6 +100,6 @@ do_files: clean cleandir: /bin/rm -f *.core ${IMAGE} ${CBIN} ${CBIN}.mk ${CBIN}*.cache \ lib*.a lib*.olist ${CBIN}.map \ - *.o *.lo *.c bsd bsd.rd bsd.gz bsd.strip floppy*.fs rdsetroot + *.o *.lo *.c bsd bsd.rd bsd.gz bsd.strip floppy*.fs .include <bsd.subdir.mk> diff --git a/distrib/sparc64/ramdisk/Makefile b/distrib/sparc64/ramdisk/Makefile index 7c0f93fec4b..9acd15ce1d6 100644 --- a/distrib/sparc64/ramdisk/Makefile +++ b/distrib/sparc64/ramdisk/Makefile @@ -1,4 +1,4 @@ -# $OpenBSD: Makefile,v 1.36 2017/09/19 19:23:57 jasper Exp $ +# $OpenBSD: Makefile,v 1.37 2019/04/05 21:08:01 deraadt Exp $ TOP= ${.CURDIR}/.. @@ -58,9 +58,9 @@ ${FLOPPY}: bsd.gz ${BOOT} /usr/ dd if=${REALIMAGE} of=${FLOPPY} count=${FLOPPYSIZE} rm -f ${REALIMAGE} -${BSD_RD}: ${CBIN} ${IMAGE} bsd elfrdsetroot +${BSD_RD}: ${CBIN} ${IMAGE} bsd cp bsd ${BSD_RD} - ${.OBJDIR}/elfrdsetroot ${BSD_RD} < ${IMAGE} + rdsetroot ${BSD_RD} ${IMAGE} strip -R .SUNW_ctf ${BSD_RD} ${IMAGE}: ${CBIN} @@ -80,11 +80,6 @@ bsd: su ${BUILDUSER} -c '${MAKE} config && ${MAKE} clean && env COPTS=-Oz ${MAKE}' cp -p ${TOP}/../../sys/arch/sparc64/compile/${KERNEL}/obj/bsd bsd -elfrdsetroot: ${TOP}/../common/elfrdsetroot.c - ${HOSTCC} ${HOSTCFLAGS} -o elfrdsetroot \ - ${TOP}/../common/elfrdsetroot.c ${TOP}/../common/elf32.c \ - ${TOP}/../common/elf64.c - unconfig: -umount -f ${MOUNT_POINT} -vnconfig -u ${VND} @@ -101,7 +96,7 @@ ${CBIN}: ${CBIN}.mk ${CBIN}.cache ${CBIN}.c clean cleandir: /bin/rm -f *.core ${IMAGE} ${CBIN} ${CBIN}.mk ${CBIN}.cache \ lib*.a lib*.olist ${CBIN}.map \ - *.o *.lo *.c bsd ${BSD_RD} bsd.gz ${FLOPPY} elfrdsetroot + *.o *.lo *.c bsd ${BSD_RD} bsd.gz ${FLOPPY} /bin/rm -rf ${IMAGE}.d .ifdef RELEASEDIR diff --git a/distrib/sparc64/ramdiskB/Makefile b/distrib/sparc64/ramdiskB/Makefile index e66e426ad90..940f5a1801e 100644 --- a/distrib/sparc64/ramdiskB/Makefile +++ b/distrib/sparc64/ramdiskB/Makefile @@ -1,4 +1,4 @@ -# $OpenBSD: Makefile,v 1.30 2017/09/19 19:23:57 jasper Exp $ +# $OpenBSD: Makefile,v 1.31 2019/04/05 21:08:01 deraadt Exp $ TOP= ${.CURDIR}/.. @@ -58,9 +58,9 @@ ${FLOPPY}: bsd.gz ${BOOT} /usr/ dd if=${REALIMAGE} of=${FLOPPY} count=${FLOPPYSIZE} rm -f ${REALIMAGE} -${BSD_RD}: ${CBIN} ${IMAGE} bsd elfrdsetroot +${BSD_RD}: ${CBIN} ${IMAGE} bsd cp bsd ${BSD_RD} - ${.OBJDIR}/elfrdsetroot ${BSD_RD} < ${IMAGE} + rdsetroot ${BSD_RD} ${IMAGE} strip -R .SUNW_ctf ${BSD_RD} ${IMAGE}: ${CBIN} @@ -80,11 +80,6 @@ bsd: su ${BUILDUSER} -c '${MAKE} config && ${MAKE} clean && env COPTS=-Oz ${MAKE}' cp -p ${TOP}/../../sys/arch/sparc64/compile/${KERNEL}/obj/bsd bsd -elfrdsetroot: ${TOP}/../common/elfrdsetroot.c - ${HOSTCC} ${HOSTCFLAGS} -o elfrdsetroot \ - ${TOP}/../common/elfrdsetroot.c ${TOP}/../common/elf32.c \ - ${TOP}/../common/elf64.c - unconfig: -umount -f ${MOUNT_POINT} -vnconfig -u ${VND} @@ -101,7 +96,7 @@ ${CBIN}: ${CBIN}.mk ${CBIN}.cache ${CBIN}.c clean cleandir: /bin/rm -f *.core ${IMAGE} ${CBIN} ${CBIN}.mk ${CBIN}.cache \ lib*.a lib*.olist ${CBIN}.map \ - *.o *.lo *.c bsd ${BSD_RD} bsd.gz ${FLOPPY} elfrdsetroot + *.o *.lo *.c bsd ${BSD_RD} bsd.gz ${FLOPPY} /bin/rm -rf ${IMAGE}.d .ifdef RELEASEDIR |