From patchwork Sat Nov 23 16:04:29 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 11258855 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 7D5726C1 for ; Sat, 23 Nov 2019 16:05:45 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 542C12070E for ; Sat, 23 Nov 2019 16:05:45 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=nifty.com header.i=@nifty.com header.b="N7FL27dA" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726887AbfKWQFB (ORCPT ); Sat, 23 Nov 2019 11:05:01 -0500 Received: from conuserg-12.nifty.com ([210.131.2.79]:49448 "EHLO conuserg-12.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726638AbfKWQFB (ORCPT ); Sat, 23 Nov 2019 11:05:01 -0500 Received: from grover.flets-west.jp (softbank126093102113.bbtec.net [126.93.102.113]) (authenticated) by conuserg-12.nifty.com with ESMTP id xANG4l5I019106; Sun, 24 Nov 2019 01:04:48 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-12.nifty.com xANG4l5I019106 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1574525088; bh=6aYBJLETzzZ9tKk9VjyP9bE0/hE74dTgHGjrEeWx9tY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=N7FL27dA/kBwCUd2PiBYIDy2zn0eXNV0eFrD9GtjMz/7rjD/f+UGAV1/F9JwuYckj 7YnV9+dRizG4tIHpkPqPmdhqenRw6KOj9pO+ZsFtJ5M5pAuhMOttzkV1/y9CpJPVf7 xwerW59vgpNG13UM0Ci/y9v0ba1HtJGD4wFxr3mE+yDGnAKEQh0jK1GZyjK47N6Sws jJaJ/DNQMHmfRrZP6MNkB6JBRuBnT7iJfphGkcfaM9ulj3ex4FJZ6JGzVSVXMwP3+A 046/QJQ2F8xrsv1/wSnqdGZpw2qjFDXRQRT/iDW8Ch5K3FhotK5XvhTiINI2tSuryN oDbPZ4skevYFw== X-Nifty-SrcIP: [126.93.102.113] From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: Masahiro Yamada , linux-kernel@vger.kernel.org Subject: [PATCH v2 01/16] scripts/kallsyms: remove unneeded #ifndef ARRAY_SIZE Date: Sun, 24 Nov 2019 01:04:29 +0900 Message-Id: <20191123160444.11251-2-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191123160444.11251-1-yamada.masahiro@socionext.com> References: <20191123160444.11251-1-yamada.masahiro@socionext.com> Sender: linux-kbuild-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kbuild@vger.kernel.org This is not defined in the standard headers. #ifndef is unneeded. Signed-off-by: Masahiro Yamada --- Changes in v2: None scripts/kallsyms.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/scripts/kallsyms.c b/scripts/kallsyms.c index ae6504d07fd6..918c2ba071b5 100644 --- a/scripts/kallsyms.c +++ b/scripts/kallsyms.c @@ -24,9 +24,7 @@ #include #include -#ifndef ARRAY_SIZE #define ARRAY_SIZE(arr) (sizeof(arr) / sizeof(arr[0])) -#endif #define KSYM_NAME_LEN 128 From patchwork Sat Nov 23 16:04:30 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 11258831 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 017C56C1 for ; Sat, 23 Nov 2019 16:05:02 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id CF5082070E for ; Sat, 23 Nov 2019 16:05:02 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=nifty.com header.i=@nifty.com header.b="gp4THjHF" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726855AbfKWQFB (ORCPT ); Sat, 23 Nov 2019 11:05:01 -0500 Received: from conuserg-12.nifty.com ([210.131.2.79]:49444 "EHLO conuserg-12.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726487AbfKWQFB (ORCPT ); Sat, 23 Nov 2019 11:05:01 -0500 Received: from grover.flets-west.jp (softbank126093102113.bbtec.net [126.93.102.113]) (authenticated) by conuserg-12.nifty.com with ESMTP id xANG4l5J019106; Sun, 24 Nov 2019 01:04:48 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-12.nifty.com xANG4l5J019106 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1574525088; bh=WZZFA6dol6oYL7xPQCp9izlpiyCZuwW4132+Q9wwKac=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gp4THjHFa0mPASPXe10mzi1lw1vjiNOyzebQLbBxg6WwQ0kO7VHCfoqqbGMIBZ2bu ogDa4JhABiSWOBlP+etmaJ9AohyLKDBDrRp8otdiZYPFKwWTf9mhlpg5rw5mVW3uVr Sxf/26CmgGYt9CEmrqvYZSCN2TWjMr7BzN0XF4Fvl6uEWRQeQMmVZ2fvFwWcI5o4co 8dpDv2r1GXrNk0PlCLB83+75aX+UoeVyTxcO80XO7c0ob7t2C82GQ7Pmsb/Ed29XIU jEqGT6qVp3PcbryuBq1vnV/vd/N3UoIkCd0F7037ct8HA+v6gRTMUSpErkG7pRkpLK FINV9xO1FxSUw== X-Nifty-SrcIP: [126.93.102.113] From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: Masahiro Yamada , linux-kernel@vger.kernel.org Subject: [PATCH v2 02/16] scripts/kallsyms: fix definitely-lost memory leak Date: Sun, 24 Nov 2019 01:04:30 +0900 Message-Id: <20191123160444.11251-3-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191123160444.11251-1-yamada.masahiro@socionext.com> References: <20191123160444.11251-1-yamada.masahiro@socionext.com> Sender: linux-kbuild-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kbuild@vger.kernel.org build_initial_tok_table() overwrites unused sym_entry to shrink the table size. Before the entry is overwritten, table[i].sym must be freed since it is malloc'ed data. This fixes the 'definitely lost' report from valgrind. I ran valgrind against x86_64_defconfig of v5.4-rc8 kernel, and here is the summary: [Before the fix] LEAK SUMMARY: definitely lost: 53,184 bytes in 2,874 blocks [After the fix] LEAK SUMMARY: definitely lost: 0 bytes in 0 blocks Signed-off-by: Masahiro Yamada --- Changes in v2: None scripts/kallsyms.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/scripts/kallsyms.c b/scripts/kallsyms.c index 918c2ba071b5..79641874d860 100644 --- a/scripts/kallsyms.c +++ b/scripts/kallsyms.c @@ -487,6 +487,8 @@ static void build_initial_tok_table(void) table[pos] = table[i]; learn_symbol(table[pos].sym, table[pos].len); pos++; + } else { + free(table[i].sym); } } table_cnt = pos; From patchwork Sat Nov 23 16:04:31 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 11258843 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C49BE138C for ; Sat, 23 Nov 2019 16:05:31 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id A4D382071C for ; Sat, 23 Nov 2019 16:05:31 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=nifty.com header.i=@nifty.com header.b="v/+rqumx" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727111AbfKWQFW (ORCPT ); Sat, 23 Nov 2019 11:05:22 -0500 Received: from conuserg-12.nifty.com ([210.131.2.79]:49454 "EHLO conuserg-12.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726836AbfKWQFC (ORCPT ); Sat, 23 Nov 2019 11:05:02 -0500 Received: from grover.flets-west.jp (softbank126093102113.bbtec.net [126.93.102.113]) (authenticated) by conuserg-12.nifty.com with ESMTP id xANG4l5K019106; Sun, 24 Nov 2019 01:04:49 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-12.nifty.com xANG4l5K019106 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1574525089; bh=NiWcGoRSkJ1ToZ+rAR8uqUuIB/kFxxkQ/T4OsoV5GoA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=v/+rqumxnqCo8borqbNoOmcZ+UTQtLFg9D1qGgnjRgnSouqHHc8n+EmdrhMdd/HG1 LTZG0bOtEcXsaKegzYSDoSJ9D6cBGbuDElcmL24fG9g8ERHI6eVZchYbdbMnEkOjr4 Mz8qVFnTNoOExJsgK+Nw7rpQyTkVCH8TczsWzVdKRgYXpo6cZPAXkWByCJWKKfCDKF q1KwHmqmf8oBI8eC8AYyteryM5oIzT8fiyF5VdSd9CLAvMohFnyE1cQndL0HCn7m36 AILp2k/NrjHd2qkW3lwRoRMFZ08O/XD9r673m7i8elxA+cizFjNIP0xR2ASKgmM1wJ tyj9amgzO1hQA== X-Nifty-SrcIP: [126.93.102.113] From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: Masahiro Yamada , linux-kernel@vger.kernel.org Subject: [PATCH v2 03/16] scripts/kallsyms: shrink table before sorting it Date: Sun, 24 Nov 2019 01:04:31 +0900 Message-Id: <20191123160444.11251-4-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191123160444.11251-1-yamada.masahiro@socionext.com> References: <20191123160444.11251-1-yamada.masahiro@socionext.com> Sender: linux-kbuild-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kbuild@vger.kernel.org Currently, build_initial_tok_table() trims unused symbols, which is called after sort_symbol(). It is not efficient to sort the huge table that contains unused entries. Shrink the table before sorting it. Signed-off-by: Masahiro Yamada --- Changes in v2: - New patch scripts/kallsyms.c | 49 +++++++++++++++++++++++++++------------------- 1 file changed, 29 insertions(+), 20 deletions(-) diff --git a/scripts/kallsyms.c b/scripts/kallsyms.c index 79641874d860..de986eda41a6 100644 --- a/scripts/kallsyms.c +++ b/scripts/kallsyms.c @@ -268,6 +268,30 @@ static int symbol_valid(struct sym_entry *s) return 1; } +/* remove all the invalid symbols from the table */ +static void shrink_table(void) +{ + unsigned int i, pos; + + pos = 0; + for (i = 0; i < table_cnt; i++) { + if (symbol_valid(&table[i])) { + if (pos != i) + table[pos] = table[i]; + pos++; + } else { + free(table[i].sym); + } + } + table_cnt = pos; + + /* When valid symbol is not registered, exit to error */ + if (!table_cnt) { + fprintf(stderr, "No valid symbol.\n"); + exit(1); + } +} + static void read_map(FILE *in) { while (!feof(in)) { @@ -475,23 +499,13 @@ static void forget_symbol(unsigned char *symbol, int len) token_profit[ symbol[i] + (symbol[i + 1] << 8) ]--; } -/* remove all the invalid symbols from the table and do the initial token count */ +/* do the initial token count */ static void build_initial_tok_table(void) { - unsigned int i, pos; + unsigned int i; - pos = 0; - for (i = 0; i < table_cnt; i++) { - if ( symbol_valid(&table[i]) ) { - if (pos != i) - table[pos] = table[i]; - learn_symbol(table[pos].sym, table[pos].len); - pos++; - } else { - free(table[i].sym); - } - } - table_cnt = pos; + for (i = 0; i < table_cnt; i++) + learn_symbol(table[i].sym, table[i].len); } static void *find_token(unsigned char *str, int len, unsigned char *token) @@ -614,12 +628,6 @@ static void optimize_token_table(void) insert_real_symbols_in_table(); - /* When valid symbol is not registered, exit to error */ - if (!table_cnt) { - fprintf(stderr, "No valid symbol.\n"); - exit(1); - } - optimize_result(); } @@ -756,6 +764,7 @@ int main(int argc, char **argv) usage(); read_map(stdin); + shrink_table(); if (absolute_percpu) make_percpus_absolute(); if (base_relative) From patchwork Sat Nov 23 16:04:32 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 11258847 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 9BFF86C1 for ; Sat, 23 Nov 2019 16:05:40 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 7B39E2071C for ; Sat, 23 Nov 2019 16:05:40 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=nifty.com header.i=@nifty.com header.b="FV5lkNil" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727175AbfKWQFg (ORCPT ); Sat, 23 Nov 2019 11:05:36 -0500 Received: from conuserg-12.nifty.com ([210.131.2.79]:49450 "EHLO conuserg-12.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726762AbfKWQFC (ORCPT ); Sat, 23 Nov 2019 11:05:02 -0500 Received: from grover.flets-west.jp (softbank126093102113.bbtec.net [126.93.102.113]) (authenticated) by conuserg-12.nifty.com with ESMTP id xANG4l5L019106; Sun, 24 Nov 2019 01:04:49 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-12.nifty.com xANG4l5L019106 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1574525089; bh=jnfvjcB5kg6ke5illdITerqCOO0i1ll9kEjlHRPbqGY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FV5lkNildmiiTubSxu06HhEHVwMSCweueZUvG39cNL4RC+2Y06tdbNeQ+n+4gIaOg mz8MvphMJNMQaJ77fuMEifS//aXw4yo9HUy9PjOK82SF5/FeffaWpAEqSIioZyKuh0 SoT0F1o60PUaujqnJDfQzyD5tLAVkUiJZycvr0+EieuQSf3oV4PUUYx1cGCNrl1bRN eryi/OfaiFCnoN0acxhAdZaF1H/VIl10EbSswtRhbbZZTi9aYciQdPd20LgXXIguiu Eh+B3GeDep7xVK/CPK2XKiNMlqnp520LumaCkvxPLZLcXnmCmjjN1+FY52EYIy2b2U 8vhLr9bI/+LkQ== X-Nifty-SrcIP: [126.93.102.113] From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: Masahiro Yamada , linux-kernel@vger.kernel.org Subject: [PATCH v2 04/16] scripts/kallsyms: set relative_base more effectively Date: Sun, 24 Nov 2019 01:04:32 +0900 Message-Id: <20191123160444.11251-5-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191123160444.11251-1-yamada.masahiro@socionext.com> References: <20191123160444.11251-1-yamada.masahiro@socionext.com> Sender: linux-kbuild-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kbuild@vger.kernel.org Currently, record_relative_base() iterates over the entire table to find the minimum address, but it is not efficient because we sort the table anyway. After sort_symbol(), the table is sorted by address. (kallsyms parses the 'nm -n' output, so the data is already sorted by address, but this commit does not rely on it.) Move record_relative_base() after sort_symbols(), and take the first non-absolute symbol value. Signed-off-by: Masahiro Yamada --- Changes in v2: None scripts/kallsyms.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/scripts/kallsyms.c b/scripts/kallsyms.c index de986eda41a6..c9efb67c6ecb 100644 --- a/scripts/kallsyms.c +++ b/scripts/kallsyms.c @@ -739,11 +739,15 @@ static void record_relative_base(void) { unsigned int i; - relative_base = -1ULL; for (i = 0; i < table_cnt; i++) - if (!symbol_absolute(&table[i]) && - table[i].addr < relative_base) + if (!symbol_absolute(&table[i])) { + /* + * The table is sorted by address. + * Take the first non-absolute symbol value. + */ relative_base = table[i].addr; + return; + } } int main(int argc, char **argv) @@ -767,9 +771,9 @@ int main(int argc, char **argv) shrink_table(); if (absolute_percpu) make_percpus_absolute(); + sort_symbols(); if (base_relative) record_relative_base(); - sort_symbols(); optimize_token_table(); write_src(); From patchwork Sat Nov 23 16:04:33 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 11258835 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 12728138C for ; Sat, 23 Nov 2019 16:05:12 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id DBBE82070E for ; Sat, 23 Nov 2019 16:05:11 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=nifty.com header.i=@nifty.com header.b="GbAAVpbg" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726825AbfKWQFI (ORCPT ); Sat, 23 Nov 2019 11:05:08 -0500 Received: from conuserg-12.nifty.com ([210.131.2.79]:49493 "EHLO conuserg-12.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726842AbfKWQFD (ORCPT ); Sat, 23 Nov 2019 11:05:03 -0500 Received: from grover.flets-west.jp (softbank126093102113.bbtec.net [126.93.102.113]) (authenticated) by conuserg-12.nifty.com with ESMTP id xANG4l5M019106; Sun, 24 Nov 2019 01:04:50 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-12.nifty.com xANG4l5M019106 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1574525090; bh=IIQsi1izm8K/GBPuGItQbp2rWTEbFo+vUJb/JZsPBDI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GbAAVpbgjzpdtjqkO8wl3cJej1h/ITGS5yHcTf9awSi3XY26RsKP4Ki1jX1rnYzIB JH7UZ3e472ol+0QSqmBjgH/huyJdnyIPiByIYYeiIxQkWEEGrkiQ38gzRS35nc+UVy RALjM0UoNDh1KduT0bwIMM9ndb6vfMucqhI5QbIPA7RlZZVlZy8VxIdUOxPThnKYRv SVJ0Du52HgWW/ypuwRfhoBLbp71ZzmHo3Jox4VR/mez9NfogoksbeiE7PMYP4yq1oA 91XXY7FZ+1wVOhUreeYPH7vMkSo8M6ezucg8MS2KuM10OmvPvB2eEV4NXzpxBasSPT suh+56AJBy2xQ== X-Nifty-SrcIP: [126.93.102.113] From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: Masahiro Yamada , linux-kernel@vger.kernel.org Subject: [PATCH v2 05/16] scripts/kallsyms: remove redundant is_arm_mapping_symbol() Date: Sun, 24 Nov 2019 01:04:33 +0900 Message-Id: <20191123160444.11251-6-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191123160444.11251-1-yamada.masahiro@socionext.com> References: <20191123160444.11251-1-yamada.masahiro@socionext.com> Sender: linux-kbuild-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kbuild@vger.kernel.org Since commit 6f00df24ee39 ("[PATCH] Strip local symbols from kallsyms"), all symbols starting '$' are ignored. is_arm_mapping_symbol() particularly ignores $a, $t, etc. but it is redundant. Signed-off-by: Masahiro Yamada --- Changes in v2: None scripts/kallsyms.c | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/scripts/kallsyms.c b/scripts/kallsyms.c index c9efb67c6ecb..14a50c8d3f34 100644 --- a/scripts/kallsyms.c +++ b/scripts/kallsyms.c @@ -74,16 +74,6 @@ static void usage(void) exit(1); } -/* - * This ignores the intensely annoying "mapping symbols" found - * in ARM ELF files: $a, $t and $d. - */ -static int is_arm_mapping_symbol(const char *str) -{ - return str[0] == '$' && strchr("axtd", str[1]) - && (str[2] == '\0' || str[2] == '.'); -} - static int check_symbol_range(const char *sym, unsigned long long addr, struct addr_range *ranges, int entries) { @@ -139,10 +129,13 @@ static int read_symbol(FILE *in, struct sym_entry *s) return -1; } - else if (toupper(stype) == 'U' || - is_arm_mapping_symbol(sym)) + else if (toupper(stype) == 'U') return -1; - /* exclude also MIPS ELF local symbols ($L123 instead of .L123) */ + /* + * Ignore generated symbols such as: + * - mapping symbols in ARM ELF files ($a, $t, and $d) + * - MIPS ELF local symbols ($L123 instead of .L123) + */ else if (sym[0] == '$') return -1; /* exclude debugging symbols */ From patchwork Sat Nov 23 16:04:34 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 11258859 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id CF4AE6C1 for ; Sat, 23 Nov 2019 16:05:50 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id AE6502070E for ; Sat, 23 Nov 2019 16:05:50 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=nifty.com header.i=@nifty.com header.b="vIz5p4JA" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726784AbfKWQFu (ORCPT ); Sat, 23 Nov 2019 11:05:50 -0500 Received: from conuserg-12.nifty.com ([210.131.2.79]:49451 "EHLO conuserg-12.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726760AbfKWQFB (ORCPT ); Sat, 23 Nov 2019 11:05:01 -0500 Received: from grover.flets-west.jp (softbank126093102113.bbtec.net [126.93.102.113]) (authenticated) by conuserg-12.nifty.com with ESMTP id xANG4l5N019106; Sun, 24 Nov 2019 01:04:50 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-12.nifty.com xANG4l5N019106 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1574525090; bh=lxCDJ/TzRamerzIHNtq7hRwp1rjH2y4uMZMCuV7ILJg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=vIz5p4JABWr2ukQchXCPsHDjkp9lot5DP65ulXNWDBNpkGwr6lpe3sbq6Wq6h4yUI CTPa8hO/pnYsxUW3L8QgPtlW9oPaihXyL0Gyu/M+fwXVTWl+KLNf2L6nkLWQSQvnca MRU4S7CXku89X7hLsHUgk4eyDKmlJw2c011IZ2EHIMKrSgoolLDKHb+B4LqhxYC62V znZ4YrKLWyyp0UEoJXzZHMoMBEyNxQx76fFp+X1gCzi1bHwQABbJjyNZZ/1bvIh002 I6SA7YmkDoKKqLoqCL2L2Uurq/XlPmQXHbR4DAygejWWjInPiAO4yvoJXfV4KbL4Zy HI8R+OWSJ+hJQ== X-Nifty-SrcIP: [126.93.102.113] From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: Masahiro Yamada , linux-kernel@vger.kernel.org Subject: [PATCH v2 06/16] scripts/kallsyms: remove unneeded length check for prefix matching Date: Sun, 24 Nov 2019 01:04:34 +0900 Message-Id: <20191123160444.11251-7-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191123160444.11251-1-yamada.masahiro@socionext.com> References: <20191123160444.11251-1-yamada.masahiro@socionext.com> Sender: linux-kbuild-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kbuild@vger.kernel.org l <= strlen(sym_name) is unnecessary for prefix matching. strncmp() will do. Signed-off-by: Masahiro Yamada --- Changes in v2: None scripts/kallsyms.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/scripts/kallsyms.c b/scripts/kallsyms.c index 14a50c8d3f34..a57636c6f84f 100644 --- a/scripts/kallsyms.c +++ b/scripts/kallsyms.c @@ -246,8 +246,7 @@ static int symbol_valid(struct sym_entry *s) for (i = 0; special_prefixes[i]; i++) { int l = strlen(special_prefixes[i]); - if (l <= strlen(sym_name) && - strncmp(sym_name, special_prefixes[i], l) == 0) + if (strncmp(sym_name, special_prefixes[i], l) == 0) return 0; } From patchwork Sat Nov 23 16:04:35 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 11258837 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 9917C6C1 for ; Sat, 23 Nov 2019 16:05:13 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 783B02071C for ; Sat, 23 Nov 2019 16:05:13 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=nifty.com header.i=@nifty.com header.b="dhx5Vk9A" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726842AbfKWQFM (ORCPT ); Sat, 23 Nov 2019 11:05:12 -0500 Received: from conuserg-12.nifty.com ([210.131.2.79]:49458 "EHLO conuserg-12.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726833AbfKWQFC (ORCPT ); Sat, 23 Nov 2019 11:05:02 -0500 Received: from grover.flets-west.jp (softbank126093102113.bbtec.net [126.93.102.113]) (authenticated) by conuserg-12.nifty.com with ESMTP id xANG4l5O019106; Sun, 24 Nov 2019 01:04:51 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-12.nifty.com xANG4l5O019106 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1574525091; bh=5gU5mTeXomynZztjP51R9lorDaBP4CN8eEVudih4LaA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dhx5Vk9AJvt0Op2JB+kGtg0JPl6yuizFEzP+J8nR3M6CG2ZT56IpztMeEFwO6OOLf oJ6F/BApszEqr4AoIcxPwc29Hcnoiyqm/dTqaZT2pdozhZzjLUaA9M7S+3V5h/teJ1 D/zZtLXvacAovXuzOf3QAD8EgXNUw7GVQOzZOUA04K/BdFZF04AF2md3VjV2sZMcNG M9nKpTZhatL0W7ztKYxo6dFd1/Sho4ayXi6hO4RQlVn9BOL8XWyaX52AnRuo+8Cz8r PbrifJL0hvV8kP5gHiwG3n/VDQT4eIs0th3hY4bxYiFo/khTfYWmcrk0qQZhnsfN6L ZQojm/CsRlllw== X-Nifty-SrcIP: [126.93.102.113] From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: Masahiro Yamada , linux-kernel@vger.kernel.org Subject: [PATCH v2 07/16] scripts/kallsyms: add sym_name() to mitigate cast ugliness Date: Sun, 24 Nov 2019 01:04:35 +0900 Message-Id: <20191123160444.11251-8-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191123160444.11251-1-yamada.masahiro@socionext.com> References: <20191123160444.11251-1-yamada.masahiro@socionext.com> Sender: linux-kbuild-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kbuild@vger.kernel.org sym_entry::sym is (unsigned char *) instead of (char *) because kallsyms exploits the MSB for compression, and the characters are used as the index of token_profit array. However, it requires casting (unsigned char *) to (char *) in some places since standard library functions such as strcmp(), strlen() expect (char *). Introduce a new helper, sym_name(), which advances the given pointer by 1 and casts it to (char *). Signed-off-by: Masahiro Yamada --- Changes in v2: None scripts/kallsyms.c | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/scripts/kallsyms.c b/scripts/kallsyms.c index a57636c6f84f..baa2fa5692b0 100644 --- a/scripts/kallsyms.c +++ b/scripts/kallsyms.c @@ -74,6 +74,11 @@ static void usage(void) exit(1); } +static char *sym_name(const struct sym_entry *s) +{ + return (char *)s->sym + 1; +} + static int check_symbol_range(const char *sym, unsigned long long addr, struct addr_range *ranges, int entries) { @@ -154,7 +159,7 @@ static int read_symbol(FILE *in, struct sym_entry *s) "unable to allocate required amount of memory\n"); exit(EXIT_FAILURE); } - strcpy((char *)s->sym + 1, sym); + strcpy(sym_name(s), sym); s->sym[0] = stype; s->percpu_absolute = 0; @@ -215,7 +220,7 @@ static int symbol_valid(struct sym_entry *s) NULL }; int i; - char *sym_name = (char *)s->sym + 1; + const char *name = sym_name(s); /* if --all-symbols is not specified, then symbols outside the text * and inittext sections are discarded */ @@ -230,30 +235,28 @@ static int symbol_valid(struct sym_entry *s) * rules. */ if ((s->addr == text_range_text->end && - strcmp(sym_name, - text_range_text->end_sym)) || + strcmp(name, text_range_text->end_sym)) || (s->addr == text_range_inittext->end && - strcmp(sym_name, - text_range_inittext->end_sym))) + strcmp(name, text_range_inittext->end_sym))) return 0; } /* Exclude symbols which vary between passes. */ for (i = 0; special_symbols[i]; i++) - if (strcmp(sym_name, special_symbols[i]) == 0) + if (strcmp(name, special_symbols[i]) == 0) return 0; for (i = 0; special_prefixes[i]; i++) { int l = strlen(special_prefixes[i]); - if (strncmp(sym_name, special_prefixes[i], l) == 0) + if (strncmp(name, special_prefixes[i], l) == 0) return 0; } for (i = 0; special_suffixes[i]; i++) { - int l = strlen(sym_name) - strlen(special_suffixes[i]); + int l = strlen(name) - strlen(special_suffixes[i]); - if (l >= 0 && strcmp(sym_name + l, special_suffixes[i]) == 0) + if (l >= 0 && strcmp(name + l, special_suffixes[i]) == 0) return 0; } @@ -626,7 +629,7 @@ static void optimize_token_table(void) /* guess for "linker script provide" symbol */ static int may_be_linker_script_provide_symbol(const struct sym_entry *se) { - const char *symbol = (char *)se->sym + 1; + const char *symbol = sym_name(se); int len = se->len - 1; if (len < 8) @@ -696,8 +699,8 @@ static int compare_symbols(const void *a, const void *b) return wa - wb; /* sort by the number of prefix underscores */ - wa = prefix_underscores_count((const char *)sa->sym + 1); - wb = prefix_underscores_count((const char *)sb->sym + 1); + wa = prefix_underscores_count(sym_name(sa)); + wb = prefix_underscores_count(sym_name(sb)); if (wa != wb) return wa - wb; From patchwork Sat Nov 23 16:04:36 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 11258851 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0B19F1575 for ; Sat, 23 Nov 2019 16:05:41 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id D60742071C for ; Sat, 23 Nov 2019 16:05:40 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=nifty.com header.i=@nifty.com header.b="VwmXuzPh" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726920AbfKWQFB (ORCPT ); Sat, 23 Nov 2019 11:05:01 -0500 Received: from conuserg-12.nifty.com ([210.131.2.79]:49445 "EHLO conuserg-12.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726705AbfKWQFB (ORCPT ); Sat, 23 Nov 2019 11:05:01 -0500 Received: from grover.flets-west.jp (softbank126093102113.bbtec.net [126.93.102.113]) (authenticated) by conuserg-12.nifty.com with ESMTP id xANG4l5P019106; Sun, 24 Nov 2019 01:04:51 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-12.nifty.com xANG4l5P019106 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1574525091; bh=5lggXg5IEg7tnVaBbwPVhFClDCwiRJJs4nnaP/eGSlc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=VwmXuzPhD1uessmiV+Ruu8F6Y+D7MZ687YsdNBGIvHKg70mg4Cx3SfLSORXOhsTJv Xt6pGQ9lYlHZ0xdSJx03kM/pNj/PFozWAbmMrXm9S+lnwRAsDv4jHBoFj1YFjeCbto i/1MPAf1c4xLkNrE+HzM78xumNwG+c3Fo5UjVLZkTojpicyMZ5nZ9P/bGCknI05A6H qPkuQ6oNJTO0J6Q6kXy2/5IVMwM0Uai2H6LxNdL4D2WsQm6MdCgEqN4D3rV2uCRH3w N1MEH7SSDC7WI+BqjqZ7c49dYRM9Eevk3iPhm+V28EWvBQjbIVzBTEo0FcMOsHntDI dUS9rNz6/YCdw== X-Nifty-SrcIP: [126.93.102.113] From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: Masahiro Yamada , linux-kernel@vger.kernel.org Subject: [PATCH v2 08/16] scripts/kallsyms: replace prefix_underscores_count() with strspn() Date: Sun, 24 Nov 2019 01:04:36 +0900 Message-Id: <20191123160444.11251-9-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191123160444.11251-1-yamada.masahiro@socionext.com> References: <20191123160444.11251-1-yamada.masahiro@socionext.com> Sender: linux-kbuild-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kbuild@vger.kernel.org You can do equivalent things with strspn(). I do not see noticeable performance difference. Signed-off-by: Masahiro Yamada --- Changes in v2: None scripts/kallsyms.c | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/scripts/kallsyms.c b/scripts/kallsyms.c index baa2fa5692b0..89cc7c098c51 100644 --- a/scripts/kallsyms.c +++ b/scripts/kallsyms.c @@ -661,16 +661,6 @@ static int may_be_linker_script_provide_symbol(const struct sym_entry *se) return 0; } -static int prefix_underscores_count(const char *str) -{ - const char *tail = str; - - while (*tail == '_') - tail++; - - return tail - str; -} - static int compare_symbols(const void *a, const void *b) { const struct sym_entry *sa; @@ -699,8 +689,8 @@ static int compare_symbols(const void *a, const void *b) return wa - wb; /* sort by the number of prefix underscores */ - wa = prefix_underscores_count(sym_name(sa)); - wb = prefix_underscores_count(sym_name(sb)); + wa = strspn(sym_name(sa), "_"); + wb = strspn(sym_name(sb), "_"); if (wa != wb) return wa - wb; From patchwork Sat Nov 23 16:04:37 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 11258857 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id B778A1575 for ; Sat, 23 Nov 2019 16:05:45 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 8E19D2070E for ; Sat, 23 Nov 2019 16:05:45 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=nifty.com header.i=@nifty.com header.b="NQSJuzMy" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726820AbfKWQFp (ORCPT ); Sat, 23 Nov 2019 11:05:45 -0500 Received: from conuserg-12.nifty.com ([210.131.2.79]:49446 "EHLO conuserg-12.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726784AbfKWQFB (ORCPT ); Sat, 23 Nov 2019 11:05:01 -0500 Received: from grover.flets-west.jp (softbank126093102113.bbtec.net [126.93.102.113]) (authenticated) by conuserg-12.nifty.com with ESMTP id xANG4l5Q019106; Sun, 24 Nov 2019 01:04:52 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-12.nifty.com xANG4l5Q019106 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1574525092; bh=ST5LRkJJeHH7On7Bbq1YlVG0Rs9L/Y4/DythexYfliU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=NQSJuzMyjfcrZ60At93JKcETtagGnDncoY8ShgTiWSEH3PwcQnMWfM9HSyaIwVt/+ ooeDAihoomWwymaLfST4PPkx7zou4KtnMlCsbXXM2zjW7IqiPaOG/vKq6mss9QUx8N XKaAVfU1tYwz/tEeoR3GCGo5e+L9XS58/uZHwpMtQgQkZ56oWYZkoKZkh2hp6O8m1S xkJco+A9rwomJJH0w/zYJ9fCHkk5F0JIIKEvkUs5SKs+ncqYcmtI81PNKWNRHBya65 j+Xqc0JhhFGsH5m5ozQpRjFDNWHcqgcnSPmhlybii0wLlP9IjGpktiMmORvhk1zex1 Pnu0KkPAkgcjA== X-Nifty-SrcIP: [126.93.102.113] From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: Masahiro Yamada , linux-kernel@vger.kernel.org Subject: [PATCH v2 09/16] scripts/kallsyms: make find_token() return (unsigned char *) Date: Sun, 24 Nov 2019 01:04:37 +0900 Message-Id: <20191123160444.11251-10-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191123160444.11251-1-yamada.masahiro@socionext.com> References: <20191123160444.11251-1-yamada.masahiro@socionext.com> Sender: linux-kbuild-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kbuild@vger.kernel.org The callers of this function expect (unsigned char *). I do not see a good reason to make this function return (void *). Signed-off-by: Masahiro Yamada --- Changes in v2: None scripts/kallsyms.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/scripts/kallsyms.c b/scripts/kallsyms.c index 89cc7c098c51..274a77bfbd63 100644 --- a/scripts/kallsyms.c +++ b/scripts/kallsyms.c @@ -503,7 +503,8 @@ static void build_initial_tok_table(void) learn_symbol(table[i].sym, table[i].len); } -static void *find_token(unsigned char *str, int len, unsigned char *token) +static unsigned char *find_token(unsigned char *str, int len, + unsigned char *token) { int i; From patchwork Sat Nov 23 16:04:38 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 11258841 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 563AB138C for ; Sat, 23 Nov 2019 16:05:21 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 366BC2071C for ; Sat, 23 Nov 2019 16:05:21 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=nifty.com header.i=@nifty.com header.b="1i5yw/SO" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726833AbfKWQFR (ORCPT ); Sat, 23 Nov 2019 11:05:17 -0500 Received: from conuserg-12.nifty.com ([210.131.2.79]:49452 "EHLO conuserg-12.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726803AbfKWQFC (ORCPT ); Sat, 23 Nov 2019 11:05:02 -0500 Received: from grover.flets-west.jp (softbank126093102113.bbtec.net [126.93.102.113]) (authenticated) by conuserg-12.nifty.com with ESMTP id xANG4l5R019106; Sun, 24 Nov 2019 01:04:52 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-12.nifty.com xANG4l5R019106 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1574525092; bh=TqAVE85oDKpy1eWHxD/8KLZmwl3zyQtGJJFbn4W7YnQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=1i5yw/SOLwH/DwJsCx+Uv4HD6c+KnXEA/xMqf+faLL0RPm/HsMiaJMq5FwpCfnF1J ZiXPYaOECNh8LFNAWfGbwV+ZDuskFk/QruKmDzfMOlg2gZHWtKxrYbKO49uoAxO5lg JX1TNNX29XpXu2LNex95EYkvUOF5sr4uVcSqwR6SSAjxVwo8YZ0numa97G/oQCyUqY t32ZyN6dT+BkFSNLzappuTtMW8wOAPaQQwVyKwq4TQVIA9o95/jeKlQwF3e7pNW3Ez gP0ApTluces2GggGcRn3MTxfyZx06LsxyxsbcZ0WctvblBwQR+LTCZJK4VNRiqKNIw xau0jAXnELx1Q== X-Nifty-SrcIP: [126.93.102.113] From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: Masahiro Yamada , linux-kernel@vger.kernel.org Subject: [PATCH v2 10/16] scripts/kallsyms: add const qualifiers where possible Date: Sun, 24 Nov 2019 01:04:38 +0900 Message-Id: <20191123160444.11251-11-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191123160444.11251-1-yamada.masahiro@socionext.com> References: <20191123160444.11251-1-yamada.masahiro@socionext.com> Sender: linux-kbuild-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kbuild@vger.kernel.org Add 'const' where a function does not write to the pointer dereferenes. Signed-off-by: Masahiro Yamada --- Changes in v2: None scripts/kallsyms.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/scripts/kallsyms.c b/scripts/kallsyms.c index 274a77bfbd63..056bde436540 100644 --- a/scripts/kallsyms.c +++ b/scripts/kallsyms.c @@ -170,11 +170,11 @@ static int read_symbol(FILE *in, struct sym_entry *s) return 0; } -static int symbol_in_range(struct sym_entry *s, struct addr_range *ranges, - int entries) +static int symbol_in_range(const struct sym_entry *s, + const struct addr_range *ranges, int entries) { size_t i; - struct addr_range *ar; + const struct addr_range *ar; for (i = 0; i < entries; ++i) { ar = &ranges[i]; @@ -186,14 +186,14 @@ static int symbol_in_range(struct sym_entry *s, struct addr_range *ranges, return 0; } -static int symbol_valid(struct sym_entry *s) +static int symbol_valid(const struct sym_entry *s) { /* Symbols which vary between passes. Passes 1 and 2 must have * identical symbol lists. The kallsyms_* symbols below are only added * after pass 1, they would be included in pass 2 when --all-symbols is * specified so exclude them to get a stable symbol list. */ - static char *special_symbols[] = { + static const char * const special_symbols[] = { "kallsyms_addresses", "kallsyms_offsets", "kallsyms_relative_base", @@ -208,12 +208,12 @@ static int symbol_valid(struct sym_entry *s) "_SDA2_BASE_", /* ppc */ NULL }; - static char *special_prefixes[] = { + static const char * const special_prefixes[] = { "__crc_", /* modversions */ "__efistub_", /* arm64 EFI stub namespace */ NULL }; - static char *special_suffixes[] = { + static const char * const special_suffixes[] = { "_veneer", /* arm */ "_from_arm", /* arm */ "_from_thumb", /* arm */ @@ -305,7 +305,7 @@ static void read_map(FILE *in) } } -static void output_label(char *label) +static void output_label(const char *label) { printf(".globl %s\n", label); printf("\tALGN\n"); @@ -314,7 +314,7 @@ static void output_label(char *label) /* uncompress a compressed symbol. When this function is called, the best table * might still be compressed itself, so the function needs to be recursive */ -static int expand_symbol(unsigned char *data, int len, char *result) +static int expand_symbol(const unsigned char *data, int len, char *result) { int c, rlen, total=0; @@ -339,7 +339,7 @@ static int expand_symbol(unsigned char *data, int len, char *result) return total; } -static int symbol_absolute(struct sym_entry *s) +static int symbol_absolute(const struct sym_entry *s) { return s->percpu_absolute; } @@ -477,7 +477,7 @@ static void write_src(void) /* table lookup compression functions */ /* count all the possible tokens in a symbol */ -static void learn_symbol(unsigned char *symbol, int len) +static void learn_symbol(const unsigned char *symbol, int len) { int i; @@ -486,7 +486,7 @@ static void learn_symbol(unsigned char *symbol, int len) } /* decrease the count for all the possible tokens in a symbol */ -static void forget_symbol(unsigned char *symbol, int len) +static void forget_symbol(const unsigned char *symbol, int len) { int i; @@ -504,7 +504,7 @@ static void build_initial_tok_table(void) } static unsigned char *find_token(unsigned char *str, int len, - unsigned char *token) + const unsigned char *token) { int i; @@ -517,7 +517,7 @@ static unsigned char *find_token(unsigned char *str, int len, /* replace a given token in all the valid symbols. Use the sampled symbols * to update the counts */ -static void compress_symbols(unsigned char *str, int idx) +static void compress_symbols(const unsigned char *str, int idx) { unsigned int i, len, size; unsigned char *p1, *p2; From patchwork Sat Nov 23 16:04:39 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 11258839 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C52EE6C1 for ; Sat, 23 Nov 2019 16:05:20 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id A52152070E for ; Sat, 23 Nov 2019 16:05:20 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=nifty.com header.i=@nifty.com header.b="koLs9OL+" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727102AbfKWQFR (ORCPT ); Sat, 23 Nov 2019 11:05:17 -0500 Received: from conuserg-12.nifty.com ([210.131.2.79]:49447 "EHLO conuserg-12.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726767AbfKWQFC (ORCPT ); Sat, 23 Nov 2019 11:05:02 -0500 Received: from grover.flets-west.jp (softbank126093102113.bbtec.net [126.93.102.113]) (authenticated) by conuserg-12.nifty.com with ESMTP id xANG4l5S019106; Sun, 24 Nov 2019 01:04:53 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-12.nifty.com xANG4l5S019106 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1574525093; bh=L3zUH6rFXSpzUIwhA4bPRr4LzEsUQo/+LU2wclGFUeM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=koLs9OL+iw4m7NwJ6DHSqxM62gT4jNuvHmeGX23Vg7wCLnclSKzxlEAWgjIYuujuy BWhtpWvMNEKpaEKJrUITq4FMLLGjwMmNW2In+pUb2qqlDrn3kssQp5qRwpkXxgIUZZ 1lZCFo2T51boOVR5lDFjTczRLrMTpYJbsSyLysKKN51m8AgndwEPgJJzSvR7hwfUuH 6MZuCAxBRQGT2IyyCrtVfjlUKvxTJcFouhhzyrpQ4kUWx8q+pf7rE5WaCYrsX+ZWA0 r+A6/G0fmPxkmD5HJGC+ndc+FLTubwnuuUONKND/gyjoOhOkOKmRuzBWMH9oHUkyyE JH+umBKBAvA+A== X-Nifty-SrcIP: [126.93.102.113] From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: Masahiro Yamada , linux-kernel@vger.kernel.org Subject: [PATCH v2 11/16] scripts/kallsyms: skip ignored symbols very early Date: Sun, 24 Nov 2019 01:04:39 +0900 Message-Id: <20191123160444.11251-12-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191123160444.11251-1-yamada.masahiro@socionext.com> References: <20191123160444.11251-1-yamada.masahiro@socionext.com> Sender: linux-kbuild-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kbuild@vger.kernel.org Unless the address range matters, symbols can be ignored earlier, which avoids unneeded memory allocation. Signed-off-by: Masahiro Yamada --- Changes in v2: None scripts/kallsyms.c | 113 +++++++++++++++++++++++++-------------------- 1 file changed, 62 insertions(+), 51 deletions(-) diff --git a/scripts/kallsyms.c b/scripts/kallsyms.c index 056bde436540..843615c1d384 100644 --- a/scripts/kallsyms.c +++ b/scripts/kallsyms.c @@ -18,6 +18,7 @@ * */ +#include #include #include #include @@ -79,6 +80,64 @@ static char *sym_name(const struct sym_entry *s) return (char *)s->sym + 1; } +static bool is_ignored_symbol(const char *name, char type) +{ + static const char * const ignored_symbols[] = { + /* + * Symbols which vary between passes. Passes 1 and 2 must have + * identical symbol lists. The kallsyms_* symbols below are + * only added after pass 1, they would be included in pass 2 + * when --all-symbols is specified so exclude them to get a + * stable symbol list. + */ + "kallsyms_addresses", + "kallsyms_offsets", + "kallsyms_relative_base", + "kallsyms_num_syms", + "kallsyms_names", + "kallsyms_markers", + "kallsyms_token_table", + "kallsyms_token_index", + /* Exclude linker generated symbols which vary between passes */ + "_SDA_BASE_", /* ppc */ + "_SDA2_BASE_", /* ppc */ + NULL + }; + + static const char * const ignored_prefixes[] = { + "__crc_", /* modversions */ + "__efistub_", /* arm64 EFI stub namespace */ + NULL + }; + + static const char * const ignored_suffixes[] = { + "_from_arm", /* arm */ + "_from_thumb", /* arm */ + "_veneer", /* arm */ + NULL + }; + + const char * const *p; + + /* Exclude symbols which vary between passes. */ + for (p = ignored_symbols; *p; p++) + if (!strcmp(name, *p)) + return true; + + for (p = ignored_prefixes; *p; p++) + if (!strncmp(name, *p, strlen(*p))) + return true; + + for (p = ignored_suffixes; *p; p++) { + int l = strlen(name) - strlen(*p); + + if (l >= 0 && !strcmp(name + l, *p)) + return true; + } + + return false; +} + static int check_symbol_range(const char *sym, unsigned long long addr, struct addr_range *ranges, int entries) { @@ -118,6 +177,9 @@ static int read_symbol(FILE *in, struct sym_entry *s) return -1; } + if (is_ignored_symbol(sym, stype)) + return -1; + /* Ignore most absolute/undefined (?) symbols. */ if (strcmp(sym, "_text") == 0) _text = s->addr; @@ -188,38 +250,6 @@ static int symbol_in_range(const struct sym_entry *s, static int symbol_valid(const struct sym_entry *s) { - /* Symbols which vary between passes. Passes 1 and 2 must have - * identical symbol lists. The kallsyms_* symbols below are only added - * after pass 1, they would be included in pass 2 when --all-symbols is - * specified so exclude them to get a stable symbol list. - */ - static const char * const special_symbols[] = { - "kallsyms_addresses", - "kallsyms_offsets", - "kallsyms_relative_base", - "kallsyms_num_syms", - "kallsyms_names", - "kallsyms_markers", - "kallsyms_token_table", - "kallsyms_token_index", - - /* Exclude linker generated symbols which vary between passes */ - "_SDA_BASE_", /* ppc */ - "_SDA2_BASE_", /* ppc */ - NULL }; - - static const char * const special_prefixes[] = { - "__crc_", /* modversions */ - "__efistub_", /* arm64 EFI stub namespace */ - NULL }; - - static const char * const special_suffixes[] = { - "_veneer", /* arm */ - "_from_arm", /* arm */ - "_from_thumb", /* arm */ - NULL }; - - int i; const char *name = sym_name(s); /* if --all-symbols is not specified, then symbols outside the text @@ -241,25 +271,6 @@ static int symbol_valid(const struct sym_entry *s) return 0; } - /* Exclude symbols which vary between passes. */ - for (i = 0; special_symbols[i]; i++) - if (strcmp(name, special_symbols[i]) == 0) - return 0; - - for (i = 0; special_prefixes[i]; i++) { - int l = strlen(special_prefixes[i]); - - if (strncmp(name, special_prefixes[i], l) == 0) - return 0; - } - - for (i = 0; special_suffixes[i]; i++) { - int l = strlen(name) - strlen(special_suffixes[i]); - - if (l >= 0 && strcmp(name + l, special_suffixes[i]) == 0) - return 0; - } - return 1; } From patchwork Sat Nov 23 16:04:40 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 11258845 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E5BAE138C for ; Sat, 23 Nov 2019 16:05:33 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id BC0A12070E for ; Sat, 23 Nov 2019 16:05:33 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=nifty.com header.i=@nifty.com header.b="KFpeQPl7" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727141AbfKWQFc (ORCPT ); Sat, 23 Nov 2019 11:05:32 -0500 Received: from conuserg-12.nifty.com ([210.131.2.79]:49456 "EHLO conuserg-12.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726774AbfKWQFC (ORCPT ); Sat, 23 Nov 2019 11:05:02 -0500 Received: from grover.flets-west.jp (softbank126093102113.bbtec.net [126.93.102.113]) (authenticated) by conuserg-12.nifty.com with ESMTP id xANG4l5T019106; Sun, 24 Nov 2019 01:04:53 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-12.nifty.com xANG4l5T019106 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1574525093; bh=9iKDRL9d6hTzpOpmUOinbE+RaKJ+14kZ7Ic+FqY8y+Y=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=KFpeQPl7WSOVE5M+4JYWJ8DMYIoVWCT9dijqhBO0BSP29OO5sbiSI38pWWHLPvQsR 3P2tCKW9H7g5pB3N1UJXUEJTKd77GHg0d+36p4dO0Sy1++uNzc32sO2iMtc/hUE5dX U3Slqh0jkDfZUIZqhHaTMgOv+AawhekGBWj4+qJHz5LSRhrlrcp/AKa9i6DPxm8Fh0 FqxhmXd46eEK7LPhlTg38Tbh7TIYT+U69UZchvJz/Uy0IQ1T9Xj/1NleQbNrneYbBM t76u28L7Rz6MhKlUlcFoIjeHeTGRSsyYwOREi1teDNknwm2oBNv/iczAabOK8Hnup5 Y5V1zze2RuJnw== X-Nifty-SrcIP: [126.93.102.113] From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: Masahiro Yamada , linux-kernel@vger.kernel.org Subject: [PATCH v2 12/16] scripts/kallsyms: move more patterns to the ignored_prefixes array Date: Sun, 24 Nov 2019 01:04:40 +0900 Message-Id: <20191123160444.11251-13-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191123160444.11251-1-yamada.masahiro@socionext.com> References: <20191123160444.11251-1-yamada.masahiro@socionext.com> Sender: linux-kbuild-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kbuild@vger.kernel.org Refactoring for shortening the code. Signed-off-by: Masahiro Yamada --- Changes in v2: None scripts/kallsyms.c | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/scripts/kallsyms.c b/scripts/kallsyms.c index 843615c1d384..04a1dd16edcf 100644 --- a/scripts/kallsyms.c +++ b/scripts/kallsyms.c @@ -105,6 +105,8 @@ static bool is_ignored_symbol(const char *name, char type) }; static const char * const ignored_prefixes[] = { + "$", /* local symbols for ARM, MIPS, etc. */ + ".LASANPC", /* s390 kasan local symbols */ "__crc_", /* modversions */ "__efistub_", /* arm64 EFI stub namespace */ NULL @@ -198,19 +200,9 @@ static int read_symbol(FILE *in, struct sym_entry *s) } else if (toupper(stype) == 'U') return -1; - /* - * Ignore generated symbols such as: - * - mapping symbols in ARM ELF files ($a, $t, and $d) - * - MIPS ELF local symbols ($L123 instead of .L123) - */ - else if (sym[0] == '$') - return -1; /* exclude debugging symbols */ else if (stype == 'N' || stype == 'n') return -1; - /* exclude s390 kasan local symbols */ - else if (!strncmp(sym, ".LASANPC", 8)) - return -1; /* include the type field in the symbol name, so that it gets * compressed together */ From patchwork Sat Nov 23 16:04:41 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 11258833 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D28F36C1 for ; Sat, 23 Nov 2019 16:05:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id B22752070E for ; Sat, 23 Nov 2019 16:05:11 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=nifty.com header.i=@nifty.com header.b="mGJ7eDDU" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726757AbfKWQFF (ORCPT ); Sat, 23 Nov 2019 11:05:05 -0500 Received: from conuserg-12.nifty.com ([210.131.2.79]:49492 "EHLO conuserg-12.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726846AbfKWQFD (ORCPT ); Sat, 23 Nov 2019 11:05:03 -0500 Received: from grover.flets-west.jp (softbank126093102113.bbtec.net [126.93.102.113]) (authenticated) by conuserg-12.nifty.com with ESMTP id xANG4l5U019106; Sun, 24 Nov 2019 01:04:54 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-12.nifty.com xANG4l5U019106 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1574525094; bh=MJZKY+LNnUcmoA8/8v1d9mnVbNRYD0Hp8Ly2ZpnRV9k=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mGJ7eDDUJ/MkRY2+xwDSNHG2eQ/ZOUJh1wAD4uYUzIFhkEL1Fi2xbIM89oOVsxwdq W7T1Juhy8d4BtYO/g5ddpCysacO26UjhC+v8Tfiy2hEImld0TIcXr5+QCXCQ5gdUUJ HEbqQn5oBTmDTcu6GXWkUZnnByLyOiaf1D6DgM3dJRLUCwF0zQMOFFeSndgeKMQZWo eUzt+b/HyLocv9oHq9pGQirNI0Q4EHa7CFjWdfRAY+N2Cp3crUueTxTOTNgnPyI1Gj ttRHmaaCJCwaLVZu5OyaT9oWBw1zLPUjhekwSw62QSKjD2adzaJlb506hl7RsU+hRV 5APOT1SbSb0AQ== X-Nifty-SrcIP: [126.93.102.113] From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: Masahiro Yamada , linux-kernel@vger.kernel.org Subject: [PATCH v2 13/16] scripts/kallsyms: move ignored symbol types to is_ignored_symbol() Date: Sun, 24 Nov 2019 01:04:41 +0900 Message-Id: <20191123160444.11251-14-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191123160444.11251-1-yamada.masahiro@socionext.com> References: <20191123160444.11251-1-yamada.masahiro@socionext.com> Sender: linux-kbuild-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kbuild@vger.kernel.org Collect the ignored patterns to is_ignored_symbol(). Signed-off-by: Masahiro Yamada --- Changes in v2: None scripts/kallsyms.c | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/scripts/kallsyms.c b/scripts/kallsyms.c index 04a1dd16edcf..d90a6133d7b8 100644 --- a/scripts/kallsyms.c +++ b/scripts/kallsyms.c @@ -137,6 +137,21 @@ static bool is_ignored_symbol(const char *name, char type) return true; } + if (type == 'U' || type == 'u') + return true; + /* exclude debugging symbols */ + if (type == 'N' || type == 'n') + return true; + + if (toupper(type) == 'A') { + /* Keep these useful absolute symbols */ + if (strcmp(name, "__kernel_syscall_via_break") && + strcmp(name, "__kernel_syscall_via_epc") && + strcmp(name, "__kernel_sigtramp") && + strcmp(name, "__gp")) + return true; + } + return false; } @@ -188,21 +203,6 @@ static int read_symbol(FILE *in, struct sym_entry *s) else if (check_symbol_range(sym, s->addr, text_ranges, ARRAY_SIZE(text_ranges)) == 0) /* nothing to do */; - else if (toupper(stype) == 'A') - { - /* Keep these useful absolute symbols */ - if (strcmp(sym, "__kernel_syscall_via_break") && - strcmp(sym, "__kernel_syscall_via_epc") && - strcmp(sym, "__kernel_sigtramp") && - strcmp(sym, "__gp")) - return -1; - - } - else if (toupper(stype) == 'U') - return -1; - /* exclude debugging symbols */ - else if (stype == 'N' || stype == 'n') - return -1; /* include the type field in the symbol name, so that it gets * compressed together */ From patchwork Sat Nov 23 16:04:42 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 11258853 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C52BA138C for ; Sat, 23 Nov 2019 16:05:44 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id A454C2070E for ; Sat, 23 Nov 2019 16:05:44 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=nifty.com header.i=@nifty.com header.b="x4VIQ1/V" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727194AbfKWQFk (ORCPT ); Sat, 23 Nov 2019 11:05:40 -0500 Received: from conuserg-12.nifty.com ([210.131.2.79]:49457 "EHLO conuserg-12.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726820AbfKWQFC (ORCPT ); Sat, 23 Nov 2019 11:05:02 -0500 Received: from grover.flets-west.jp (softbank126093102113.bbtec.net [126.93.102.113]) (authenticated) by conuserg-12.nifty.com with ESMTP id xANG4l5V019106; Sun, 24 Nov 2019 01:04:54 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-12.nifty.com xANG4l5V019106 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1574525094; bh=9MAnCdg3hR5ROOX8y8hcsA9VaCetvt+YAuylmAsTUL4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=x4VIQ1/VqdKlMPmJB8JIlJnPeiDjw2UMJPvdhqrzJQXJM40hLJ87fsHejr4cCTmTg 50BMgOnpUNp8aKEup82RBfUju4WPG3xqBJD50ihPyUtSaFXaxi12GsAZB3Fux3yFL0 AJEodQDkTKfQrHaX7BYQzOh7VpGlVWQf3aWhhL2qjg8P1ekPdRA1tip2D0oGBzuici ImZ5hWIP0XV7a2PWUkW9kIZ8V7GhPnNdW8ZQvvZ3FH5YqZqrTCpGjJwWL7jf6Pa03r ThOFqS+ftEUK5BW3/2lI/qZ9ZjU+1jllYHrf0JhWO56ilJw9MZs3BdiMZ3Kee0OMYK bjohBVT5LLiTg== X-Nifty-SrcIP: [126.93.102.113] From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: Masahiro Yamada , linux-kernel@vger.kernel.org Subject: [PATCH v2 14/16] scripts/kallsyms: make check_symbol_range() void function Date: Sun, 24 Nov 2019 01:04:42 +0900 Message-Id: <20191123160444.11251-15-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191123160444.11251-1-yamada.masahiro@socionext.com> References: <20191123160444.11251-1-yamada.masahiro@socionext.com> Sender: linux-kbuild-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kbuild@vger.kernel.org There is no more reason to check the return value of check_symbol_range(). Signed-off-by: Masahiro Yamada --- Changes in v2: None scripts/kallsyms.c | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/scripts/kallsyms.c b/scripts/kallsyms.c index d90a6133d7b8..f4d5f131556d 100644 --- a/scripts/kallsyms.c +++ b/scripts/kallsyms.c @@ -155,8 +155,8 @@ static bool is_ignored_symbol(const char *name, char type) return false; } -static int check_symbol_range(const char *sym, unsigned long long addr, - struct addr_range *ranges, int entries) +static void check_symbol_range(const char *sym, unsigned long long addr, + struct addr_range *ranges, int entries) { size_t i; struct addr_range *ar; @@ -166,14 +166,12 @@ static int check_symbol_range(const char *sym, unsigned long long addr, if (strcmp(sym, ar->start_sym) == 0) { ar->start = addr; - return 0; + return; } else if (strcmp(sym, ar->end_sym) == 0) { ar->end = addr; - return 0; + return; } } - - return 1; } static int read_symbol(FILE *in, struct sym_entry *s) @@ -200,9 +198,8 @@ static int read_symbol(FILE *in, struct sym_entry *s) /* Ignore most absolute/undefined (?) symbols. */ if (strcmp(sym, "_text") == 0) _text = s->addr; - else if (check_symbol_range(sym, s->addr, text_ranges, - ARRAY_SIZE(text_ranges)) == 0) - /* nothing to do */; + + check_symbol_range(sym, s->addr, text_ranges, ARRAY_SIZE(text_ranges)); /* include the type field in the symbol name, so that it gets * compressed together */ From patchwork Sat Nov 23 16:04:43 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 11258863 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 6C9321575 for ; Sat, 23 Nov 2019 16:06:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 433532070E for ; Sat, 23 Nov 2019 16:06:01 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=nifty.com header.i=@nifty.com header.b="Ls8Ej6lz" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727236AbfKWQFu (ORCPT ); Sat, 23 Nov 2019 11:05:50 -0500 Received: from conuserg-12.nifty.com ([210.131.2.79]:49449 "EHLO conuserg-12.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726740AbfKWQFB (ORCPT ); Sat, 23 Nov 2019 11:05:01 -0500 Received: from grover.flets-west.jp (softbank126093102113.bbtec.net [126.93.102.113]) (authenticated) by conuserg-12.nifty.com with ESMTP id xANG4l5W019106; Sun, 24 Nov 2019 01:04:54 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-12.nifty.com xANG4l5W019106 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1574525095; bh=jA3oyA+zBfgpdI/EjevUAFgNYlad6/34++q2OdZf31k=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Ls8Ej6lzwh4m25ICQmLvpNEmvovUsuCJ4C3qbnAgD1chP/UidRNAzql0uxWy25+7p 8DqN7YSD3JMYFEfaEC/ah4vFxymxc4YKfGp5g4j5ofQU0Te2JJpl0NBb7Yo1rgqrAS aiZ2iOhmO7JoFZtTxbc5UNgfvyuPpCly4OY/VUK6JcwQEatCPj5McFCYorIzht0tzM QbzLq9AvWdPo4ePLfSH5OvmtQeFhUjBPOOBwge0TWp8x7/dPMxwsv/12xsyZvZI9xz OaDsaYQe+dAX8ySAUxAV1k8Q9OxQepfEcYzj/hZCY3tpXiqlA5tVOHZcgButhqtA5F jPc6R7aUvjYMw== X-Nifty-SrcIP: [126.93.102.113] From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: Masahiro Yamada , linux-kernel@vger.kernel.org Subject: [PATCH v2 15/16] scripts/kallsyms: put check_symbol_range() calls close together Date: Sun, 24 Nov 2019 01:04:43 +0900 Message-Id: <20191123160444.11251-16-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191123160444.11251-1-yamada.masahiro@socionext.com> References: <20191123160444.11251-1-yamada.masahiro@socionext.com> Sender: linux-kbuild-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kbuild@vger.kernel.org Put the relevant code close together. Signed-off-by: Masahiro Yamada --- Changes in v2: None scripts/kallsyms.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/scripts/kallsyms.c b/scripts/kallsyms.c index f4d5f131556d..b9b1a4cf1c65 100644 --- a/scripts/kallsyms.c +++ b/scripts/kallsyms.c @@ -200,6 +200,7 @@ static int read_symbol(FILE *in, struct sym_entry *s) _text = s->addr; check_symbol_range(sym, s->addr, text_ranges, ARRAY_SIZE(text_ranges)); + check_symbol_range(sym, s->addr, &percpu_range, 1); /* include the type field in the symbol name, so that it gets * compressed together */ @@ -215,9 +216,6 @@ static int read_symbol(FILE *in, struct sym_entry *s) s->percpu_absolute = 0; - /* Record if we've found __per_cpu_start/end. */ - check_symbol_range(sym, s->addr, &percpu_range, 1); - return 0; } From patchwork Sat Nov 23 16:04:44 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 11258849 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id CCF7A138C for ; Sat, 23 Nov 2019 16:05:40 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id A3EE12071C for ; Sat, 23 Nov 2019 16:05:40 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=nifty.com header.i=@nifty.com header.b="cjUQ/FkK" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726931AbfKWQFC (ORCPT ); Sat, 23 Nov 2019 11:05:02 -0500 Received: from conuserg-12.nifty.com ([210.131.2.79]:49453 "EHLO conuserg-12.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726775AbfKWQFB (ORCPT ); Sat, 23 Nov 2019 11:05:01 -0500 Received: from grover.flets-west.jp (softbank126093102113.bbtec.net [126.93.102.113]) (authenticated) by conuserg-12.nifty.com with ESMTP id xANG4l5X019106; Sun, 24 Nov 2019 01:04:55 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-12.nifty.com xANG4l5X019106 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1574525095; bh=bQe/3Y9Yl+Kq9fBfAZOWGkCZwUqZVs1ZvuNfALS8C3M=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cjUQ/FkK+GKaB9FQDS2oQmQIFqTtwvMn+XU1w5kuJ6vuHntQh4WviKuCipgVTOF6q NzeW7B9KsE0GmU8xIkFvUv7XNpcbQjMUsYsSfZrjwBqQDhXsoltaIx3fE8NjBUvQCB sas9D0BQCiU/9W9yDBKqbz3tRMJJB8aQQ787SEfNd7jHDKAkSKQeamVl3eg9vyhgVh EXrv+fluli/i+h6ys9DnIzcLUfEriwp/nsqUP0Au24yHYt+ywR05MPfG1yB0JbDXqd bzpFWevKawuhs8VpksT8PQ19fCGK3G7WWQ9RyaYaYwnpo7oSaH3mLUD3o3eP5pBL+L hmKdJHq1iwlSA== X-Nifty-SrcIP: [126.93.102.113] From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: Masahiro Yamada , linux-kernel@vger.kernel.org Subject: [PATCH v2 16/16] scripts/kallsyms: remove redundant initializers Date: Sun, 24 Nov 2019 01:04:44 +0900 Message-Id: <20191123160444.11251-17-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191123160444.11251-1-yamada.masahiro@socionext.com> References: <20191123160444.11251-1-yamada.masahiro@socionext.com> Sender: linux-kbuild-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kbuild@vger.kernel.org These are set to zero without the explicit initializers. Signed-off-by: Masahiro Yamada --- Changes in v2: None scripts/kallsyms.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/kallsyms.c b/scripts/kallsyms.c index b9b1a4cf1c65..fb55f262f42d 100644 --- a/scripts/kallsyms.c +++ b/scripts/kallsyms.c @@ -57,9 +57,9 @@ static struct addr_range percpu_range = { static struct sym_entry *table; static unsigned int table_size, table_cnt; -static int all_symbols = 0; -static int absolute_percpu = 0; -static int base_relative = 0; +static int all_symbols; +static int absolute_percpu; +static int base_relative; static int token_profit[0x10000];