# SPDX-License-Identifier: GPL-3.0-or-later # CMOC --limit checks program_end (data end for split layouts). Check ALL ranges. use strict; use warnings; open my $map,'<',$ARGV[0] or die "$ARGV[0]: $!"; my ($code_end,$data_end)=(0,0); while(<$map>){ next unless /^Section: (\S+) \([^)]*\) load at ([0-9A-F]+), length ([0-9A-F]+)/; my ($section,$start,$length)=($1,hex($2),hex($3));next unless $length; my $end=$start+$length; if($section eq 'bss'||$section eq 'rwdata'){ die "Static data outside 0E00..13FF" if $start<0x0E00||$end>0x1400; $data_end=$end if $end>$data_end; }else{ die "Code/read-only data outside 1400..7AFF ($section ends at ".sprintf('%04X',$end).")" if $start<0x1400||$end>0x7B00; $code_end=$end if $end>$code_end; } } die "Missing link-map sections" unless $code_end&&$data_end; printf "Memory bounds: code/const end %04X; static data end %04X; stack reserve 1024 bytes.\n",$code_end,$data_end;