diff options
Diffstat (limited to 'scripts')
-rwxr-xr-x | scripts/recordmcount.pl | 48 |
1 files changed, 38 insertions, 10 deletions
diff --git a/scripts/recordmcount.pl b/scripts/recordmcount.pl index eeac71c87c66..0197e2f6b544 100755 --- a/scripts/recordmcount.pl +++ b/scripts/recordmcount.pl | |||
@@ -130,11 +130,13 @@ my %weak; # List of weak functions | |||
130 | my %convert; # List of local functions used that needs conversion | 130 | my %convert; # List of local functions used that needs conversion |
131 | 131 | ||
132 | my $type; | 132 | my $type; |
133 | my $nm_regex; # Find the local functions (return function) | ||
133 | my $section_regex; # Find the start of a section | 134 | my $section_regex; # Find the start of a section |
134 | my $function_regex; # Find the name of a function | 135 | my $function_regex; # Find the name of a function |
135 | # (return offset and func name) | 136 | # (return offset and func name) |
136 | my $mcount_regex; # Find the call site to mcount (return offset) | 137 | my $mcount_regex; # Find the call site to mcount (return offset) |
137 | my $alignment; # The .align value to use for $mcount_section | 138 | my $alignment; # The .align value to use for $mcount_section |
139 | my $section_type; # Section header plus possible alignment command | ||
138 | 140 | ||
139 | if ($arch eq "x86") { | 141 | if ($arch eq "x86") { |
140 | if ($bits == 64) { | 142 | if ($bits == 64) { |
@@ -144,9 +146,18 @@ if ($arch eq "x86") { | |||
144 | } | 146 | } |
145 | } | 147 | } |
146 | 148 | ||
149 | # | ||
150 | # We base the defaults off of i386, the other archs may | ||
151 | # feel free to change them in the below if statements. | ||
152 | # | ||
153 | $nm_regex = "^[0-9a-fA-F]+\\s+t\\s+(\\S+)"; | ||
154 | $section_regex = "Disassembly of section\\s+(\\S+):"; | ||
155 | $function_regex = "^([0-9a-fA-F]+)\\s+<(.*?)>:"; | ||
156 | $mcount_regex = "^\\s*([0-9a-fA-F]+):.*\\smcount\$"; | ||
157 | $section_type = '@progbits'; | ||
158 | $type = ".long"; | ||
159 | |||
147 | if ($arch eq "x86_64") { | 160 | if ($arch eq "x86_64") { |
148 | $section_regex = "Disassembly of section\\s+(\\S+):"; | ||
149 | $function_regex = "^([0-9a-fA-F]+)\\s+<(.*?)>:"; | ||
150 | $mcount_regex = "^\\s*([0-9a-fA-F]+):.*\\smcount([+-]0x[0-9a-zA-Z]+)?\$"; | 161 | $mcount_regex = "^\\s*([0-9a-fA-F]+):.*\\smcount([+-]0x[0-9a-zA-Z]+)?\$"; |
151 | $type = ".quad"; | 162 | $type = ".quad"; |
152 | $alignment = 8; | 163 | $alignment = 8; |
@@ -158,10 +169,6 @@ if ($arch eq "x86_64") { | |||
158 | $cc .= " -m64"; | 169 | $cc .= " -m64"; |
159 | 170 | ||
160 | } elsif ($arch eq "i386") { | 171 | } elsif ($arch eq "i386") { |
161 | $section_regex = "Disassembly of section\\s+(\\S+):"; | ||
162 | $function_regex = "^([0-9a-fA-F]+)\\s+<(.*?)>:"; | ||
163 | $mcount_regex = "^\\s*([0-9a-fA-F]+):.*\\smcount\$"; | ||
164 | $type = ".long"; | ||
165 | $alignment = 4; | 172 | $alignment = 4; |
166 | 173 | ||
167 | # force flags for this arch | 174 | # force flags for this arch |
@@ -170,6 +177,27 @@ if ($arch eq "x86_64") { | |||
170 | $objcopy .= " -O elf32-i386"; | 177 | $objcopy .= " -O elf32-i386"; |
171 | $cc .= " -m32"; | 178 | $cc .= " -m32"; |
172 | 179 | ||
180 | } elsif ($arch eq "sh") { | ||
181 | $alignment = 2; | ||
182 | |||
183 | # force flags for this arch | ||
184 | $ld .= " -m shlelf_linux"; | ||
185 | $objcopy .= " -O elf32-sh-linux"; | ||
186 | $cc .= " -m32"; | ||
187 | |||
188 | } elsif ($arch eq "powerpc") { | ||
189 | $nm_regex = "^[0-9a-fA-F]+\\s+t\\s+(\\.?\\S+)"; | ||
190 | $function_regex = "^([0-9a-fA-F]+)\\s+<(\\.?.*?)>:"; | ||
191 | $mcount_regex = "^\\s*([0-9a-fA-F]+):.*\\s\\.?_mcount\$"; | ||
192 | |||
193 | if ($bits == 64) { | ||
194 | $type = ".quad"; | ||
195 | } | ||
196 | |||
197 | } elsif ($arch eq "arm") { | ||
198 | $alignment = 2; | ||
199 | $section_type = '%progbits'; | ||
200 | |||
173 | } else { | 201 | } else { |
174 | die "Arch $arch is not supported with CONFIG_FTRACE_MCOUNT_RECORD"; | 202 | die "Arch $arch is not supported with CONFIG_FTRACE_MCOUNT_RECORD"; |
175 | } | 203 | } |
@@ -239,7 +267,7 @@ if (!$found_version) { | |||
239 | # | 267 | # |
240 | open (IN, "$nm $inputfile|") || die "error running $nm"; | 268 | open (IN, "$nm $inputfile|") || die "error running $nm"; |
241 | while (<IN>) { | 269 | while (<IN>) { |
242 | if (/^[0-9a-fA-F]+\s+t\s+(\S+)/) { | 270 | if (/$nm_regex/) { |
243 | $locals{$1} = 1; | 271 | $locals{$1} = 1; |
244 | } elsif (/^[0-9a-fA-F]+\s+([wW])\s+(\S+)/) { | 272 | } elsif (/^[0-9a-fA-F]+\s+([wW])\s+(\S+)/) { |
245 | $weak{$2} = $1; | 273 | $weak{$2} = $1; |
@@ -290,8 +318,8 @@ sub update_funcs | |||
290 | if (!$opened) { | 318 | if (!$opened) { |
291 | open(FILE, ">$mcount_s") || die "can't create $mcount_s\n"; | 319 | open(FILE, ">$mcount_s") || die "can't create $mcount_s\n"; |
292 | $opened = 1; | 320 | $opened = 1; |
293 | print FILE "\t.section $mcount_section,\"a\",\@progbits\n"; | 321 | print FILE "\t.section $mcount_section,\"a\",$section_type\n"; |
294 | print FILE "\t.align $alignment\n"; | 322 | print FILE "\t.align $alignment\n" if (defined($alignment)); |
295 | } | 323 | } |
296 | printf FILE "\t%s %s + %d\n", $type, $ref_func, $offsets[$i] - $offset; | 324 | printf FILE "\t%s %s + %d\n", $type, $ref_func, $offsets[$i] - $offset; |
297 | } | 325 | } |