将 AMDGPU Code Object (.co) 反汇编为 LLVM 汇编 (.s) 文件
Project description
feifei-hsa-elf-diss
将 AMDGPU Code Object 二进制文件(.co)反汇编为可被 clang/LLVM 重新汇编的 LLVM 汇编 .s 文件,便于修改指令后再编译回 .co。
功能
- 输入:ELF64 amdhsa 格式的
.co文件 - 输出:含
.text、.rodata/.amdhsa_kernel、.amdgpu_metadata的.s文件 - 反汇编:使用 ROCm 提供的
llvm-objdump -d获取指令助记符(含注释与符号行)
安装
pip install feifei-hsa-elf-diss
依赖:Python 3.8+、pyelftools、msgpack。安装时会自动安装。另需系统中有 llvm-objdump(如 ROCm 的 /opt/rocm/llvm/bin/llvm-objdump),可通过环境变量 LLVM_OBJDUMP 指定路径。
用法
feifei-hsa-elf-diss -i kernel.co -o kernel.s
指定 llvm-objdump 路径:
LLVM_OBJDUMP=/path/to/llvm-objdump feifei-hsa-elf-diss -i kernel.co -o kernel.s
或:
feifei-hsa-elf-diss -i kernel.co -o kernel.s --objdump /path/to/llvm-objdump
再汇编为 .co
编辑生成的 kernel.s 后,用 clang 重新汇编:
# 根据实际 gfx 替换 <gfx>,如 gfx942
/opt/rocm/llvm/bin/clang++ -x assembler -target amdgcn--amdhsa --offload-arch=<gfx> kernel.s -o kernel.co
开发 / 从源码运行
git clone https://gitee.com/feifei14119/feifei-hsa-elf-diss.git
cd feifei-hsa-elf-diss
pip install -e .
feifei-hsa-elf-diss -i your.co -o your.s
或在不安装的情况下:
cd codiss && pip install -r requirements.txt
PYTHONPATH=. python tools/codiss.py -i kernel.co -o kernel.s
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file feifei_hsa_elf_diss-0.1.1.tar.gz.
File metadata
- Download URL: feifei_hsa_elf_diss-0.1.1.tar.gz
- Upload date:
- Size: 17.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ee2c37bf6b525558ec99ab37a84ea42d007aff82266f1fbd01110e19998dd336
|
|
| MD5 |
0410f5ec8a0d872b64fbf8cd254cefc7
|
|
| BLAKE2b-256 |
96c9324f5fa47712d76687cd47eaf0cdbce4c1f0fd8ddb838b58792891150e79
|
File details
Details for the file feifei_hsa_elf_diss-0.1.1-py3-none-any.whl.
File metadata
- Download URL: feifei_hsa_elf_diss-0.1.1-py3-none-any.whl
- Upload date:
- Size: 18.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d1d14a6677e4117f6685316cb3efe59caba867f4dcd4c84868b11f193f447492
|
|
| MD5 |
75603788afa636514fac382dda370992
|
|
| BLAKE2b-256 |
964273af02054b3d3837c6b8bf55365c1f163822426eddd867534bae5c4cc238
|