|
92 | 92 | # |
93 | 93 | # Here are the steps we take: |
94 | 94 | # |
95 | | -# 1) Record all the local symbols by using 'nm' |
| 95 | +# 1) Record all the local and weak symbols by using 'nm' |
96 | 96 | # 2) Use objdump to find all the call site offsets and sections for |
97 | 97 | # mcount. |
98 | 98 | # 3) Compile the list into its own object. |
|
152 | 152 | my %convert; # List of local functions used that needs conversion |
153 | 153 |
|
154 | 154 | my $type; |
155 | | -my $nm_regex; # Find the local functions (return function) |
| 155 | +my $local_regex; # Match a local function (return function) |
| 156 | +my $weak_regex; # Match a weak function (return function) |
156 | 157 | my $section_regex; # Find the start of a section |
157 | 158 | my $function_regex; # Find the name of a function |
158 | 159 | # (return offset and func name) |
@@ -197,7 +198,8 @@ sub check_objcopy |
197 | 198 | # We base the defaults off of i386, the other archs may |
198 | 199 | # feel free to change them in the below if statements. |
199 | 200 | # |
200 | | -$nm_regex = "^[0-9a-fA-F]+\\s+t\\s+(\\S+)"; |
| 201 | +$local_regex = "^[0-9a-fA-F]+\\s+t\\s+(\\S+)"; |
| 202 | +$weak_regex = "^[0-9a-fA-F]+\\s+([wW])\\s+(\\S+)"; |
201 | 203 | $section_regex = "Disassembly of section\\s+(\\S+):"; |
202 | 204 | $function_regex = "^([0-9a-fA-F]+)\\s+<(.*?)>:"; |
203 | 205 | $mcount_regex = "^\\s*([0-9a-fA-F]+):.*\\smcount\$"; |
@@ -246,7 +248,7 @@ sub check_objcopy |
246 | 248 | $cc .= " -m32"; |
247 | 249 |
|
248 | 250 | } elsif ($arch eq "powerpc") { |
249 | | - $nm_regex = "^[0-9a-fA-F]+\\s+t\\s+(\\.?\\S+)"; |
| 251 | + $local_regex = "^[0-9a-fA-F]+\\s+t\\s+(\\.?\\S+)"; |
250 | 252 | $function_regex = "^([0-9a-fA-F]+)\\s+<(\\.?.*?)>:"; |
251 | 253 | $mcount_regex = "^\\s*([0-9a-fA-F]+):.*\\s\\.?_mcount\$"; |
252 | 254 |
|
@@ -322,13 +324,13 @@ sub check_objcopy |
322 | 324 |
|
323 | 325 | # |
324 | 326 | # Step 1: find all the local (static functions) and weak symbols. |
325 | | -# 't' is local, 'w/W' is weak (we never use a weak function) |
| 327 | +# 't' is local, 'w/W' is weak |
326 | 328 | # |
327 | 329 | open (IN, "$nm $inputfile|") || die "error running $nm"; |
328 | 330 | while (<IN>) { |
329 | | - if (/$nm_regex/) { |
| 331 | + if (/$local_regex/) { |
330 | 332 | $locals{$1} = 1; |
331 | | - } elsif (/^[0-9a-fA-F]+\s+([wW])\s+(\S+)/) { |
| 333 | + } elsif (/$weak_regex/) { |
332 | 334 | $weak{$2} = $1; |
333 | 335 | } |
334 | 336 | } |
|
0 commit comments