#!/usr/bin/perl

# This script will output an assembly language source file (x86 only, but
# it's a one-liner to fix) that will give you sort of a "I'm too lazy to
# write decent stubs" file. Perhaps it might be useful in a contrib
# subdirectory of the Checker distribution?

$return_instruction = "ret";
#                      ^^^
# CHANGE THIS to make this script work on different architectures
#-- Elliot

print <<EOF;
	.file "aliases.s"
	.text
EOF

@funclist = ();
while($aline = <>) {
	chomp($aline);
	if($aline !~ /^[0-9a-f]+\s+T\s+(.*)$/) { next; }
	$afunc = $1;
	push(@funclist, $afunc);
}

foreach(@funclist) {
	print <<EOF;
.globl $_
	.weak $_
$_:
EOF
}

print $return_instruction."\n";


foreach(@funclist) {
	print <<EOF;
.globl chkr.$_
	.weak chkr.$_
	.set chkr.$_, $_
EOF
}
