设置标志__randomize_layout时,Marco Offsetof如何工作?
当我研究内核源代码时,这是一个疑问。 我知道,如果定义了compiler_offsetof
,Marco将调用__ compiler_offsetof
,否则将运行((size_t)&((类型 *)0) - > member)
。 但是,当我启用_randomize_layout
标记到一个结构时,编译器会将其在结构内部供电。那么,在这种情况下,Marco如何工作? 我的理解之一是,如果定义了compiler_offsetof
,编译器将在内部解决它。但是我不知道compiler_offsetof
未定义。
This is a doubt when I studying kernel source codes.
I know that if a compiler_offsetof
is defined, the marco will call __compiler_offsetof
, otherwise it will run ((size_t)&((TYPE *)0)->MEMBER)
.
But when I enable _randomize_layout
flag to a struct, the compiler will shuffle the items inside the struct. So how does the marco work in this condition?
One of my understanding is that compiler will solve it internally if compiler_offsetof
was defined. But I have no idea when compiler_offsetof
is not defined.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论