免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 26064 | 回复: 9
打印 上一主题 下一主题

[学习分享] 错误could not read symbols: File in wrong format [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2012-11-20 19:15 |只看该作者 |倒序浏览
朋友们:
     我用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。
    拜托各位高手!

论坛徽章:
0
2 [报告]
发表于 2012-11-21 08:53 |只看该作者
你执行一下:

$file hello.o

把输出结果贴出来

论坛徽章:
0
3 [报告]
发表于 2012-11-21 09:01 |只看该作者
我在CentOS  6.3, NASM 2.07的环境里试验了一下。一切正常啊。

论坛徽章:
0
4 [报告]
发表于 2012-11-25 14:55 |只看该作者
$ file hello.o
hello.o: ELF 32-bit LSB relocatable, Intel 80386, version 1 (SYSV), not stripped

论坛徽章:
0
5 [报告]
发表于 2012-11-25 14:56 |只看该作者
回复 2# sakulagi


    $ file hello.o
hello.o: ELF 32-bit LSB relocatable, Intel 80386, version 1 (SYSV), not stripped

论坛徽章:
0
6 [报告]
发表于 2012-11-27 10:34 |只看该作者
本帖最后由 sakulagi 于 2012-11-27 10:34 编辑

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

  1. gcc -v -o hello hello.o
复制代码
你会看到一个巨长的命令行,那个才是正确的linker的执行方法。

论坛徽章:
0
7 [报告]
发表于 2012-11-30 16:00 |只看该作者
回复 6# sakulagi


    感谢您!我通过file hello.o看到hello.o是32位的,而我的环境是64位的。

论坛徽章:
0
8 [报告]
发表于 2012-11-30 18:48 |只看该作者
这个也是一个问题。谢谢分享你的发现。

论坛徽章:
0
9 [报告]
发表于 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,求指导,谢谢!

论坛徽章:
0
10 [报告]
发表于 2014-03-03 20:35 |只看该作者
回复 7# 329191721
怎么看环境是64位的,你指的是操作系统还是你的pc。

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

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP