|
@@ -92,7 +92,7 @@
|
|
#
|
|
#
|
|
# Here are the steps we take:
|
|
# Here are the steps we take:
|
|
#
|
|
#
|
|
-# 1) Record all the local symbols by using 'nm'
|
|
|
|
|
|
+# 1) Record all the local and weak symbols by using 'nm'
|
|
# 2) Use objdump to find all the call site offsets and sections for
|
|
# 2) Use objdump to find all the call site offsets and sections for
|
|
# mcount.
|
|
# mcount.
|
|
# 3) Compile the list into its own object.
|
|
# 3) Compile the list into its own object.
|
|
@@ -152,7 +152,8 @@ my %weak; # List of weak functions
|
|
my %convert; # List of local functions used that needs conversion
|
|
my %convert; # List of local functions used that needs conversion
|
|
|
|
|
|
my $type;
|
|
my $type;
|
|
-my $nm_regex; # Find the local functions (return function)
|
|
|
|
|
|
+my $local_regex; # Match a local function (return function)
|
|
|
|
+my $weak_regex; # Match a weak function (return function)
|
|
my $section_regex; # Find the start of a section
|
|
my $section_regex; # Find the start of a section
|
|
my $function_regex; # Find the name of a function
|
|
my $function_regex; # Find the name of a function
|
|
# (return offset and func name)
|
|
# (return offset and func name)
|
|
@@ -197,7 +198,8 @@ if ($arch eq "x86") {
|
|
# We base the defaults off of i386, the other archs may
|
|
# We base the defaults off of i386, the other archs may
|
|
# feel free to change them in the below if statements.
|
|
# feel free to change them in the below if statements.
|
|
#
|
|
#
|
|
-$nm_regex = "^[0-9a-fA-F]+\\s+t\\s+(\\S+)";
|
|
|
|
|
|
+$local_regex = "^[0-9a-fA-F]+\\s+t\\s+(\\S+)";
|
|
|
|
+$weak_regex = "^[0-9a-fA-F]+\\s+([wW])\\s+(\\S+)";
|
|
$section_regex = "Disassembly of section\\s+(\\S+):";
|
|
$section_regex = "Disassembly of section\\s+(\\S+):";
|
|
$function_regex = "^([0-9a-fA-F]+)\\s+<(.*?)>:";
|
|
$function_regex = "^([0-9a-fA-F]+)\\s+<(.*?)>:";
|
|
$mcount_regex = "^\\s*([0-9a-fA-F]+):.*\\smcount\$";
|
|
$mcount_regex = "^\\s*([0-9a-fA-F]+):.*\\smcount\$";
|
|
@@ -246,7 +248,7 @@ if ($arch eq "x86_64") {
|
|
$cc .= " -m32";
|
|
$cc .= " -m32";
|
|
|
|
|
|
} elsif ($arch eq "powerpc") {
|
|
} elsif ($arch eq "powerpc") {
|
|
- $nm_regex = "^[0-9a-fA-F]+\\s+t\\s+(\\.?\\S+)";
|
|
|
|
|
|
+ $local_regex = "^[0-9a-fA-F]+\\s+t\\s+(\\.?\\S+)";
|
|
$function_regex = "^([0-9a-fA-F]+)\\s+<(\\.?.*?)>:";
|
|
$function_regex = "^([0-9a-fA-F]+)\\s+<(\\.?.*?)>:";
|
|
$mcount_regex = "^\\s*([0-9a-fA-F]+):.*\\s\\.?_mcount\$";
|
|
$mcount_regex = "^\\s*([0-9a-fA-F]+):.*\\s\\.?_mcount\$";
|
|
|
|
|
|
@@ -322,13 +324,13 @@ check_objcopy();
|
|
|
|
|
|
#
|
|
#
|
|
# Step 1: find all the local (static functions) and weak symbols.
|
|
# Step 1: find all the local (static functions) and weak symbols.
|
|
-# 't' is local, 'w/W' is weak (we never use a weak function)
|
|
|
|
|
|
+# 't' is local, 'w/W' is weak
|
|
#
|
|
#
|
|
open (IN, "$nm $inputfile|") || die "error running $nm";
|
|
open (IN, "$nm $inputfile|") || die "error running $nm";
|
|
while (<IN>) {
|
|
while (<IN>) {
|
|
- if (/$nm_regex/) {
|
|
|
|
|
|
+ if (/$local_regex/) {
|
|
$locals{$1} = 1;
|
|
$locals{$1} = 1;
|
|
- } elsif (/^[0-9a-fA-F]+\s+([wW])\s+(\S+)/) {
|
|
|
|
|
|
+ } elsif (/$weak_regex/) {
|
|
$weak{$2} = $1;
|
|
$weak{$2} = $1;
|
|
}
|
|
}
|
|
}
|
|
}
|