lineiform icon indicating copy to clipboard operation
lineiform copied to clipboard

Handle dynamically linked functions

Open chc4 opened this issue 2 years ago • 1 comments

Right now we just use /proc/self/exe as the ELF to load to look for symbols. This is OK for normal Rust code, since it's statically linked by default, but not for things like "any calls to a malloc" or "any external library".

We should instead open /proc/self/maps to find what ELF the address we're trying to resolve is inside, and check that for the symbol instead. Once we're getting the section mappings from proc maps we also need to use that for finding the base address for symbol vaddr calculation. Currently we just use a .needle symbol, which is hacky af and doesn't work for external ELFs.

We should cache the ELFs (and what sections they're mapped at ) with a RangeMap<usize, Rc<Elf>> or something similar, marking each range to what ELF it's part of so we don't have to keep checking proc maps or reading the ELF from disk.

chc4 avatar Sep 12 '21 22:09 chc4

https://github.com/gimli-rs/findshlibs

chc4 avatar Apr 02 '22 14:04 chc4