Skip to content

Commit 5b31a85

Browse files
committed
Add segment index to segment labels
This change is needed to support analyzing embedded microcontroller ELF files, which leverage segments to place code and data in either flash or RAM.
1 parent 60ead97 commit 5b31a85

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

src/elf.cc

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1117,7 +1117,20 @@ static void DoReadELFSegments(RangeSink* sink, ReportSegmentsBy report_by) {
11171117
continue;
11181118
}
11191119

1120-
std::string name = "LOAD [";
1120+
// Include the segment index in the label, to support embedded.
1121+
//
1122+
// Including the index in the segment label differentiates
1123+
// segments with the same access control (e.g. RWX vs RW). In
1124+
// ELF files built for embedded microcontroller projects, a
1125+
// segment is used for each distinct type of memory. In simple
1126+
// cases, there is a segment for the flash (which will store
1127+
// code and read-only data) and a segment for RAM (which
1128+
// usually stores globals, stacks, and maybe a heap). In more
1129+
// involved projects, there may be special segments for faster
1130+
// RAM (e.g. core coupled RAM or CCRAM), or there may even be
1131+
// memory overlays to support manual paging of code from flash
1132+
// (which may be slow) into RAM.
1133+
std::string name(absl::StrCat("LOAD #", i, " ["));
11211134

11221135
if (header.p_flags & PF_R) {
11231136
name += 'R';

0 commit comments

Comments
 (0)