@@ -437,24 +437,21 @@ impl StaticMethods for CodegenCx<'ll, 'tcx> {
437
437
//
438
438
// We could remove this hack whenever we decide to drop macOS 10.10 support.
439
439
if self . tcx . sess . target . target . options . is_like_osx {
440
- assert_eq ! ( alloc. relocations( ) . len( ) , 0 ) ;
441
-
442
- let is_zeroed = {
443
- // Treats undefined bytes as if they were defined with the byte value that
444
- // happens to be currently assigned in mir. This is valid since reading
445
- // undef bytes may yield arbitrary values.
446
- //
447
- // FIXME: ignore undef bytes even with representation `!= 0`.
448
- //
449
- // The `inspect` method is okay here because we checked relocations, and
450
- // because we are doing this access to inspect the final interpreter state
451
- // (not as part of the interpreter execution).
452
- alloc
440
+ // The `inspect` method is okay here because we checked relocations, and
441
+ // because we are doing this access to inspect the final interpreter state
442
+ // (not as part of the interpreter execution).
443
+ //
444
+ // FIXME: This check requires that the (arbitrary) value of undefined bytes
445
+ // happens to be zero. Instead, we should only check the value of defined bytes
446
+ // and set all undefined bytes to zero if this allocation is headed for the
447
+ // BSS.
448
+ let all_bytes_are_zero = alloc. relocations ( ) . is_empty ( )
449
+ && alloc
453
450
. inspect_with_undef_and_ptr_outside_interpreter ( 0 ..alloc. len ( ) )
454
451
. iter ( )
455
- . all ( |b| * b == 0 )
456
- } ;
457
- let sect_name = if is_zeroed {
452
+ . all ( |& byte| byte == 0 ) ;
453
+
454
+ let sect_name = if all_bytes_are_zero {
458
455
CStr :: from_bytes_with_nul_unchecked ( b"__DATA,__thread_bss\0 " )
459
456
} else {
460
457
CStr :: from_bytes_with_nul_unchecked ( b"__DATA,__thread_data\0 " )
0 commit comments