File tree 2 files changed +10
-1
lines changed
2 files changed +10
-1
lines changed Original file line number Diff line number Diff line change @@ -1640,7 +1640,14 @@ impl ReprOptions {
1640
1640
1641
1641
// Generate a deterministically-derived seed from the item's path hash
1642
1642
// 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
+ }
1644
1651
1645
1652
for attr in tcx. get_attrs ( did) . iter ( ) {
1646
1653
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! {
1321
1321
"print some statistics about the query system (default: no)" ) ,
1322
1322
randomize_layout: bool = ( false , parse_bool, [ TRACKED ] ,
1323
1323
"randomize the layout of types (default: no)" ) ,
1324
+ layout_seed: Option <u64 > = ( None , parse_opt_number, [ TRACKED ] ,
1325
+ "seed layout randomization" ) ,
1324
1326
relax_elf_relocations: Option <bool > = ( None , parse_opt_bool, [ TRACKED ] ,
1325
1327
"whether ELF relocations can be relaxed" ) ,
1326
1328
relro_level: Option <RelroLevel > = ( None , parse_relro_level, [ TRACKED ] ,
You can’t perform that action at this time.
0 commit comments