^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) #!/usr/bin/env perl
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) # SPDX-License-Identifier: GPL-2.0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) #
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) # Takes a (sorted) output of readprofile and turns it into a list suitable for
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) # linker scripts
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) #
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) # usage:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) # readprofile | sort -rn | perl profile2linkerlist.pl > functionlist
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) #
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) use strict;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) while (<>) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) my $line = $_;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) $_ =~ /\W*[0-9]+\W*([a-zA-Z\_0-9]+)\W*[0-9]+/;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) print "*(.text.$1)\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) unless ($line =~ /unknown/) || ($line =~ /total/);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) }