summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@zytor.com>2016-10-12 04:04:03 (GMT)
committerH. Peter Anvin <hpa@zytor.com>2016-10-12 04:04:03 (GMT)
commitb7e845c0ef0e4dcd8a117ac701e81b568b493217 (patch)
tree4eb539cd57ff98d6f0313d4026294d0aa38860c0
parentcc2a3de1a2fc0deec265902de2838740b2d894a6 (diff)
downloadabc80-b7e845c0ef0e4dcd8a117ac701e81b568b493217.zip
abc80-b7e845c0ef0e4dcd8a117ac701e81b568b493217.tar.gz
abc80-b7e845c0ef0e4dcd8a117ac701e81b568b493217.tar.bz2
abc80-b7e845c0ef0e4dcd8a117ac701e81b568b493217.tar.xz
bin2bac: find the entrypoint in the .def file
Make it possible to find a symbolic entry point in the .def file.
-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);