Lines Matching +full:0 +full:- +full:9 +full:a +full:- +full:fa +full:- +full:f
2 # SPDX-License-Identifier: GPL-2.0-only
5 # recordmcount.pl - makes a section called __mcount_loc that holds
9 # What we want to end up with this is that each object file will have a
22 # functions in a section that has a call site to mcount, will have the
30 # The trick is to change the call offset referring the start of a section to
31 # referring a function symbol in this section. During the link step, 'ld' will
40 # call mcount (offset: 0x10)
44 # func2: (offset: 0x20)
50 # call mcount (offset: 0x30)
54 # offset from .sched.text. If we choose global symbol func2 as a reference and
58 # .quad func2 - 0x10
59 # .quad func2 + 0x10
66 # in this section. In such a case we have to select a local one. E.g. func1:
71 # call mcount (offset: 0x10)
76 # call mcount (offset: 0x20)
83 # an undefined reference to func1 or a wrong reference to another global
87 # a way to make tmp.o reference the local objects of the original object
89 # into a global symbol before linking tmp.o. Then after we link tmp.o
90 # we will only have a single symbol for func1 that is global.
91 # We can convert func1 back into a local symbol and we are done.
106 # 9) Move the result back to the original object.
112 my $P = $0;
128 exit(0);
145 # Acceptable section-prefixes to record.
150 # Note: we are nice to C-programmers here, thus we skip the '||='-idiom.
167 my $local_regex; # Match a local function (return function)
168 my $weak_regex; # Match a weak function (return function)
169 my $section_regex; # Find the start of a section
170 my $function_regex; # Find the name of a function
189 $local_regex = "^[0-9a-fA-F]+\\s+t\\s+(\\S+)";
190 $weak_regex = "^[0-9a-fA-F]+\\s+([wW])\\s+(\\S+)";
192 $function_regex = "^([0-9a-fA-F]+)\\s+<([^^]*?)>:";
193 $mcount_regex = "^\\s*([0-9a-fA-F]+):.*\\s(mcount|__fentry__)\$";
195 $mcount_adjust = 0;
199 $mcount_regex = "^\\s*([0-9a-fA-F]+):.*\\s(mcount|__fentry__)([+-]0x[0-9a-zA-Z]+)?\$";
202 $mcount_adjust = -1;
205 $ld .= " -m elf_x86_64";
206 $objdump .= " -M x86-64";
207 $objcopy .= " -O elf64-x86-64";
208 $cc .= " -m64";
212 $mcount_adjust = -1;
215 $ld .= " -m elf_i386";
216 $objdump .= " -M i386";
217 $objcopy .= " -O elf32-i386";
218 $cc .= " -m32";
221 if ($cc =~ /-DCC_USING_HOTPATCH/) {
222 …$mcount_regex = "^\\s*([0-9a-fA-F]+):\\s*c0 04 00 00 00 00\\s*(brcl\\s*0,|jgnop\\s*)[0-9a-f]+ <([^…
223 $mcount_adjust = 0;
227 $ld .= " -m elf64_s390";
228 $cc .= " -m64";
234 $ld .= " -m shlelf_linux";
236 $objcopy .= " -O elf32-shbig-linux";
238 $objcopy .= " -O elf32-sh-linux";
244 $local_regex = "^[0-9a-fA-F]+\\s+t\\s+(\\.?\\S+)";
246 $function_regex = "^([0-9a-fA-F]+)\\s+<(\\.?\\w*?)>:";
247 $mcount_regex = "^\\s*([0-9a-fA-F]+):.*\\s\\.?_mcount\$";
250 $cc .= " -mbig-endian ";
251 $ld .= " -EB ";
254 $cc .= " -mlittle-endian ";
255 $ld .= " -EL ";
260 $cc .= " -m64 ";
261 $ld .= " -m elf64".$ldemulation." ";
263 $cc .= " -m32 ";
264 $ld .= " -m elf32".$ldemulation." ";
270 $mcount_regex = "^\\s*([0-9a-fA-F]+):\\s*R_ARM_(CALL|PC24|THM_CALL)" .
276 $mcount_regex = "^\\s*([0-9a-fA-F]+):\\s*R_AARCH64_CALL26\\s+_mcount\$";
280 # 0000000000000000 <igmp_net_exit-0x18>:
288 $function_regex = "^([0-9a-fA-F]+)\\s+<(\\w*?)>:";
291 $mcount_regex = "^\\s*([0-9a-fA-F]+):.*\\s_mcount\$";
295 $ld .= " -m elf64_sparc";
296 $cc .= " -m64";
297 $objcopy .= " -O elf64-sparc";
299 # To enable module support, we need to enable the -mlong-calls option
303 # first one, and then we can replace this instruction by a branch
308 # c: 3c030000 lui v1,0x0
312 # 10: 64630000 daddiu v1,v1,0
322 # 14: 0c000000 jal 0 <loongson_halt>
327 if ($is_module eq "0") {
328 $mcount_regex = "^\\s*([0-9a-fA-F]+): R_MIPS_26\\s+_mcount\$";
330 $mcount_regex = "^\\s*([0-9a-fA-F]+): R_MIPS_HI16\\s+_mcount\$";
332 $objdump .= " -Melf-trad".$endian."mips ";
335 $endian = " -EB ";
336 $ld .= " -melf".$bits."btsmip";
338 $endian = " -EL ";
339 $ld .= " -melf".$bits."ltsmip";
342 $cc .= " -mno-abicalls -fno-pic -mabi=" . $bits . $endian;
347 "^([0-9a-fA-F]+)\\s+<(.|[^\$]L.*?|\$[^L].*?|[^\$][^L].*?)>:";
352 $mcount_regex = "^\\s*([0-9a-fA-F]+):.*\\s_mcount\$";
354 $function_regex = "^([0-9a-fA-F]+)\\s+<([^.0-9][0-9a-zA-Z_\\.]+)>:";
355 $mcount_regex = "^\\s*([0-9a-fA-F]+):\\sR_RISCV_CALL(_PLT)?\\s_mcount\$";
359 $mcount_regex = "^\\s*([0-9a-fA-F]+):\\s*R_CKCORE_PCREL_JSR_IMM26BY2\\s+_mcount\$";
365 my $text_found = 0;
366 my $read_function = 0;
367 my $opened = 0;
410 my $offset = 0; # offset of ref_func to section beginning
413 # update_funcs - print out the current mcount callers
416 # the output file in a format that can be read by an assembler.
422 # Sanity check on weak function. A weak function may be overwritten by
434 # Loop through all the mcount caller offsets and print a reference
439 print FILE "\t.section $mcount_section,\"a\",$section_type\n";
443 printf FILE "\t%s %s + %d\n", $type, $ref_func, $cur_offset - $offset;
450 open(IN, "LC_ALL=C $objdump -hdr $inputfile|") || die "error running $objdump";
472 exit(-1);
475 # is it a section?
477 $read_headers = 0;
483 if (substr($1, 0, length $prefix) eq $prefix) {
493 $text_found = 0;
497 # section found, now is this a start of a function?
502 # if this is either a local function or a weak function
507 $read_function = 0;
510 # if we already have a function, and this is weak, skip it
520 # is this a call site to mcount? If so, record it to print later
531 exit(0);
539 `$cc -o $mcount_o -c $mcount_s`;
546 if ($#converts >= 0) {
551 $globallist .= " --globalize-symbol $con";
552 $locallist .= " --localize-symbol $con";
559 # Step 5: set up each local function as a global
566 `$ld -r $globalobj $mcount_o -o $globalmix`;
583 `$ld -r $inputfile $mcount_o -o $mix`;
586 # Step 9: Move the result back to the original object.
594 exit(0);