rustwasm/twiggy

die_parse::item_name should probably use DW_AT_linkage_name instead of DW_AT_name.

Closed this issue · 0 comments

eddyb commented

While it's possible to recover the full path by taking into account the full stack of DW_TAG_namespaces a DW_TAG_subprogram is nested in, it seems easier to rely on DW_AT_linkage_name to get a mangled symbol.

For example is an excerpt from llvm-dwarfdump on a WASM binary:

0x00003712:     DW_TAG_namespace
                  DW_AT_name    ("fmt")

0x00003722:       DW_TAG_namespace
                    DW_AT_name  ("{{impl}}")

0x00003727:         DW_TAG_subprogram
                      DW_AT_low_pc      (0x0000000000002121)
                      DW_AT_high_pc     (0x0000000000002137)
                      DW_AT_linkage_name        ("_ZN50_$LT$$RF$mut$u20$W$u20$as$u20$core..fmt..Write$GT$9write_str17hbf3f51d4e3d51dd3E")
                      DW_AT_name        ("write_str<alloc::string::String>")
                      DW_AT_decl_file   ("/home/eddy/Projects/rust-1/src/libcore/fmt/mod.rs")
                      DW_AT_decl_line   (203)

After replacing DW_AT_name with DW_AT_linkage_name in parser/object_parse/die_parse/item_name.rs, full demangled symbols were available in --mode=dwarf output, so it seems to "just work".