aboutsummaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/recordmcount.pl39
1 files changed, 18 insertions, 21 deletions
diff --git a/scripts/recordmcount.pl b/scripts/recordmcount.pl
index ea6f6e3adaea..f3c9c0a90b98 100755
--- a/scripts/recordmcount.pl
+++ b/scripts/recordmcount.pl
@@ -136,13 +136,14 @@ my %text_sections = (
136 ".text.unlikely" => 1, 136 ".text.unlikely" => 1,
137); 137);
138 138
139$objdump = "objdump" if ((length $objdump) == 0); 139# Note: we are nice to C-programmers here, thus we skip the '||='-idiom.
140$objcopy = "objcopy" if ((length $objcopy) == 0); 140$objdump = 'objdump' if (!$objdump);
141$cc = "gcc" if ((length $cc) == 0); 141$objcopy = 'objcopy' if (!$objcopy);
142$ld = "ld" if ((length $ld) == 0); 142$cc = 'gcc' if (!$cc);
143$nm = "nm" if ((length $nm) == 0); 143$ld = 'ld' if (!$ld);
144$rm = "rm" if ((length $rm) == 0); 144$nm = 'nm' if (!$nm);
145$mv = "mv" if ((length $mv) == 0); 145$rm = 'rm' if (!$rm);
146$mv = 'mv' if (!$mv);
146 147
147#print STDERR "running: $P '$arch' '$objdump' '$objcopy' '$cc' '$ld' " . 148#print STDERR "running: $P '$arch' '$objdump' '$objcopy' '$cc' '$ld' " .
148# "'$nm' '$rm' '$mv' '$inputfile'\n"; 149# "'$nm' '$rm' '$mv' '$inputfile'\n";
@@ -432,14 +433,14 @@ sub update_funcs
432 433
433 # Loop through all the mcount caller offsets and print a reference 434 # Loop through all the mcount caller offsets and print a reference
434 # to the caller based from the ref_func. 435 # to the caller based from the ref_func.
435 for (my $i=0; $i <= $#offsets; $i++) { 436 if (!$opened) {
436 if (!$opened) { 437 open(FILE, ">$mcount_s") || die "can't create $mcount_s\n";
437 open(FILE, ">$mcount_s") || die "can't create $mcount_s\n"; 438 $opened = 1;
438 $opened = 1; 439 print FILE "\t.section $mcount_section,\"a\",$section_type\n";
439 print FILE "\t.section $mcount_section,\"a\",$section_type\n"; 440 print FILE "\t.align $alignment\n" if (defined($alignment));
440 print FILE "\t.align $alignment\n" if (defined($alignment)); 441 }
441 } 442 foreach my $cur_offset (@offsets) {
442 printf FILE "\t%s %s + %d\n", $type, $ref_func, $offsets[$i] - $offset; 443 printf FILE "\t%s %s + %d\n", $type, $ref_func, $cur_offset - $offset;
443 } 444 }
444} 445}
445 446
@@ -476,11 +477,7 @@ while (<IN>) {
476 $read_headers = 0; 477 $read_headers = 0;
477 478
478 # Only record text sections that we know are safe 479 # Only record text sections that we know are safe
479 if (defined($text_sections{$1})) { 480 $read_function = defined($text_sections{$1});
480 $read_function = 1;
481 } else {
482 $read_function = 0;
483 }
484 # print out any recorded offsets 481 # print out any recorded offsets
485 update_funcs(); 482 update_funcs();
486 483
@@ -514,7 +511,7 @@ while (<IN>) {
514 } 511 }
515 # is this a call site to mcount? If so, record it to print later 512 # is this a call site to mcount? If so, record it to print later
516 if ($text_found && /$mcount_regex/) { 513 if ($text_found && /$mcount_regex/) {
517 $offsets[$#offsets + 1] = hex $1; 514 push(@offsets, hex $1);
518 } 515 }
519} 516}
520 517