Chinaunix

标题: 错误could not read symbols: File in wrong format [打印本页]

作者: 329191721    时间: 2012-11-20 19:15
标题: 错误could not read symbols: File in wrong format
朋友们:
     我用nasm -f elf hello.asm -o hello.o 编译了hello.asm文件,功能为输出"Hello world!"。但是,用ld -s hello.o -o hello命令是报错“hello.o: could not read symbols: File in wrong format”,网上没有找到答案。
     我的系统为Centos6.3,nasm 版本为2.07。
    拜托各位高手!
作者: sakulagi    时间: 2012-11-21 08:53
你执行一下:

$file hello.o

把输出结果贴出来
作者: sakulagi    时间: 2012-11-21 09:01
我在CentOS  6.3, NASM 2.07的环境里试验了一下。一切正常啊。
作者: 329191721    时间: 2012-11-25 14:55
$ file hello.o
hello.o: ELF 32-bit LSB relocatable, Intel 80386, version 1 (SYSV), not stripped
作者: 329191721    时间: 2012-11-25 14:56
回复 2# sakulagi


    $ file hello.o
hello.o: ELF 32-bit LSB relocatable, Intel 80386, version 1 (SYSV), not stripped
作者: sakulagi    时间: 2012-11-27 10:34
本帖最后由 sakulagi 于 2012-11-27 10:34 编辑

我对linker不熟悉,但是ld不是这么简单用的。建议你运行一下

  1. gcc -v -o hello hello.o
复制代码
你会看到一个巨长的命令行,那个才是正确的linker的执行方法。
作者: 329191721    时间: 2012-11-30 16:00
回复 6# sakulagi


    感谢您!我通过file hello.o看到hello.o是32位的,而我的环境是64位的。
作者: sakulagi    时间: 2012-11-30 18:48
这个也是一个问题。谢谢分享你的发现。
作者: pisen-奇迹    时间: 2014-02-28 16:08
你好,交叉编译iperf 时出现错误:/usr/bin/ld: Extractor.o: Relocations in generic ELF (EM: ,用file命令查看结果是:ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.18, not stripped,命令uname -a:Linux pisen.localdomain 2.6.32-71.el6.i686 #1 SMP Fri Nov 12 04:17:17 GMT 2010 i686 i686 i386 GNU/Linux,求指导,谢谢!
作者: pisen-奇迹    时间: 2014-03-03 20:35
回复 7# 329191721
怎么看环境是64位的,你指的是操作系统还是你的pc。

   




欢迎光临 Chinaunix (http://bbs.chinaunix.net/) Powered by Discuz! X3.2