From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751991AbcHGS0r (ORCPT ); Sun, 7 Aug 2016 14:26:47 -0400 Received: from mail-it0-f66.google.com ([209.85.214.66]:35834 "EHLO mail-it0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751712AbcHGS0q (ORCPT ); Sun, 7 Aug 2016 14:26:46 -0400 Message-ID: <57A77EF6.5030200@gmail.com> Date: Sun, 07 Aug 2016 12:33:26 -0600 From: Jorge Natz User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Icedove/31.8.0 MIME-Version: 1.0 To: mmarek@suse.com, linux-kernel@vger.kernel.org, arjan@linux.intel.com CC: trivial@kernel.org Subject: [PATCH] scripts: Translate profile2linkerlist. Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- 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