加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > Linux > 正文

汇编 – 如何在64位Linux上使用Gas(‘as’)组装32位二进制文??件

发布时间:2020-12-14 00:51:42 所属栏目:Linux 来源:网络整理
导读:如何在64位 Linux上使用Gas(‘as’)将源代码组装成32位二进制文??件? 这是为了遵循32位教程而无需将所有指针和大量指令更改为四字的麻烦. 谢谢, 克里斯. 附:我可以在C中轻松完成这个… chris@chris-linux-desktop:~$cat test.c#include "stdio.h"int main(
如何在64位 Linux上使用Gas(‘as’)将源代码组装成32位二进制文??件?

这是为了遵循32位教程而无需将所有指针和大量指令更改为四字的麻烦.

谢谢,

克里斯.

附:我可以在C中轻松完成这个…

chris@chris-linux-desktop:~$cat test.c
#include "stdio.h"

int main() {
    printf("hello world");
    return 0;
}

chris@chris-linux-desktop:~$gcc test.c -o test64
chris@chris-linux-desktop:~$gcc -m32 test.c -o test32
chris@chris-linux-desktop:~$file test32
test32: ELF 32-bit LSB executable,Intel 80386,version 1 (SYSV),dynamically linked (uses shared libs),for GNU/Linux 2.6.15,not stripped
chris@chris-linux-desktop:~$file test64
test64: ELF 64-bit LSB executable,x86-64,not stripped

解决方法

与选项“–32”一样使用,如

as –32 source.s -o objectfile

或者您可以使用gcc来汇编和链接汇编源文件. gcc在结尾处认出它.

gcc -m32 source.s -o executable

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读