From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753520AbdBHF3e (ORCPT ); Wed, 8 Feb 2017 00:29:34 -0500 Received: from mail-pg0-f41.google.com ([74.125.83.41]:35506 "EHLO mail-pg0-f41.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753167AbdBHF3c (ORCPT ); Wed, 8 Feb 2017 00:29:32 -0500 From: David Carrillo-Cisneros To: linux-kernel@vger.kernel.org Cc: Ingo Molnar , Peter Zijlstra , Arnaldo Carvalho de Melo , Jiri Olsa , Alexander Shishkin , Wang Nan , He Kuang , Michal Marek , =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= , Stephane Eranian , Paul Turner , David Carrillo-Cisneros Subject: [PATCH v2] tools lib traceevent: Robustify do_generate_dynamic_list_file Date: Tue, 7 Feb 2017 21:28:40 -0800 Message-Id: <20170208052840.112182-1-davidcc@google.com> X-Mailer: git-send-email 2.11.0.483.g087da7b7c-goog In-Reply-To: References: Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org v2: Accept "W" and "w" symbol options. The dynamic-list-file used to export dynamic symbols introduced in commit e3d09ec8126f ("tools lib traceevent: Export dynamic symbols used by traceevent plugins") is generated without any sort of error checking. I experienced problems due to an old version of nm (v 0.158) that outputs in a format distinct from the assumed by the script. Robustify the built of dynamic symbol list by enforcing that the second column of $(NM) -u is either "U" (Undefined), "W" or "w" (undefined weak), which are the possible outputs from non-ancient $(NM) versions. Print an error if format is unexpected. Signed-off-by: David Carrillo-Cisneros --- tools/lib/traceevent/Makefile | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/tools/lib/traceevent/Makefile b/tools/lib/traceevent/Makefile index 2616c66e10c1..a7046ec01a5b 100644 --- a/tools/lib/traceevent/Makefile +++ b/tools/lib/traceevent/Makefile @@ -257,10 +257,16 @@ define do_install_plugins endef define do_generate_dynamic_list_file - (echo '{'; \ - $(NM) -u -D $1 | awk 'NF>1 {print "\t"$$2";"}' | sort -u; \ - echo '};'; \ - ) > $2 + symbol_type=`$(NM) -u -D $1 | awk 'NF>1 {print $$1}' | \ + xargs echo "U W w" | tr ' ' '\n' | sort -u | xargs echo`;\ + if [ "$$symbol_type" == "U W w" ];then \ + (echo '{'; \ + $(NM) -u -D $1 | awk 'NF>1 {print "\t"$$2";"}' | sort -u;\ + echo '};'; \ + ) > $2; \ + else \ + (echo Either missing one of [$1] or bad version of $(NM)) 1>&2;\ + fi endef install_lib: all_cmd install_plugins -- 2.11.0.483.g087da7b7c-goog