内核是使用命令“make buildkernel”构建的。如果您查看/usr/src/Makefile.inc1
buildkernel 的定义:
@echo "--------------------------------------------------------------"
@echo ">>> stage 3.2: building everything"
@echo "--------------------------------------------------------------"
cd ${KRNLOBJDIR}/${_kernel}; ${KMAKE} all -DNO_MODULES_OBJ
@echo "--------------------------------------------------------------"
@echo ">>> Kernel build for ${_kernel} completed on `LC_ALL=C date`"
@echo "--------------------------------------------------------------"
如果您查看内核构建 makefile /usr/obj/usr/src/sys/GENERIC/Makefile
(假设您正在构建 GENERIC 内核),您将看到这些文件kern.pre.mk
并kern.post.mk
包含在内。查看kern.pre.mk
您将看到以下链接器定义:
SYSTEM_LD= @${LD} -Bdynamic -T ${LDSCRIPT} \
-warn-common -export-dynamic -dynamic-linker /red/herring \
-o ${.TARGET} -X ${SYSTEM_OBJS} vers.o
不同架构的ldscript
文件可以在/usr/src/sys/conf/
.