noseglasses / elf_diff

A tool to compare ELF binaries
GNU General Public License v3.0
171 stars 21 forks source link

Allow to ignore certain pattern in disassembly diff #98

Closed ensc closed 5 months ago

ensc commented 1 year ago

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

The generated diff might show differences on identical code just because other functions where moved. E.g.

image

is the same code but the disassembled addresses differ because DMAUSBIntHandler was moved some bytes.

Another example is

image

Due to this, almost all reported differences in "Persisting Symbols" are false positives.

Describe the solution you'd like

It would be nice when certain patterns can be ignored. This list of pattern will depend on the target architecture; e.g. on ARM, running disassembly output through

s!(b[a-z\.]*[[:space:]]+)[[a-f0-9]]*([[:space:]]+<.*>)!\1XXXX\2!

would normalize branch instructions so that only symbol relative information in "<...>" (e.g. DMAUSBIntHandler+0x26) are used for comparision.

noseglasses commented 1 year ago

Hi, sorry that it took me so long to get back to this.

I like your idea of masking addresses in a way to suppress address-differencences in the code. But I totally agree, it seems impossible to implement that in a way that would work with all variants of binutitils.

I could imagine providing means to allow the user to define objdump-replacement regex e.g. via command line arguments or via a dedicated yaml file. But this would only make sense if we would also ship meaningful replacement files with this project. Also, some users might consider altered symbol addresses relevant information rather than false positives. Therefore, an address-masking would need to be optional.

Unfortunately, I am currently lacking time to spend on this project. But I would be happy to review a PR that is adding this feature.

noseglasses commented 5 months ago

Closing this as there's no generally applicable solution available. Feel free to re-open if new ideas are available to address this problems or directly submit a PR.