Skip to content

Commit

Permalink
Sanitize auto-function-split names
Browse files Browse the repository at this point in the history
  • Loading branch information
encounter committed Dec 21, 2023
1 parent 2681e51 commit 2271531
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
7 changes: 7 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ ppc750cl = { git = "https://github.com/encounter/ppc750cl", rev = "4a2bbbc6f84dc
rayon = "1.8.0"
regex = "1.10.2"
rustc-hash = "1.1.0"
sanitise-file-name = "1.0.0"
serde = "1.0.192"
serde_json = "1.0.108"
serde_repr = "0.1.17"
Expand Down
8 changes: 7 additions & 1 deletion src/util/split.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ use std::{
use anyhow::{anyhow, bail, ensure, Context, Result};
use itertools::Itertools;
use petgraph::{graph::NodeIndex, Graph};
use sanitise_file_name::sanitize_with_options;
use tracing_attributes::instrument;

use crate::{
Expand Down Expand Up @@ -69,7 +70,12 @@ fn split_ctors_dtors(obj: &mut ObjInfo, start: SectionAddress, end: SectionAddre
.section
.and_then(|idx| obj.sections.get(idx).map(|s| s.name.clone()))
.unwrap_or_else(|| "unknown".to_string());
format!("auto_{}_{}", function_symbol.name, section_name.trim_start_matches('.'))
let name =
sanitize_with_options(&function_symbol.name, &sanitise_file_name::Options {
length_limit: 20,
..Default::default()
});
format!("auto_{}_{}", name, section_name.trim_start_matches('.'))
});
log::debug!("Adding splits to unit {}", unit);

Expand Down

0 comments on commit 2271531

Please sign in to comment.