diff --git a/src/core/Jitter.cpp b/src/core/Jitter.cpp index 4faad2ad..7eb58aad 100644 --- a/src/core/Jitter.cpp +++ b/src/core/Jitter.cpp @@ -107,9 +107,6 @@ std::unique_ptr Jitter::jitAsm(const std::string& Asm, size_t Size orc::LLJITBuilder Builder; std::string TT = Triple_; orc::JITTargetMachineBuilder JTMB{llvm::Triple(TT)}; - // Note(romain): At this point, the code crashes on OSX/iOS. - // -> To be investigated -#if 0 JTMB.setRelocationModel(Reloc::Model::PIC_); JTMB.setCodeModel(CodeModel::Large); JTMB.setCodeGenOptLevel(CodeGenOpt::Level::None); @@ -117,7 +114,6 @@ std::unique_ptr Jitter::jitAsm(const std::string& Asm, size_t Size Builder .setPlatformSetUp(orc::setUpInactivePlatform) // /!\Only for iOS??? .setJITTargetMachineBuilder(JTMB); -#endif Builder .setJITTargetMachineBuilder(std::move(JTMB)); diff --git a/src/test/passes/break-cfg/basic-aarch64-ios.c b/src/test/passes/break-cfg/basic-aarch64-ios.c new file mode 100644 index 00000000..b33c7a4b --- /dev/null +++ b/src/test/passes/break-cfg/basic-aarch64-ios.c @@ -0,0 +1,56 @@ +// REQUIRES: aarch64-registered-target +// XFAIL: host-platform-linux + +// RUN: clang -target arm64-apple-ios -fno-legacy-pass-manager -O1 -fno-verbose-asm -S %s -o - | FileCheck %s +// RUN: env OMVLL_CONFIG=%S/config_all.py clang -target arm64-apple-ios -fno-legacy-pass-manager -fpass-plugin=%libOMVLL -O1 -fno-verbose-asm -S %s -o - | FileCheck --check-prefix=BREAKCFG-IOS %s + +// BREAKCFG-IOS-LABEL: _check_password.1: +// ; adr x1, #0x10 +// ; ldr x0, [x1, #61] +// ; ldr x1, #16 +// ; blr x1 +// BREAKCFG-IOS: .byte 129 +// BREAKCFG-IOS: .byte 0 +// BREAKCFG-IOS: .byte 0 +// BREAKCFG-IOS: .byte 16 +// BREAKCFG-IOS: .byte 32 +// BREAKCFG-IOS: .byte 208 +// BREAKCFG-IOS: .byte 67 +// BREAKCFG-IOS: .byte 248 +// BREAKCFG-IOS: .byte 129 +// BREAKCFG-IOS: .byte 0 +// BREAKCFG-IOS: .byte 0 +// BREAKCFG-IOS: .byte 88 +// BREAKCFG-IOS: .byte 32 +// BREAKCFG-IOS: .byte 0 +// BREAKCFG-IOS: .byte 63 +// BREAKCFG-IOS: .byte 214 + +// CHECK-LABEL: _check_password: +// BREAKCFG-IOS: Lloh0: +// BREAKCFG-IOS: adrp x8, _check_password.1@PAGE +// BREAKCFG-IOS: Lloh1: +// BREAKCFG-IOS: add x8, x8, _check_password.1@PAGEOFF +// BREAKCFG-IOS: str x8, [sp] +// BREAKCFG-IOS: add x8, x8, #32 +// BREAKCFG-IOS: str x8, [sp, #8] +// BREAKCFG-IOS: ldr x8, [sp, #8] +// BREAKCFG-IOS: blr x8 + +int check_password(const char* passwd, unsigned len) { + if (len != 5) { + return 0; + } + if (passwd[0] == 'O') { + if (passwd[1] == 'M') { + if (passwd[2] == 'V') { + if (passwd[3] == 'L') { + if (passwd[4] == 'L') { + return 1; + } + } + } + } + } + return 0; +} diff --git a/src/test/passes/break-cfg/config_all.py b/src/test/passes/break-cfg/config_all.py new file mode 100644 index 00000000..149959e7 --- /dev/null +++ b/src/test/passes/break-cfg/config_all.py @@ -0,0 +1,12 @@ +import omvll +from functools import lru_cache + +class MyConfig(omvll.ObfuscationConfig): + def __init__(self): + super().__init__() + def break_control_flow(self, mod: omvll.Module, func: omvll.Function): + return True + +@lru_cache(maxsize=1) +def omvll_get_config() -> omvll.ObfuscationConfig: + return MyConfig()