tools: add find-reachable-from-loader-func cmd to check_callgraph.py#554
tools: add find-reachable-from-loader-func cmd to check_callgraph.py#554almir-okato wants to merge 1 commit into
Conversation
|
In |
find-reachable-from-loader-func find the call/object references reachable from a given root function that should be placed in the i/dram_loader_seg of MCUboot bootloader. Signed-off-by: Almir Okato <almir.okato@espressif.com>
8315325 to
66f22df
Compare
Checking Regarding the |
| return 'IRAM_LOADER' | ||
| # DRAM data/rodata/bss placement | ||
| if (sym.is_object() or sec.startswith('.rodata') or sec.startswith('.bss') or '.rodata' in sec or '.bss' in sec or '.data' in sec): | ||
| if any(sec.startswith(s) for s in dram_like + ['.dram', '.dram0', '.dram0.bss', '.dram0.data', '.dram0.rodata']): |
There was a problem hiding this comment.
Should you also add here '.rodata', '.bss', '.data', '.sbss', '.sdata', '.srodata' as well? In bootloader.ld files, those areas lives in DRAM area, right?
| from collections import deque | ||
| from functools import partial | ||
| from typing import BinaryIO, Callable, Dict, Generator, List, Optional, Tuple | ||
| from typing import BinaryIO, Callable, Dict, Generator, List, Optional, Tuple, Set |
| # Optionally annotate symbols with origin from map | ||
| if map_path: | ||
| symbol_names: Set[str] = {s.name for s in symbols} | ||
| origin_map = build_origin_map(map_path, symbol_names) |
There was a problem hiding this comment.
What happens when two same-named static symbols from different object files? Perhaps it should check name,addr instead?
| ), | ||
| ] | ||
|
|
||
| def print_loader_linker_summary(origins: List[str]) -> None: |
There was a problem hiding this comment.
From AI assisted review:
When the --summary path runs, it always emits linker fragments for all three segments regardless of what was actually found. If a user runs this against a binary where only IRAM symbols are out of place, the output will still suggest adding object patterns to .dram_loader.bss and .dram_loader.data — which would be wrong linker script additions. That can actively mislead whoever is acting on the output.
The fix is straightforward: pass two separate origin sets to the summary function (one for IRAM, one for DRAM) and only emit the segment entries that have at least one pattern.
find-reachable-from-loader-func find the call/object references from a given root function that should be placed in the i/dram_loader_seg of MCUboot bootloader (works for Espressif Port and Zephyr Port).