Skip to content

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

@Gankra

Description

@Gankra

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions