本文基于 ndk r25c (25.2.9519653)
仅测试 Linux 和 macOS
点只因下载:https://dl.google.com/android/repository/android-ndk-r25c-linux.zip
坑:archlinux 需要 sudo archlinux-java set java-8-openjdk
内容:
然后去Google的 prebuilt clang仓库找到 r450784d1 相关的分支并打开:
https://android.googlesource.com/platform/prebuilts/clang/host/linux-x86/+log/refs/heads/master/clang-r450784d
点开最新的一个commit,进入
https://android.googlesource.com/platform/prebuilts/clang/host/linux-x86/+/4d52068718fb7940b103cc49506f77e5d22f25df/clang-r450784d1/
然后点击tgz下载这一份clang
然后基于这一份clang直接编译llvm动态库插件就可以直接用ndk加载了
解压
这个时候cmake ..
会报错
这个时候去注释掉clang/lib64/cmake/llvm/LLVMExports.cmake
下面这一段代码
然后
测试代码来自 https://github.com/bluesadi/Pluto-Obfuscator/tree/main/test/aes
build.sh:
编译后:
差不多鸟~
由于Google编译macOS工具链的系统版本太低,加载so的时候会报错
解决办法:
使用下载的clang替换掉ndk里面的clang
找不到头文件是macOS的问题,修改 build.sh
为
后重新编译,成功混淆
https://www.leadroyal.cn/p/1008/
在我的博客中查看:
https://xtuly.cn/article/ndk-load-llvm-pass-plugin
$ANDROID_HOME
/
tools
/
bin
/
sdkmanager
-
-
install
"ndk;25.2.9519653"
$ANDROID_HOME
/
tools
/
bin
/
sdkmanager
-
-
install
"ndk;25.2.9519653"
cat $ANDROID_HOME
/
ndk
/
25.2
.
9519653
/
toolchains
/
llvm
/
prebuilt
/
linux
-
x86_64
/
AndroidVersion.txt
cat $ANDROID_HOME
/
ndk
/
25.2
.
9519653
/
toolchains
/
llvm
/
prebuilt
/
linux
-
x86_64
/
AndroidVersion.txt
14.0
.
7
based on r450784d1
for
additional information on LLVM revision
and
cherry
-
picks, see clang_source_info.md
14.0
.
7
based on r450784d1
for
additional information on LLVM revision
and
cherry
-
picks, see clang_source_info.md
mkdir clang
tar xzvf clang
-
r450784d1.tar.gz
-
C clang
mkdir clang
tar xzvf clang
-
r450784d1.tar.gz
-
C clang
git clone https:
/
/
github.com
/
LeadroyaL
/
llvm
-
pass
-
tutorial
git clone https:
/
/
github.com
/
LeadroyaL
/
llvm
-
pass
-
tutorial
set
(CMAKE_C_COMPILER
/
home
/
ylarod
/
ndk
-
r25c
/
clang
/
bin
/
clang)
set
(CMAKE_CXX_COMPILER
/
home
/
ylarod
/
ndk
-
r25c
/
clang
/
bin
/
clang)
set
(ENV{LLVM_HOME}
/
home
/
ylarod
/
ndk
-
r25c
/
clang)
set
(CMAKE_C_COMPILER
/
home
/
ylarod
/
ndk
-
r25c
/
clang
/
bin
/
clang)
set
(CMAKE_CXX_COMPILER
/
home
/
ylarod
/
ndk
-
r25c
/
clang
/
bin
/
clang)
set
(ENV{LLVM_HOME}
/
home
/
ylarod
/
ndk
-
r25c
/
clang)
CMake Error at
/
home
/
ylarod
/
ndk
-
r25c
/
clang
/
lib64
/
cmake
/
llvm
/
LLVMExports.cmake:
1036
(message):
The imported target
"LLVMDemangle"
references the
file
"/home/ylarod/ndk-r25c/clang/lib64/libLLVMDemangle.a"
but this
file
does
not
exist. Possible reasons include:
*
The
file
was deleted, renamed,
or
moved to another location.
*
An install
or
uninstall procedure did
not
complete successfully.
*
The installation package was faulty
and
contained
"/home/ylarod/ndk-r25c/clang/lib64/cmake/llvm/LLVMExports.cmake"
but
not
all
the files it references.
Call Stack (most recent call first):
/
home
/
ylarod
/
ndk
-
r25c
/
clang
/
lib64
/
cmake
/
llvm
/
LLVMConfig.cmake:
251
(include)
CMakeLists.txt:
14
(find_package)
CMake Error at
/
home
/
ylarod
/
ndk
-
r25c
/
clang
/
lib64
/
cmake
/
llvm
/
LLVMExports.cmake:
1036
(message):
The imported target
"LLVMDemangle"
references the
file
"/home/ylarod/ndk-r25c/clang/lib64/libLLVMDemangle.a"
but this
file
does
not
exist. Possible reasons include:
*
The
file
was deleted, renamed,
or
moved to another location.
*
An install
or
uninstall procedure did
not
complete successfully.
*
The installation package was faulty
and
contained
"/home/ylarod/ndk-r25c/clang/lib64/cmake/llvm/LLVMExports.cmake"
but
not
all
the files it references.
Call Stack (most recent call first):
[注意]传递专业知识、拓宽行业人脉——看雪讲师团队等你加入!
最后于 2023-5-23 21:29
被Ylarod编辑
,原因: