summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Baldwin <jhb@FreeBSD.org>2020-12-10 21:12:25 +0000
committerJohn Baldwin <jhb@FreeBSD.org>2020-12-10 21:12:25 +0000
commit15af8574cc269c0afc17961511aebba25bfb1607 (patch)
tree27ff8d275b8b012a065d3b5162dfd976818aa14f
parent1a6fcc935b99d55ceee53c7ee950d971463479f6 (diff)
downloadsrc-test2-15af8574cc269c0afc17961511aebba25bfb1607.tar.gz
src-test2-15af8574cc269c0afc17961511aebba25bfb1607.zip
Notes
-rw-r--r--sys/conf/kern.post.mk21
-rw-r--r--sys/conf/kern.pre.mk31
-rw-r--r--sys/dev/md/embedfs.S46
3 files changed, 49 insertions, 49 deletions
diff --git a/sys/conf/kern.post.mk b/sys/conf/kern.post.mk
index 61230bcb8627..cce9fcfd1c6d 100644
--- a/sys/conf/kern.post.mk
+++ b/sys/conf/kern.post.mk
@@ -426,24 +426,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
diff --git a/sys/conf/kern.pre.mk b/sys/conf/kern.pre.mk
index 079377daedfa..65646da42faa 100644
--- a/sys/conf/kern.pre.mk
+++ b/sys/conf/kern.pre.mk
@@ -277,37 +277,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
diff --git a/sys/dev/md/embedfs.S b/sys/dev/md/embedfs.S
new file mode 100644
index 000000000000..f7574631a0c6
--- /dev/null
+++ b/sys/dev/md/embedfs.S
@@ -0,0 +1,46 @@
+/*-
+ * SPDX-License-Identifier: BSD-2-Clause
+ *
+ * Copyright (c) 2020 John Baldwin <jhb@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