diff options
Diffstat (limited to 'scripts/recordmcount.pl')
-rwxr-xr-x | scripts/recordmcount.pl | 48 |
1 files changed, 36 insertions, 12 deletions
diff --git a/scripts/recordmcount.pl b/scripts/recordmcount.pl index c67cec8e90f4..fe831412bea9 100755 --- a/scripts/recordmcount.pl +++ b/scripts/recordmcount.pl | |||
@@ -112,6 +112,9 @@ my ($arch, $bits, $objdump, $objcopy, $cc, | |||
112 | # Acceptable sections to record. | 112 | # Acceptable sections to record. |
113 | my %text_sections = ( | 113 | my %text_sections = ( |
114 | ".text" => 1, | 114 | ".text" => 1, |
115 | ".sched.text" => 1, | ||
116 | ".spinlock.text" => 1, | ||
117 | ".irqentry.text" => 1, | ||
115 | ); | 118 | ); |
116 | 119 | ||
117 | $objdump = "objdump" if ((length $objdump) == 0); | 120 | $objdump = "objdump" if ((length $objdump) == 0); |
@@ -130,10 +133,13 @@ my %weak; # List of weak functions | |||
130 | my %convert; # List of local functions used that needs conversion | 133 | my %convert; # List of local functions used that needs conversion |
131 | 134 | ||
132 | my $type; | 135 | my $type; |
136 | my $nm_regex; # Find the local functions (return function) | ||
133 | my $section_regex; # Find the start of a section | 137 | my $section_regex; # Find the start of a section |
134 | my $function_regex; # Find the name of a function | 138 | my $function_regex; # Find the name of a function |
135 | # (return offset and func name) | 139 | # (return offset and func name) |
136 | my $mcount_regex; # Find the call site to mcount (return offset) | 140 | my $mcount_regex; # Find the call site to mcount (return offset) |
141 | my $alignment; # The .align value to use for $mcount_section | ||
142 | my $section_type; # Section header plus possible alignment command | ||
137 | 143 | ||
138 | if ($arch eq "x86") { | 144 | if ($arch eq "x86") { |
139 | if ($bits == 64) { | 145 | if ($bits == 64) { |
@@ -143,11 +149,21 @@ if ($arch eq "x86") { | |||
143 | } | 149 | } |
144 | } | 150 | } |
145 | 151 | ||
152 | # | ||
153 | # We base the defaults off of i386, the other archs may | ||
154 | # feel free to change them in the below if statements. | ||
155 | # | ||
156 | $nm_regex = "^[0-9a-fA-F]+\\s+t\\s+(\\S+)"; | ||
157 | $section_regex = "Disassembly of section\\s+(\\S+):"; | ||
158 | $function_regex = "^([0-9a-fA-F]+)\\s+<(.*?)>:"; | ||
159 | $mcount_regex = "^\\s*([0-9a-fA-F]+):.*\\smcount\$"; | ||
160 | $section_type = '@progbits'; | ||
161 | $type = ".long"; | ||
162 | |||
146 | if ($arch eq "x86_64") { | 163 | if ($arch eq "x86_64") { |
147 | $section_regex = "Disassembly of section\\s+(\\S+):"; | ||
148 | $function_regex = "^([0-9a-fA-F]+)\\s+<(.*?)>:"; | ||
149 | $mcount_regex = "^\\s*([0-9a-fA-F]+):.*\\smcount([+-]0x[0-9a-zA-Z]+)?\$"; | 164 | $mcount_regex = "^\\s*([0-9a-fA-F]+):.*\\smcount([+-]0x[0-9a-zA-Z]+)?\$"; |
150 | $type = ".quad"; | 165 | $type = ".quad"; |
166 | $alignment = 8; | ||
151 | 167 | ||
152 | # force flags for this arch | 168 | # force flags for this arch |
153 | $ld .= " -m elf_x86_64"; | 169 | $ld .= " -m elf_x86_64"; |
@@ -156,10 +172,7 @@ if ($arch eq "x86_64") { | |||
156 | $cc .= " -m64"; | 172 | $cc .= " -m64"; |
157 | 173 | ||
158 | } elsif ($arch eq "i386") { | 174 | } elsif ($arch eq "i386") { |
159 | $section_regex = "Disassembly of section\\s+(\\S+):"; | 175 | $alignment = 4; |
160 | $function_regex = "^([0-9a-fA-F]+)\\s+<(.*?)>:"; | ||
161 | $mcount_regex = "^\\s*([0-9a-fA-F]+):.*\\smcount\$"; | ||
162 | $type = ".long"; | ||
163 | 176 | ||
164 | # force flags for this arch | 177 | # force flags for this arch |
165 | $ld .= " -m elf_i386"; | 178 | $ld .= " -m elf_i386"; |
@@ -168,16 +181,26 @@ if ($arch eq "x86_64") { | |||
168 | $cc .= " -m32"; | 181 | $cc .= " -m32"; |
169 | 182 | ||
170 | } elsif ($arch eq "sh") { | 183 | } elsif ($arch eq "sh") { |
171 | $section_regex = "Disassembly of section\\s+(\\S+):"; | 184 | $alignment = 2; |
172 | $function_regex = "^([0-9a-fA-F]+)\\s+<(.*?)>:"; | ||
173 | $mcount_regex = "^\\s*([0-9a-fA-F]+):.*\\smcount\$"; | ||
174 | $type = ".long"; | ||
175 | 185 | ||
176 | # force flags for this arch | 186 | # force flags for this arch |
177 | $ld .= " -m shlelf_linux"; | 187 | $ld .= " -m shlelf_linux"; |
178 | $objcopy .= " -O elf32-sh-linux"; | 188 | $objcopy .= " -O elf32-sh-linux"; |
179 | $cc .= " -m32"; | 189 | $cc .= " -m32"; |
180 | 190 | ||
191 | } elsif ($arch eq "powerpc") { | ||
192 | $nm_regex = "^[0-9a-fA-F]+\\s+t\\s+(\\.?\\S+)"; | ||
193 | $function_regex = "^([0-9a-fA-F]+)\\s+<(\\.?.*?)>:"; | ||
194 | $mcount_regex = "^\\s*([0-9a-fA-F]+):.*\\s\\.?_mcount\$"; | ||
195 | |||
196 | if ($bits == 64) { | ||
197 | $type = ".quad"; | ||
198 | } | ||
199 | |||
200 | } elsif ($arch eq "arm") { | ||
201 | $alignment = 2; | ||
202 | $section_type = '%progbits'; | ||
203 | |||
181 | } else { | 204 | } else { |
182 | die "Arch $arch is not supported with CONFIG_FTRACE_MCOUNT_RECORD"; | 205 | die "Arch $arch is not supported with CONFIG_FTRACE_MCOUNT_RECORD"; |
183 | } | 206 | } |
@@ -247,7 +270,7 @@ if (!$found_version) { | |||
247 | # | 270 | # |
248 | open (IN, "$nm $inputfile|") || die "error running $nm"; | 271 | open (IN, "$nm $inputfile|") || die "error running $nm"; |
249 | while (<IN>) { | 272 | while (<IN>) { |
250 | if (/^[0-9a-fA-F]+\s+t\s+(\S+)/) { | 273 | if (/$nm_regex/) { |
251 | $locals{$1} = 1; | 274 | $locals{$1} = 1; |
252 | } elsif (/^[0-9a-fA-F]+\s+([wW])\s+(\S+)/) { | 275 | } elsif (/^[0-9a-fA-F]+\s+([wW])\s+(\S+)/) { |
253 | $weak{$2} = $1; | 276 | $weak{$2} = $1; |
@@ -298,7 +321,8 @@ sub update_funcs | |||
298 | if (!$opened) { | 321 | if (!$opened) { |
299 | open(FILE, ">$mcount_s") || die "can't create $mcount_s\n"; | 322 | open(FILE, ">$mcount_s") || die "can't create $mcount_s\n"; |
300 | $opened = 1; | 323 | $opened = 1; |
301 | print FILE "\t.section $mcount_section,\"a\",\@progbits\n"; | 324 | print FILE "\t.section $mcount_section,\"a\",$section_type\n"; |
325 | print FILE "\t.align $alignment\n" if (defined($alignment)); | ||
302 | } | 326 | } |
303 | printf FILE "\t%s %s + %d\n", $type, $ref_func, $offsets[$i] - $offset; | 327 | printf FILE "\t%s %s + %d\n", $type, $ref_func, $offsets[$i] - $offset; |
304 | } | 328 | } |