my @incoming_array;
+my @imported_functions;
+
# Perl trim function to remove whitespace from the start and end of the string
sub trim($)
{
# Make function visible to linker, and make additional symbol with
# prepended underscore
s/EXPORT\s+\|([\$\w]*)\|/.globl _$1\n\t.globl $1/;
- s/IMPORT\s+\|([\$\w]*)\|/.globl $1/;
+
+ # Prepend imported functions with _
+ if (s/IMPORT\s+\|([\$\w]*)\|/.globl $1/)
+ {
+ $function = trim($1);
+ push(@imported_functions, $function);
+ }
+
+ foreach $function (@imported_functions)
+ {
+ s/$function/_$function/;
+ }
# No vertical bars required; make additional symbol with prepended
# underscore