首页 > 系统服务 > 详细

汇编: Linux中汇编程序的编译

时间:2021-03-14 13:55:34      阅读:20      评论:0      收藏:0      [点我收藏+]

NASM在Linux系统上创建汇编程序

NASM与ld不兼容

  • 创建程序

    nasm -f elf -g -F stabs helloworld.asm
    
    ld -o helloworld helloworld.o
    
    • 可能出现错误: ld: i386 architecture of input file ‘helloworld.o‘ is incompatible with i386:x86-64 output
    • 原因:
      • nasm编译器默认输出32位程序, 在而ld默认输出64位,不兼容

正确创建方法

  • 64位

    nasm -f elf64 -g -F stabs helloworld.asm -o helloworld.o
    
    ld -o helloworld helloworld.o
    
  • 32位

    nasm -f elf -g -F stabs helloworld.asm -o helloworld.o
    
    ld -m elf_i386 -o helloworld helloworld.o
    

汇编: Linux中汇编程序的编译

原文:https://www.cnblogs.com/ieeqc/p/14531991.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!