-
-
Notifications
You must be signed in to change notification settings - Fork 361
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
Autodetect asm.cpu
whenever possible
#3747
Comments
Hi. I would like to work on this issue. I think I have got an idea on how to resolve this. |
Hi. Just to be clear, is our intention to simply recognize the cpu profile (eg: A, M, R, etc) or the specific processor family (eg: cortex, neoverse, etc.) that the elf is expected to run on? Based on what I have understood after reading through ARM's addenda to their ABI and this wikipedia page on the list of ARM processors, it's quite clear that the "M" profile implies the cortex-m processor family or a similar family (like SecurCore) which shares the same features. However, the "A" cpu profile could imply the cortex-a family or the neoverse family. I noticed the following struct in RzAsmPlugin rz_asm_plugin_arm_cs = {
.name = "arm",
.desc = "Capstone ARM disassembler",
.cpus = "v8,cortexm,arm1176,cortexA72,cortexA8",
.platforms = "bcm2835,omap3430",
.features = "v8",
.license = "BSD",
.arch = "arm",
.bits = 16 | 32 | 64,
.endian = RZ_SYS_ENDIAN_LITTLE | RZ_SYS_ENDIAN_BIG,
.disassemble = &disassemble,
...
} The |
@valdaarhun for now detecting profile is enough, but since Rizin ARM decoding is based on Capstone, only those make sense for autodetection (https://github.com/capstone-engine/capstone/blob/next/include/capstone/arm.h#L1638):
As rizin doesn't have a way to select particular features, only CPUs with sets of particular features are possible for now. cc @Rot127 |
@valdaarhun if you check |
I see. In that case, I'll just focus on these two classes. |
Hi. The functions In When rizin is run with |
Hmm, I thought this value is used somewhere, my bad. Ok, you need to pass it to the config somehow, yes. It's probably should be done somewhere in |
Thank you for your response. I'll take a look at |
@valdaarhun Sorry, I missed the mention above from @XVilka. It's fine, if for now it can only check for |
It is common to have ELF for ARM Cortex-M profile but it's not shown in the ELF header:
But the CPU profile can affect analysis drastically in the case of ARM Cortex-M, for example, because of additional instructions, and being Thumb, it has some effect on the sequence of disassembly.
We should figure out a way to detect Cortex-M ELFs whenever possible. Currently you have to specify it from command line:
Would be nice to autodetect cortexm/cortexa profiles whenever possible.
Quite often compilers add a special section
.ARM.attributes
that has that information (note theTag_CPU_arch_profile
andTag_CPU_arch
attributes):See https://stackoverflow.com/questions/70071681/how-can-i-know-if-an-elf-file-is-for-cortex-a-or-cortex-m for more information
It should be changed somewhere probably in
librz/bin/format/elf/
.See file
librz/bin/format/elf/elf_info.c
andget_cpu_mips()
function as an example.The text was updated successfully, but these errors were encountered: