Linux   发布时间:2022-04-01  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了汇编 – 如何在64位Linux上使用Gas(‘as’)组装32位二进制文​​件?大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。

概述

如何在64位 Linux上使用Gas(‘as’)将源代码组装成32位二进制文​​件? 这是为了遵循32位教程而无需将所有指针和大量指令更改为四字的麻烦. 谢谢, 克里斯. 附:我可以在C中轻松完成这个… chris@chris-linux-desktop:~$cat test.c #include "stdio.h" int main() { printf("hello world");
如何在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

大佬总结

以上是大佬教程为你收集整理的汇编 – 如何在64位Linux上使用Gas(‘as’)组装32位二进制文​​件?全部内容,希望文章能够帮你解决汇编 – 如何在64位Linux上使用Gas(‘as’)组装32位二进制文​​件?所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。