【嵌入式Linux】[内核编译]:内核编译时出现的问题:undefined reference to `__gnu_mcount_nc'

时间:2021-09-14 18:46:15

编译内核时出现了以下错误信息:

To see full details build your kernel with:
'make CONFIG_DEBUG_SECTION_MISMATCH=y'
  GEN     .version
  CHK     include/linux/compile.h
  UPD     include/linux/compile.h
  CC      init/version.o
  LD      init/built-in.o
  LD      .tmp_vmlinux1
init/built-in.o: In function `run_init_process':
/home/liuhui8989/Information/linux-2.6.31/init/main.c:827: undefined reference to `__gnu_mcount_nc'
init/built-in.o: In function `init_post':
/home/liuhui8989/Information/linux-2.6.31/init/main.c:837: undefined reference to `__gnu_mcount_nc'
init/built-in.o: In function `do_one_initcall':
/home/liuhui8989/Information/linux-2.6.31/init/main.c:741: undefined reference to `__gnu_mcount_nc'
init/built-in.o: In function `name_to_dev_t':
/home/liuhui8989/Information/linux-2.6.31/init/do_mounts.c:78: undefined reference to `__gnu_mcount_nc'
init/built-in.o: In function `rest_init':
/home/liuhui8989/Information/linux-2.6.31/init/main.c:451: undefined reference to `__gnu_mcount_nc'
init/built-in.o:/home/liuhui8989/Information/linux-2.6.31/init/calibrate.c:123: more undefined references to `__gnu_mcount_nc' follow
make: *** [.tmp_vmlinux1] 错误 1


查找了很多资料最后在整出来,记下来以后参考。

首先参考:http://www.linuxidc.com/Linux/2012-02/53883.htm

这个基本就可以解决问题了,只不过一开始自己没有那么高的觉悟,操作失误的。

首先申明,这些文件的操作是针对你编译的内核源码包的,不要操作错误。

现在开始写具体的解决步骤的:

需要补丁__gnu_mcount_nc_patch.patch.gz

免费下载地址在 http://linux.linuxidc.com/

用户名与密码都是www.linuxidc.com

具体下载目录在 /2012年资料/2月/11日/Linux内核编译错误/

下载之后放在Linux内核根目录下,如我的是:/home/liuhui8989/Information/linux-2.6.31

从终端下进入根目录/home/liuhui8989/Information/linux-2.6.31下执行以下操作:

 gunzip -dc __gnu_mcount_nc_patch.patch.gz |patch -p1

 (注意:“__”为两个下划线连在一起,“p1”后面的是阿拉伯数字1,还要注意空格)

打印出以下信息即表示成功:

root@ubuntu:/home/liuhui8989/Information/linux-2.6.31# gunzip -dc __gnu_mcount_nc_patch.patch.gz |patch -p1
patching file arch/arm/include/asm/ftrace.h
patching file arch/arm/kernel/armksyms.c
patching file arch/arm/kernel/entry-common.S

注:解压__gnu_mcount_nc_patch.patch.gz的,命令:gunzip  -d __gnu_mcount_nc_patch.patch.gz


原文:http://blog.csdn.net/liuhui_8989/article/details/8105139