编译cuttlefish内核遇到的问题

参考

我使用的是common-android13-5.10,在编译的时候使用的是build.sh的方法,在实际编译的时候遇到System.map找不到的问题,需要修改build.sh,将System.map从内核编译目录下拷贝到dist目录下即可,patch如下:

pengdl@ubuntu:~/work/android/common-android13-5.10/build/kernel$ git diff
diff --git a/build.sh b/build.sh
index e33f44f5d97d..7d001733b6d6 100755
--- a/build.sh
+++ b/build.sh
@@ -982,6 +982,11 @@ if [ -z "${SKIP_CP_KERNEL_HDR}" ]; then
   tar -czf ${KERNEL_UAPI_HEADERS_TAR} --directory=${KERNEL_UAPI_HEADERS_DIR} usr/
 fi

+if [ -f ${OUT_DIR}/System.map ];then
+echo " Copying System.map to ${DIST_DIR}"
+cp ${OUT_DIR}/System.map ${DIST_DIR}
+fi
+
 if [ -z "${SKIP_CP_KERNEL_HDR}" ] ; then
   echo "========================================================"
   KERNEL_HEADERS_TAR=${DIST_DIR}/kernel-headers.tar.gz

如果要支持kprobe的话,使用common-modules/virtual-device/build.config.virtual_device_kprobes.x86_64,下面是我是用的配置:

$ cat common-modules/virtual-device/build.config.virtual_device_kprobes.x86_64
. ${ROOT_DIR}/common-modules/virtual-device/build.config.virtual_device
. ${ROOT_DIR}/${KERNEL_DIR}/build.config.x86_64
. ${ROOT_DIR}/${KERNEL_DIR}/build.config.gki_kprobes

DEFCONFIG=cf_x86_64_gki_defconfig
PRE_DEFCONFIG_CMDS="KCONFIG_CONFIG=${ROOT_DIR}/${KERNEL_DIR}/arch/x86/configs/${DEFCONFIG} ${ROOT_DIR}/${KERNEL_DIR}/scripts/kconfig/merge_config.sh -m -r ${ROOT_DIR}/${KERNEL_DIR}/arch/x86/configs/gki_defconfig ${ROOT_DIR}/common-modules/virtual-device/virtual_device.fragment"
POST_DEFCONFIG_CMDS="rm ${ROOT_DIR}/${KERNEL_DIR}/arch/x86/configs/${DEFCONFIG} && update_kprobes_config"
DO_NOT_STRIP_MODULES=1
function update_kprobes_config() {
    ${KERNEL_DIR}/scripts/config --file ${OUT_DIR}/.config \
         -d LTO_CLANG_THIN \
         -d LTO_CLANG_FULL \
         -d CFI_PERMISSIVE \
         -d CFI_CLANG \
         -e CONFIG_FTRACE_SYSCALLS \
         -e CONFIG_STACK_TRACER \
         -e CONFIG_DYNAMIC_FTRACE \
         -e CONFIG_FUNCTION_TRACER \
         -e CONFIG_FUNCTION_GRAPH_TRACER \
         -e CONFIG_SCHED_TRACER \
         -e CONFIG_BLK_DEV_IO_TRACE \
         -e CONFIG_BPF_KPROBE_OVERRIDE \
         -e CONFIG_BPF_LSM \
         -e CONFIG_CFS_BANDWIDTH \
         -e CONFIG_IRQSOFF_TRACER \
         -e CONFIG_FUNCTION_PROFILER \
         -e CONFIG_PREEMPT_TRACER \
         -e CONFIG_CHECKPOINT_RESTORE \
         -d CONFIG_RANDOMIZE_BASE
    (cd ${OUT_DIR} && \
     make ${TOOL_ARGS} O=${OUT_DIR} olddefconfig)
}

# Not saving any kernel images. This build step is meant purely to generate the .kos.
FILES=""

使用下面的命令进行编译:

SKIP_MRPROPER=1 BUILD_CONFIG=common-modules/virtual-device/build.config.virtual_device_kprobes.x86_64 ./build/build.sh

完。

posted @ 2023-12-31 20:08  dolinux  阅读(203)  评论(0编辑  收藏  举报