-
Notifications
You must be signed in to change notification settings - Fork 22
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Exit status does not report "same" or "different", making it impossible to write a script around elf_diff #107
Comments
Thanks for the detailed report. However, what you are asking for would be a really nice feature. But there are other more simple tools that can already tell if two binaries are different. If a true binary comparison e.g. of stripped binaries or hex-files would not work for you, I wonder whether you are rather looking for something that answers the question whether two binaries are equivalent. How is such an equivalence defined? Would it e.g. mean that the stripped binaries are equal and only symbol names changed. Anyway, it would be easy to add an additional command line flag that would make elf_diff report true/false via its exit code. |
Hi. |
Ok, got it. That's kind of what I had in mind when I wrote about "equivalence". I will see what I can do with enabling this feature. For the time being a possible workaround would be to write a small wrapper script that makes elf_diff write its report to a temp-file, grep the report to find out if there are differences and then let the script return the exit code that you expected of elf_diff. An addition to the script approach would be to replace the html plugin with a custom version that simply writes the sum of counts of the migrated, disappeared, ... symbols to a text file. That would greatly simply parsing the report. That solution, however, requires some knowledge of Python's Jinja package. |
I just added a plugin that creates text files that only contain statistics of the diff. The change has not been released yet but is available in current master. |
@noseglasses Hi & thank your for sharing your work! I'm in a diffrent situation, but have tried
EDIT: Would it not be practical to have a way too look at a summary of those changes too? (i.e. the left hand navigation) Any help would be greatly appreciated. |
@fkerle, could you possibly provide a minimum example with two binary files and the exact binutils-versions you are using? THX |
...happy holidays to you, too! |
Just had a try with the test binaries |
Regarding the question whether elf_diff is smart with assembly and relocations. No, it's not. It completely relies on binutils and only compares (mangled) symbol names, symbol sizes and assembly code (text-based). |
Hi @noseglasses If I understand your previous comment correctly, assembly code difference should trigger a significant difference? Example: formatted-main.elf <> formatted-none.elf comparing assembly code manually shows differences. As does the multipage report, for at least
command for diffing the ELFs was: binutils version: |
@fkerle , thanks for the detailed information. Yes, assembly differences are colsidered "significant". |
@noseglasses you're welcome. I appreciate you taking the time to investigate. let me know if I should provide the toolchain (and which executables) for you. BR Florian |
@fkerle, sorry I was busy last week so it took me a while to come back to this. |
@noseglasses no need to apologize. |
Describe the bug
I am trying to use elf_diff in a script to compare whether there was a change in code between two compiles of (ostensibly) the same code. Because this is in a script, I was looking to use the exit code from elf_diff (similar to how you can use the exit code from diff, or cmp, to know if the files being compared are the same or have differences). Unfortunately elf_diff appears to always exit with the same exit code regardless of whether there are actual differences.
To Reproduce
Steps to reproduce the behavior:
Expected behavior
I expected the exit status to be a summary of whether or not the compared files are the same. For example, if you use 'cmp' instead then when comparing /bin/bash to itself you get an exit status of 0, and when comparing bash to true you get an exit status of one. This makes it scriptable.
The text was updated successfully, but these errors were encountered: