rizinorg / rz-libdemangle

Rizin Library to demangle symbols
7 stars 6 forks source link

Rust 2021 demangling support #30

Closed XVilka closed 1 year ago

XVilka commented 1 year ago

Currently it fails to demangle most of the functions.

rizin -A rust-clap-example.release
[0x100005e84]> afl~sym.__ZN
0x1000580a8    1 76           sym.__ZN4core3ops8function5impls80__LT_impl_u20_core..ops..function..FnOnce_LT_A_GT__u20_for_u20__RF_mut_u20_F_GT_9call_once17hee
0x1000580f8    6 132          sym.__ZN4core3ptr104drop_in_place_LT_alloc..vec..Vec_LT__LP_usize_C_std..backtrace_rs..symbolize..gimli..Mapping_RP__GT__GT_17hf8
0x1000581b0    3 32           sym.__ZN4core3ptr111drop_in_place_LT_alloc..raw_vec..RawVec_LT__LP_usize_C_std..backtrace_rs..symbolize..gimli..Mapping_RP__GT__G
0x1000581e0    1 4            sym.__ZN4core3ptr117drop_in_place_LT_std..sys_common..backtrace.._print_fmt.._u7b__u7b_closure_u7d__u7d_.._u7b__u7b_closure_u7d
0x100058330    4 44           sym.__ZN4core3ptr125drop_in_place_LT_addr2line..FrameIter_LT_gimli..read..endian_slice..EndianSlice_LT_gimli..endianity..LittleEn
0x10005835c    3 24           sym.__ZN4core3ptr126drop_in_place_LT_core..cell..UnsafeCell_LT_core..option..Option_LT_std..backtrace_rs..symbolize..gimli..mmap.
0x100058374    3 36   -> 20   sym.__ZN4core3ptr130drop_in_place_LT_gimli..read..dwarf..Dwarf_LT_gimli..read..endian_slice..EndianSlice_LT_gimli..endianity..Lit
0x10005899c    5 112          sym.__ZN4core3ptr92drop_in_place_LT_std..io..Write..write_fmt..Adapter_LT_std..sys..unix..stdio..Stderr_GT__GT_17h0981bbcea8dbcc3
0x100058a34   11 192          sym.__ZN4core3ptr93drop_in_place_LT_core..option..Option_LT_std..backtrace_rs..symbolize..gimli..Mapping_GT__GT_17h2ea33d423b71ae
0x100058b28    3 20           sym.__ZN4core3ptr95drop_in_place_LT_alloc..vec..Vec_LT_std..backtrace_rs..symbolize..gimli..LibrarySegment_GT__GT_17h89973ee0e59d
0x10005cfac    3 20           sym.__ZN4core3ptr118drop_in_place_LT_alloc..vec..Vec_LT__LP_gimli..common..DebugInfoOffset_C_gimli..common..DebugArangesOffset_RP
0x10005d0b8    1 4            sym.__ZN4core3ptr122drop_in_place_LT__RF_alloc..boxed..Box_LT_dyn_u20_core..error..Error_u2b_core..marker..Send_u2b_core..marker.
0x10005d114    9 152          sym.__ZN4core3ptr137drop_in_place_LT_gimli..read..dwarf..Unit_LT_gimli..read..endian_slice..EndianSlice_LT_gimli..endianity..Litt
0x10005d1c4    6 128          sym.__ZN4core3ptr146drop_in_place_LT_alloc..vec..Vec_LT_addr2line..ResUnit_LT_gimli..read..endian_slice..EndianSlice_LT_gimli..en
0x10005d2b8    3 36   -> 20   sym.__ZN4core3ptr159drop_in_place_LT_alloc..sync..ArcInner_LT_gimli..read..dwarf..Dwarf_LT_gimli..read..endian_slice..EndianSlice
0x10005e118   26 404          sym.__ZN99__LT_alloc..collections..btree..map..BTreeMap_LT_K_C_V_C_A_GT__u20_as_u20_core..ops..drop..Drop_GT_4drop17h8813af00e3eb
0x1000633bc    1 12           sym.__ZN4core3ptr101drop_in_place_LT_alloc..sync..Arc_LT_std..sync..mutex..Mutex_LT_alloc..vec..Vec_LT_u8_GT__GT__GT__GT_17h635e5
0x1000633dc    1 4            sym.__ZN4core3ptr120drop_in_place_LT__LP__RF_std..ffi..os_str..OsString_C__RF_core..option..Option_LT_std..ffi..os_str..OsString
0x100063be8   16 332          sym.__ZN3std2io5impls74__LT_impl_u20_std..io..Write_u20_for_u20_alloc..vec..Vec_LT_u8_C_A_GT__GT_14write_vectored17hde45469881818
0x100063d34    1 8            sym.__ZN3std2io5impls74__LT_impl_u20_std..io..Write_u20_for_u20_alloc..vec..Vec_LT_u8_C_A_GT__GT_17is_write_vectored17h6f6398f294

Demangling rules and algorithms are defined here:

Attaching debug, release binaries, along with the sources (updated from https://github.com/mytechtip/rust-clap-example): rust-2021.zip