gcc编译-m32、-mx32有什么区别

本文详细介绍了gcc编译器在x86-64环境下-m32、-m64、-mx32和-m16选项的区别。-m32生成32位代码,适用于所有i386系统;-m64生成64位代码,适合x86-64架构;-mx32则为x86-64架构下生成32位指针和long类型的数据,旨在节省内存和提高运行效率;而-m16选项输出16位代码,需要特定环境支持。文章还通过readelf命令展示了不同选项下编译结果的elf头信息。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

先来看看gcc官方手册吧

These ‘-m’ switches are supported in addition to the above on x86-64 processors in 64-bit
environments.
-m32
-m64
-mx32
-m16


-miamcu Generate code for a 16-bit, 32-bit or 64-bit environment.

The ‘-m32’ option
sets int, long, and pointer types to 32 bits, and generates code that runs on
any i386 system.

The ‘-m64’ option sets int to 32 bits and long and pointer types to 64 bits, and
generates code for the x86-64 architecture. For Darwin only the ‘-m64’ option
also turns off the ‘-fno-pic’ and ‘-mdynamic-no-pic’ options.


The ‘-mx32’ option sets int, long, and pointer types to 32 bits, and generates
code for the x86-64 architecture.


The ‘-m16’ option is the same as ‘-m32’, except for that it outputs the
.code16gcc assembly directive at the beginning of the assembly output so
that the binary can run in 16-bit mode.


T

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值