0.11内核编译出错 kernel/kernel.o:在函数‘copy_process’中:对'memcpy'未定义的引用。...
在编译内核的时候连接出错了,出错内容如下:
kernel/kernel.o:在函数‘copy_process’中:
/home/yao/kernel/linux/linux-gdb-rh9/linux/kernel/fork.c:84:对'memcpy'未定义的引用。
查看对应的代码:
*p = *current; /* NOTE! this doesn't copy the supervisor stack */
一时间想不明白,在工程里找memcpy的引用和定义,却一直找不找原因。后来才在oldlinux上找到答案,连接如下:
http://www.oldlinux.org/oldlinux/archiver/?tid-3965-page-3.html
我将解决方法复制了过来:
发现第一处的修改有问题,如果改为 #if 0 *p = *current; /* NOTE! this doesn't copy the supervisor stack */ #else /* * gcc 3.4.2 seems use the "memcpy" to do sturct assign * action,since the kernel do not have the function,we changed the * line do manual copy char by char */ { unsigned char *p1,*p2; int i; p1 = (unsigned char*)p; p2 = (unsigned char*)current; for(i = 0;i < sizeof(*p);i++) { *p1++ = *p2++; } } #endif 则编译出来的Image可以正常运行。
高版本的gcc使用memcpy来对结构赋值,编译内核时却不能使用这些函数。这是编译器版本不同导致的问题。