svn commit: r366897 - in head/sys: conf dev/md
John Baldwin
jhb at FreeBSD.org
Tue Oct 20 16:48:46 UTC 2020
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 <jhb at FreeBSD.org>
+ *
+ * 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 <sys/cdefs.h>
+
+ .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
More information about the svn-src-head
mailing list