'How does marco offsetof work when set flag __randomize_layout?

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.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source