https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116457
--- Comment #11 from Arsen Arsenović <arsen at gcc dot gnu.org> --- (In reply to Andrew Pinski from comment #9) > (In reply to Arsen Arsenović from comment #8) > > > what happens if you have 2 structs marked as randomize_layout but the > > > order > > > of the definition is different between 2 TUs? Then this breaks unless you > > > only have them not going outside the TU. > > This part was never answered on the semantics here? > And the clang documentation for > frandomize-layout-seed/frandomize-layout-seed-file is weak. > > Say you have (assuming all three have the randomize attribute on it) > > header1: > ``` > struct a > { > ... > }; > ``` > > header2: > ``` > struct b > { > ... > }; > ``` > > > You include header1 before header2 in TU1 but in TU2 the opposite is true. > > Or say you sometimes include header3 which contains `struct c{...};` > how do you set the seed for each struct? you don't - they all start from the same seed amended by the hash of the structure name or something; see https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/scripts/gcc-plugins/randomize_layout_plugin.c in any case - it is stable