Describe the bug
When invoking the headless analyzer as follows:
./analyzeHeadless $HOME/ghidra_projects test_project -import PATH_TO_ARMV7_ELF_BINARY -processor "ARM:LE:32:v7" -overwrite
the ELF sections are not analyzed, only a RAM section is created.
To Reproduce
Steps to reproduce the behavior:
Expected behavior
The analyzer should analyze the ELF sections (.data, .text etc.).
I can fix this behaviour by modifying the ARM opinion file as described by the attached patch file.
diff.txt
Environment (please complete the following information):
Is the behavior the same if you import the file through the GUI?
Is the behavior the same if you import the file through the GUI?
No, it isn't. The import functionality in the GUI works as expected.
When it works in the GUI, are you manually changing the processor from v8 to v7?
When it works in the GUI, are you manually changing the processor from v8 to v7?
Yes. I have to turn off the "Show Only Recommended Language/Compiler Specs" option and then select the v7 architecture manually. Could that indicate an issue in the GUI too?
The default languages in the GUI is populated from the opinion files, so if there was no v7 entry in the ARM opinion file, it makes sense that you'd have to show all language/compiler specs to choose v7. I have to debug it but if there is a bug it would probably be with headless not using the -processor field correctly.
I'll look into it today though and get back to you. Thanks for the report.
I think since there is no entry in the opinion file for your ELF, it's defaulting to the BinaryLoader on headless import. If you specify -loader ElfLoader in addition to your v7 processor, does it work?
I think since there is no entry in the opinion file for your ELF, it's defaulting to the BinaryLoader on headless import. If you specify
-loader ElfLoaderin addition to your v7 processor, does it work?
That didn't work either. I get the following output:
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by net.sf.cglib.core.ReflectUtils$2 (file:/build/ghidra/9.1/install/ghidra_9.1_DEV/Ghidra/Framework/Generic/lib/cglib-nodep-2.2.jar) to method java.lang.ClassLoader.defineClass(java.lang.String,byte[],int,int,java.security.ProtectionDomain)
WARNING: Please consider reporting this to the maintainers of net.sf.cglib.core.ReflectUtils$2
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
INFO No load spec found for import file: BINARY (AutoImporter)
ERROR The AutoImporter could not successfully load BINARY with the provided import parameters. Please ensure that any specified processor/cspec arguments are compatible with the loader that is used during import and try again. (HeadlessAnalyzer)
ERROR NOTE: Import failure may be due to missing opinion for "ElfLoader". If so, please contact Ghidra team for assistance. (HeadlessAnalyzer)
ERROR REPORT: Import failed for file: BINARY (HeadlessAnalyzer)
Ok, I need to dig into this...there might be a couple of problems.
Some of this code is going to need an overhaul to work correctly. In the meantime, what you added to the opinion file is a good workaround.