Mangled symbol loading from Rust

I'm writing a mangled symbol loader for Rust.

I'm actually soliciting feedback from experienced Rust programmers here, which would be greatly appreciated đź’ś.

General design

I use a design similar to Boost.DLL's mangled import.

I scan the object file for exported symbols. On Mach-O (macOS and friends), I scan the relevant architecture.

While scanning the relevant exported symbol table, I use rustc-demangle to demangle the symbols. I create a map of mangled symbols to demangled symbols (Note: on Mach-O, I also strip the leading underscore, because macOS and friends prepend an underscore to all symbols in the file).

Once I demangle the symbols, I can then use libc::dlsym or whatever to load a symbol from a string, after looking it up in the map.

Drawbacks

Obviously there are caveats I am aware of.

Comments welcome

Let me know what you think on Fedi! I welcome all constructive feedback. I'm sure I haven't thought of everything, and I really want to know what you think. đź’ś

I do ask that you please bring well-thought out arguments, and not just ad hominems and parroted, cargo culted nonsense.

— Elizabeth Ashford (Elizafox) Fedi (elsewhere): @Elizafox@social.treehouse.systems Tip jar: PayPal || CashApp || LiberaPay