unsupported relocation type: 1031#20
Open
STfly wants to merge 13 commits into
Open
Conversation
added 13 commits
June 22, 2026 11:26
- static mut引用改为addr_of!/addr_of_mut!避免Rust 2024 UB - FFI签名修复(extern C函数数组参数改为指针) - ExecMem添加unsafe impl Send支持Mutex跨线程 - setup_env.py自动检测NDK平台/版本并生成.cargo/config.toml - ldmonitor改为rust_frida可选依赖(feature gate) - 添加crate级dead_code/unused允许抑制非关键warnings
问题根因: - setup_env.py错误地覆盖config.toml而非生成config.local.toml - 缺少-fPIC标志导致生成32位重定位类型 - -mcmodel=large与-fPIC互斥,导致编译失败 修复内容: - 恢复config.toml为基础配置模板 - setup_env.py改为生成config.local.toml(已加入.gitignore) - 添加关键编译标志: -fPIC -fno-builtin -fno-stack-protector - rustflags添加relocation-model=pic - 移除互斥的-mcmodel=large标志 - 更新README添加Rust环境安装说明 验证: - loader构建成功,无32位重定位类型 - bootstrapper.bin: 8797字节 - rustfrida-loader.bin: 14275字节
- config.toml是基础模板,应该提交 - config.local.toml是本地生成文件,应该忽略
- 添加 scripts/quickstart.sh 自动检查环境和构建项目 * 自动检测 NDK、Rust、Python 等依赖 * 支持 macOS 和 Linux 平台 * 彩色输出,清晰的构建进度 * 完整的错误提示和解决建议 - 修改 .gitignore 允许提交 quickstart.sh * scripts/* 忽略其他脚本 * 例外规则保留 quickstart.sh - 完善 README.md 部署文档 * 添加详细环境依赖表格 * 区分 macOS/Linux 平台差异 * 添加首次安装指南 * 添加构建前检查清单 * 添加常见错误排查表
- .gitignore: 允许提交quickstart.sh脚本 * scripts/* 忽略其他脚本 * 保留quickstart.sh例外规则 - README.md: 添加详细环境依赖和安装指南 * 环境依赖表格(macOS/Linux) * 平台差异说明 * 首次安装指南(NDK/Rust/Python) * 构建前检查清单 * 常见错误排查表
问题根因: - cc-rs在PATH中找不到aarch64-linux-android-clang - NDK只提供带API级别的编译器(aarch64-linux-android33-clang) - config.local.toml不会被cargo自动读取 修复方案: - setup_env.py改为直接生成config.toml(不再用config.local.toml) - .gitignore忽略config.toml(本地生成文件) - quickstart.sh自动添加NDK工具链到PATH - 创建符号链接: aarch64-linux-android-clang -> aarch64-linux-android33-clang 影响: - 用户运行quickstart.sh或setup_env.py后自动配置 - config.toml不提交,每个开发者本地生成 - cc-rs现在能正确找到编译器
- 改为检测config.toml(而非config.local.toml) - 与setup_env.py的修改保持一致
问题根因: 1. quickstart.sh的cargo build命令缺少--target aarch64-linux-android参数 2. 导致TARGET环境变量为aarch64-apple-darwin(macOS)而非Android 3. cc-rs使用macOS编译器编译Android专用代码(sys/prctl.h)失败 修复方案: - quickstart.sh: cargo build添加--target aarch64-linux-android参数 - hook_engine_internal.h: #ifdef __ANDROID__包裹sys/prctl.h - build.rs: 为bindgen添加Android target和sysroot参数 影响: - quickstart.sh现在能正确交叉编译到Android平台 - hook_engine代码可在macOS上生成bindgen绑定 - 完整构建流程测试通过
问题: - libagent.so 包含 2 个 R_AARCH64_TLSDESC (1031) 重定位 - rustfrida-loader 不支持此类型,导致注入失败 - 错误信息:unsupported relocation type: 1031 修复: - 在 loader/helpers/rustfrida-loader.c 中添加 TLSDESC 支持 - 将 TLSDESC 重定位目标设为 0(项目不使用 TLS) - 添加 R_AARCH64_TLSDESC 宏定义 (1031) 文档更新: - README 添加 quickstart.sh 一键构建说明 - 更新错误排查表,说明 1031 重定位问题已修复 - 添加 TLSDESC 重定位的技术说明 测试: - 使用 quickstart.sh 完整构建 - 在 Android 设备上测试 spawn 模式注入 com.android.settings - 验证 Agent 加载成功并正常连接
文档: - doc/R_AARCH64_TLSDESC_relocation_fix.md: 详细技术文档 - PULL_REQUEST_TEMPLATE.md: 给 Frida 官方的 PR 说明 内容: - 问题描述和根因分析 - 解决方案和技术细节 - 测试验证方法 - 对 Frida 官方的建议 - 参考资料
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
在使用 rustFrida 的自定义 loader 加载
libagent.so时,遇到以下错误:data/local/tmp/rustfrida --spawn com.android.settings <
╔══════════════════════════════════════╗
║ rustFrida v0.1.0 ║
║ ARM64 Dynamic Instrumentation ║
╚══════════════════════════════════════╝
[] Spawn 模式: 准备注入 com.android.settings
[] 正在修补 SELinux 策略...
[] 找到 1 个新 zygote 进程
[→] 正在注入 zymbiote 到 zygote64 (pid=962)...
[✓] Zymbiote 注入成功: zygote64 (pid=962)
[] 正在启动应用 com.android.settings...
[] 等待进程 com.android.settings 启动... (最长 20s)
[✓] 收到 spawn hello: pid=16320, ppid=962, package=com.android.settings
[] 正在向子进程 16320 注入 agent...
[] 正在附加到进程 PID: 16320 (Frida-style bootstrapper)
[✓] 成功附加到进程 16331,等待 SIGSTOP...
[✓] 进程已停止,可以操作寄存器
[✓] bootstrapper 完成: libc API 已解析
[✓] 已分离目标进程
[!] 注入子进程 16320 失败,正在恢复子进程: Loader link 失败: unsupported relocation type: 1031
[→] 正在恢复子进程 16320...
[✓] 子进程 16320 已恢复运行
[✗] Spawn 注入失败: Loader link 失败: unsupported relocation type: 1031
[] 正在还原 zygote 962 的 patch...
[✓] Zygote 962 patch 已还原
修复意见: https://github.com/STfly/rustFrida/blob/master/PULL_REQUEST_TEMPLATE.md