simonlindholm / asm-differ

Assembly diff script
The Unlicense
109 stars 52 forks source link

Ignore differences based on the number appended to function static symbols #175

Open 1superchip opened 3 days ago

1superchip commented 3 days ago

Function static symbols are appended with a number to prevent name collisions with other symbols with the same names.

asm-differ currently matches MWCC literals with the format of @num to any other symbol with the same format. The number appended to the name is internally generated by the compiler for both instances making the numbers irrelevant when matching code. Ignoring differences for function static symbols would make the symbol handling similar in both cases.

asm-differ currently flags the entire symbol as different when the number differs but the name is the same. Different compilers handle the symbol differently. GCC emits a . as the separator while MWCC emits a $.

MWCC: l_matDL$5761 image

GCC: cnt.1

I have not seen a great place to insert the code that compares 2 symbols to each other. It seems like the best place would be somewhere in https://github.com/simonlindholm/asm-differ/blob/main/diff.py#L3140. Any thoughts on where the code should be added?

simonlindholm commented 2 days ago

I have not seen a great place to insert the code that compares 2 symbols to each other. It seems like the best place would be somewhere in https://github.com/simonlindholm/asm-differ/blob/main/diff.py#L3140. Any thoughts on where the code should be added?

Yes, I think that's exactly the place to add it. Maybe and field_matches_any_symbol(nf, config.arch) could be and (field_matches_any_symbol(nf, config.arch) or ...)?