map

A parser for Keil compiler map files, which are build reports describing where program code and data are placed in memory. It reports object sizes, memory regions, symbols, and stack or heap details.

In plain words
What is it for?
Use it in Keil MDK projects to rank object or symbol sizes, inspect memory-region usage, find symbol addresses, and review stack and heap locations.
Why use it?
It helps locate memory-heavy compiled objects and verify the linker’s memory layout without manually searching a large build report.

Command

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add commands/jzl-maker/ea-skill/map
Clone the repo
git clone --depth 1 https://github.com/jzl-maker/EA-SKILL
Per session 0 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 1,253 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00000 $0.01253
Opus 5 $0.00000 $0.00626
Sonnet 5 $0.00000 $0.00251
Haiku 4.5 $0.00000 $0.00125

Measured yesterday against content hash 973210516559, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

map scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured yesterday.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

commands/map.md · 86 lines

How it starts

The opening of the file, as written. The whole thing — 86 lines — stays where its author put it; the contents beside it link to each section on GitHub.

命令: /ea map (Map 文件解析)

功能

解析 Keil 编译生成的 .map 文件,输出 对象内存排行 / 内存分段分布 / 符号地址映射 / 栈堆详情,用于定位内存大户、核对链接布局、查符号地址。

能力 参数 数据来源
对象内存排行 --objects [N] Image component sizes(逐 .o 的 Code/RO/RW/ZI)
内存分段分布 --regions Execution Region(exec/load base、size、max、使用率)
符号排行/查询 --symbols [FILTER] Global Symbols + Image Symbol Table
栈/堆详情 --stack STACK/HEAP Section + __initial_sp/__heap_base 地址

适用:Keil MDK 工程(armcc v5 / armclang v6 的 .map 格式)。GCC/其他工具链暂不支持。

调用方式

py ~/.claude/skills/ea-skill/tools/resource/scripts/map_tool.py --project <工程目录>
# 自动扫描工程下最新 .map → 默认对象排行

# 显式指定 .map
py .../map_tool.py --map build/xxx.map --objects          # 对象排行(默认)
py .../map_tool.py --map build/xxx.map --objects --top 5  # 只看前 5

# 内存分段分布
py .../map_tool.py --map build/xxx.map --regions

# 符号排行(size>0 按字节降序)
py .../map_tool.py --map build/xxx.map --symbols

# 精确查符号地址映射(名字子串 或 0x 地址)
py .../map_tool.py --map build/xxx.map --symbols __initial_sp

# 栈/堆详情
py .../map_tool.py --map build/xxx.map --stack

参数表

参数 必须 说明
--map <file> 是(动作) 显式指定 .map 文件
--project <dir> 是(动作) 工程目录,扫描最新 .map
--objects 是(动作,默认) 对象内存排行
--regions 是(动作) 内存分段分布
--symbols [FILTER] 是(动作) 符号排行;带名字/地址过滤则精确查询
--stack 是(动作) 栈/堆详情
--top N 排行条数(默认 20)
--json 结构化 JSON 输出(整个解析结果)
--dry-run 只打印流程不解析

工作流程(AI 执行闭环)

1. 定位 .map     --project 扫描,或 --map 显式指定
2. 按需取数:
   --objects    哪个 .o 占内存最多(字库/协议栈/业务模块)
   --regions    代码/数据落在哪些区,各区使用率(核对链接脚本)
   --symbols    找内存大户变量/函数,或查某符号的地址(配合 /ea debug 断点)
   --stack      栈/堆分配量 + 初始 SP 地址
3. 分析         内存占比是否合理 → 定位优化对象或异常区

示例闭环:/ea map --objects --top 10 → ehfont_init.o(.constdata 字库 25KB)占大头 → 判断字库是否该挪外部 Flash。

注意事项

  1. 排行口径:对象按 Code+RO+RW+ZI 总量降序;符号只列 size>0 的(Section/Data/Code 类型),Number 调试符号已过滤。
  2. --symbols FILTER 是子串匹配0x 开头按地址精确匹配;空过滤(--symbols 不带值)则排行。
  3. 栈/堆是分配量:STACK/HEAP 是 startup 定义值;运行期峰值用 /ea debug 读 SP 测量。
  4. GBK 编码兼容:工程路径含中文时 .map 可能是 GBK 编码,解析器自动回退。

Read the full file on GitHub · 86 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. yesterday First seen · 86 lines · 0 tokens per session scan A 973210516559

Subscribe to this mod's changes

map is a command published in the GitHub repository jzl-maker/EA-SKILL (4 stars, last pushed 4d ago), licensed MIT. It costs nothing until one of its globs matches a file; then it loads 1,253 tokens. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.