-
Notifications
You must be signed in to change notification settings - Fork 6.2k
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
java.lang.IllegalArgumentException when running RecoverClassesFromRTTIScript.java script #7516
Comments
@redfast00 Are you able to pull from github and do a build? If so, I can add some debug messages that will help identify the issue. Just glancing at your stack trace it appears that it is getting an incorrect value from what it thinks is a vmi typeinfo structure. This makes me think it is incorrectly identifying it in the first place. If you are able to build then we can try and triage this together. I can also add checks for this so that it doesn't blow up but I am curious to know why it is happening in the first place. |
@ghidra007 yes, I can |
@redfast00 The change was pushed out. The script shouldn't blow up there anymore but instead will skip that typeinfo structure. Once you make a build and run it can you go into the log and find the debug message with the following format: : VmiTypeinfoStructure has invalid number of bases: " If you go to the typeinfo address and make a pointer at that address it should be a pointer to either the address just below this __cxxabiv1::__vmi_class_type_info::typeinfo if it is contained in a block with real memory under it or it should point to an external block address with both this symbol and the correspoinding vtable symbol. Are you seeing either of these? If so, which? Also, can you look at the bytes in the field next to the pointer you created. Are the bytes representative of the address it points to or off by some amount - likely 8 or 16? If off, then it indicates relocations are being used. I'm wondering if we are not handling the relocations well in your program and so the vmi typeinfo is being found in the wrong location. If you have relocations and they are fixed up correctly, you should see them marked as APPLIED in the Window-Relocation Table. I'm not sure if you will see relocations listed with no info or if you will not see any at all if they are not fixed up. Can you also make another pointer just below the first one? See if it points to a mangled string which may or may not be created already. I would also be curious if there are other issues with other typeinfos not being created correctly. Are there any more blowups or does the script complete? If all the rest look good then it is probably just a problem with not doing enough checks for this particular vmi structure. If all are wrong, it indicates a relocation issue or some other general processing issue in your program. You can check by looking for other references to the __cxxabiv1::__vmi_class_type_info::typeinfo, the __cxxabiv1::__si_class_type_info::typeinfo, and the __cxxabiv1::__class_type_info::typeinfo. Do you see good typeinfo structures laid down there once the script completes? If you have any other log information pertaining to this script after it runs or any log information about the import and not being able to handle relocations or other import or analysis log errors/warnings, I would be interested in those as well. Thanks! Hopefully we can get to the bottom of what is happening here. |
@ghidra007 it does work a lot better now (it can entirely complete running the plugin), but there are indeed a lot of errors in the console:
(there are a lot more errors, about half are base 0, other half base -1 I then interpreted the address above and below as pointer: The pointer in the middle points to: There are two unsupported relocations in the binary: There are a lot of other errors:
|
Can you tell me what the warning bookmark says at address 118b400? Also, what is at address 460648f0? Does it look like a mangled string? If so, can you turn it into a string and then use the GnuDemanglerScrip.java script (attached) to demangle it? You will have to copy the string and edit the script to hardcode that string. The script must be placed in your <ghidra_install>/Ghidra/Features/GnuDemangler/ghidra_scripts folder. See the comment above the hard coded string example for how to possibly manipulate the string to get it to demangle. Does it demangle to "typeinfo name for <that class's name"? If you look at the other places that reference the vmi typeinfo (11e3268) do they look like good typeinfo structs? |
NOTE: you will have to rename it from .txt to .java. |
This address is not in the binary: in the memory map, there aren't any addresses starting with 4
This is the first place that references the vmi typeinfo; I don't really know what to look for, does this look good? The warnings are EXTERNAL relocation warnings as well. |
What section is this in and what does the data around it look like? This is suspicious and I don't think this instance is valid. I'm wondering if it is choking on some unrelated reference to the vmi class type info. I find the issues with the itanium abi rtti analysis to be more of refusing to do any analysis and lying saying there is no rtti while I'm looking right at it. Edit: I think either something is wrong with the relocations or some analyzer went haywire and created an invalid reference there. A pointer to __vmi_class_typeinfo::vtable+0x4xxxxxx makes no sense. |
This is in |
@redfast00 The other typeinfo structs you shared look good to me. Is your image before or after the script ran? The script should be creating those. Can you create an ImageBaseOffset64 at this location: 460648f0 and see if it creates a reference to anything valid? If so, does it reference a mangled typeinfo-name string? I agree that the relocation amount in the bad vmi looks odd. I am going to ask our relocation expert to take a look and see if they can direct you for more information to determine if that is the issue. For the good class structures can you tell me what their warning bookmark says? Also, we need to see the entry in the Relocation Table for the bad vmi address and for a good one. So if you bring up that window filter on address 0118b400 for the bad one and also 010ae800 for a good one. Can you add the bytes column to that window so we can see that as well as the other columns you showed for the unsupported ones. Also, I'm going to walk you through how to find the relocation structure entry so you can show us what that looks like. |
Before, this is after:
I cannot: 460648f0 is not a valid address in this binary.
For your convenience, I used the export as CSV option
(also no results when I selected big endian) However, when I skipped the image base subtraction step, I did find: and |
@redfast00 Do you see both relocation record in the same binary? If so, can you indicate the name of the memory section (if available) that each is contained within. If they both exist, the implication is that the binary has been pre-linked and relocations should not be applied. We are not good at detecting and handling pre-linked ELF binaries. You could try importing the binary and disable the Import Option for Relocation Processing using default image base. Without the relocation processing the offset-reference will not be applied so I don't know how well the If relocations are being applied when they should not due to prelinking, the issues could go beyond the improper pointer markup you identified. After re-importing with relocation processing disabled, I suggesting doing a Program Diff between the two cases (Bytes only) to see what other area may have been affected. |
@redfast00 Any "EXTERNAL" data relocation cannot be pre-linked. Do you have an "EXTERNAL" block in the program? |
@redfast00 What operating system is this binary intended to load/execute under? |
I am re-opening this ticket until we come to a better understanding on the relocation processing. |
I get the following stack trace when running RecoverClassesFromRTTIScript.java
To Reproduce
Run the
RecoverClassesFromRTTIScript.java
script. I'm afraid I can't share the binary, but I can answer questions quickly.The binary is
ELF 64-bit LSB executable, ARM aarch64, version 1 (GNU/Linux), dynamically linked
. There are multiple compilers in the .comment field in the ELF; GCC and clang.Environment (please complete the following information):
cc @astrelsky @ghidra007 because you worked on similar issues before
The text was updated successfully, but these errors were encountered: