LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
楼主: faxian

编译gcc指定target为i686,在用其编译的代码能运行在i386上吗?

[复制链接]
发表于 2006-4-9 02:23:06 | 显示全部楼层
也许是静态编译?。。
我的内核是 2.6.15.6,是不是因为这个不兼容,所以出错?
回复 支持 反对

使用道具 举报

发表于 2006-4-9 07:11:57 | 显示全部楼层
估计不是,Illegal instructions 应该是机器要跑一些它不认识的指令引致的,比如编译了 i686 的程式在 i386 的机器上跑。

我推测是你的编译环境产生了非 i386 的 instruction codes,但为何会这样,不解!
回复 支持 反对

使用道具 举报

发表于 2006-4-9 19:04:41 | 显示全部楼层
有时间再试试这个?shared 方式编译的。

我想静态编译失败,也许是 glibc 的差异,我的是 2.3.6。不知道你用的是多少?

ldd 的结果,以供参考。
        linux-gate.so.1 =>  (0xffffe000)
        libc.so.6 => /lib/libc.so.6 (0xb7e3c000)
        /lib/ld-linux.so.2 (0xb7f78000)

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有帐号?注册

x
回复 支持 反对

使用道具 举报

发表于 2006-4-9 20:34:48 | 显示全部楼层
最近网络真是糟糕!

上周门前在修路,居然把电信公司的光纤缆掘断了,害我整个星期无法上网!:mad:

昨天是恢复了,可是速度又超慢,今天竟然连下载一个 65kB 的 archive 也会掉线,纳闷非常!只好深夜再来了
回复 支持 反对

使用道具 举报

发表于 2006-4-12 12:47:36 | 显示全部楼层
Post by 终极幻想
有时间再试试这个?shared 方式编译的。

我想静态编译失败,也许是 glibc 的差异,我的是 2.3.6。不知道你用的是多少?

ldd 的结果,以供参考。
        linux-gate.so.1 =>  (0xffffe000)
        libc.so.6 => /lib/libc.so.6 (0xb7e3c000)
        /lib/ld-linux.so.2 (0xb7f78000)
用了 shared 方式,另一件奇怪的事情发生了,在我的那台Pentium 133 竟然能正常运行 k8 下的 zip,不解:confused:
  1. [font=Courier New]d00m3d@BlackMesa:~/k8$ uname -a
  2. Linux BlackMesa 2.6.12.2-custom #1 Thu Jun 30 19:52:06 HKT 2005 i586 GNU/Linux
  3. d00m3d@BlackMesa:~/k8$ ls -l
  4. total 84
  5. -rwxr-xr-x  1 d00m3d d00m3d 78058 Apr  9 19:25 zip
  6. d00m3d@BlackMesa:~/k8$ ./zip
  7. Copyright (C) 1990-2005 Info-ZIP
  8. Type 'zip "-L"' for software license.
  9. Zip 2.31 (March 8th 2005). Usage:
  10. zip [-options] [-b path] [-t mmddyyyy] [-n suffixes] [zipfile list] [-xi list]
  11.   The default action is to add or replace zipfile entries from list, which
  12.   can include the special name - to compress standard input.
  13.   If zipfile and list are omitted, zip compresses stdin to stdout.
  14.   -f   freshen: only changed files  -u   update: only changed or new files
  15.   -d   delete entries in zipfile    -m   move into zipfile (delete files)
  16.   -r   recurse into directories     -j   junk (don't record) directory names
  17.   -0   store only                   -l   convert LF to CR LF (-ll CR LF to LF)
  18.   -1   compress faster              -9   compress better
  19.   -q   quiet operation              -v   verbose operation/print version info
  20.   -c   add one-line comments        -z   add zipfile comment
  21.   -@   read names from stdin        -o   make zipfile as old as latest entry
  22.   -x   exclude the following names  -i   include only the following names
  23.   -F   fix zipfile (-FF try harder) -D   do not add directory entries
  24.   -A   adjust self-extracting exe   -J   junk zipfile prefix (unzipsfx)
  25.   -T   test zipfile integrity       -X   eXclude eXtra file attributes
  26.   -y   store symbolic links as the link instead of the referenced file
  27.   -R   PKZIP recursion (see manual)
  28.   -e   encrypt                      -n   don't compress these suffixes
  29. d00m3d@BlackMesa:~/k8$ ldd ./zip
  30.         linux-gate.so.1 =>  (0xffffe000)
  31.         libc.so.6 => /lib/tls/libc.so.6 (0xb7e5d000)
  32.         /lib/ld-linux.so.2 (0xb7f98000)
  33. d00m3d@BlackMesa:~/k8$[/font]
复制代码


================================================================================
  1. [font=Courier New]d00m3d@BlackMesa:~/i386$ uname -a
  2. Linux BlackMesa 2.6.12.2-custom #1 Thu Jun 30 19:52:06 HKT 2005 i586 GNU/Linux
  3. d00m3d@BlackMesa:~/i386$ ls -l
  4. total 80
  5. -rwxr-xr-x  1 d00m3d d00m3d 75432 Apr  9 19:24 zip
  6. d00m3d@BlackMesa:~/i386$ ./zip
  7. Copyright (C) 1990-2005 Info-ZIP
  8. Type 'zip "-L"' for software license.
  9. Zip 2.31 (March 8th 2005). Usage:
  10. zip [-options] [-b path] [-t mmddyyyy] [-n suffixes] [zipfile list] [-xi list]
  11.   The default action is to add or replace zipfile entries from list, which
  12.   can include the special name - to compress standard input.
  13.   If zipfile and list are omitted, zip compresses stdin to stdout.
  14.   -f   freshen: only changed files  -u   update: only changed or new files
  15.   -d   delete entries in zipfile    -m   move into zipfile (delete files)
  16.   -r   recurse into directories     -j   junk (don't record) directory names
  17.   -0   store only                   -l   convert LF to CR LF (-ll CR LF to LF)
  18.   -1   compress faster              -9   compress better
  19.   -q   quiet operation              -v   verbose operation/print version info
  20.   -c   add one-line comments        -z   add zipfile comment
  21.   -@   read names from stdin        -o   make zipfile as old as latest entry
  22.   -x   exclude the following names  -i   include only the following names
  23.   -F   fix zipfile (-FF try harder) -D   do not add directory entries
  24.   -A   adjust self-extracting exe   -J   junk zipfile prefix (unzipsfx)
  25.   -T   test zipfile integrity       -X   eXclude eXtra file attributes
  26.   -y   store symbolic links as the link instead of the referenced file
  27.   -R   PKZIP recursion (see manual)
  28.   -e   encrypt                      -n   don't compress these suffixes
  29. d00m3d@BlackMesa:~/i386$ ldd ./zip
  30.         linux-gate.so.1 =>  (0xffffe000)
  31.         libc.so.6 => /lib/tls/libc.so.6 (0xb7e40000)
  32.         /lib/ld-linux.so.2 (0xb7f7b000)
  33. d00m3d@BlackMesa:~/i386$
  34. [/font]
复制代码
我的 glibc 版本是 Debian 的 2.3.4-i386
回复 支持 反对

使用道具 举报

发表于 2006-4-12 13:15:56 | 显示全部楼层
也许 zip 没有用到 k8 的指令,所以还是使用 i386 指令集了。。

我不知道如何找到这样的程序来验证,,不懂编程就是惨。。。
回复 支持 反对

使用道具 举报

发表于 2006-4-12 13:18:32 | 显示全部楼层
不是用了 -march 吗?
回复 支持 反对

使用道具 举报

发表于 2006-4-12 13:23:06 | 显示全部楼层
但是如果 zip 用到的指令集 k8 并没有优化的话,那么就还是用 i386 的,那就没区别了噢。。

比如 main(){} 这个dummy.c 程序,我想应该什么都没有优化,所以不管你用什么march 来编译,都可以运行。。。
回复 支持 反对

使用道具 举报

发表于 2006-4-12 13:50:14 | 显示全部楼层
不会吧!它们的体积明显是不同的,相信它们之间是有差异的。

哪位懂汇编的能否帮忙验证?
回复 支持 反对

使用道具 举报

发表于 2006-4-12 14:15:53 | 显示全部楼层
amd和Intel应该是指令集兼容的吧,只有那些需要用到amd专有指令的时候才会出现运行问题吧.也许碰巧没用到这些指令,或者是运行期间没运行到这样的指令,所以才会运行正常的.
回复 支持 反对

使用道具 举报

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

本版积分规则

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