From e7d126f682249dd148ce50eb4a7b817e380c2aa5 Mon Sep 17 00:00:00 2001 From: AK6DN Date: Sun, 9 Apr 2017 19:41:18 -0700 Subject: [PATCH] Updated PSECT address/length processing --- obj2bin.pl | 32 ++++++++++++++++++++++---------- 1 file changed, 22 insertions(+), 10 deletions(-) diff --git a/obj2bin.pl b/obj2bin.pl index 312567f..b9a63ee 100644 --- a/obj2bin.pl +++ b/obj2bin.pl @@ -774,16 +774,28 @@ sub parse_rec ($$$) { $psect{$nam}{FLG}{$flg&(1<<4) ? "R/O" : "R/W"}++; $psect{$nam}{FLG}{$flg&(1<<5) ? "REL" : "ABS"}++; $psect{$nam}{FLG}{$flg&(1<<7) ? "D" : "I/D"}++; - $val++ if $val & 1; - if ($psect{$nam}{FLG}{CON}) { - $psect{$nam}{LENGTH} = $val; - $psect{$nam}{START} = $psectaddr; - $psectname = $nam; - $psectaddr += $val; - } elsif ($psect{$nam}{FLG}{ABS}) { - $psect{$nam}{LENGTH} = $val; - $psect{$nam}{START} = 0; - $psectname = $nam; + $psectname = $nam; + if ($psect{$nam}{FLG}{ABS}) { + # absolute + if ($psect{$nam}{FLG}{CON}) { + # concatenated + warn sprintf("Warning: psect ABS,CON is not supported, psect='%s'\n", $psectname); + } else { + # overlaid + $psect{$nam}{LENGTH} = $val; + $psect{$nam}{START} = 0; + } + } else { + # relative + if ($psect{$nam}{FLG}{CON}) { + # concatenated + $psect{$nam}{LENGTH} = $val; + $psect{$nam}{START} = $psectaddr & 1 ? ++$psectaddr : $psectaddr; + $psectaddr += $val; + } else { + # overlaid + warn sprintf("Warning: psect REL,OVR is not supported, psect='%s'\n", $psectname); + } } } if ($DEBUG) {