linux – 与nasm和ld的汇编/链接问题
发布时间:2020-12-30 16:30:43 所属栏目:Linux 来源:互联网
导读:我有一个用nasm编译的示例程序集文件: nasm -f elf syscall.asm 这会生成一个syscall.o文件.我尝试将它与ld链接: ld -o syscall syscall.o ld命令失败,并显示以下错误: ld: i386 architecture of input file `syscall.o is incompatible with i386:x86-64
我有一个用nasm编译的示例程序集文件: nasm -f elf syscall.asm 这会生成一个syscall.o文件.我尝试将它与ld链接: ld -o syscall syscall.o ld命令失败,并显示以下错误: ld: i386 architecture of input file `syscall.o' is incompatible with i386:x86-64 output 但是,如果我这样做 ld -o syscall syscall.o -melf_i386 命令成功,我得到一个系统调用可执行文件. 弄清楚nasm没有生成x86-64格式的目标代码我在syscall.asm文件的开头添加了“BITS 64”指令. 然后尝试使用nasm组装syscall.asm会出现以下错误: error: elf output format does not support 64-bit code 这看起来很奇怪,因为在我的终端上执行“file /usr/bin/nasm”会给出: /usr/bin/nasm: ELF 64-bit LSB executable,x86-64,version 1 (SYSV),dynamically linked (uses shared libs),for GNU/Linux 2.6.18,stripped 我的64位Fedora Core 11安装了最新版本的nasm,我的CPU是Intel Core 2 Duo E7200. [编辑] 我的问题是如何让nasm发出与i386兼容的目标文件:x86-64. 解决方法尝试使用elf64作为输出格式.示例运行: $cat elf64.asm section .text jmp [rax] $nasm -f elf64 elf64.asm $objdump -Sr elf64.o elf64.o: file format elf64-x86-64 Disassembly of section .text: 0000000000000000 <.text>: 0: ff 20 jmpq *(%rax) (编辑:鄂州站长网) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- linux – 新节点配置中缺少“通过Java Web Start启动从属代
- Linux getopt()函数 getopt_long()函数---转
- LINUX教程:OpenLDAP安装及设置普通用户修改自己密码
- 如何遍历linux内核中的文件地址空间的页面缓存树(基数树)
- linux – shell脚本如何判断它是否在支持256色的xterm窗口中
- linux / libusb获取usb设备路径
- Linux Setup Creator [暂停]
- linux – 从终端历史记录中搜索和替换命令
- linux – 为for循环设置IFS然后在for循环中取消设置是否安全
- LINUX教程:php similar_text()函数的定义和用法
推荐文章
站长推荐
热点阅读