aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xdata/bin2bac.pl27
1 files changed, 24 insertions, 3 deletions
diff --git a/data/bin2bac.pl b/data/bin2bac.pl
index 2fab8a4..edc67bd 100755
--- a/data/bin2bac.pl
+++ b/data/bin2bac.pl
@@ -156,10 +156,10 @@ sub makebac($$$$) {
return $q;
}
-($file, $org, $entry) = @ARGV;
+($file, $org, $entry, $entryname) = @ARGV;
if (!defined($file)) {
- die "Usage: $0 inputfile {load_addr|relocfile} [entrypoint]\n";
+ die "Usage: $0 inputfile {load_addr|relocfile} [entrypoint|deffile [entryname]]\n";
}
if ($org !~ /^[0-9]/) {
@@ -169,7 +169,28 @@ if ($org !~ /^[0-9]/) {
$org = oct $org if ( $org =~ /^0/ );
}
-$entry = oct $entry if ( $entry =~ /^0/ );
+if ($entry !~ /^[0-9]/) {
+ $entryfile = $entry;
+ $entryname = '_start' unless(defined($entryname));
+ undef $entry;
+
+ open(DEF, '<', $entryfile) or die "$0: $entryfile: $!\n";
+ while ($line = <DEF>) {
+ chomp $line;
+ @l = split(/\s+/, $line);
+ if ($l[0] =~ /^DEFC$/i && $l[1] eq $entryname && $l[2] eq '=' &&
+ $l[3] =~ /^\$([0-9a-f]+)$/i) {
+ $entry = hex $1;
+ last;
+ }
+ }
+ close(DEF);
+ if (!defined($entry)) {
+ die "$0: symbol $entryname not found in file $entryfile\n";
+ }
+} else {
+ $entry = oct $entry if ( $entry =~ /^0/ );
+}
open(FILE, '<:raw', $file) or die "$0: $file: $!\n";
read(FILE, $dd, 65536);