fortrangoingonforty/afs-ld / a3512fb

Browse files

Align leftover linker helpers

Authored by mfwolffe <wolffemf@dukes.jmu.edu>
SHA
a3512fba6bbf38e76eb3b8089ef2a0192315d6dc
Parents
4919d68
Tree
853369f

8 changed files

StatusFile+-
M src/atom.rs 3 1
M src/layout.rs 4 1
M src/link_map.rs 1 1
M src/macho/writer.rs 3 2
M src/reloc/arm64.rs 4 1
M src/string_table.rs 2 3
M src/why_live.rs 2 10
M tests/common/harness.rs 6 3
src/atom.rsmodified
@@ -861,7 +861,9 @@ fn resolve_function_parent(
861861
                             .map(|section| section.addr)
862862
                             .unwrap_or(0),
863863
                     ) as u32;
864
-                    atom_index.get(&(input_sym.sect_idx(), target_offset)).copied()
864
+                    atom_index
865
+                        .get(&(input_sym.sect_idx(), target_offset))
866
+                        .copied()
865867
                 })
866868
                 .flatten()
867869
         }
src/layout.rsmodified
@@ -528,7 +528,10 @@ fn insert_extra_sections(sections: &mut Vec<OutputSection>, extra_sections: &[Ex
528528
                 })
529529
                 .map(|idx| idx + 1)
530530
                 .unwrap_or_else(|| {
531
-                    panic!("missing anchor {:?} for synthetic section {},{}", anchor, section.segment, section.name)
531
+                    panic!(
532
+                        "missing anchor {:?} for synthetic section {},{}",
533
+                        anchor, section.segment, section.name
534
+                    )
532535
                 });
533536
             sections.insert(insert_at, section);
534537
         } else {
src/macho/writer.rsmodified
@@ -2894,12 +2894,13 @@ mod tests {
28942894
         });
28952895
 
28962896
         let by_input_section = atoms.by_input_section();
2897
+        let atom_ranges = build_atom_range_index(&atoms, &by_input_section, None);
28972898
         assert_eq!(
2898
-            find_containing_atom(&atoms, &by_input_section, InputId(7), 3, 4, None),
2899
+            find_containing_atom(&atom_ranges, InputId(7), 3, 4),
28992900
             Some((first, 4))
29002901
         );
29012902
         assert_eq!(
2902
-            find_containing_atom_range(&atoms, &by_input_section, InputId(7), 3, 10, 2, None),
2903
+            find_containing_atom_range(&atom_ranges, InputId(7), 3, 10, 2),
29032904
             Some((second, 2))
29042905
         );
29052906
     }
src/reloc/arm64.rsmodified
@@ -123,7 +123,10 @@ pub struct ThunkPlan {
123123
 
124124
 impl ThunkPlan {
125125
     pub fn split_after_atoms(&self) -> Vec<crate::resolve::AtomId> {
126
-        self.islands.iter().map(|island| island.after_atom).collect()
126
+        self.islands
127
+            .iter()
128
+            .map(|island| island.after_atom)
129
+            .collect()
127130
     }
128131
 
129132
     pub fn output_sections(&self) -> Vec<ExtraOutputSection> {
src/string_table.rsmodified
@@ -159,9 +159,8 @@ impl StringTableBuilder {
159159
             .iter()
160160
             .find_map(|&idx| {
161161
                 let existing = &self.roots[idx];
162
-                (existing.name.len() >= name.len() && existing.name.ends_with(name)).then(|| {
163
-                    existing.offset + (existing.name.len() - name.len()) as u32
164
-                })
162
+                (existing.name.len() >= name.len() && existing.name.ends_with(name))
163
+                    .then(|| existing.offset + (existing.name.len() - name.len()) as u32)
165164
             })
166165
     }
167166
 }
src/why_live.rsmodified
@@ -268,11 +268,7 @@ pub fn format_explanations(
268268
                 out.push('\n');
269269
             }
270270
             if winner != requested {
271
-                writeln!(
272
-                    &mut out,
273
-                    "{requested} was folded to {winner} by -icf=safe"
274
-                )
275
-                .unwrap();
271
+                writeln!(&mut out, "{requested} was folded to {winner} by -icf=safe").unwrap();
276272
             }
277273
             out.push_str(&dead_strip.format_symbol_explanation(sym_table, target));
278274
         }
@@ -293,11 +289,7 @@ pub fn format_explanations(
293289
             out.push('\n');
294290
         }
295291
         if winner != requested {
296
-            writeln!(
297
-                &mut out,
298
-                "{requested} was folded to {winner} by -icf=safe"
299
-            )
300
-            .unwrap();
292
+            writeln!(&mut out, "{requested} was folded to {winner} by -icf=safe").unwrap();
301293
         }
302294
         let target_name = graph.symbol_name(target);
303295
         writeln!(&mut out, "{target_name} is live because:").unwrap();
tests/common/harness.rsmodified
@@ -374,10 +374,13 @@ pub fn load_corpus(root: &Path) -> Result<Vec<LinkCase>, String> {
374374
         let page_ref_checks = read_page_refs(&path.join("page_refs.txt"))?;
375375
         let command_checks = read_command_checks(&path.join("command_checks.txt"))?;
376376
         let artifacts = read_artifacts(&path.join("artifacts.txt"))?;
377
-        let artifact_srcs: HashSet<&str> =
378
-            artifacts.iter().map(|artifact| artifact.src_name.as_str()).collect();
377
+        let artifact_srcs: HashSet<&str> = artifacts
378
+            .iter()
379
+            .map(|artifact| artifact.src_name.as_str())
380
+            .collect();
379381
         inputs.retain(|input| {
380
-            input.file_name()
382
+            input
383
+                .file_name()
381384
                 .and_then(|s| s.to_str())
382385
                 .map(|name| !artifact_srcs.contains(name))
383386
                 .unwrap_or(true)