Ram initialization and small c.
Steve Gehlbach
steve at nexpath.com
Wed Feb 26 22:46:01 CET 2003
Eric W. Biederman wrote:
> Oh. I think I can have some answers in less than a month. That is
> just what I have allocated for investigation. But it will take a week
> or so to get something working well enough to compare with the inline
> tweaking approach.
>
> Plus write now I am enjoying the change of pace.
Cool, let's see how it goes. Feed it the decode routine from nrv2b.c
and see how it likes that. gcc is a long ways from doing this in
registers without a major re-write, which is probably about as much work
as your implementation in assy. Very clever assy code, BTW.
Also I think the .S files don't have to be kept if we use a trivial post
processing program like below.
-Steve
#!/usr/bin/perl
#
# program to process a .s file generated by gcc
# to eliminate gcc gingerbread so the file
# can be used for linuxbios.
# Also check for register spillage and use of the
# stack since this code is intended to run without
# ram.
#
# GPL for the linuxbios project
#
# by. Steve M. Gehlbach (steve @ kesa . com)
#
$ret = 0;
while (<STDIN>) {
#
# save everything and go over it
# once to check for errors
#
$line = $_;
# get everthing up to comment
# we don't want to bail out on items
# in comments.
$_ = (split(/\#/))[0];
next unless ($_);
#
# now check for things that indicate that
# the stack is being used, which means that gcc
# failed to fully inline code
# with no stack pushes
&Abort if /\(\%esp\)/;
if (/\(\%ebp\)/) {
&Abort unless /\%esp/;
}
&Abort if /\scall\s/;
&Abort if /\.Lfe2\:/;
/pushl/ && ($line = '#'.$line);
/pop/ && ($line = '#'.$line);
/leave/ && ($line = '#'.$line);
/\%esp/ && ($line = '#'.$line);
/ret/ && do
{
# only one return should be there
&Abort if ($ret);
# convert the last return to a jump in case
# ret is in middle of code; rel jump okay?
$line =~ s/ret/jmp \.Lfe1/;
$ret++;
};
# save the processed line
push @lines,$line;
}
#
# okay so print it out
#
while ($_ = shift @lines) {
print $_;
}
exit (0);
#
# error print it with gas pseudo-ops
# and bail
#
sub Abort {
chomp $line;
print ".print \"$line <<< ERROR*** gcc uses stack or failed to
inline code!\"\n";
print ".err\n";
exit (1);
}
More information about the coreboot
mailing list