feat(ostool): prepare boot readiness artifacts#129
Draft
MRNIU wants to merge 1 commit into
Draft
Conversation
Co-authored-by: OpenAI Codex <codex@openai.com> Signed-off-by: Niu Zhihong <zhihong@nzhnb.com>
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.
摘要
disassembly、elf_info、symbols,字段表达产物名而不是底层命令名。__executable_start和首个 load segment。ostool boot prepare,从构建出的 ELF 准备target/boot启动产物包、FIT、DTB copy、boot script、rootfs/boot-partition staging 目录和boot-artifacts.jsonv1 manifest。kernel_os与地址覆盖;需要 FIT 时自动派生 BIN,不要求用户显式配置 binary。[boot] mode = "uboot"配置骨架,当前对缺少boot.firmware的配置提前报错,固件构建与完整 QEMU U-Boot 启动留给后续 PR。整体思路
本 PR 先落非固件的 boot readiness 基座:ELF 仍是唯一 canonical kernel 产物,后续 FIT、BIN、manifest 和 staging 目录都从 ELF 与用户显式 DTB/地址覆盖派生。需要 raw BIN 的路径由 ostool 内部自动准备,避免让配置再暴露手动 binary 选择。
固件相关只保留配置识别和 fail-fast 边界,不在本 PR 里引入 ATF/OpenSBI/U-Boot/UEFI 的 recipe、下载、构建或加载顺序设计。
变更模块
ostool/src/artifact/analysis.rs: 新增 analysis artifact 生成器,使用现有 Rust object tools 映射生成 disassembly、ELF info 和 symbols 文本产物。ostool/src/artifact/elf_metadata.rs: 新增 ELF boot metadata 读取器。ostool/src/boot/prepare.rs: 新增 boot prepare API、v1 manifest、FIT/DTB/boot script/staging 目录准备逻辑。ostool/src/main.rs: 新增ostool boot prepareCLI,支持 build config、Cargo selector、DTB、输出目录、FIT 地址和 staging 开关。ostool/src/run/qemu.rs: 新增[boot]配置和uboot模式 fail-fast。README.md/README.en.md: 同步 boot prepare、analysis artifacts、QEMU boot mode 和to_bin兼容字段说明。兼容性
.build.toml/.qemu.toml不需要修改;新增字段都有默认值。to_bin保留为兼容字段,现有配置仍可继续使用。boot prepare默认会生成 FIT;不支持 FIT arch 的目标可用--no-fit只生成 manifest、ELF metadata、boot script 和 staging 目录。mode = "uboot"当前不会静默 fallback 到 direct boot;缺少或即使显式提供 firmware 都会提前返回明确错误,避免误以为已经完成固件启动链。验证
cargo fmt --all -- --checkcargo clippy --target x86_64-unknown-linux-gnu --all-featurescargo build --target x86_64-unknown-linux-gnu --all-featurescargo test --target x86_64-unknown-linux-gnu -- --nocapturecargo test -p ostool风险
后续