Skip to content
This repository has been archived by the owner on Sep 25, 2023. It is now read-only.

Please support arm64e #77

Open
sohsatoh opened this issue Apr 20, 2019 · 20 comments
Open

Please support arm64e #77

sohsatoh opened this issue Apr 20, 2019 · 20 comments

Comments

@sohsatoh
Copy link

Could not compile for arm64e.

Error Message
clang-8: error: invalid arch name '-arch arm64e'

@Naville
Copy link
Member

Naville commented Apr 20, 2019

Not something I can do if Apple doesn’t support it. Try using alternative solutions in this project’s repo

@Naville Naville closed this as completed Apr 20, 2019
@Naville
Copy link
Member

Naville commented Apr 20, 2019

I updated the documentation to explain this, take a look https://github.com/HikariObfuscator/Hikari/wiki/Troubleshooting#aarch64e-support

@Naville
Copy link
Member

Naville commented Apr 20, 2019

Updated documentation to add a detailed guide on how to support arm64e

@sohsatoh
Copy link
Author

Thank you!

@Naville Naville reopened this Mar 12, 2020
@Naville
Copy link
Member

Naville commented Mar 12, 2020

Apple has now open-sourced their arm64e implementation, with quite some porting work we can get Hikari proper arm64e now. swiftlang/llvm-project#14

@ca13ra1
Copy link

ca13ra1 commented Sep 20, 2020

@Naville I attempted to compile for arm64e using the Hanabi alternative method which hasn't worked, installed and patched. Am I missing something? Getting the error "invalid arch name '-arch arm64e'". I can compile arm64 no problem. Using in a Theos tweak.

@Naville
Copy link
Member

Naville commented Sep 20, 2020

Not really sure. Apple has now open-sourced their ARM64E so I just ported Hikari to LLVM9+ and used Apple's fork instead. That port won't be open-sourced though

@ca13ra1
Copy link

ca13ra1 commented Sep 20, 2020

@Naville I used the latest HikariObfuscatorInstaller-2020.05.04Signed.pkg and then Hanabi and then that would technically be enough to compile for arm64e as in your documentation about AArch64e Support? In my makefile I include the _CFLAGS += -fobjc-arc -mllvm -enable-allobf Thanks for the quick reply!

@Naville
Copy link
Member

Naville commented Sep 20, 2020

No. Either my documentation is unclear or you misunderstood it. PKG installers were based off now "deprecated" (Or should I say old) LLVM versions which doesn't contain ARM64E support. For AArch64E you'll need to inject Hikari into Apple Clang's Pass Pipeline. Either using Binary hooking(which the subproject Hanabi achieved in older Xcode versions) or port the passes to the LLVM version Apple Clang is using and inject the passes at source-level based off Apple's LLVM fork

EDIT: Typo

@ca13ra1
Copy link

ca13ra1 commented Sep 21, 2020

@Naville Sorry for bugging you again, do you have a link to the binary hooking in Hanabi or code used? I’m not a super experienced developer so bear with me.

I seen a fellow tweak developer using the function wrapper method and it works on arm64e so it’s obviously possible, just unsure how to do it for my tweak just yet.

@Naville
Copy link
Member

Naville commented Sep 21, 2020

The hook itself is pretty trivial, just use standard InlineHook Libraries(I used MobileSubstrate), the actual difficulty lies in knowing where to hook and handling issues which requires actual understanding of LLVM due to it's complexity.

@Naville
Copy link
Member

Naville commented Sep 21, 2020

Hanabi's core mechanism should work fine at least for last major Xcode Release (11 I think) but never bothered porting that implementation due to private fork switching to alternative implementation. But AFAIK it should still work reasonably well as long as you take care of the remaining quirks

@ca13ra1
Copy link

ca13ra1 commented Sep 21, 2020

@Naville I’d really like to get it working for a mobile substrate tweak, so I’ll keep trying and see how far I can get.

@Naville
Copy link
Member

Naville commented Sep 21, 2020

Basically you have two options:

  • Re-adjust the pass pipeline and move those explicit pass execution code into the pass pipeline. Open-Source version of Hikari implicitly assumes those passes are ran in that order to transform the LLVM IR into a canonicalized form that Hikari can handle properly.
  • Rewrite Hikari's core logic to remove those implicit assumptions on the input IR

@sohsatoh
Copy link
Author

sohsatoh commented Sep 21, 2020

@ca13ra1 You may have already tried it, but there are many other simple Obfuscators out there. I merged one of them (LLVM10 compatible) into Apple's LLVM and it's probably working fine; Hikari is one of the most powerful obfuscators and I love it, but that doesn't mean it can't be cracked. (In fact, my tweak once got cracked by Julioverne, probably it is because arm64e isn't obfuscated tho)
My point is that it is easier to use another obfuscator than to rewrite Hikari.

@ca13ra1
Copy link

ca13ra1 commented Sep 25, 2020

@Naville Is it at all possible to just compile to just the function wrapper into my tweak manually? Sorry for the last question. I’m very interested in this project and it’s unfortunate it’s now private.

I’m assuming that’s exactly how the other developer of a tweak did it for arm64e. the developer of the tweak did have issues but seem to resolved them but still using Hakari.

I disassembled the dylib and there’s function built into maybe the %ctor method when the tweak is initialized.

4576D662-D8EA-40B8-941A-714E4D55FF60

@Naville
Copy link
Member

Naville commented Sep 25, 2020

Replied in that repo

@ca13ra1
Copy link

ca13ra1 commented Sep 25, 2020

@Naville Thanks, been pulling my hair out trying to figure this out 😅

@Naville
Copy link
Member

Naville commented Sep 25, 2020

Why are you compiling a compiler pass with your Tweak? It's supposed to be used with your compiler

@ca13ra1
Copy link

ca13ra1 commented Sep 25, 2020

Oops, I'm still trying to figure this all out. Apparently the incorrect way. I'll just have to wait and see what the other developer used or at least hints towards.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants