- Home /
iOS obfuscation: mono-xcompile produces broken .dll.s
I've been experimenting with obfuscation for Assembly-CSharp.dll on Android and iOS. For Android it was quite simple.
extract the dll from the apk
obfuscate it
put it back in the apk
re-sign it
For iOS it proved to be much more difficult. After Unity generates the XCode project, there is a corresponding .dll.s file for every managed .dll. After lots of googling I found that these .dll.s files are generated from the .dll files by a tool named mono-xcompiler. This tool is invoked by Unity during the build process.
So my strategy was:
let Unity build an XCode project
remove the old Assembly-CSharp.dll.s from Libraries/
obfuscate Data/Managed/Assembly-CSharp.dll
generate a new Assembly-CSharp.dll.s from the obfuscated Assembly-CSharp.dll using mono-xcompiler which comes with Unity
let XCode build the app
However, building the app fails while XCode tries to compile Assembly-CSharp.dll.s into Assembly-CSharp.dll.o. I don't have access to the build environment atm, so I can't give you the exact CompileC command, but the error was something like
/path/to/Assembly-CSharp.dll.s:[numbers]:[number]: error: invalid symbol redefinition plt__class_init_____: ^
/path/to/Assembly-CSharp.dll.s:[numbers]:[number]: error: invalid symbol redefinition plt_class_init: ^
/path/to/Assembly-CSharp.dll.s:[numbers]:[number]: error: invalid symbol redefinition plt_class_init: ^
I suspect one of the following:
I used Eazfuscator.NET to obfuscate the Assembly-CSharp.dll on Windows, however the file was surrounded only by iOS-versions of dependency DLLs so it should be fine. Still, it might be a problem.
I might have used mono-xcompiler in a wrong way:
export MONO_PATH=[xcode-project]/Data/Managed export GAC_PATH=[xcode-project]/Data/Managed export GC_DONT_GC="yes please" mono-xcompiler --aot=full,static,nodebug,asmonly,outfile="../Libraries/Assembly-CSharp.dll.s" "Managed/Assembly-CSharp.dll"
mono-xcompiler or .dll.s-files might be unable to handle an obfuscated .dll. This would totally suck.
Any ideas? Any information about mono-xcompiler or .dll.s that might be helpful?
Answer by Thomas GF · Apr 05, 2013 at 01:22 PM
And I answer myself: plt__class_init_____
(the board filters out the underscores, sorry for that) is actually the static class initializer of a .NET class. And there are exactly as many errors as there are static class initializers in my dll :-) So I removed name obfuscation for those classes and voila: everything works as intended, I have an obfuscated dll in my iOS app.
I am still planning to figure out how I can have class names of classes obfuscated, that use static initializers, but that shouldn't be much of a problem. In the worst case I'll have to replace the static initializers or encapsulate them into another class or something.
Still: obfuscation for Android and iOS works, q.e.d.
Can you assist me in running these lines. I don't know how to start.
Where do i have to put these. It doesn't look like regular ter$$anonymous$$al commands:
export $$anonymous$$ONO_PATH=[xcode-project]/Data/$$anonymous$$anaged
export GAC_PATH=[xcode-project]/Data/$$anonymous$$anaged
export GCDONTGC="yes please"
Thanks,
Peter. :-)
Your answer
Follow this Question
Related Questions
AOT Error for plugin that support both iOS and Android 0 Answers
C++ windows DLL and Android? 1 Answer
I'm looking for help with enemy AI scripting and animations. 1 Answer
iOS and Android Publishing 2 Answers
GameObjects Array Problem 2 Answers