File tree Expand file tree Collapse file tree 2 files changed +10
-1
lines changed Expand file tree Collapse file tree 2 files changed +10
-1
lines changed Original file line number Diff line number Diff line change @@ -1640,7 +1640,14 @@ impl ReprOptions {
16401640
16411641 // Generate a deterministically-derived seed from the item's path hash
16421642 // to allow for cross-crate compilation to actually work
1643- let field_shuffle_seed = tcx. def_path_hash ( did) . 0 . to_smaller_hash ( ) ;
1643+ let mut field_shuffle_seed = tcx. def_path_hash ( did) . 0 . to_smaller_hash ( ) ;
1644+
1645+ // If the user defined a custom seed for layout randomization, xor the item's
1646+ // path hash with the user defined seed, this will allowing determinism while
1647+ // still allowing users to further randomize layout generation for e.g. fuzzing
1648+ if let Some ( user_seed) = tcx. sess . opts . debugging_opts . layout_seed {
1649+ field_shuffle_seed ^= user_seed;
1650+ }
16441651
16451652 for attr in tcx. get_attrs ( did) . iter ( ) {
16461653 for r in attr:: find_repr_attrs ( & tcx. sess , attr) {
Original file line number Diff line number Diff line change @@ -1321,6 +1321,8 @@ options! {
13211321 "print some statistics about the query system (default: no)" ) ,
13221322 randomize_layout: bool = ( false , parse_bool, [ TRACKED ] ,
13231323 "randomize the layout of types (default: no)" ) ,
1324+ layout_seed: Option <u64 > = ( None , parse_opt_number, [ TRACKED ] ,
1325+ "seed layout randomization" ) ,
13241326 relax_elf_relocations: Option <bool > = ( None , parse_opt_bool, [ TRACKED ] ,
13251327 "whether ELF relocations can be relaxed" ) ,
13261328 relro_level: Option <RelroLevel > = ( None , parse_relro_level, [ TRACKED ] ,
You can’t perform that action at this time.
0 commit comments