Skip to content

Commit 2271531

Browse files
committed
Sanitize auto-function-split names
Fixes #16
1 parent 2681e51 commit 2271531

File tree

3 files changed

+15
-1
lines changed

3 files changed

+15
-1
lines changed

Cargo.lock

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ ppc750cl = { git = "https://github.com/encounter/ppc750cl", rev = "4a2bbbc6f84dc
5656
rayon = "1.8.0"
5757
regex = "1.10.2"
5858
rustc-hash = "1.1.0"
59+
sanitise-file-name = "1.0.0"
5960
serde = "1.0.192"
6061
serde_json = "1.0.108"
6162
serde_repr = "0.1.17"

src/util/split.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ use std::{
66
use anyhow::{anyhow, bail, ensure, Context, Result};
77
use itertools::Itertools;
88
use petgraph::{graph::NodeIndex, Graph};
9+
use sanitise_file_name::sanitize_with_options;
910
use tracing_attributes::instrument;
1011

1112
use crate::{
@@ -69,7 +70,12 @@ fn split_ctors_dtors(obj: &mut ObjInfo, start: SectionAddress, end: SectionAddre
6970
.section
7071
.and_then(|idx| obj.sections.get(idx).map(|s| s.name.clone()))
7172
.unwrap_or_else(|| "unknown".to_string());
72-
format!("auto_{}_{}", function_symbol.name, section_name.trim_start_matches('.'))
73+
let name =
74+
sanitize_with_options(&function_symbol.name, &sanitise_file_name::Options {
75+
length_limit: 20,
76+
..Default::default()
77+
});
78+
format!("auto_{}_{}", name, section_name.trim_start_matches('.'))
7379
});
7480
log::debug!("Adding splits to unit {}", unit);
7581

0 commit comments

Comments
 (0)