Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Experiment with optional mode where sym files contain mangled names #431

Open
Gankra opened this issue Jul 28, 2022 · 1 comment
Open

Experiment with optional mode where sym files contain mangled names #431

Gankra opened this issue Jul 28, 2022 · 1 comment

Comments

@Gankra
Copy link
Contributor

Gankra commented Jul 28, 2022

Filing this so I don't forget it. This could significantly improve compression, and actually help downstream code in understanding the "structure" of the names as the mangling includes some metadata that you have to moreso guess at from the demangled version.

Apparently it's as simple as removing all the name.demangle calls in these files:

dump_syms/src/linux/elf.rs

Lines 119 to 151 in 213bd65

fn demangle(name: &Name) -> String {
let name = common::fix_symbol_name(name);
if let Language::C = name.language() {
return name.as_str().to_string();
}
match name.demangle(DemangleOptions::complete()) {
Some(demangled) => demangled,
None => {
let aname = name.as_str();
warn!("Didn't manage to demangle {:?}", name);
aname.to_string()
}
}
}
fn demangle_str(name: &str) -> String {
let lang = Name::new(name, NameMangling::Mangled, Language::Unknown).detect_language();
if lang == Language::Unknown {
return name.to_string();
}
let name = Name::new(name, NameMangling::Mangled, lang);
let name = common::fix_symbol_name(&name);
match name.demangle(DemangleOptions::complete()) {
Some(demangled) => demangled,
None => {
warn!("Didn't manage to demangle {}", name);
name.to_string()
}
}
}

match name.demangle(DemangleOptions::complete()) {


Rough design sketch:

  • Off by default, enabled by passing --keep-mangled to dump_syms
  • If enabled, emit INFO MANGLED 1 at the ~top of the file to make it unambiguous to tools that it support it whether the names are mangled or not.

That's it. All the hard work would be in all the downstream tools checking for INFO MANGLED and embedding/invoking a demangler.

@Gankra
Copy link
Contributor Author

Gankra commented Jul 28, 2022

initial conclusion: v0 mangled names are on average longer than the demangled name -- doing this makes the sym file longer. However this is without inlinees, which are presumably the home of really nasty generic balls.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant