type
status
date
slug
summary
tags
category
icon
password
Property
Aug 8, 2023 11:36 AM
本文基于 ndk r25c (25.2.9519653)
获取ndk r25c
直接下载
使用sdkmanager安装
坑:archlinux 需要sudo archlinux-java set java-8-openjdk
查看clang信息
内容:
下载未精简的clang
![notion image](https://www.notion.so/image/https%3A%2F%2Fs3-us-west-2.amazonaws.com%2Fsecure.notion-static.com%2F342a29a7-6a23-4674-9b83-23015fa45bb7%2FUntitled.png?table=block&id=4f88692c-88b5-477b-a9ad-81eb962c8410&t=4f88692c-88b5-477b-a9ad-81eb962c8410&width=1458&cache=v2)
然后去Google的 prebuilt clang仓库找到 r450784d1 相关的分支并打开:
![notion image](https://www.notion.so/image/https%3A%2F%2Fs3-us-west-2.amazonaws.com%2Fsecure.notion-static.com%2Fa2476bc5-1300-4e79-afca-b7672adc9acd%2FUntitled.png?table=block&id=341a9b55-2d02-4308-bebb-8444ee91e777&t=341a9b55-2d02-4308-bebb-8444ee91e777&width=1788&cache=v2)
点开最新的一个commit,进入
然后点击tgz下载这一份clang
![notion image](https://www.notion.so/image/https%3A%2F%2Fs3-us-west-2.amazonaws.com%2Fsecure.notion-static.com%2F914c728f-0335-4ee0-8b57-4660fb5dd387%2FUntitled.png?table=block&id=feb4c365-2581-4959-972d-97acd41c8f72&t=feb4c365-2581-4959-972d-97acd41c8f72&width=2132&cache=v2)
然后基于这一份clang直接编译llvm动态库插件就可以直接用ndk加载了
解压
编译使用pass实例
- 下载代码
- 修改 CMakeLists.txt,在
project()
后加上
这个时候
cmake ..
会报错这个时候去注释掉
clang/lib64/cmake/llvm/LLVMExports.cmake
下面这一段代码![notion image](https://www.notion.so/image/https%3A%2F%2Fs3-us-west-2.amazonaws.com%2Fsecure.notion-static.com%2Fb6dd05d5-4d4b-4b1c-85fa-2749fff1403c%2FUntitled.png?table=block&id=05f250c5-1dd4-402a-8e70-311e81201e4b&t=05f250c5-1dd4-402a-8e70-311e81201e4b&width=1226&cache=v2)
然后
![notion image](https://www.notion.so/image/https%3A%2F%2Fs3-us-west-2.amazonaws.com%2Fsecure.notion-static.com%2F5ad76a3d-a2d8-4ce2-8b1f-24f96f8c5554%2FUntitled.png?table=block&id=bce8b430-67ff-44f0-9add-60cda7f8d67d&t=bce8b430-67ff-44f0-9add-60cda7f8d67d&width=674&cache=v2)
build.sh:
编译后:
![notion image](https://www.notion.so/image/https%3A%2F%2Fs3-us-west-2.amazonaws.com%2Fsecure.notion-static.com%2F62d9e7fc-a5fe-4053-8c58-d7d7b5b4c4b7%2FUntitled.png?table=block&id=98e288fc-9a90-4065-8f49-3878d65ab8d2&t=98e288fc-9a90-4065-8f49-3878d65ab8d2&width=836&cache=v2)
差不多鸟~
当我们来到macOS上
由于Google编译macOS工具链的系统版本太低,加载so的时候会报错
解决办法:
使用下载的clang替换掉ndk里面的clang
找不到头文件是macOS的问题,修改
build.sh
为后重新编译,成功混淆
![notion image](https://www.notion.so/image/https%3A%2F%2Fs3-us-west-2.amazonaws.com%2Fsecure.notion-static.com%2F59f5fac3-78e8-4d08-bf73-527a93b0fa25%2FUntitled.png?table=block&id=97bceb32-7742-4387-919a-5657736ea78f&t=97bceb32-7742-4387-919a-5657736ea78f&width=810&cache=v2)