orhun / binsider

Analyze ELF binaries like a boss πŸ˜ΌπŸ•΅οΈβ€β™‚οΈ
https://binsider.dev/
Apache License 2.0
2.66k stars 60 forks source link

Sort Symbols by Name or Address #22

Open jgreenbaum opened 1 month ago

jgreenbaum commented 1 month ago

Is your feature request related to a problem? Please describe.

Often I'm looking for symbols around a particular address. I can search for a particular address, but not sort by address so I can browse symbols surrounding an address.

Describe the solution you'd like

A key to sort by address, or sort by name

Describe alternatives you've considered

top is an example of a text UI that provides flexible sorting, like shift-p to sort by process load, and shift-m to sort by memory usage.

Additional context

Filtering would be nice too, like "only show symbols of type FUNC", or sort by symbol type then name or address.

jgreenbaum commented 1 month ago

This should be easy. If you know how you would like this done I can look at prototyping.

orhun commented 1 month ago

Hey, thanks for the issue & idea! I like it ⚑

I think we can add a new key binding (e.g. s) to change the sorting. You can take a look at src/elf/symbols.rs to get an idea of the data structure being used there.

It is wrapped in the Elf struct:

https://github.com/orhun/binsider/blob/236d19e3b264e5550baca849f43e76fbc4bcfa8b/src/elf/mod.rs#L81-L100

And that can be accessed via state.analyzer:

https://github.com/orhun/binsider/blob/236d19e3b264e5550baca849f43e76fbc4bcfa8b/src/app.rs#L27-L28

So we can modify that data to apply the sorting :)

Would you be down to implement it? 🐻