heroims / obfuscator

ollvm,base on llvm-clang 5.0.2, 6.0.1 , 7.0.1,8.0,9.0,9.0.1,10.x,11.x,12.x,13.x,14.x,swift-llvm-clang 5.0,swift-llvm-clang 5.5
1.08k stars 315 forks source link

aesSeed flag causing duplicate symbols #32

Open ghost opened 2 years ago

ghost commented 2 years ago

Describe the bug Getting Duplicate symbols error when trying to use aesSeed flag. Without the aesSeed flags, it works fine

To Reproduce Use this flag LOCAL_CPPFLAGS += -mllvm -sub -mllvm -fla -mllvm -split -mllvm -bcf -mllvm -sobf -mllvm -aesSeed=0xada46ab5da824b96a18409c49dc91dc3 in Android.mk

Expected behavior Should be able to compile without errors

Desktop (please complete the following information):

Souce Code (please complete the following information): Cannot share my private source code

Additional context I'm using NDK 25.1.8937393 with llvm 14.0.6. I patched llvm 14.x branch with legacy patch and followed this tutorial to compile https://blog.csdn.net/qq_41923691/article/details/123258565

This issue does not happen on Ollvm 9.0.1

Logs

[armeabi-v7a] SharedLibrary  : libab.so
ld: error: duplicate symbol: .datadiv_decode14922226972744637069
>>> defined at And64InlineHook.cpp
>>>            ./obj/local/armeabi-v7a/objs/ab/And64InlineHook/And64InlineHook.o:(.datadiv_decode14922226972744637069)
>>> defined at near_trampoline_arm64.cc
>>>            ./obj/local/armeabi-v7a/objs/ab/dobby/source/InterceptRouting/RoutingPlugin/NearBranchTrampoline/near_trampoline_arm64.o:(.text..datadiv_decode14922226972744637069+0x0)

ld: error: duplicate symbol: .datadiv_decode14922226972744637069
>>> defined at And64InlineHook.cpp
>>>            ./obj/local/armeabi-v7a/objs/ab/And64InlineHook/And64InlineHook.o:(.datadiv_decode14922226972744637069)
>>> defined at CpuRegister.cc
>>>            ./obj/local/armeabi-v7a/objs/ab/dobby/source/core/arch/CpuRegister.o:(.text..datadiv_decode14922226972744637069+0x0)

ld: error: duplicate symbol: .datadiv_decode14922226972744637069
>>> defined at And64InlineHook.cpp
>>>            ./obj/local/armeabi-v7a/objs/ab/And64InlineHook/And64InlineHook.o:(.datadiv_decode14922226972744637069)
>>> defined at assembler-arm64.cc
>>>            ./obj/local/armeabi-v7a/objs/ab/dobby/source/core/assembler/assembler-arm64.o:(.text..datadiv_decode14922226972744637069+0x0)

ld: error: duplicate symbol: .datadiv_decode14922226972744637069
>>> defined at And64InlineHook.cpp
>>>            ./obj/local/armeabi-v7a/objs/ab/And64InlineHook/And64InlineHook.o:(.datadiv_decode14922226972744637069)
>>> defined at codegen-arm64.cc
>>>            ./obj/local/armeabi-v7a/objs/ab/dobby/source/core/codegen/codegen-arm64.o:(.text..datadiv_decode14922226972744637069+0x0)

ld: error: duplicate symbol: .datadiv_decode14922226972744637069
>>> defined at And64InlineHook.cpp
>>>            ./obj/local/armeabi-v7a/objs/ab/And64InlineHook/And64InlineHook.o:(.datadiv_decode14922226972744637069)
>>> defined at InstructionRelocationARM64.cc
>>>            ./obj/local/armeabi-v7a/objs/ab/dobby/source/InstructionRelocation/arm64/InstructionRelocationARM64.o:(.text..datadiv_decode14922226972744637069+0x0)

ld: error: duplicate symbol: .datadiv_decode14922226972744637069
>>> defined at And64InlineHook.cpp
>>>            ./obj/local/armeabi-v7a/objs/ab/And64InlineHook/And64InlineHook.o:(.datadiv_decode14922226972744637069)
>>> defined at trampoline_arm64.cc
>>>            ./obj/local/armeabi-v7a/objs/ab/dobby/source/TrampolineBridge/Trampoline/arm64/trampoline_arm64.o:(.text..datadiv_decode14922226972744637069+0x0)

ld: error: duplicate symbol: .datadiv_decode14922226972744637069
>>> defined at And64InlineHook.cpp
>>>            ./obj/local/armeabi-v7a/objs/ab/And64InlineHook/And64InlineHook.o:(.datadiv_decode14922226972744637069)
>>> defined at helper_arm64.cc
>>>            ./obj/local/armeabi-v7a/objs/ab/dobby/source/TrampolineBridge/ClosureTrampolineBridge/arm64/helper_arm64.o:(.text..datadiv_decode14922226972744637069+0x0)

ld: error: duplicate symbol: .datadiv_decode14922226972744637069
>>> defined at And64InlineHook.cpp
>>>            ./obj/local/armeabi-v7a/objs/ab/And64InlineHook/And64InlineHook.o:(.datadiv_decode14922226972744637069)
>>> defined at closure_bridge_arm64.cc
>>>            ./obj/local/armeabi-v7a/objs/ab/dobby/source/TrampolineBridge/ClosureTrampolineBridge/arm64/closure_bridge_arm64.o:(.text..datadiv_decode14922226972744637069+0x0)

ld: error: duplicate symbol: .datadiv_decode14922226972744637069
>>> defined at And64InlineHook.cpp
>>>            ./obj/local/armeabi-v7a/objs/ab/And64InlineHook/And64InlineHook.o:(.datadiv_decode14922226972744637069)
>>> defined at ClosureTrampolineARM64.cc
>>>            ./obj/local/armeabi-v7a/objs/ab/dobby/source/TrampolineBridge/ClosureTrampolineBridge/arm64/ClosureTrampolineARM64.o:(.text..datadiv_decode14922226972744637069+0x0)

ld: error: duplicate symbol: .datadiv_decode16268766865428279510
>>> defined at helper_arm.cc
>>>            ./obj/local/armeabi-v7a/objs/ab/dobby/source/TrampolineBridge/ClosureTrampolineBridge/arm/helper_arm.o:(.datadiv_decode16268766865428279510)
>>> defined at InterceptEntry.cpp
>>>            ./obj/local/armeabi-v7a/objs/ab/dobby/source/InterceptEntry.o:(.text..datadiv_decode16268766865428279510+0x0)
clang++: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [E:/AndroidSDK/ndk/25.1.8937393/build/../build/core/build-binary.mk:657: obj/local/armeabi-v7a/libab.so] Error 1
make: *** Waiting for unfinished jobs....
[arm64-v8a] Compile++      : ab <= hook.cpp
[arm64-v8a] Compile++      : ab <= InterceptEntry.cpp
[arm64-v8a] Compile++      : ab <= closure_bridge_arm64.cc
ghost commented 2 years ago

Same problem

ghost commented 1 year ago

I got the same issue too. I'm using cmake with NDK 25

[D:\Android\Sdk\cmake\3.22.1\bin\cmake, -HD:\A\AT\oc5BF\nmm\dex2c, -DCMAKE_TOOLCHAIN_FILE=D:\Android\Sdk\ndk\25.1.8937393\build\cmake\android.toolchain.cmake, -DCMAKE_BUILD_TYPE=Release, -DANDROID_ABI=arm64-v8a, -DANDROID_NDK=D:/Android/Sdk/ndk/25.1.8937393, -DANDROID_PLATFORM=android-21, -DCMAKE_ANDROID_ARCH_ABI=arm64-v8a, -DCMAKE_ANDROID_NDK=D:/Android/Sdk/ndk/25.1.8937393, -DCMAKE_EXPORT_COMPILE_COMMANDS=ON, -DCMAKE_LIBRARY_OUTPUT_DIRECTORY=D:\A\AT\oc5BF\nmm\obj\arm64-v8a, -DCMAKE_MAKE_PROGRAM=D:\Android\Sdk\cmake\3.22.1\bin\ninja, -DCMAKE_SYSTEM_NAME=Android, -DCMAKE_SYSTEM_VERSION=21, -BD:\A\AT\oc5BF\nmm\.cxx\cmake\Release\arm64-v8a, -GNinja]
-- The C compiler identification is Clang 14.0.6
-- The CXX compiler identification is Clang 14.0.6
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: D:/Android/Sdk/ndk/25.1.8937393/toolchains/llvm/prebuilt/windows-x86_64/bin/clang.exe - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: D:/Android/Sdk/ndk/25.1.8937393/toolchains/llvm/prebuilt/windows-x86_64/bin/clang++.exe - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Configuring done
-- Generating done
-- Build files have been written to: D:/A/AT/oc5BF/nmm/.cxx/cmake/Release/arm64-v8a
[D:\Android\Sdk\cmake\3.22.1\bin\cmake, --build, D:\A\AT\oc5BF\nmm\.cxx\cmake\Release\arm64-v8a]
[1/19] Building C object CMakeFiles/bevuOKmgzuPtrh.dir/ConstantPool.c.o
[2/19] Building C object CMakeFiles/bevuOKmgzuPtrh.dir/generated/classes5_native_functions.c.o
[3/19] Building C object CMakeFiles/bevuOKmgzuPtrh.dir/generated/classes4_native_functions.c.o
[4/19] Building C object CMakeFiles/bevuOKmgzuPtrh.dir/generated/classes3_native_functions.c.o
[5/19] Building C object CMakeFiles/bevuOKmgzuPtrh.dir/generated/classes8_native_functions.c.o
[6/19] Building C object CMakeFiles/bevuOKmgzuPtrh.dir/generated/classes6_native_functions.c.o
[7/19] Building C object CMakeFiles/bevuOKmgzuPtrh.dir/generated/classes2_native_functions.c.o
[8/19] Building C object CMakeFiles/bevuOKmgzuPtrh.dir/generated/classes7_native_functions.c.o
[9/19] Building C object CMakeFiles/bevuOKmgzuPtrh.dir/generated/jni_init.c.o
[10/19] Building C object CMakeFiles/bevuOKmgzuPtrh.dir/generated/classes_native_functions.c.o
[11/19] Building C object CMakeFiles/bevuOKmgzuPtrh.dir/generated/classes9_native_functions.c.o
[12/19] Building C object CMakeFiles/bevuOKmgzuPtrh.dir/generated/classes10_native_functions.c.o
[13/19] Building CXX object vm/CMakeFiles/RjjptjURNkyiz.dir/Exception.cpp.o
[14/19] Building CXX object vm/CMakeFiles/RjjptjURNkyiz.dir/Interp.cpp.o
[15/19] Building CXX object vm/CMakeFiles/RjjptjURNkyiz.dir/GlobalCache.cpp.o
[16/19] Building CXX object vm/CMakeFiles/RjjptjURNkyiz.dir/DexCatch.cpp.o
[17/19] Building CXX object vm/CMakeFiles/RjjptjURNkyiz.dir/InterpC-portable.cpp.o
vmInterpret Contains Exception Handing Instructions and is unsupported for flattening in the open-source version of Hikari.
[18/19] Linking CXX shared library D:\A\AT\oc5BF\nmm\obj\arm64-v8a\libRjjptjURNkyiz.so
[19/19] Linking C shared library D:\A\AT\oc5BF\nmm\obj\arm64-v8a\libbevuOKmgzuPtrh.so
FAILED: D:/A/AT/oc5BF/nmm/obj/arm64-v8a/libbevuOKmgzuPtrh.so 
cmd.exe /C "cd . && D:\Android\Sdk\ndk\25.1.8937393\toolchains\llvm\prebuilt\windows-x86_64\bin\clang.exe --target=aarch64-none-linux-android21 --sysroot=D:/Android/Sdk/ndk/25.1.8937393/toolchains/llvm/prebuilt/windows-x86_64/sysroot -fPIC -g -DANDROID -fdata-sections -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -D_FORTIFY_SOURCE=2 -Wformat -Werror=format-security  -mllvm -sub -mllvm -fla -mllvm -split -mllvm -bcf -mllvm -sobf -mllvm -aesSeed=0x29da86e29c7595ad14ea994897b8c76f -O3 -DNDEBUG  -fvisibility=hidden -Wno-error=format-security -ffunction-sections -fdata-sections -w  -static-libstdc++ -Wl,--build-id=sha1 -Wl,--no-rosegment -Wl,--fatal-warnings -Wl,--gc-sections -Wl,--no-undefined -Qunused-arguments -shared -Wl,-soname,libbevuOKmgzuPtrh.so -o D:\A\AT\oc5BF\nmm\obj\arm64-v8a\libbevuOKmgzuPtrh.so CMakeFiles/bevuOKmgzuPtrh.dir/ConstantPool.c.o CMakeFiles/bevuOKmgzuPtrh.dir/generated/classes10_native_functions.c.o CMakeFiles/bevuOKmgzuPtrh.dir/generated/classes2_native_functions.c.o CMakeFiles/bevuOKmgzuPtrh.dir/generated/classes3_native_functions.c.o CMakeFiles/bevuOKmgzuPtrh.dir/generated/classes4_native_functions.c.o CMakeFiles/bevuOKmgzuPtrh.dir/generated/classes5_native_functions.c.o CMakeFiles/bevuOKmgzuPtrh.dir/generated/classes6_native_functions.c.o CMakeFiles/bevuOKmgzuPtrh.dir/generated/classes7_native_functions.c.o CMakeFiles/bevuOKmgzuPtrh.dir/generated/classes8_native_functions.c.o CMakeFiles/bevuOKmgzuPtrh.dir/generated/classes9_native_functions.c.o CMakeFiles/bevuOKmgzuPtrh.dir/generated/classes_native_functions.c.o CMakeFiles/bevuOKmgzuPtrh.dir/generated/jni_init.c.o  D:/A/AT/oc5BF/nmm/obj/arm64-v8a/libRjjptjURNkyiz.so  -llog  -latomic -lm && cd ."
Exception in thread "main" java.io.IOException: Cmd '[D:\Android\Sdk\cmake\3.22.1\bin\cmake, --build, D:\A\AT\oc5BF\nmm\.cxx\cmake\Release\arm64-v8a]' exec failed
ld: error: duplicate symbol: .datadiv_decode14541771729251396985
    at com.nmmedit.apkprotect.BuildNativeLib.execCmd(BuildNativeLib.java:61)
>>> defined at classes2_native_functions.c
    at com.nmmedit.apkprotect.BuildNativeLib.build(BuildNativeLib.java:27)
>>>            CMakeFiles/bevuOKmgzuPtrh.dir/generated/classes2_native_functions.c.o:(.datadiv_decode14541771729251396985)
    at com.nmmedit.apkprotect.ApkProtect.generateNativeLibs(ApkProtect.java:237)
>>> defined at classes3_native_functions.c
    at com.nmmedit.apkprotect.ApkProtect.run(ApkProtect.java:137)
>>>            CMakeFiles/bevuOKmgzuPtrh.dir/generated/classes3_native_functions.c.o:(.text..datadiv_decode14541771729251396985+0x0)
    at com.nmmedit.protect.Main.main(Main.java:60)
ld: error: duplicate symbol: .datadiv_decode14541771729251396985
>>> defined at classes2_native_functions.c
>>>            CMakeFiles/bevuOKmgzuPtrh.dir/generated/classes2_native_functions.c.o:(.datadiv_decode14541771729251396985)
>>> defined at classes4_native_functions.c
>>>            CMakeFiles/bevuOKmgzuPtrh.dir/generated/classes4_native_functions.c.o:(.text..datadiv_decode14541771729251396985+0x0)
ld: error: duplicate symbol: .datadiv_decode14541771729251396985
>>> defined at classes2_native_functions.c
>>>            CMakeFiles/bevuOKmgzuPtrh.dir/generated/classes2_native_functions.c.o:(.datadiv_decode14541771729251396985)
>>> defined at classes5_native_functions.c
>>>            CMakeFiles/bevuOKmgzuPtrh.dir/generated/classes5_native_functions.c.o:(.text..datadiv_decode14541771729251396985+0x0)
ld: error: duplicate symbol: .datadiv_decode14541771729251396985
>>> defined at classes2_native_functions.c
>>>            CMakeFiles/bevuOKmgzuPtrh.dir/generated/classes2_native_functions.c.o:(.datadiv_decode14541771729251396985)
>>> defined at classes6_native_functions.c
>>>            CMakeFiles/bevuOKmgzuPtrh.dir/generated/classes6_native_functions.c.o:(.text..datadiv_decode14541771729251396985+0x0)
ld: error: duplicate symbol: .datadiv_decode14541771729251396985
>>> defined at classes2_native_functions.c
>>>            CMakeFiles/bevuOKmgzuPtrh.dir/generated/classes2_native_functions.c.o:(.datadiv_decode14541771729251396985)
>>> defined at classes7_native_functions.c
>>>            CMakeFiles/bevuOKmgzuPtrh.dir/generated/classes7_native_functions.c.o:(.text..datadiv_decode14541771729251396985+0x0)
ld: error: duplicate symbol: .datadiv_decode14541771729251396985
>>> defined at classes2_native_functions.c
>>>            CMakeFiles/bevuOKmgzuPtrh.dir/generated/classes2_native_functions.c.o:(.datadiv_decode14541771729251396985)
>>> defined at classes8_native_functions.c
>>>            CMakeFiles/bevuOKmgzuPtrh.dir/generated/classes8_native_functions.c.o:(.text..datadiv_decode14541771729251396985+0x0)
ld: error: duplicate symbol: .datadiv_decode14541771729251396985
>>> defined at classes2_native_functions.c
>>>            CMakeFiles/bevuOKmgzuPtrh.dir/generated/classes2_native_functions.c.o:(.datadiv_decode14541771729251396985)
>>> defined at classes_native_functions.c
>>>            CMakeFiles/bevuOKmgzuPtrh.dir/generated/classes_native_functions.c.o:(.text..datadiv_decode14541771729251396985+0x0)
clang: error: linker command failed with exit code 1 (use -v to see invocation)
ninja: build stopped: subcommand failed.
ghost commented 1 year ago

Kk, I tried heroims ollvm 9.0.1 on NDK 21.3 and got the same error too, so aesSeed is obviously broken