* [PATCH] scripts: Translate profile2linkerlist.
@ 2016-08-07 18:33 Jorge Natz
2016-08-07 20:16 ` Michal Marek
0 siblings, 1 reply; 2+ messages in thread
From: Jorge Natz @ 2016-08-07 18:33 UTC (permalink / raw)
To: mmarek, linux-kernel, arjan; +Cc: trivial
profile2linkerlist.pl is a script that takes the sorted output of the
readprofile command and turns it into a list of C functions in a
format for linker lists. Make the script more portable across POSIX
systems. This script does not use any shell-specific features, only
POSIX ones. A POSIX shell is present on all UNIX systems, while Perl
is not as commonplace.
Signed-off-by: Jorge Natz <jorgenatzdev@gmail.com>
---
diff -uprN a/scripts/profile2linkerlist.pl b/scripts/profile2linkerlist.pl
--- a/scripts/profile2linkerlist.pl 2016-06-10 17:27:15.333317028 -0600
+++ b/scripts/profile2linkerlist.pl 1969-12-31 17:00:00.000000000 -0700
@@ -1,19 +0,0 @@
-#!/usr/bin/perl
-
-#
-# Takes a (sorted) output of readprofile and turns it into a list suitable for
-# linker scripts
-#
-# usage:
-# readprofile | sort -rn | perl profile2linkerlist.pl > functionlist
-#
-use strict;
-
-while (<>) {
- my $line = $_;
-
- $_ =~ /\W*[0-9]+\W*([a-zA-Z\_0-9]+)\W*[0-9]+/;
-
- print "*(.text.$1)\n"
- unless ($line =~ /unknown/) || ($line =~ /total/);
-}
diff -uprN a/scripts/profile2linkerlist.sh b/scripts/profile2linkerlist.sh
--- a/scripts/profile2linkerlist.sh 1969-12-31 17:00:00.000000000 -0700
+++ b/scripts/profile2linkerlist.sh 2016-03-24 17:26:58.044958415 -0600
@@ -0,0 +1,18 @@
+#!/bin/sh
+
+# Takes a (sorted) output of readprofile and turns it into a list suitable for
+# linker scripts.
+#
+# usage:
+# readprofile | sort -rn | ./profile2linkerlist.sh > functionlist
+
+# Exit on error
+set -e
+
+while read LINE; do
+ LINE=$( echo $LINE | sed -e s"/[0-9.][0-9.]*//" -e s"/[0-9.][0-9.]*$//" | xargs)
+ case $LINE in *unknown*|*total* ) continue
+ ;;
+ esac
+ echo '*(.text.'$LINE')'
+done
^ permalink raw reply [flat|nested] 2+ messages in thread* Re: [PATCH] scripts: Translate profile2linkerlist.
2016-08-07 18:33 [PATCH] scripts: Translate profile2linkerlist Jorge Natz
@ 2016-08-07 20:16 ` Michal Marek
0 siblings, 0 replies; 2+ messages in thread
From: Michal Marek @ 2016-08-07 20:16 UTC (permalink / raw)
To: Jorge Natz, arjan; +Cc: linux-kernel, trivial
Dne 7.8.2016 v 20:33 Jorge Natz napsal(a):
> -while (<>) {
> - my $line = $_;
> -
> - $_ =~ /\W*[0-9]+\W*([a-zA-Z\_0-9]+)\W*[0-9]+/;
> -
> - print "*(.text.$1)\n"
[...]
> + LINE=$( echo $LINE | sed -e s"/[0-9.][0-9.]*//" -e s"/[0-9.][0-9.]*$//" | xargs)
> + case $LINE in *unknown*|*total* ) continue
> + ;;
> + esac
> + echo '*(.text.'$LINE')'
> +done
The two regular expressions are not equivalent and the shell version
does not take into account the locale-dependent decimal separator. It
also does not handle localized "total", but that's an issue of the perl
version as well. Since this script is not used during kernel build, its
dependency on perl is less of an issue and it can be left as is.
Michal
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2016-08-07 20:17 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-08-07 18:33 [PATCH] scripts: Translate profile2linkerlist Jorge Natz
2016-08-07 20:16 ` Michal Marek
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox