关于arm:关于ARM大小端模式和CPU有关还是编译器有关

对于ARM大小端模式和CPU无关还是编译器无关

论断,ARM大小端模式和CPU无关也和编译器有关系。

ARM默认状态配置为小端模式,编译器不指定编译模式也默认是小端模式。但有些ARM是能够配置为大端模式的。例如:

  • ARMv7-R: SCTLR.IE, bit[31], that indicates the instruction endianness configuration.
  • ARMv7-A: In ARMv7-A, the mapping of instruction memory is always little-endian.
  • ARMv8: This data endianness is controlled independently for each Execution level. For EL3, EL2 and EL1, the relevant register of SCTLR_ELn

如果在ARM下面配置了大端模式,gcc编译器则须要减少参数-mbig-endian

-mlittle-endian
Generate code for a processor running in little-endian mode. This is the default for all standard configurations.
-mbig-endian
Generate code for a processor running in big-endian mode; the default is to compile code for a little-endian processor.

与CPU配置保持一致。

参考文献:

https://gcc.gnu.org/onlinedoc…
https://developer.arm.com/doc…
https://developer.arm.com/doc…

评论

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

这个站点使用 Akismet 来减少垃圾评论。了解你的评论数据如何被处理