fortrangoingonforty/afs-ld / e0ad541

Browse files

Tighten unwind byte parity

Authored by espadonne
SHA
e0ad541b0f685447f55eac61dad089e2a3402167
Parents
718cb1c
Tree
ba1e5e6

1 changed file

StatusFile+-
M tests/linker_run.rs 2 28
tests/linker_run.rsmodified
@@ -515,32 +515,6 @@ struct DataInCodeRecord {
515515
     kind: u16,
516516
 }
517517
 
518
-fn normalized_unwind_words(bytes: &[u8]) -> Vec<u32> {
519
-    let (_, unwind) = output_section(bytes, "__TEXT", "__unwind_info").unwrap();
520
-    let decoded = decode_unwind_info(&unwind).unwrap();
521
-    let mut words: Vec<u32> = unwind
522
-        .chunks_exact(4)
523
-        .map(|chunk| u32::from_le_bytes(chunk.try_into().unwrap()))
524
-        .collect();
525
-    if words.len() < 7 {
526
-        return words;
527
-    }
528
-    let indices_offset_words = words[5] as usize / 4;
529
-    let indices_count = words[6] as usize;
530
-    if indices_count == 0 || words.len() < indices_offset_words + indices_count * 3 {
531
-        return words;
532
-    }
533
-    let base = words[indices_offset_words];
534
-    for idx in 0..indices_count {
535
-        let word = indices_offset_words + idx * 3;
536
-        words[word] = words[word].saturating_sub(base);
537
-    }
538
-    if !decoded.records.is_empty() {
539
-        assert_eq!(decoded.records[0].function_offset, base);
540
-    }
541
-    words
542
-}
543
-
544518
 fn rebased_unwind_bytes(bytes: &[u8]) -> Vec<u8> {
545519
     let header_base = segment_vmaddr(bytes, "__TEXT").unwrap_or(0);
546520
     let text_base = output_section(bytes, "__TEXT", "__text").unwrap().0 - header_base;
@@ -4119,8 +4093,8 @@ fn linker_run_emits_backtrace_metadata_like_apple_ld() {
41194093
     let our_bytes = fs::read(&our_out).unwrap();
41204094
     let apple_bytes = fs::read(&apple_out).unwrap();
41214095
     assert_eq!(
4122
-        normalized_unwind_words(&our_bytes),
4123
-        normalized_unwind_words(&apple_bytes)
4096
+        rebased_unwind_bytes(&our_bytes),
4097
+        rebased_unwind_bytes(&apple_bytes)
41244098
     );
41254099
     assert_eq!(
41264100
         normalize_function_start_offsets(&decode_function_starts(&our_bytes)),