为什么二进制文件那么大?
What
CodeSizer 是一个静态代码大小分析工具。
在注重尺寸的嵌入式固件开发中,最终二进制文件经过大量内联和链接时优化。单个函数符号可能覆盖数十个内联函数。CodeSizer 使用 objdump 和 addr2line 在每个指令地址处展开内联调用栈,从而将代码大小正确归因于每个函数内联调用树中的正确节点。
输出是一个静态 HTML 报告文件,包含少量 JavaScript 用于树状视图展开/折叠等 UI 功能。
How
来自交互式帮助:
usage: codesizer.py [-h] [--cross-prefix CROSS_PREFIX] [--section SECTION]
elf output
Analyse static code size of an ELF file. Disassemble via objdump, unwind inline
call stacks via addr2line, and emit a static HTML report.
positional arguments:
elf input ELF file
output output HTML file
options:
-h, --help show this help message and exit
--cross-prefix CROSS_PREFIX
prefix for objdump and addr2line (default: riscv32-unknown-
elf-)
--section, -j SECTION
Specify ELF section. Pass multiple times for multiple
sections. If unspecified, .text is used.
正确的工具链必须以指定前缀存在于 $PATH 中,或者必须指定工具链二进制文件的完整路径。例如:
-
如果您在 Ubuntu 上安装了
gcc-arm-none-eabi包,请使用--cross-prefix=arm-none-eabi-。 -
如果您在
/opt/riscv/gcc15安装了riscv-gnu-toolchain构建版本,请使用--cross-prefix=/opt/riscv/gcc15/bin/riscv32-unknown-elf-。
Example Output
此 HTML 报告 由以下命令生成:
./codesizer.py --cross-prefix arm-none-eabi- arm-bootrom.elf arm-bootrom.html -j .text -j .secure_gateways
ELF 文件来自 RP2350 A4 bootrom 发布版本。
0 Comments
Log in to join the conversation.No comments yet. Be the first to share your thoughts.