LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 835|回复: 7

gcc 3.4.3 编译 kernel 2.6.11.x 出错

[复制链接]
发表于 2005-5-9 15:52:34 | 显示全部楼层 |阅读模式
用的英文版的不稳定版跟着做的,机器比较慢,另外时间不连贯,前后做了有一个月,终于快到终点的时候,出错了。
编译 linux-2.6.11.7 时报错,

gcc -Wp,-MD,arch/i386/kernel/.process.o.d -nostdinc -isystem /usr/lib/gcc/i686-pc-linux-gnu/3.4.3/include -D__KERNEL__ -Iinclude  -Wall -Wstrict-prototypes -Wno-trigraphs -fno-strict-aliasing -fno-common -ffreestanding -O2     -fomit-frame-pointer -pipe -msoft-float -mpreferred-stack-boundary=2 -fno-unit-at-a-time -march=i686 -Iinclude/asm-i386/mach-default -Wdeclaration-after-statement     -DKBUILD_BASENAME=process -DKBUILD_MODNAME=process -c -o arch/i386/kernel/process.o arch/i386/kernel/process.c
{standard input}: Assembler messages:
{standard input}:864: Error: suffix or operands invalid for `mov'
{standard input}:865: Error: suffix or operands invalid for `mov'
{standard input}:1071: Error: suffix or operands invalid for `mov'
{standard input}:1072: Error: suffix or operands invalid for `mov'
{standard input}:1139: Error: suffix or operands invalid for `mov'
{standard input}:1140: Error: suffix or operands invalid for `mov'
{standard input}:1210: Error: suffix or operands invalid for `mov'
{standard input}:1211: Error: suffix or operands invalid for `mov'
{standard input}:1312: Error: suffix or operands invalid for `mov'
{standard input}:1324: Error: suffix or operands invalid for `mov'

用本机上的fedora 3, gcc3.4.2 就可以通过,郁闷呀。。。
这里有人知道怎么回事吗
 楼主| 发表于 2005-5-9 17:18:36 | 显示全部楼层
进一步分析了一下,是在汇编代码生成后,汇编阶段出的错。

是在形如 movl %fs, 504(%ebp) 这类的语句时出错
凡是有%fs,%gs出现的地方都会出错,而3.4.2编译出来的汇编代码在出错的几个地方和3.4.3的结果一样
回复 支持 反对

使用道具 举报

 楼主| 发表于 2005-5-9 17:52:39 | 显示全部楼层
继续研究发现,写一句最简单的汇编

movl %fs, 0

lfs 下面的 gcc-3.4.3 就出上面的错误,而本机的gcc-3.4.2就没问题。

正在按照本机上的gcc的编译选项重新编译gcc中。。。
回复 支持 反对

使用道具 举报

发表于 2005-5-9 18:47:09 | 显示全部楼层
问题在 binutils
试着把 movl 改成 mov
回复 支持 反对

使用道具 举报

 楼主| 发表于 2005-5-9 19:16:52 | 显示全部楼层
重新编译gcc还是不行,去掉 l 以后测试果然通过了。
binutil的哪里的问题呢?正在摸索……

P.S. 是因为编译成机器码是binutil的工作吗?
回复 支持 反对

使用道具 举报

 楼主| 发表于 2005-5-9 22:53:47 | 显示全部楼层
找到原因了,果然是binutil的问题。

lfs 用的 binutil-2.15.x,我自作主张,用了binutil-2.16,当时编译的时候还碰到了一些问题,自己手工解决了。不过这个问题倒是和手工搞的事没啥关系。
今天仔细看了binutil-2.16.90.2的release notes,原来从2.16开始,就不在支持movl %ds, (%eax)这种预发了,只支持mov %ds,(%eax),同时新增了movw。看来lfs没更新到2.16还是有道理的。
同时,binutil还专门提供了一个对kernel的补丁,我看了看,上来第一个就是把process.c中的movl改成mov,
我晕,整整搞了我2天呀……
重新下载最新的binutil中……完成后,给大家一个结语。
回复 支持 反对

使用道具 举报

 楼主| 发表于 2005-5-10 02:01:10 | 显示全部楼层
问题已经解决。
kernel补丁地址如下:

http://www.kernel.org/pub/linux/ ... nux-2.6-seg-5.patch

----------------------------------------------------------------------------------------

附上binutil自己的说明

The new i386/x86_64 assemblers no longer accept instructions for moving
between a segment register and a 32bit memory location, i.e.,

        movl (%eax),%ds
        movl %ds,(%eax)

To generate instructions for moving between a segment register and a
16bit memory location without the 16bit operand size prefix, 0x66,

        mov (%eax),%ds
        mov %ds,(%eax)

should be used. It will work with both new and old assemblers. The
assembler starting from 2.16.90.0.2 will also support

        movw (%eax),%ds
        movw %ds,(%eax)

without the 0x66 prefix. Patches for 2.4 and 2.6 Linux kernels are
available at

http://www.kernel.org/pub/linux/ ... nux-2.4-seg-4.patch
http://www.kernel.org/pub/linux/ ... nux-2.6-seg-5.patch
回复 支持 反对

使用道具 举报

发表于 2005-5-10 02:25:50 | 显示全部楼层
binutils-2.16.x is buggy.....
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表