Linux编译|无效的入口点 [英] Linux compilation | Invalid entrypoint

查看:78
本文介绍了Linux编译|无效的入口点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用mipsel工具链编译 Linux内核

I am compiling a linux kernel using mipsel toolchain.

一切正常,除了在最后一点指出无效的入口点:

Everything works fine except at the very last point which states invalid entry point:

sh: 0: Can't open /arch/mips/boot/tools/entry
rm -f arch/mips/boot/vmlinux.bin.gz
gzip -9 arch/mips/boot/vmlinux.bin
mkimage -A mips -O linux -T kernel -C gzip \
    -a 0x80010000 -e  \
    -n 'Linux-2.6.31.3-g29b45174-dirty' \
    -d arch/mips/boot/vmlinux.bin.gz arch/mips/boot/uImage
mkimage: invalid entry point -n

现在提到了sh: 0: Can't open/arch/mips/boot/tools/entry

所以我检查了该文件,它具有以下内容:

So I checked that file and it has following:

#!/bin/sh

# grab the kernel_entry address from the vmlinux elf image
entry=`$1 $2  | grep kernel_entry`

fs=`echo $entry | grep ffffffff`  # check toolchain output

if [ -n "$fs" ]; then
    echo "0x"`$1 $2  | grep kernel_entry | cut -c9- | awk '{print $1}'`
else
    echo "0x"`$1 $2  | grep kernel_entry | cut -c1- | awk '{print $1}'`
fi

现在我知道有些东西正在生成内核入口点,但生成的入口点无效.

Now i understand something is generating the kernel entry point, but that generated entry point is invalid.

问题:究竟是什么生成内核入口点以及可以采取哪些措施解决该问题?

Question: What exactly generates kernel entry point and what potentially could be done to fix the issue?

可以通过以下步骤重现该问题:

The problem can be reproduced through following steps:

编译说明:

$ cd
$ wget https://github.com/steward-fu/a320/releases/download/v1.0/mipsel-4.1.2-nopic.tar.bz2
$ tar xvf mipsel-4.1.2-nopic.tar.bz2
$ sudo mv mipsel-4.1.2-nopic /opt/rg300
$ export PATH=$PATH:/opt/rg300/bin
$ git clone https://github.com/rs-97-cfw/rs97-linux-kernel-NoNDA rg300_kernel
$ cd rg300_kernel
$ ARCH=mips make uImage

推荐答案

这似乎是由环境变量的值不正确引起的路径问题.
错误消息 sh:0:无法打开/arch/mips/boot/tools/entry 是相对于/的完整路径,即根目录,而不是正确指定内核源的实际存储位置,例如/home/您的用户名/rg300_kernel/arch/mips/boot/tools/entry .

This looks like a path issue caused by improper value of an environment variable.
The error message sh: 0: Can't open /arch/mips/boot/tools/entry is a full path relative to /, i.e. the root directory, instead of correctly specifying where your kernel source is actually stored, e.g. /home/your_username/rg300_kernel/arch/mips/boot/tools/entry.

问题:到底是什么生成内核入口点?有什么可能解决此问题?

Question: What exactly generates kernel entry point and what potentially could be done to fix the issue?

问题不在于脚本本身,而在于如何调用脚本.
您的内核源代码所在的目录路径指定不正确.
因为从未找到并执行脚本,所以没有为 -e 选项提供用于指定入口点的值.
因此, mkimage 实用程序(错误地)抱怨无效的入口点" ,但实际的问题是无法获得任何值,因为该脚本从未定位过.被执行.

The issue is not the script itself, but rather how the script is invoked.
The directory path to where your kernel source resides is incorrectly specified.
Because the script is never found and executed, there is no value provided for the -e option for specifying the entry point.
Consequently the mkimage utility (incorrectly) complains of an "invalid entry point", but the actual problem is that no value was obtainable because the script was never located & executed.

用于指定脚本路径的突出文本为:

The salient text for specifying the path of the script is:

$(KBUILD_SRC)/$(obj)/tools/entry

您的构建输出表明 obj 环境变量已正确设置为 arch/mips/boot .
但是 KBUILD_SRC 似乎被错误地设置为/(根目录)或为空(??? !!!)或未定义,而不是诸如之类的东西>/home/您的用户名/rg300_kernel 或其他正确路径.

Your build output indicates that the obj environment variable is correctly set to arch/mips/boot.
But KBUILD_SRC seems to be incorrectly set to just / (the root directory) or is blank (???!!!) or is undefined, rather than something like /home/your_username/rg300_kernel or whatever the correct path is.

要解决此问题,您可以尝试在 arch/mips/boot/Makefile 中用 srctree 替换变量 KBUILD_SRC :

For a workaround you could try replacing variable KBUILD_SRC with srctree in arch/mips/boot/Makefile:

 uImage: $(VMLINUX) vmlinux.bin
     rm -f $(obj)/vmlinux.bin.gz
     gzip -9 $(obj)/vmlinux.bin
     mkimage -A mips -O linux -T kernel -C gzip \
-        -a $(LOADADDR) -e $(shell sh $(KBUILD_SRC)/$(obj)/tools/entry $(NM) $(VMLINUX) ) \
+        -a $(LOADADDR) -e $(shell sh $(srctree)/$(obj)/tools/entry $(NM) $(VMLINUX) ) \
         -n 'Linux-$(KERNELRELEASE)' \
         -d $(obj)/vmlinux.bin.gz $(obj)/uImage
     @echo '  Kernel: arch/mips/boot/$@ is ready' 


变量 srctree 似乎是从 KBUILD_SRC (在顶层内核Makefile中)派生的,并且将其用作替代品确实是一种解决方法.br/>也许某个地方 KBUILD_SRC 变得混乱不堪,或者没有导出,但是makefile(和脚本)不是我的专长,所以我无法解释根本原因.


Variable srctree appears to be derived from KBUILD_SRC (in the top-level kernel Makefile), and using it as a substitution is really a WAG for a workaround.
Perhaps somewhere KBUILD_SRC is getting clobbered or not exported, but makefiles (and scripts) is not my expertise so I am unable to explain the underlying cause.

这篇关于Linux编译|无效的入口点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆