From owner-svn-src-all@freebsd.org Tue Oct 20 16:48:46 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id BA841435D2B; Tue, 20 Oct 2020 16:48:46 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4CG0264YZnz4W88; Tue, 20 Oct 2020 16:48:46 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 80CBC17FBB; Tue, 20 Oct 2020 16:48:46 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 09KGmktL026238; Tue, 20 Oct 2020 16:48:46 GMT (envelope-from jhb@FreeBSD.org) Received: (from jhb@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 09KGmjpo026236; Tue, 20 Oct 2020 16:48:45 GMT (envelope-from jhb@FreeBSD.org) Message-Id: <202010201648.09KGmjpo026236@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: jhb set sender to jhb@FreeBSD.org using -f From: John Baldwin Date: Tue, 20 Oct 2020 16:48:45 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r366897 - in head/sys: conf dev/md X-SVN-Group: head X-SVN-Commit-Author: jhb X-SVN-Commit-Paths: in head/sys: conf dev/md X-SVN-Commit-Revision: 366897 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.33 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 20 Oct 2020 16:48:46 -0000 Author: jhb Date: Tue Oct 20 16:48:45 2020 New Revision: 366897 URL: https://svnweb.freebsd.org/changeset/base/366897 Log: Use a template assembly file to generate the embedded MFS. This uses the .incbin directive to pull in the MFS image contents. Using assembly directly ensures that symbols can be defined with the name and properties (such as .size) desired without having to rename symbols, etc. via a second objcopy invocation. Since it is compiled by the C compiler driver, it also avoids the need for all of the EMBEDFS* make variables. Suggested by: jrtc27 Reviewed by: kib, markj Obtained from: CheriBSD MFC after: 2 weeks Sponsored by: DARPA Differential Revision: https://reviews.freebsd.org/D26781 Added: head/sys/dev/md/embedfs.S (contents, props changed) Modified: head/sys/conf/kern.post.mk head/sys/conf/kern.pre.mk Modified: head/sys/conf/kern.post.mk ============================================================================== --- head/sys/conf/kern.post.mk Tue Oct 20 13:15:26 2020 (r366896) +++ head/sys/conf/kern.post.mk Tue Oct 20 16:48:45 2020 (r366897) @@ -457,24 +457,9 @@ vnode_if_typedef.h: .if ${MFS_IMAGE:Uno} != "no" .if empty(MD_ROOT_SIZE_CONFIGURED) -# Generate an object file from the file system image to embed in the kernel -# via linking. Make sure the contents are in the mfs section and rename the -# start/end/size variables to __start_mfs, __stop_mfs, and mfs_size, -# respectively. -embedfs_${MFS_IMAGE:T:R}.o: ${MFS_IMAGE} - ${OBJCOPY} --input-target binary \ - --output-target ${EMBEDFS_FORMAT.${MACHINE_ARCH}} \ - --binary-architecture ${EMBEDFS_ARCH.${MACHINE_ARCH}} \ - ${MFS_IMAGE} ${.TARGET} - ${OBJCOPY} \ - --rename-section .data=mfs,contents,alloc,load,readonly,data \ - --redefine-sym \ - _binary_${MFS_IMAGE:C,[^[:alnum:]],_,g}_size=__mfs_root_size \ - --redefine-sym \ - _binary_${MFS_IMAGE:C,[^[:alnum:]],_,g}_start=mfs_root \ - --redefine-sym \ - _binary_${MFS_IMAGE:C,[^[:alnum:]],_,g}_end=mfs_root_end \ - ${.TARGET} +embedfs_${MFS_IMAGE:T:R}.o: ${MFS_IMAGE} $S/dev/md/embedfs.S + ${CC} ${CFLAGS} ${ACFLAGS} -DMFS_IMAGE="${MFS_IMAGE}" -c \ + $S/dev/md/embedfs.S -o ${.TARGET} .endif .endif Modified: head/sys/conf/kern.pre.mk ============================================================================== --- head/sys/conf/kern.pre.mk Tue Oct 20 13:15:26 2020 (r366896) +++ head/sys/conf/kern.pre.mk Tue Oct 20 16:48:45 2020 (r366897) @@ -358,37 +358,6 @@ MKMODULESENV+= DEBUG_FLAGS="${DEBUG}" MKMODULESENV+= __MPATH="${__MPATH}" .endif -# Architecture and output format arguments for objcopy to convert image to -# object file - -.if ${MFS_IMAGE:Uno} != "no" -.if empty(MD_ROOT_SIZE_CONFIGURED) -.if !defined(EMBEDFS_FORMAT.${MACHINE_ARCH}) -EMBEDFS_FORMAT.${MACHINE_ARCH}!= awk -F'"' '/OUTPUT_FORMAT/ {print $$2}' ${LDSCRIPT} -.if empty(EMBEDFS_FORMAT.${MACHINE_ARCH}) -.undef EMBEDFS_FORMAT.${MACHINE_ARCH} -.endif -.endif - -.if !defined(EMBEDFS_ARCH.${MACHINE_ARCH}) -EMBEDFS_ARCH.${MACHINE_ARCH}!= sed -n '/OUTPUT_ARCH/s/.*(\(.*\)).*/\1/p' ${LDSCRIPT} -.if empty(EMBEDFS_ARCH.${MACHINE_ARCH}) -.undef EMBEDFS_ARCH.${MACHINE_ARCH} -.endif -.endif - -EMBEDFS_FORMAT.arm?= elf32-littlearm -EMBEDFS_FORMAT.armv6?= elf32-littlearm -EMBEDFS_FORMAT.armv7?= elf32-littlearm -EMBEDFS_FORMAT.aarch64?= elf64-littleaarch64 -EMBEDFS_FORMAT.mips?= elf32-tradbigmips -EMBEDFS_FORMAT.mipsel?= elf32-tradlittlemips -EMBEDFS_FORMAT.mips64?= elf64-tradbigmips -EMBEDFS_FORMAT.mips64el?= elf64-tradlittlemips -EMBEDFS_FORMAT.riscv64?= elf64-littleriscv -.endif -.endif - # Detect kernel config options that force stack frames to be turned on. DDB_ENABLED!= grep DDB opt_ddb.h || true ; echo DTR_ENABLED!= grep KDTRACE_FRAME opt_kdtrace.h || true ; echo Added: head/sys/dev/md/embedfs.S ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/sys/dev/md/embedfs.S Tue Oct 20 16:48:45 2020 (r366897) @@ -0,0 +1,46 @@ +/*- + * SPDX-License-Identifier: BSD-2-Clause + * + * Copyright (c) 2020 John Baldwin + * + * This software was developed by SRI International and the University of + * Cambridge Computer Laboratory (Department of Computer Science and + * Technology) under DARPA contract HR0011-18-C-0016 ("ECATS"), as part of the + * DARPA SSITH research programme. + * + * 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 + + .section mfs, "a", %progbits + .globl mfs_root + .type mfs_root, %object +mfs_root: + .incbin __XSTRING(MFS_IMAGE) + .size mfs_root, . - mfs_root + .globl mfs_root_end + .type mfs_root_end, %object +mfs_root_end: + .size mfs_root_end, . - mfs_root_end