From patchwork Sat Nov 23 13:27:12 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 11258787 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 9DB0D930 for ; Sat, 23 Nov 2019 13:28:50 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 7E3F4204FD for ; Sat, 23 Nov 2019 13:28:50 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=nifty.com header.i=@nifty.com header.b="H/QNOBq0" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726759AbfKWN2l (ORCPT ); Sat, 23 Nov 2019 08:28:41 -0500 Received: from conuserg-10.nifty.com ([210.131.2.77]:39545 "EHLO conuserg-10.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726774AbfKWN2A (ORCPT ); Sat, 23 Nov 2019 08:28:00 -0500 Received: from grover.flets-west.jp (softbank126093102113.bbtec.net [126.93.102.113]) (authenticated) by conuserg-10.nifty.com with ESMTP id xANDRbka000733; Sat, 23 Nov 2019 22:27:38 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-10.nifty.com xANDRbka000733 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1574515659; bh=SAOvNT84T6xkejq7UF7LxRxPz4hv3O9WHTksxFtpRFk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=H/QNOBq0Zk6CKGMqWoCEuAz2fi60YD1+FO7Lr7biE94WhZLYyRrERh3MlsKV4VoqM vQXAL5EjB4pVnLD1cTWeMikh0xCAqgo5KElZpCJ39tmQecK8dRGxtLFXfz8KD8Bx06 c8EXuPkpm9sZU+J62WsE8gF073ii1xDfnaSTBKyLBJo3lOfVTNsbnCdp8cSAtl9yVF 4q45wtiwY2e+dbeoEwPgVV+FpJX6VuLMl5rzSZuds6MxrI3+3l0o1Ec5tsDtOQIYZD v3nq+QU4PQkxY0oLAYRS0W5c0ccY0x41tYt2qJdiYnOAWrNGTz/va6auTdHtXkqS/Y M3IpqY7aeFojA== 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 01/16] scripts/kallsyms: remove unneeded #ifndef ARRAY_SIZE Date: Sat, 23 Nov 2019 22:27:12 +0900 Message-Id: <20191123132727.30151-2-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191123132727.30151-1-yamada.masahiro@socionext.com> References: <20191123132727.30151-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 --- 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 13:27:13 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 11258793 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 138841871 for ; Sat, 23 Nov 2019 13:28:59 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id DE35C204FD for ; Sat, 23 Nov 2019 13:28:58 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=nifty.com header.i=@nifty.com header.b="YlRnKr4T" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726842AbfKWN17 (ORCPT ); Sat, 23 Nov 2019 08:27:59 -0500 Received: from conuserg-10.nifty.com ([210.131.2.77]:39550 "EHLO conuserg-10.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726757AbfKWN17 (ORCPT ); Sat, 23 Nov 2019 08:27:59 -0500 Received: from grover.flets-west.jp (softbank126093102113.bbtec.net [126.93.102.113]) (authenticated) by conuserg-10.nifty.com with ESMTP id xANDRbkb000733; Sat, 23 Nov 2019 22:27:39 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-10.nifty.com xANDRbkb000733 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1574515659; bh=JLQ/nMugg5YVM+foR8VQqNloJc4DhmgRZ+4CrOZuEX4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YlRnKr4Tk7d0Czt/xTJcgSf5lnYUu2xV02JwJ71fH12BaC/fHaPJDlCF0pG/sYmQx aXtYH7PnNvV2VLk89VcXdKbTXRAaNs0tu4j5UVmtMU0ovsHmf7U7xTDEdBNoAclqP8 korgTc4lM/6/z9UgWSuQsPMdCQoBM/DL3+MD1v/JqwU9XpKWR5w8uVTaqimecsThdM P0hfUMzntuaYspaOTxbSd/eGO6IHVmf5CNzd7qdftSZ1c+2+NKIZt0RMOeHQz3JKYR D8hRO9bnbrXUKZPVa2eS/D9NcT/DOoGoaeJTO7C4j8+RcetSo/hdum6V0q36G5u65z WGMpgJ6Z/JcVA== 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 02/16] scripts/kallsyms: fix definitely-lost memory leak Date: Sat, 23 Nov 2019 22:27:13 +0900 Message-Id: <20191123132727.30151-3-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191123132727.30151-1-yamada.masahiro@socionext.com> References: <20191123132727.30151-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 --- 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 13:27:14 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 11258777 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 495B3913 for ; Sat, 23 Nov 2019 13:28:33 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 2918020719 for ; Sat, 23 Nov 2019 13:28:33 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=nifty.com header.i=@nifty.com header.b="N85SUdQu" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726792AbfKWN2Z (ORCPT ); Sat, 23 Nov 2019 08:28:25 -0500 Received: from conuserg-10.nifty.com ([210.131.2.77]:39544 "EHLO conuserg-10.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726775AbfKWN2B (ORCPT ); Sat, 23 Nov 2019 08:28:01 -0500 Received: from grover.flets-west.jp (softbank126093102113.bbtec.net [126.93.102.113]) (authenticated) by conuserg-10.nifty.com with ESMTP id xANDRbkc000733; Sat, 23 Nov 2019 22:27:39 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-10.nifty.com xANDRbkc000733 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1574515660; bh=7GX2WjlpLbqGoaEHNabrSpwDglBUHJ7U4pgd8VDnbJY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=N85SUdQujbubtocMqLhU8ab+LMgOFbjmqCW2+pDR5QuUdFSlVXl1WfcDuc2YIl1DP LhpXB5v9kq586eMLSiXzINnuMSKD3TMchRKDq00iMWpQRPT+fLJ/w+CHXpbnHe7qML 5UYc8LlRI667jDTiqQlL0p61zE8KsnB8WCaE67lQ1DAExl+p39H5Vwzx+G7eN/HT6d ZvnfSjD4jUR4g49QEpc9mlDT9PDNXbNnUt5mfa7EbZlhefjvU8XAAp286O5Um5J5aN 9h4SN8UWq06tlNo0qLHiZoxpWxe0Z8YT6avbsYoYuuAJz0RbFVGmc/2Z4PKFr+6HN1 C4kV72XZoqNNg== 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 03/16] scripts/kallsyms: set relative_base more effectively Date: Sat, 23 Nov 2019 22:27:14 +0900 Message-Id: <20191123132727.30151-4-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191123132727.30151-1-yamada.masahiro@socionext.com> References: <20191123132727.30151-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 --- scripts/kallsyms.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/scripts/kallsyms.c b/scripts/kallsyms.c index 79641874d860..0959e1de381c 100644 --- a/scripts/kallsyms.c +++ b/scripts/kallsyms.c @@ -731,11 +731,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) @@ -758,9 +762,9 @@ int main(int argc, char **argv) read_map(stdin); 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 13:27:15 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 11258783 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 C7DDA913 for ; Sat, 23 Nov 2019 13:28:40 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id A758E2071B for ; Sat, 23 Nov 2019 13:28:40 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=nifty.com header.i=@nifty.com header.b="H7Kordq0" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727166AbfKWN2g (ORCPT ); Sat, 23 Nov 2019 08:28:36 -0500 Received: from conuserg-10.nifty.com ([210.131.2.77]:39539 "EHLO conuserg-10.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726759AbfKWN2A (ORCPT ); Sat, 23 Nov 2019 08:28:00 -0500 Received: from grover.flets-west.jp (softbank126093102113.bbtec.net [126.93.102.113]) (authenticated) by conuserg-10.nifty.com with ESMTP id xANDRbkd000733; Sat, 23 Nov 2019 22:27:40 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-10.nifty.com xANDRbkd000733 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1574515660; bh=TgBBfAjF1gkWIAkBRfUA0hcVefTdXQgpgZ7bt3b2OO4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=H7Kordq0Z3UH2HxIwpMry7Xy/ka2OwWKrm8/MbDl8o+VMj6UepLQG0Im0Ge2986cn LdjrPJvM9rw/X9NGSQXcA2zWxw5MlkTQhdSycp26sGeihRfHY/9nPY18veRTm50Tk6 uxP2eEJt9NInF+3HypKPbS8G1xTByQBIOM7ZIdenaLjWmyaKdgXNFbmXikWE2u40JF uCGpo+RyQyfZ5yhhtfxj5W2XwztuW5wDUPlGUeFq5zzPsEHBfLTAfsJrBvYmEIr3WO /n+0ONRE+pJiO2Su9xcXjlYRUEFd8r9t/E+7NcovY0LeHx9nLYwUbw3THUEbKkk/r8 eh+CNe5vWBn4g== 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 04/16] scripts/kallsyms: remove redundant is_arm_mapping_symbol() Date: Sat, 23 Nov 2019 22:27:15 +0900 Message-Id: <20191123132727.30151-5-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191123132727.30151-1-yamada.masahiro@socionext.com> References: <20191123132727.30151-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 --- scripts/kallsyms.c | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/scripts/kallsyms.c b/scripts/kallsyms.c index 0959e1de381c..265475d3cffb 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 13:27:16 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 11258779 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 935A7930 for ; Sat, 23 Nov 2019 13:28:33 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 6924620719 for ; Sat, 23 Nov 2019 13:28:33 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=nifty.com header.i=@nifty.com header.b="oxh5mWc9" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726887AbfKWN2A (ORCPT ); Sat, 23 Nov 2019 08:28:00 -0500 Received: from conuserg-10.nifty.com ([210.131.2.77]:39549 "EHLO conuserg-10.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726802AbfKWN2A (ORCPT ); Sat, 23 Nov 2019 08:28:00 -0500 Received: from grover.flets-west.jp (softbank126093102113.bbtec.net [126.93.102.113]) (authenticated) by conuserg-10.nifty.com with ESMTP id xANDRbke000733; Sat, 23 Nov 2019 22:27:40 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-10.nifty.com xANDRbke000733 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1574515661; bh=X/uShYh5Ocw7jutbX526YPdGr8N3XPBBqlaV1xcxg9U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=oxh5mWc96I+dx8zaiAIm+RHL7+53qCiLu2kJsIbZgwwZGEI5K21EwDRaod0Rvdxu1 i+714hNlRZrZW5gmzETRL/Ganlpv5XqVthtjwXxZpQ8BXrg1cLnT0a1JZMNNK9Apb0 Ua6x2CSif+fVJ+IEJ2jmWFt5J8fx1jTmSYG/OT/HXEKcctl4GWAfzZacfiB5b2Z/Rv 6H/Rhx2ydHc1clJEFyTnheUF46FAHcKguzHV5m6zdxvgK0fIscT81vvHDYshWQwQiw 4h2MfWHf2jd5y6vv/5u3Iop7azUbqj8DqEsxihkaQPCBL+inIbBPVaPTwOFVCkxuKF Jwd/J43AiTqPA== 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 05/16] scripts/kallsyms: remove unneeded length check for prefix matching Date: Sat, 23 Nov 2019 22:27:16 +0900 Message-Id: <20191123132727.30151-6-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191123132727.30151-1-yamada.masahiro@socionext.com> References: <20191123132727.30151-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 --- scripts/kallsyms.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/scripts/kallsyms.c b/scripts/kallsyms.c index 265475d3cffb..d06f373b3a96 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 13:27:17 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 11258767 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 EFFD7913 for ; Sat, 23 Nov 2019 13:28:16 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id CE46F20719 for ; Sat, 23 Nov 2019 13:28:16 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=nifty.com header.i=@nifty.com header.b="GCR/49nO" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726939AbfKWN2C (ORCPT ); Sat, 23 Nov 2019 08:28:02 -0500 Received: from conuserg-10.nifty.com ([210.131.2.77]:39588 "EHLO conuserg-10.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726830AbfKWN2C (ORCPT ); Sat, 23 Nov 2019 08:28:02 -0500 Received: from grover.flets-west.jp (softbank126093102113.bbtec.net [126.93.102.113]) (authenticated) by conuserg-10.nifty.com with ESMTP id xANDRbkf000733; Sat, 23 Nov 2019 22:27:41 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-10.nifty.com xANDRbkf000733 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1574515661; bh=ypUpU2nBI/A1XdRJXgUsR35+rlaygjU5MVZjZEkz4gY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GCR/49nO3EdI/2Iw7QoHmt7RCHQZWY6McY+mNOJ1elseV+MByzbfA/ec1KTtMtrug 3qZO9+XsmRI/HkAbjgkR61ULTJz4UgIJfQ7q01zF4uw+sAypOI2DaMFOZ2sZIY2PL6 Ifd5TOhpSiT6IT8bh8V13ioJXFwakDN8OmbiWVxFyBFtoM8Ljc9kOARSPGar4JCthx iMxFWeW+qL1S+W2hyRpFotA6tEyQ60sNNLtPhqOKFgDyABivO07PDNLwvEuuEm3EDm FH8b7bvp9UxTpU2cGc+YqCroL3aqWPbPsZR4KRoUYilIvixzLe+qONzA/FcQDa19sj oL2+XYyhhQC9A== 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 06/16] scripts/kallsyms: add sym_name() to mitigate cast ugliness Date: Sat, 23 Nov 2019 22:27:17 +0900 Message-Id: <20191123132727.30151-7-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191123132727.30151-1-yamada.masahiro@socionext.com> References: <20191123132727.30151-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 --- scripts/kallsyms.c | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/scripts/kallsyms.c b/scripts/kallsyms.c index d06f373b3a96..7b00b4030be4 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; } @@ -618,7 +621,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) @@ -688,8 +691,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 13:27:18 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 11258791 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 BFE9D913 for ; Sat, 23 Nov 2019 13:28:58 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 95F6A20706 for ; Sat, 23 Nov 2019 13:28:58 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=nifty.com header.i=@nifty.com header.b="hiCg3yvw" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726767AbfKWN2v (ORCPT ); Sat, 23 Nov 2019 08:28:51 -0500 Received: from conuserg-10.nifty.com ([210.131.2.77]:39536 "EHLO conuserg-10.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726762AbfKWN2A (ORCPT ); Sat, 23 Nov 2019 08:28:00 -0500 Received: from grover.flets-west.jp (softbank126093102113.bbtec.net [126.93.102.113]) (authenticated) by conuserg-10.nifty.com with ESMTP id xANDRbkg000733; Sat, 23 Nov 2019 22:27:41 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-10.nifty.com xANDRbkg000733 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1574515662; bh=YReDcxfG08+KN/ys3qrGQn3f4QFwxWEt7XHh/6OsNjk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hiCg3yvwtEG/PzPVSGTTU1RZvNrR30Q1AprIKE9IONc8dSnD4iIYhvVJKaj5F6ZiF /YThI0c9Vo12j5gg4J1+nnxnHq/AxZyU8ptViG4eQJKrCfSo6Vn9x4MVPndxNYT/u7 rCsjOiR+98C6dMaNDtFAcCxY8up1TwoY3ktDLGoHenMMreco65ClIQJqxnukZmlpdI LX2mF+33j4FicRkzKIL/dXcijupEkxsJrfdl1z7NyES+CVNYHPE7B/eN+sMVxJQsue 2/svM7js9DjmpU3VIV2WiJpT2zi+naJ6qS6o9OhMZ/a1qX4dY9u8/Rct657kkaMSff GykvGVGEB7KZA== 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 07/16] scripts/kallsyms: replace prefix_underscores_count() with strspn() Date: Sat, 23 Nov 2019 22:27:18 +0900 Message-Id: <20191123132727.30151-8-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191123132727.30151-1-yamada.masahiro@socionext.com> References: <20191123132727.30151-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 with strspn(). I do not see noticeable performance difference. Signed-off-by: Masahiro Yamada --- scripts/kallsyms.c | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/scripts/kallsyms.c b/scripts/kallsyms.c index 7b00b4030be4..a007d901c3a5 100644 --- a/scripts/kallsyms.c +++ b/scripts/kallsyms.c @@ -653,16 +653,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; @@ -691,8 +681,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 13:27:19 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 11258789 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 75D38930 for ; Sat, 23 Nov 2019 13:28:58 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 55AED204FD for ; Sat, 23 Nov 2019 13:28:58 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=nifty.com header.i=@nifty.com header.b="IBzj/6q7" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727225AbfKWN2v (ORCPT ); Sat, 23 Nov 2019 08:28:51 -0500 Received: from conuserg-10.nifty.com ([210.131.2.77]:39535 "EHLO conuserg-10.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726765AbfKWN2A (ORCPT ); Sat, 23 Nov 2019 08:28:00 -0500 Received: from grover.flets-west.jp (softbank126093102113.bbtec.net [126.93.102.113]) (authenticated) by conuserg-10.nifty.com with ESMTP id xANDRbkh000733; Sat, 23 Nov 2019 22:27:42 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-10.nifty.com xANDRbkh000733 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1574515662; bh=yRF2y3vF9C7Zci91xsHHxMzbjmKu+VkByjExrmElrLw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=IBzj/6q7RtiAFwtZwDOxwgbmWOQJxTLhfJ/YpLZW8YexI1LOIFB8mmvB17aYxaoLf XEinzqXo9GkOUyfQmjUPSSj8PgbjlS9pt8GuXQdl02fsGxZATqidDHd+B6nTBxTKfH 3f2iTj/f4GPfMfvUi5YnurpMNdsriOPx830y+Hysphf19Z1LcTL6UO19y+IAmPXA5C zFNdcDVFspXn9IrR7KLIuukkRjf9FGYNj0WmN5vupnviOFnaNZUho5tVDRrMIk0Bfy 2mqdQ2Htlvsn542ufSmpmYeSHRiZ1MBbYhA82VJvwJHM0UUJlmiRKSIaNQUvgxJTPp qM1oejpG0s14A== 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 08/16] scripts/kallsyms: make find_token() return (unsigned char *) Date: Sat, 23 Nov 2019 22:27:19 +0900 Message-Id: <20191123132727.30151-9-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191123132727.30151-1-yamada.masahiro@socionext.com> References: <20191123132727.30151-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 --- scripts/kallsyms.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/scripts/kallsyms.c b/scripts/kallsyms.c index a007d901c3a5..c4f7f20ecfb7 100644 --- a/scripts/kallsyms.c +++ b/scripts/kallsyms.c @@ -489,7 +489,8 @@ static void build_initial_tok_table(void) table_cnt = pos; } -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 13:27:20 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 11258771 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 C5D1B930 for ; Sat, 23 Nov 2019 13:28:17 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id A4CF320719 for ; Sat, 23 Nov 2019 13:28:17 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=nifty.com header.i=@nifty.com header.b="OugDC2Ik" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726830AbfKWN2R (ORCPT ); Sat, 23 Nov 2019 08:28:17 -0500 Received: from conuserg-10.nifty.com ([210.131.2.77]:39540 "EHLO conuserg-10.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726784AbfKWN2B (ORCPT ); Sat, 23 Nov 2019 08:28:01 -0500 Received: from grover.flets-west.jp (softbank126093102113.bbtec.net [126.93.102.113]) (authenticated) by conuserg-10.nifty.com with ESMTP id xANDRbki000733; Sat, 23 Nov 2019 22:27:42 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-10.nifty.com xANDRbki000733 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1574515663; bh=A1pH5sFWnicqKcGRYR3bGaguX1Aj6aoTLBQi/Wtt0iA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OugDC2IkWj5dXOoQuC/L+F79/gvUzPwpxJyjnzD6xvV3KTS92nxGNS3atPMmCzanc ENMo/QgrCGu/Yc4KaGWo0qz8KIdWVXjVshT+RL2uQVSAT42s4Zux2T2huq3IXFdBSa 4+Z5HlMTlLvaHEJRVqYCmVPgRzxyFrGJAr+mK4DXQzBI0pXYMV7LgXvlLHYk+IpJS3 TuM4qfTtmrvKM807YZwZXMFvn9PfHdBNrSFlUkhs+6I9sIC5JP2mn3RcugGYKn/isx J/YZMMsYmyK0EOLRxwSyXZOc7xmok5PPlgy1sQaYIbKDaIIuxYbxdsySLjpXEf6KZ+ TTfmHd0Sf1mCw== 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 09/16] scripts/kallsyms: add const qualifiers where possible Date: Sat, 23 Nov 2019 22:27:20 +0900 Message-Id: <20191123132727.30151-10-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191123132727.30151-1-yamada.masahiro@socionext.com> References: <20191123132727.30151-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 --- scripts/kallsyms.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/scripts/kallsyms.c b/scripts/kallsyms.c index c4f7f20ecfb7..d745fd2c7247 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 */ @@ -281,7 +281,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"); @@ -290,7 +290,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; @@ -315,7 +315,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; } @@ -453,7 +453,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; @@ -462,7 +462,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; @@ -490,7 +490,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; @@ -503,7 +503,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 13:27:21 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 11258773 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 EDC3F14ED for ; Sat, 23 Nov 2019 13:28:17 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id CD89920719 for ; Sat, 23 Nov 2019 13:28:17 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=nifty.com header.i=@nifty.com header.b="WrTp4OB9" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727071AbfKWN2R (ORCPT ); Sat, 23 Nov 2019 08:28:17 -0500 Received: from conuserg-10.nifty.com ([210.131.2.77]:39546 "EHLO conuserg-10.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726792AbfKWN2B (ORCPT ); Sat, 23 Nov 2019 08:28:01 -0500 Received: from grover.flets-west.jp (softbank126093102113.bbtec.net [126.93.102.113]) (authenticated) by conuserg-10.nifty.com with ESMTP id xANDRbkj000733; Sat, 23 Nov 2019 22:27:43 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-10.nifty.com xANDRbkj000733 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1574515663; bh=VDV0cx69m4DwPpF44Vbld+kv89R0ZXuzwtz3kyXW5XA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=WrTp4OB9QdcpBPwRnc6TWEX/KLLonFnhg5UPkZIF/U07HSoqNXFDVcSxoO5y43Pu3 REpPTpNte4SLML/2yuvP5ejvBQtJ6egLpH2yaDQIvyz0jh03ynLLz2d+OERncU0WBk Kw9YOqoGDuIUToGL/RvROyWLhD/qOW42WFi0pdmfdAlbvoYbjgOdM2zbD6Ll4E30Wj /51581QiI3oUYSxQYuyZiNPJhMkJP9QHo5OQeF9Yfz6uWH/uFrLSq+QM+jm815Gvu5 jzre8IUYDtskPMQB+SYhC9o0XAcAeOH95e6JBG1lhmTeXIUSnqwT7QsCPonr+hxE0N bbyp3ekj/CyAw== 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 10/16] scripts/kallsyms: skip ignored symbols very early Date: Sat, 23 Nov 2019 22:27:21 +0900 Message-Id: <20191123132727.30151-11-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191123132727.30151-1-yamada.masahiro@socionext.com> References: <20191123132727.30151-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 --- scripts/kallsyms.c | 113 +++++++++++++++++++++++++-------------------- 1 file changed, 62 insertions(+), 51 deletions(-) diff --git a/scripts/kallsyms.c b/scripts/kallsyms.c index d745fd2c7247..5553843631d4 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 13:27:22 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 11258785 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 3FAE0913 for ; Sat, 23 Nov 2019 13:28:43 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 2029620719 for ; Sat, 23 Nov 2019 13:28:43 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=nifty.com header.i=@nifty.com header.b="Atkfyh8Q" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727188AbfKWN2l (ORCPT ); Sat, 23 Nov 2019 08:28:41 -0500 Received: from conuserg-10.nifty.com ([210.131.2.77]:39537 "EHLO conuserg-10.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726767AbfKWN2A (ORCPT ); Sat, 23 Nov 2019 08:28:00 -0500 Received: from grover.flets-west.jp (softbank126093102113.bbtec.net [126.93.102.113]) (authenticated) by conuserg-10.nifty.com with ESMTP id xANDRbkk000733; Sat, 23 Nov 2019 22:27:43 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-10.nifty.com xANDRbkk000733 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1574515664; bh=WauG9D9YqzAMxDQWtyV5l/7rFsL3kICN4sbEOWLPOkk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Atkfyh8QyZvNdKwiRXs5OY/qwqpMMMo2N0WjBKKh+FGfMLwSX7fFeADxa9XOSzcpp vMU8+MhgrX4IjbMl00w26VFNZIRm/dA1R39mMGtONOiPbmosblhDZeEOUlcmgQ5p3l mTZV1ynHyDrhAFRqO2BJHFqcInvnvsGYhOsg6iEr9Dh4DHKElIq/XiOQ/mCBZZaaxl UWvKRv/Tiuv62pGW5eiIhiDIlIpQQD1nrXNoQ4THBDgkhiPyUozLIDdgLHVt+Su8IB 1kQGU1yNRmma8S0WWKvHFe8O+/D5LG3hdR6tlQdRzkck4KWwL+BTTkQnVor3EjSXVA j7b6o2WNwFTyg== 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 11/16] scripts/kallsyms: move more patterns to the ignored_prefixes array Date: Sat, 23 Nov 2019 22:27:22 +0900 Message-Id: <20191123132727.30151-12-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191123132727.30151-1-yamada.masahiro@socionext.com> References: <20191123132727.30151-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 --- scripts/kallsyms.c | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/scripts/kallsyms.c b/scripts/kallsyms.c index 5553843631d4..63473924d4de 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 13:27:23 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 11258769 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 2DBD514ED for ; Sat, 23 Nov 2019 13:28:17 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 03A1620719 for ; Sat, 23 Nov 2019 13:28:17 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=nifty.com header.i=@nifty.com header.b="GvWKc7iJ" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726931AbfKWN2B (ORCPT ); Sat, 23 Nov 2019 08:28:01 -0500 Received: from conuserg-10.nifty.com ([210.131.2.77]:39586 "EHLO conuserg-10.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726820AbfKWN2B (ORCPT ); Sat, 23 Nov 2019 08:28:01 -0500 Received: from grover.flets-west.jp (softbank126093102113.bbtec.net [126.93.102.113]) (authenticated) by conuserg-10.nifty.com with ESMTP id xANDRbkl000733; Sat, 23 Nov 2019 22:27:44 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-10.nifty.com xANDRbkl000733 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1574515664; bh=hAJ9FDYVP0u9Ii/HSaYqoI2vQAxjSnoxdt8vCxrWv6U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GvWKc7iJn6Qg4qrKwA8rfc9kTqAI7pL7QFgTbtm54DfJ+sod3xnhO8l0Pmz7DiBUl 6FLfKsWxbGVLfyM1T05TTBWUgRu5lHE8zwcoplElM/HTJ6mLg+cPV/ZHKA4fJupevx k6KKCJ04Z1yLYL8eRiib6wNze/sWtTh/Qw2wGzqte45EQbVbA0ggVzd0GmeyW8SLtc mFwR9c47u3KfB9VG3jDk0E9OsPiCmFqsArNozuxw0NHmR3M94Y4mS0huqsTxxDKNNL nC2M4CkjVLJZ6kZ0RloUHvhv0Wgm/kTMSQDIbiExvSsoSkPl3dts5fHzCGCwelPefG lTtERlJWbZN/g== 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 12/16] scripts/kallsyms: move ignored symbol types to is_ignored_symbol() Date: Sat, 23 Nov 2019 22:27:23 +0900 Message-Id: <20191123132727.30151-13-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191123132727.30151-1-yamada.masahiro@socionext.com> References: <20191123132727.30151-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 --- scripts/kallsyms.c | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/scripts/kallsyms.c b/scripts/kallsyms.c index 63473924d4de..21f4d347f371 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 13:27:24 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 11258765 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 6EB3D930 for ; Sat, 23 Nov 2019 13:28:03 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 4F8662071B for ; Sat, 23 Nov 2019 13:28:03 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=nifty.com header.i=@nifty.com header.b="jze3904v" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726921AbfKWN2B (ORCPT ); Sat, 23 Nov 2019 08:28:01 -0500 Received: from conuserg-10.nifty.com ([210.131.2.77]:39548 "EHLO conuserg-10.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726803AbfKWN2B (ORCPT ); Sat, 23 Nov 2019 08:28:01 -0500 Received: from grover.flets-west.jp (softbank126093102113.bbtec.net [126.93.102.113]) (authenticated) by conuserg-10.nifty.com with ESMTP id xANDRbkm000733; Sat, 23 Nov 2019 22:27:44 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-10.nifty.com xANDRbkm000733 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1574515665; bh=GdWZ/Oaov377i0Vjzbhs1TEelv4AZ1oW6iHWPykbggE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jze3904vfDeLn5mblmlhroba0/JIdGcDdE1OoMG4Abr+vKKLGA+UPQ9QthOo4a+Ru VSKuxbQLs4SIewdIZcnAwU/ZSGOGeQm+91fa4UXTQO4JoS00dN1WkJImk/9/VkaAam B8y+xlYSTjb1if2pesUPLk/rTvZRwpEpfK9ezaxco4BqFSLC/4uk5X2LEgLubbaeHH dhe7hZ/lg59fL/VjkpkQcP6wZfQKTKp2UFLTbHrNw9hjHPGl9mDCsE5an3hAW/AlAl NcNYNJyQPYy+jYO09igX4CFgE9+nmRoZpi2BUwAKto3tcN4PLcxBhQ6ZHzGxC4hUqZ dxkVXFRt3yZ+Q== 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 13/16] scripts/kallsyms: make check_symbol_range() void function Date: Sat, 23 Nov 2019 22:27:24 +0900 Message-Id: <20191123132727.30151-14-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191123132727.30151-1-yamada.masahiro@socionext.com> References: <20191123132727.30151-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 --- scripts/kallsyms.c | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/scripts/kallsyms.c b/scripts/kallsyms.c index 21f4d347f371..144f43363c4d 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 13:27:25 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 11258781 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 2A106913 for ; Sat, 23 Nov 2019 13:28:36 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 09B6320719 for ; Sat, 23 Nov 2019 13:28:36 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=nifty.com header.i=@nifty.com header.b="NyXRf2mr" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726825AbfKWN2d (ORCPT ); Sat, 23 Nov 2019 08:28:33 -0500 Received: from conuserg-10.nifty.com ([210.131.2.77]:39547 "EHLO conuserg-10.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726813AbfKWN2A (ORCPT ); Sat, 23 Nov 2019 08:28:00 -0500 Received: from grover.flets-west.jp (softbank126093102113.bbtec.net [126.93.102.113]) (authenticated) by conuserg-10.nifty.com with ESMTP id xANDRbkn000733; Sat, 23 Nov 2019 22:27:45 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-10.nifty.com xANDRbkn000733 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1574515665; bh=nDLRImXyMlZ9Sa0C3TUQcIOX+p9zCip3EBLry72jMm4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=NyXRf2mr61YPIKX/D1c5VdBLre5GK/iwkCt/CzSlA9jOkVNB+Y6ic0XuFR2KR17yr f+9dQuPGW5CiPdHgZfp2KJykooh8fWlgdA4o65ICk+wKjMJ7d9XOCuQIk6JoDO2ba7 3slvx8/uwMbimUgTO1HNFXZPxm6BAtx2O40WiI2MxQ29z26+KRFaaubLNt1KWlCLD5 raUEPQP8krxcqenzLnDA6V3kA2T5m8BPSuYv97Cv0ZR1/IauVqUOxZ7PIh4mPCL4TZ J0LtmJ2O5j4xvVxxgTjGQoJ8pPMkzhr1Z5+2GAL91hZtd/wT4MzHf55zR2mtnjshH+ s3yLvNsFAwJ1Q== 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 14/16] scripts/kallsyms: check no valid symbol earlier Date: Sat, 23 Nov 2019 22:27:25 +0900 Message-Id: <20191123132727.30151-15-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191123132727.30151-1-yamada.masahiro@socionext.com> References: <20191123132727.30151-1-yamada.masahiro@socionext.com> Sender: linux-kbuild-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kbuild@vger.kernel.org insert_real_symbols_in_table() does not touch table_cnt, so the no valid symbol check can be moved before it. Signed-off-by: Masahiro Yamada --- scripts/kallsyms.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/kallsyms.c b/scripts/kallsyms.c index 144f43363c4d..919cb45ce9db 100644 --- a/scripts/kallsyms.c +++ b/scripts/kallsyms.c @@ -608,14 +608,14 @@ static void optimize_token_table(void) { build_initial_tok_table(); - 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); } + insert_real_symbols_in_table(); + optimize_result(); } From patchwork Sat Nov 23 13:27:26 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 11258775 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 C6056913 for ; Sat, 23 Nov 2019 13:28:26 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id A61D02071C for ; Sat, 23 Nov 2019 13:28:26 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=nifty.com header.i=@nifty.com header.b="F2YKCV/1" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727109AbfKWN2Z (ORCPT ); Sat, 23 Nov 2019 08:28:25 -0500 Received: from conuserg-10.nifty.com ([210.131.2.77]:39587 "EHLO conuserg-10.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726825AbfKWN2B (ORCPT ); Sat, 23 Nov 2019 08:28:01 -0500 Received: from grover.flets-west.jp (softbank126093102113.bbtec.net [126.93.102.113]) (authenticated) by conuserg-10.nifty.com with ESMTP id xANDRbko000733; Sat, 23 Nov 2019 22:27:45 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-10.nifty.com xANDRbko000733 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1574515666; bh=ABZMLzbkwxvv1sZSUxQf78l1xgdh6waH3ITd4vzDgwo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=F2YKCV/1k0N+2w6nTOzMUtwwF5td+ZQanVC8b8+iw8Xi6oJE/NwrybKQsoEvhj2lb pDaQSJFcTQyxe82MOF+em5Fr2oNejhAMkd2Byz9KLi4U/CcOaw5UBYsGx2JPvN5I5M 5ofi/bsZgFyhXWpoujJX3xvVfnmd8bPS6Blq3YiJs2yAaqG3sWsUx8cmhHcqQrcHBF MyH0a8KonGI3VHMnzA4QPWcB+xK+Z5GyJXaGMERIlbSutwPgAz6HVhBm+0sgotEcBz dKHnqs6rbPm2M5ysJgioER7gM6afNFDdAoHHl4EdJ/+ZRsEOrNUN4FpDFxhJWVAGxO /VAC3METJmIdQ== 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 15/16] scripts/kallsyms: put check_symbol_range() calls close together Date: Sat, 23 Nov 2019 22:27:26 +0900 Message-Id: <20191123132727.30151-16-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191123132727.30151-1-yamada.masahiro@socionext.com> References: <20191123132727.30151-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 --- scripts/kallsyms.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/scripts/kallsyms.c b/scripts/kallsyms.c index 919cb45ce9db..22ff206e2533 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 13:27:27 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 11258763 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 B1058913 for ; Sat, 23 Nov 2019 13:28:00 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 4154F20706 for ; Sat, 23 Nov 2019 13:28:00 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=nifty.com header.i=@nifty.com header.b="jMRMBPFr" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726833AbfKWN17 (ORCPT ); Sat, 23 Nov 2019 08:27:59 -0500 Received: from conuserg-10.nifty.com ([210.131.2.77]:39541 "EHLO conuserg-10.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726451AbfKWN17 (ORCPT ); Sat, 23 Nov 2019 08:27:59 -0500 Received: from grover.flets-west.jp (softbank126093102113.bbtec.net [126.93.102.113]) (authenticated) by conuserg-10.nifty.com with ESMTP id xANDRbkp000733; Sat, 23 Nov 2019 22:27:46 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-10.nifty.com xANDRbkp000733 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1574515666; bh=luGOrRAMG4Y9tsglVetzZHHjl9Wj2M3UbgJuHFlQLIw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jMRMBPFrPMoV8uQ78+xnQ35IvxVtduNrPhP2JftuIYO2wGY19bLTLM8/BXv6Kitjj W8x8Q80hpb4vGpG3kIkjQcZ2hop9KiCCKDk+JF0ALU3C+YOG9B3cp3+ZTTNv9LSMFk jQqfBwdJgzMZCz6IUzVjp99fJQxIAWw4J21QSOlCDHdABx6tXus5NlkTbKfFAq6WPy I4ubZdVGYezT1WzhxXHFmoF+EIXRem6Yz6cesRgwkZn+8QI3xYGLtEle9EhtrQnVXq WvKg1JZIZM8L2u1TLCOY6AMhaw7g8+GM8HjPCllzCx4D+pXUDCwnKeGN41P9jJSnum OAw6nhJ4E7RvA== 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 16/16] scripts/kallsyms: remove redundant initializers Date: Sat, 23 Nov 2019 22:27:27 +0900 Message-Id: <20191123132727.30151-17-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191123132727.30151-1-yamada.masahiro@socionext.com> References: <20191123132727.30151-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 --- scripts/kallsyms.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/kallsyms.c b/scripts/kallsyms.c index 22ff206e2533..803df71e5069 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];