noseglasses / elf_diff

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

Warning: Unable to read assembly from binary and the html report has no meaningful data. #97

Open AceTheWiz opened 2 years ago

AceTheWiz commented 2 years ago

Describe the bug When I compare two files I get an warning. !!!!!!!!! Warning: Unable to read assembly from binary 'FTD_03_00_00-DEV-BIN/ta1l'. !!!!!!!!! an the html report has no meaningful data.

To Reproduce run py -m elf_diff --old_binary_filename "FTD_03_00_00-DEV-BIN/aiu1l" --new_binary_filename "FTD_03_00_00-BIN/aiu1l" --html_file "diff_report.html"

Expected behavior No warnings or errors and detailed info in the report.

Screenshots N/A

Desktop (please complete the following information):

See attached report and log. console.log diff_report.txt

The report is actually the html output.

noseglasses commented 2 years ago

The log message Unable to detect binary file format of FTD_03_00_00-DEV-BIN/aiu1l suggests that the binutils used (those in c:\MinGW\bin) are not compatible with the supplied binaries. Could you please post the output of file FTD_03_00_00-DEV-BIN/aiu1l. Are your binaries possibly stripped? How do you compile them?

sylveon commented 1 year ago

I am seeing the same issue when trying to use the objdump from the Android NDK (tried both r17 and r21). Manually running ./i686-linux-android-objdump -drwS libmylib.so works fine however

sylveon commented 1 year ago
Tools:
   objdump: /home/sylveon/Android/Sdk/ndk/17.2.4988734/toolchains/x86-4.9/prebuilt/linux-x86_64/bin/i686-linux-android-objdump
   nm:      /home/sylveon/Android/Sdk/ndk/17.2.4988734/toolchains/x86-4.9/prebuilt/linux-x86_64/bin/i686-linux-android-nm
   readelf:      /home/sylveon/Android/Sdk/ndk/17.2.4988734/toolchains/x86-4.9/prebuilt/linux-x86_64/bin/i686-linux-android-readelf
   size:    /home/sylveon/Android/Sdk/ndk/17.2.4988734/toolchains/x86-4.9/prebuilt/linux-x86_64/bin/i686-linux-android-size
Verifying config keys...
Symbol selection regex:
   old binary: 'None'
   new binary: 'None'
Symbol exclusion regex:
   old binary: 'None'
   new binary: 'None'
Parsing symbols of old binary (libRMSDKWrapper_ndk15.so)
File format of binary libRMSDKWrapper_ndk15.so: elf32-i386
Extracting symbols
- |#                                                                                          | 0 Elapsed Time: 0:00:00
Gathering instructions
- |#                                                                                          | 0 Elapsed Time: 0:00:00
⚠⚠⚠ Warning: Unable to read assembly from binary 'libRMSDKWrapper_ndk15.so'. ⚠⚠⚠
Parsing symbols of new binary (libRMSDKWrapper_ndk17.so)
File format of binary libRMSDKWrapper_ndk17.so: elf32-i386
Extracting symbols
- |#                                                                                          | 0 Elapsed Time: 0:00:00
Gathering instructions
- |#                                                                                          | 0 Elapsed Time: 0:00:00
⚠⚠⚠ Warning: Unable to read assembly from binary 'libRMSDKWrapper_ndk17.so'. ⚠⚠⚠
Symbol Statistics:
   old binary (libRMSDKWrapper_ndk15.so):
      0 total symbol(s)
      0 symbol(s) selected
   new binary (libRMSDKWrapper_ndk17.so):
      0 total symbol(s)
      0 symbol(s) selected

   0 persisting symbol(s)
   0 disappeared symbol(s)
   0 new symbol(s)
Adding old symbols to document
- |#                                                                                          | 0 Elapsed Time: 0:00:00
Adding new symbols to document
- |#                                                                                          | 0 Elapsed Time: 0:00:00
Adding appeared symbols to document
- |#                                                                                          | 0 Elapsed Time: 0:00:00
Adding disappeared symbols to document
- |#                                                                                          | 0 Elapsed Time: 0:00:00
Adding persisting symbols to document
- |#                                                                                          | 0 Elapsed Time: 0:00:00
Adding similar symbols to document
- |#                                                                                          | 0 Elapsed Time: 0:00:00
Adding migrated symbols to document
- |#                                                                                          | 0 Elapsed Time: 0:00:00
- |#                                                                                          | 0 Elapsed Time: 0:00:00
- |#                                                                                          | 0 Elapsed Time: 0:00:00
Plugin HTMLExportPairReportPlugin: Multi page html pair report written to directory 'report'
🏁 Done.
⚠ Watch out! Warnings occurred.
LepilkinaElena commented 1 year ago

The similar problem with calling objdump happens with using llvm-objdump, because of this argument https://github.com/noseglasses/elf_diff/blob/8b0b7236fe9cd7bc09aa011528fb904321a0bd5a/src/elf_diff/instruction_collector.py#L140

llvm-objdump has no flag --source-comment. Could it be made optional under the flag?

noseglasses commented 1 year ago

Thanks, @LepilkinaElena for pointing out the source of the problem. Unfortunately, this is something that is not easy to fix as currently elf_diff heavily relies of the --source-comment flag being available. It is required for tagging the assembly and, thus, allowing it to be parsed in a platform-agnostic fashion. Without that we would need an individual assembly parser for each platform that would allow us to distinguish assembly instructions from the rest of binutil's output.

If you have any idea for a workaround, please let me know.

CHy-KK commented 6 months ago

Im also using llvm-objdump in windows platform, is it fixed now?

noseglasses commented 6 months ago

Unfortunately not. If you find a way to convince the llvm-objdump devs to add the missing flag, please let me know.