5 ms·
Clang 15 Lands Support to Randomize Structure Layout, Linux Prepares to Use It
- rowanG077 5y agoHow does this work? I thought the struct layout needed to be the same between API boundaries. E.g. If I call a function `foo(struct bar* x)` in some library how does the compiler know what random struct layout was used for that library?
- karmakaze 5y ago> The Clang RandStruct support is implemented similarly to GCC and intended as compile-time hardening to make it harder for attackers to retrieve data from program structures. The support can be enabled via the "-frandomize-layout-seed=" or "-frandomize-layout-seed-file=" options for providing the deterministic random seed for allowing reproducible builds. So if the struct needs to be shared across compile units they have to use the same seed in a specified source file. Seems of limited use given Linux source is freely distributed which would include these seed files.