Itanium ABI在什么程度上真正指定了填充和对齐? [英] To what extent does the Itanium ABI really specify padding and alignment?

查看:442
本文介绍了Itanium ABI在什么程度上真正指定了填充和对齐?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我被告知:


[ABIs]保证结构的精确布局,每个成员的字节偏移,


但我一直相信填充和填充对齐未指定且不可靠。



Itanium ABI (GCC使用)实际上指定了这些东西(只要可以告诉,它超出指定范围后不会显示



如果是,如 __ attribute__ ((packed))适合吗?它们最终通过改变事物的一致性来破坏ABI?



或者,正如引用所暗示的,在工具链之间仅仅包装未指定,但实际上是可靠的和可预测的在使用某个ABI?再次, __ attribute__((packed))如何适应?

解决方案

填充和对齐未经ISO标准C ++规范指定,因此不可靠。



在引用中使用exact 。 Itanium ABI(GCC使用)可以根据需要而不是总是和确切来指定这些东西(在指定范围内)。


$假定预定的目标架构和工具包在工具链的使用中,包装事实上是可靠的和可预测的。环境。 ABI。当所有适用于工具链的目标特定细节都是预先确定的 __ attribute__((packed))和任何其他构造一样,将生成可预测的输出,以使工具链正常工作。 / p>

I've been told:

[ABIs] guarantee the exact layout of the struct, byte offset of every member, which bits are used for bit fields, where and how much padding there is, etc...

But I've always believed that padding and alignment were unspecified and unreliable.

Does the Itanium ABI (which GCC uses) in fact specify these things (as far as I can tell, it doesn't appear to beyond specifying ranges)?

And if it does, how do options like __attribute__ ((packed)) fit into that? Do they ultimately break the ABI by altering the alignment of things?

Or, as the quotee implies, is packing merely unspecified between toolchains but in fact reliable and predictable within the use of a certain ABI? And then, again, how does something like __attribute__ ((packed)) fit into that?

解决方案

padding and alignment are unspecified by the ISO standard C++ specification and hence unreliable.

The use of the word "exact" in the quote is exaggeration. The Itanium ABI (which GCC uses) may specify these things (as within specifying ranges) as needed rather than always and exact ly.

Packing is in fact reliable and predictable within the use of toolchains assuming predetermined target architecture & environment- viz. ABI. When all target specific details applicable to the tool-chain are predetermined __attribute__ ((packed)) like any other construct will generate output predictably for the tool-chain to work correctly.

这篇关于Itanium ABI在什么程度上真正指定了填充和对齐?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆