| 3469 | bool Arm64PluginInit() |
| 3470 | #else |
| 3471 | BINARYNINJAPLUGIN bool CorePluginInit() |
| 3472 | #endif |
| 3473 | { |
| 3474 | InitAArch64Settings(); |
| 3475 | |
| 3476 | Architecture* arm64 = new Arm64Architecture(); |
| 3477 | |
| 3478 | Architecture::Register(arm64); |
| 3479 | |
| 3480 | // Register calling convention |
| 3481 | Ref<CallingConvention> conv; |
| 3482 | conv = new Arm64CallingConvention(arm64); |
| 3483 | arm64->RegisterCallingConvention(conv); |
| 3484 | arm64->SetDefaultCallingConvention(conv); |
| 3485 | arm64->SetCdeclCallingConvention(conv); |
| 3486 | arm64->SetFastcallCallingConvention(conv); |
| 3487 | arm64->SetStdcallCallingConvention(conv); |
| 3488 | |
| 3489 | conv = new LinuxArm64SystemCallConvention(arm64); |
| 3490 | arm64->RegisterCallingConvention(conv); |
| 3491 | |
| 3492 | conv = new WindowsArm64SystemCallConvention(arm64); |
| 3493 | arm64->RegisterCallingConvention(conv); |
| 3494 | |
| 3495 | conv = new AppleArm64CallingConvention(arm64); |
| 3496 | arm64->RegisterCallingConvention(conv); |
| 3497 | |
| 3498 | for (uint32_t i = REG_X0; i <= REG_X28; i++) |
| 3499 | { |
| 3500 | if (i == REG_X16 || i == REG_X17 || i == REG_X18) // reserved by os. |
| 3501 | continue; |
| 3502 | conv = new AppleArm64ObjcFastARCCallingConvention(arm64, i); |
| 3503 | arm64->RegisterCallingConvention(conv); |
| 3504 | } |
| 3505 | |
| 3506 | // Register ARM64 specific PLT trampoline recognizer |
| 3507 | arm64->RegisterFunctionRecognizer(new Arm64ImportedFunctionRecognizer()); |
| 3508 | |
| 3509 | // Register ARM64 Relocation handlers |
| 3510 | arm64->RegisterRelocationHandler("Mach-O", new Arm64MachoRelocationHandler()); |
| 3511 | arm64->RegisterRelocationHandler("KCView", new Arm64MachoRelocationHandler()); |
| 3512 | arm64->RegisterRelocationHandler("ELF", new Arm64ElfRelocationHandler()); |
| 3513 | arm64->RegisterRelocationHandler("PE", new Arm64PeRelocationHandler()); |
| 3514 | arm64->RegisterRelocationHandler("COFF", new Arm64COFFRelocationHandler()); |
| 3515 | |
| 3516 | // Register the architectures with the binary format parsers so that they know when to use |
| 3517 | // these architectures for disassembling an executable file |
| 3518 | BinaryViewType::RegisterArchitecture("Mach-O", 0x0100000c, LittleEndian, arm64); |
| 3519 | BinaryViewType::RegisterArchitecture("Mach-O", 0x0200000c, LittleEndian, arm64); |
| 3520 | BinaryViewType::RegisterArchitecture("ELF", 0xb7, LittleEndian, arm64); |
| 3521 | BinaryViewType::RegisterArchitecture("ELF", 0xb7, BigEndian, arm64); |
| 3522 | BinaryViewType::RegisterArchitecture("COFF", 0xaa64, LittleEndian, arm64); |
| 3523 | BinaryViewType::RegisterArchitecture("PE", 0xaa64, LittleEndian, arm64); |
| 3524 | BinaryViewType::RegisterArchitecture("PE", 0xaa64, BigEndian, arm64); |
| 3525 | |
| 3526 | return true; |
| 3527 | } |
| 3528 | } |
nothing calls this directly
no test coverage detected