Ubuntu 16.04使用NASM编译时用ld链接程序出现:i386 架构于输入文件 sandbox.o 与 i386:x86-64 输出不兼容(I386 architecture in the input file sandbox.o is not compatible with i386: x86-64 output)
2017-07-25 01:15
1671 查看
错误:
问题解决过程:
1、先确定CPU的架构
2、这是以64位架构的CPU,如果使用elf参数时,默认是以32位模式去处理,那么此时需要更精确的去指定这个模式,比如elf32(32位),elf64(64位),具体的参考:http://www.nasm.us/doc/nasmdoc7.html
那么改写上面的写法可以为:
3、如果想编译程32位和64位的组合,那么可以从链接入手,写法可以改为:
其实这里说法应该是不对的,不能说是组合,而是应该说是链接生成兼容32位模式的应用程序才对。
因为从上面可以看书,elf默认是32为,而elf_i386也为32位,其中elf_x86_64才是64位。所以,应该兼容才对。
也许上面说法也是不专业,或者这样说:nasm编译出来是32位的,而链接程序ld将32位的应用程序链接到了64位上做为可执行文件,这样做是不对的,应该将32位应用程序链接到32位上做为可执行文件。
所以,我觉得应该不是与CPU架构有关,而是应该与操作系统有关,操作系统区分32位和64位,而很多的汇编例子还是停留在32位x86上,造成以上的问题出现。
还有一点,使用ld时,有些书本上会这样写“ld -m elf_i386 -o sandbox.o sandbox”,现在新版本已经不支持了。
参考:
https://stackoverflow.com/questions/31369916/unable-to-compile-assembly-usr-bin-ld-i386-architecture-of-input-file-array1?rq=1
https://stackoverflow.com/questions/19200333/architecture-of-i386-input-file-is-incompatible-with-i386x86-64
https://en.wikipedia.org/wiki/Executable_and_Linkable_Format
https://stackoverflow.com/questions/11748970/how-to-pass-m-elf-i386-to-gcc
问题解决过程:
1、先确定CPU的架构
2、这是以64位架构的CPU,如果使用elf参数时,默认是以32位模式去处理,那么此时需要更精确的去指定这个模式,比如elf32(32位),elf64(64位),具体的参考:http://www.nasm.us/doc/nasmdoc7.html
那么改写上面的写法可以为:
nasm -f elf64 -g -F stabs sandbox.asm -o sandbox.o ld -o sandbox sandbox.o
3、如果想编译程32位和64位的组合,那么可以从链接入手,写法可以改为:
nasm -f elf -g -F stabs sandbox.asm -o sandbox.o ld -m elf_i386 -o sandbox sandbox.o
其实这里说法应该是不对的,不能说是组合,而是应该说是链接生成兼容32位模式的应用程序才对。
因为从上面可以看书,elf默认是32为,而elf_i386也为32位,其中elf_x86_64才是64位。所以,应该兼容才对。
也许上面说法也是不专业,或者这样说:nasm编译出来是32位的,而链接程序ld将32位的应用程序链接到了64位上做为可执行文件,这样做是不对的,应该将32位应用程序链接到32位上做为可执行文件。
所以,我觉得应该不是与CPU架构有关,而是应该与操作系统有关,操作系统区分32位和64位,而很多的汇编例子还是停留在32位x86上,造成以上的问题出现。
还有一点,使用ld时,有些书本上会这样写“ld -m elf_i386 -o sandbox.o sandbox”,现在新版本已经不支持了。
参考:
https://stackoverflow.com/questions/31369916/unable-to-compile-assembly-usr-bin-ld-i386-architecture-of-input-file-array1?rq=1
https://stackoverflow.com/questions/19200333/architecture-of-i386-input-file-is-incompatible-with-i386x86-64
https://en.wikipedia.org/wiki/Executable_and_Linkable_Format
https://stackoverflow.com/questions/11748970/how-to-pass-m-elf-i386-to-gcc
相关文章推荐
- ld: i386 architecture of input file `eatsyscall.o' is incompatible with i386:x86-64 output
- usr/bin/ld: i386 architecture of input file XXX.a( xxx.o) is incompatible with i386:x86-64 output
- linux下出现architecture of input file `*.o' is incompatible with i386:x86-64 output的解决方法
- ld: i386 architecture of input file `exit.o' is incompatible with i386:x86-64 output
- /usr/bin/ld: i386 architecture of input file `regcomp.o' is incompatible with i386:x86-64 output
- ubuntu 64位使用nasm汇编出现问题incompatible-with-i386-x86-64-output
- 解决升级到最新版cocoaPods出现file was built for archive which is not the architecture being linked (x86_64)的问题
- 使用CocoaPods遇到一个问题:The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update ....
- 解决升级到最新版cocoaPods出现file was built for archive which is not the architecture being linked (x86_64)的问题
- IOS 从网上下载的项目,运行时出现“The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update y”
- iOS编译错误#ld: warning: ignoring file# 之 Undefined symbols for architecture x86_64 - ld: symbol(s) not found for architecture x86_64
- Xcode 开发错误点链接错误之file was built for archive which is not the architecture being linked (i386)
- The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods install
- IOS--The sandbox is not in sync with the Podfile.lock.
- The sandbox is not in sync with the Podfile.lock 解决办法
- 14、 iOS "The sandbox is not in sync with the Podfile.lock"解决方案
- iOS 链接错误file was built for archive which is not the architecture being linked (i386)
- 使用cocoapods出现ld: symbol(s) not found for architecture x86_64问题
- The provider is not compatible with the version of Oracle client sometimes (提供程序与此版本的 Oracle 客户机不兼容)
- The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods install