f3fd2d41cc
Overlay plugins got broken because ovl_offset.pl assumes the audio buffer ends where the plugin buffer starts. Buflib however keeps its handle table there, so there are a few hundred bytes fewer available, so loading the overlay fails. We work around this by linking the overlay at a slightly lower address (1024 bytes lower). If the handle table ever grows more than that, overlays will start failing again and we either need a different solution or increase the margin a bit. Change-Id: Id98cb52da2c8c4a4bc773362a46f646774112f85
35 lines
1.1 KiB
Perl
Executable file
35 lines
1.1 KiB
Perl
Executable file
#!/usr/bin/perl
|
|
|
|
# Calculate the highest possible location for an overlay based
|
|
# on a reference map file (.refmap)
|
|
|
|
sub map_scan {
|
|
# The buflib handle table is a few hundred bytes, just before
|
|
# the plugin buffer. We assume it's never more than 1024 bytes.
|
|
# If this assumption is wrong, overlay loading will fail.
|
|
my $max_handle_table_size = 1024;
|
|
my ($map) = @_;
|
|
my $ramstart = -1, $ramsize = -1, $startaddr = -1, $endaddr = -1;
|
|
open (MAP, "<$map");
|
|
while (<MAP>) {
|
|
if ($_ =~ /^PLUGIN_RAM +0x([0-9a-f]+) +0x([0-9a-f]+)$/) {
|
|
$ramstart = hex($1);
|
|
$ramsize = hex($2);
|
|
}
|
|
elsif ($_ =~ / +0x([0-9a-f]+) +_?plugin_start_addr = ./) {
|
|
$startaddr = hex($1);
|
|
}
|
|
elsif ($_ =~ / +0x([0-9a-f]+) +_?plugin_end_addr = ./) {
|
|
$endaddr = hex($1);
|
|
}
|
|
}
|
|
close (MAP);
|
|
if ($ramstart < 0 || $ramsize < 0 || $startaddr < 0 || $endaddr < 0
|
|
|| $ramstart != $startaddr) {
|
|
printf "Could not analyze map file.\n";
|
|
exit 1;
|
|
}
|
|
return $ramstart + $ramsize - $endaddr - $max_handle_table_size;
|
|
}
|
|
|
|
printf map_scan($ARGV[0]) & ~0xf;
|