From patchwork Thu Nov 14 17:42: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: 179461 Delivered-To: patch@linaro.org Received: by 2002:ac9:3c86:0:0:0:0:0 with SMTP id w6csp10954419ocf; Thu, 14 Nov 2019 09:42:53 -0800 (PST) X-Google-Smtp-Source: APXvYqzb7OqAfc4fpvt2fUMol+KExbzuL/GN747uN/7KoJq6BMRZKfqzU3tih/lEk7tLIJ7u65oB X-Received: by 2002:a50:9f65:: with SMTP id b92mr2671129edf.63.1573753373823; Thu, 14 Nov 2019 09:42:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1573753373; cv=none; d=google.com; s=arc-20160816; b=fC23i+JLgicf0NPhXVNkDGchUNKLVQ2GPXwLeeVVap8UrokuRwHG2Mghx2zANW2f5k pvWFlqar+niVDOTIUnNECo6VG6c1g0y+lr53TAdiTdkLM0tq0Yhvi63Wg8dBh1b3wsfx s+W2h/9KFkXy3zhlzi198aeGl5PJGanCnCuQFjoZ0yVdoJgAPIIk1GuURI1s1dGhi9iA Ub0LZiljS+Nm8MNL1Dxhm2zSHlY9Pdg8nDnZamKYdZkSkwVUn/Dskbpv6whmJtcmRKl8 Hcv/TMXRCMyRWwSjbAQjnLTy82scdbaErW1SMtOeK5tq5qLDsSKqGzGJH5PxRs6Fs4Y1 sY7w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature:dkim-filter; bh=D/eJT32mBwbeMEWygMHfIeG/R76XAZJvY7EI4TTqWrc=; b=xDtmN5shAIez93iZFRrJ0GVlIfNTjJowarEXoXWcrMVDHIoBneoBfIvWJj/9lfl/Y3 3huCn1ncgTiTlrR85eG6Hcnp9MsrGOVzVyR8zsIn/8HaKOrToiun0KBoQBDUm5I+3Aa8 8aOieCSVxPsm3NpvYolvXlgqGYfMl59vKvR2+93L/aiuijTgRX8NJ4O2TvuHURaCOLG6 yUekL+8UT5EYC9f8Le3iThIlmol4OtxUien01SK63KUnNqjfRAdMeakkQd9oE7WzT+3h +fammDFs6rXW480Tpcr2te4BeOWO7/XszYP9fXPyDaxu6MhDjtRS+Elz56eoO/i734nU iFpw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=TeCwteFO; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 14si4352743edz.130.2019.11.14.09.42.53; Thu, 14 Nov 2019 09:42:53 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=TeCwteFO; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727064AbfKNRmu (ORCPT + 26 others); Thu, 14 Nov 2019 12:42:50 -0500 Received: from conuserg-09.nifty.com ([210.131.2.76]:64709 "EHLO conuserg-09.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725976AbfKNRme (ORCPT ); Thu, 14 Nov 2019 12:42:34 -0500 Received: from grover.flets-west.jp (softbank126021098169.bbtec.net [126.21.98.169]) (authenticated) by conuserg-09.nifty.com with ESMTP id xAEHgSo1028428; Fri, 15 Nov 2019 02:42:28 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-09.nifty.com xAEHgSo1028428 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1573753349; bh=D/eJT32mBwbeMEWygMHfIeG/R76XAZJvY7EI4TTqWrc=; h=From:To:Cc:Subject:Date:From; b=TeCwteFO4rbpVkL6GZBxzkSITG1wka4bBagnguZvWG9oeaDuZxba8ofnIobOLyT6i ktVfWGQbvo20kFZppd1ukVCuyShjml7oh060Wxy3Y+3ogP/EBvPT+mljmcIwbsrESx VK79FOirnxcQQnJ5L1G8YkNI5AjC3Akt7BX5eHqWHpmlev7QxS8TSKemLkubTga0bM RrEgsEg3W5KmLfreCTM9Dir4Jf7ZBVAL2r/zu7QJ3o0UZ3AjM4dyIjffXdlD5y1QO3 JNPPCuElkzoQIHg3GTktn6F2DS3Ezb0nWSVMTgV31NP43Z87FicDX0S32k7SF3D78B AAhvPH7c8H2/A== X-Nifty-SrcIP: [126.21.98.169] From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: Masahiro Yamada , Michal Marek , linux-kernel@vger.kernel.org Subject: [PATCH 1/6] modpost: add a helper to get data pointed by a symbol Date: Fri, 15 Nov 2019 02:42:21 +0900 Message-Id: <20191114174226.7201-1-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.17.1 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org When CONFIG_MODULE_REL_CRCS is enabled, the value of __crc_* is not an absolute value, but the address to the CRC data embedded in the .rodata section. Getting the data pointed by the symbol value is somewhat complex. Split it out into a new helper, sym_get_data(). I will reuse it to refactor namespace_from_kstrtabns() in the next commit. Signed-off-by: Masahiro Yamada --- scripts/mod/modpost.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) -- 2.17.1 diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c index 46d7f695fe7f..cd885573daaf 100644 --- a/scripts/mod/modpost.c +++ b/scripts/mod/modpost.c @@ -308,6 +308,18 @@ static const char *sec_name(struct elf_info *elf, int secindex) return sech_name(elf, &elf->sechdrs[secindex]); } +static void *sym_get_data(const struct elf_info *info, const Elf_Sym *sym) +{ + Elf_Shdr *sechdr = &info->sechdrs[sym->st_shndx]; + unsigned long offset; + + offset = sym->st_value; + if (info->hdr->e_type != ET_REL) + offset -= sechdr->sh_addr; + + return (void *)info->hdr + sechdr->sh_offset + offset; +} + #define strstarts(str, prefix) (strncmp(str, prefix, strlen(prefix)) == 0) static enum export export_from_secname(struct elf_info *elf, unsigned int sec) @@ -697,10 +709,7 @@ static void handle_modversions(struct module *mod, struct elf_info *info, unsigned int *crcp; /* symbol points to the CRC in the ELF object */ - crcp = (void *)info->hdr + sym->st_value + - info->sechdrs[sym->st_shndx].sh_offset - - (info->hdr->e_type != ET_REL ? - info->sechdrs[sym->st_shndx].sh_addr : 0); + crcp = sym_get_data(info, sym); crc = TO_NATIVE(*crcp); } sym_update_crc(symname + strlen("__crc_"), mod, crc, From patchwork Thu Nov 14 17:42: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: 179460 Delivered-To: patch@linaro.org Received: by 2002:ac9:3c86:0:0:0:0:0 with SMTP id w6csp10954406ocf; Thu, 14 Nov 2019 09:42:53 -0800 (PST) X-Google-Smtp-Source: APXvYqyZFeoGe9iMetFDB2e3MyVAbPB0bnhWygF78i3vMMV/7qXgDBYs7+9Zj/iRM2+VjDXBXk4u X-Received: by 2002:a17:906:1c07:: with SMTP id k7mr9423738ejg.229.1573753373426; Thu, 14 Nov 2019 09:42:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1573753373; cv=none; d=google.com; s=arc-20160816; b=ZytuNWSOP9z5MzByDkTr4F62nqb7FhqSyEAK3VV6zQ9dqfXA5P780Q/G29ogkatcf/ bIthYaX93UxrAnAlrzzXPOFKRREAExi4/f4Qkof1J5Y8NJGxvI22mv6oA7JDwF4+X1JU zZKf9+N1LamGND9Yf4F3oMx0wbXcS4POm1f5RYhq6ciJ8TV5yr1Bd+8/4WA+xTfXDf1u SctqsbsK7H7eQyu9zG5qAsC8iZX8+5KOEZuVY7uC2yQbZl+ZBnQ9BCapbq7UhiDCq+fn 5YbWeeGacb7dJJ5LPpvGlgT6i/fIuAN+QHwmR8gqynHIzQhDqVxsUB3r72lSBnQ8ggnN yjEw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:dkim-filter; bh=nOkFN6j7wUXdObUwKpD/Qbkrxvoi6EK7nlyZ3Mg/dAs=; b=XRcud7OD7k9O60xMUxThbpDlIC5BkUXVo89It8e51veQ6+RmdNTysCBf/fqqcs1S25 QelrkMc3LEZetJkKQqH+hh9Tq368EKEavhvviCPWCjR65ZNHzuGE0nq/aeceXrlgmNf2 h40d+KUnH+KwNc2Hl60FDExQJGqkevlGFPq0vqyDSV/4kypJsKaDAEp0EFerVhK1nUct 4oX7vsVga6Bdo7f6t0a2NMude3XbJ3mdMtlKAeGQYJlOYBkdpITZYygG6WhGfKxwTtud NLh6FhYyP4Xve6NEP+IQc1F1Vi3nwnHZEGXK9XYoeXaiXvUjvcn5ppRjp2b826/hw0Wm KO6A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=uEncBA+O; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 14si4352743edz.130.2019.11.14.09.42.53; Thu, 14 Nov 2019 09:42:53 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=uEncBA+O; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726786AbfKNRmd (ORCPT + 26 others); Thu, 14 Nov 2019 12:42:33 -0500 Received: from conuserg-09.nifty.com ([210.131.2.76]:64704 "EHLO conuserg-09.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726444AbfKNRmd (ORCPT ); Thu, 14 Nov 2019 12:42:33 -0500 Received: from grover.flets-west.jp (softbank126021098169.bbtec.net [126.21.98.169]) (authenticated) by conuserg-09.nifty.com with ESMTP id xAEHgSo2028428; Fri, 15 Nov 2019 02:42:29 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-09.nifty.com xAEHgSo2028428 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1573753349; bh=nOkFN6j7wUXdObUwKpD/Qbkrxvoi6EK7nlyZ3Mg/dAs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=uEncBA+O3SNqUdvvNlH3dEgHHVCmaxWlnm27jkPch+McdgAj0vqYkUbKn+0Caq4v2 kCQ0irvT3KAOYSlobPeVMLWlY7CpjvOjKNnH3wN1fUGlxxXzry+jnooYyDymAQDicL f8Bu+C62B+7wHbIIqK7sVO2Y5WMXdjOieoh3ptxZmzZeDp0C/7BqmjBp0af1ZZArGq eCi1tZ+o80cyRRhphOeIJzgYKHlXD7DJelGt0++ZkI7GA60zm+YVqsjun4zoPzzTF8 Q1yLJafPe55oRAvsRxoIrtUOfKIsCT7SWHcT65Hjw4y3bfSNpotKUWB44cS1La4Kyc Ne5+izeRz9SEA== X-Nifty-SrcIP: [126.21.98.169] From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: Masahiro Yamada , Michal Marek , linux-kernel@vger.kernel.org Subject: [PATCH 2/6] modpost: refactor namespace_from_kstrtabns() to not hard-code section name Date: Fri, 15 Nov 2019 02:42:22 +0900 Message-Id: <20191114174226.7201-2-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191114174226.7201-1-yamada.masahiro@socionext.com> References: <20191114174226.7201-1-yamada.masahiro@socionext.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Currently, namespace_from_kstrtabns() relies on the fact that namespace strings are recorded in the __ksymtab_strings section. Actually, it is coded in include/linux/export.h, but modpost does not need to hard-code the section name. Elf_Sym::st_shndx holds the section number of the relevant section. Using it is a more portable way to find the namespace string. sym_get_value() takes care of it, so namespace_from_kstrtabns() can simply wrap it. Delete the unneeded info->ksymtab_strings . While I was here, I added more 'const' qualifiers to pointers. Signed-off-by: Masahiro Yamada --- scripts/mod/modpost.c | 10 +++------- scripts/mod/modpost.h | 1 - 2 files changed, 3 insertions(+), 8 deletions(-) -- 2.17.1 diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c index cd885573daaf..d9418c58a8c0 100644 --- a/scripts/mod/modpost.c +++ b/scripts/mod/modpost.c @@ -356,10 +356,10 @@ static enum export export_from_sec(struct elf_info *elf, unsigned int sec) return export_unknown; } -static const char *namespace_from_kstrtabns(struct elf_info *info, - Elf_Sym *kstrtabns) +static const char *namespace_from_kstrtabns(const struct elf_info *info, + const Elf_Sym *sym) { - char *value = info->ksymtab_strings + kstrtabns->st_value; + const char *value = sym_get_data(info, sym); return value[0] ? value : NULL; } @@ -601,10 +601,6 @@ static int parse_elf(struct elf_info *info, const char *filename) info->export_unused_gpl_sec = i; else if (strcmp(secname, "__ksymtab_gpl_future") == 0) info->export_gpl_future_sec = i; - else if (strcmp(secname, "__ksymtab_strings") == 0) - info->ksymtab_strings = (void *)hdr + - sechdrs[i].sh_offset - - sechdrs[i].sh_addr; if (sechdrs[i].sh_type == SHT_SYMTAB) { unsigned int sh_link_idx; diff --git a/scripts/mod/modpost.h b/scripts/mod/modpost.h index fe6652535e4b..64a82d2d85f6 100644 --- a/scripts/mod/modpost.h +++ b/scripts/mod/modpost.h @@ -143,7 +143,6 @@ struct elf_info { Elf_Section export_gpl_sec; Elf_Section export_unused_gpl_sec; Elf_Section export_gpl_future_sec; - char *ksymtab_strings; char *strtab; char *modinfo; unsigned int modinfo_len; From patchwork Thu Nov 14 17:42: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: 179456 Delivered-To: patch@linaro.org Received: by 2002:ac9:3c86:0:0:0:0:0 with SMTP id w6csp10954133ocf; Thu, 14 Nov 2019 09:42:39 -0800 (PST) X-Google-Smtp-Source: APXvYqxa2H4zIVFuuSaCwE46opHpw8VR4Bki2b0wYiQubHB7gAlMssq1mdvddCnxOKRXC6dYlFZI X-Received: by 2002:a50:9a85:: with SMTP id p5mr2597440edb.223.1573753358859; Thu, 14 Nov 2019 09:42:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1573753358; cv=none; d=google.com; s=arc-20160816; b=sE3XO9Vkju35Nk8FhTnqtGqal48R1GxkDmu0iH+DxgZGVh/haGYAzW8EsYZ4jtSG2/ 2nhdQStUKYhvoXLpTEMTuxQ6wWeDMBZF+dIyZZLUNjdNPOPwEOioDJZLqU25KUKrwxtU CSJGbT124MRTtXGg8US9eOzIHglnSocYuc+3TwWQZ3f6JhSIBPqF6/xecpAZRlkvu7rx xhUVu46G0IJ2jJQWPC9ZIcF524QTKG+iZkn6egCalyenajCXowsdOl4QOBA25xFmgnU+ ykY4dMmZlCccLCNnLeg+o6XhGViq/JNG+ShDzHYNvrOCPDeu1zMRiIL5vvGQrHybMjam B7gQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:dkim-filter; bh=hD5s6ssP8dZQZE8/9P7xQCgsdQSDXm2EH1M7tYSApOw=; b=WQ6TnSqHuilNSn+vPBp8mgUTBE/T6HGHgmAxG2rK0ckefOBM5OUvhCIDkwJ6FnqFNp 6E4A//IdtsfldsXyUcXbBTZ0sZLI4E6M0vMqIS+y+Tqm3lNsJ8gIYcVzYlKIdiLvrcks Rjk+m2rCdvOWlwCu5cUeOfFaDRTEgdoUlVqSl9d1dmnQWQRMgwkJYdvdGsNBCp4pYM68 ZXaweHsjr2QYg28C0ntFox53Oiqx/1fQE2fR1UXsidyUxljuTkdg6hjB2Tc314uPyBpB uxurzedyJ3MVFS48hqk0dfz1yWc2J/3X8RlFzfqcBhrzFsj9bi2Y7/wiVP/f/qo6gGLL QVMA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=ifhmGmVu; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y32si5024774ede.209.2019.11.14.09.42.38; Thu, 14 Nov 2019 09:42:38 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=ifhmGmVu; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726912AbfKNRme (ORCPT + 26 others); Thu, 14 Nov 2019 12:42:34 -0500 Received: from conuserg-09.nifty.com ([210.131.2.76]:64706 "EHLO conuserg-09.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726505AbfKNRmd (ORCPT ); Thu, 14 Nov 2019 12:42:33 -0500 Received: from grover.flets-west.jp (softbank126021098169.bbtec.net [126.21.98.169]) (authenticated) by conuserg-09.nifty.com with ESMTP id xAEHgSo3028428; Fri, 15 Nov 2019 02:42:29 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-09.nifty.com xAEHgSo3028428 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1573753350; bh=hD5s6ssP8dZQZE8/9P7xQCgsdQSDXm2EH1M7tYSApOw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ifhmGmVuudFMgB3vHiQXBnrvLtcIZ9Nlh1wHNO67OvAukdevVIYWDCrLXApxix151 2u3oHfKOrB4v320O67MMooe1vhNlxQQk1IYJkv0KdxwrcErvbOUUCjzDX2JoqGsqFh 6Uh1M6PFTxtk/52cMD/U6VOm9X6bfSQMDzCwwG8UNObHPwMU1qkxk9beRKY7WtTDyN hnV968SKvI4xd2PRmrGMtROrBzyU3VJsPrQGouylkSFqhOvjzb3vlH67+s+1Lovr+E IrVHq9owCxQYXCq5w0Bu0bma1/7T+agp7fwDnxzHsd/UbVMUVu+QYR1EqUTIRF1RT2 4eSIYJoe4FtmQ== X-Nifty-SrcIP: [126.21.98.169] From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: Masahiro Yamada , Michal Marek , linux-kernel@vger.kernel.org Subject: [PATCH 3/6] modpost: rename handle_modversions() to handle_symbol() Date: Fri, 15 Nov 2019 02:42:23 +0900 Message-Id: <20191114174226.7201-3-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191114174226.7201-1-yamada.masahiro@socionext.com> References: <20191114174226.7201-1-yamada.masahiro@socionext.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This function handles not only modversions, but also unresolved symbols, export symbols, etc. Rename it to a more proper function name. While I was here, I also added the 'const' qualifier to *sym. Signed-off-by: Masahiro Yamada --- scripts/mod/modpost.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) -- 2.17.1 diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c index d9418c58a8c0..6735ae3da4c2 100644 --- a/scripts/mod/modpost.c +++ b/scripts/mod/modpost.c @@ -683,8 +683,8 @@ static int ignore_undef_symbol(struct elf_info *info, const char *symname) return 0; } -static void handle_modversions(struct module *mod, struct elf_info *info, - Elf_Sym *sym, const char *symname) +static void handle_symbol(struct module *mod, struct elf_info *info, + const Elf_Sym *sym, const char *symname) { unsigned int crc; enum export export; @@ -2051,7 +2051,7 @@ static void read_symbols(const char *modname) for (sym = info.symtab_start; sym < info.symtab_stop; sym++) { symname = remove_dot(info.strtab + sym->st_name); - handle_modversions(mod, &info, sym, symname); + handle_symbol(mod, &info, sym, symname); handle_moddevtable(mod, &info, sym, symname); } From patchwork Thu Nov 14 17:42: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: 179457 Delivered-To: patch@linaro.org Received: by 2002:ac9:3c86:0:0:0:0:0 with SMTP id w6csp10954146ocf; Thu, 14 Nov 2019 09:42:39 -0800 (PST) X-Google-Smtp-Source: APXvYqxf39zn1pXo7GzirxRXa0wjM/IT2EVqfLntLpHjKicHFnyOneNR5oZNMk7SG84MdU5V8CGQ X-Received: by 2002:a05:6402:148d:: with SMTP id e13mr2674496edv.290.1573753359317; Thu, 14 Nov 2019 09:42:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1573753359; cv=none; d=google.com; s=arc-20160816; b=pDK+K7hUtDvq+Y3m4GxWF6asG/IyO8a0xL5qZEdsvQB+bCD7FGdHIlH54og66R9w5X Mi73LuaypMQ4DacCI/vQcg5NuWf0R/y0kTLmqKJvsuTlsRi65RweGE4x96rtqo7ACY1r V98JW6/V8ob73IemU106/Gni5RMautT3QquPpZUqf6II8OGBqzIn+rB33bskEv+HGJDi neeD9Gqw0IpU/A7i5IUmCNXRoXDDkdIBkBKkTQX6z5k+yAkQSyTtRBEWDvWS+PX5ryNh wGYbiYXf8+yj53J4w+dT48ksMey3TunVe6Y5XXcaRzQwoCSHWNxBUTFi9PFOX5h9M4lq V6kA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:dkim-filter; bh=rmpRFmxNZ/Mz3ML460iOsaBVMxNlFRyIh/Y5zJuSSiI=; b=ptuxdEGSLD68xirlaw3z9sR0omtszg9nr0oWDqGfvU82WMsiX1p7I7t2ngV7gUZq3T 41u///8pBNDHEkKq/sv6pQqEtIDqYJ7C0sbSJfwTSvGUspR0vsdyozJHAB0XfrWcHcN+ +0wv9VHy0KpzyNHvBuGOFXGZGM+LNNvFv6qucYHHEbzuzBNMFoEsMW+a+0M/B88fHlgi 6gI2f28GxLz6NuM9Vf0VyX6Sc1LWwjQp6uJGV1lwM7bFAUaoZTlTtQENaiI8yWjk7AmD zBFxt9csiZNrXd4R9g6Jh//O2wqlgolzDMB1OvKF+x1AAY8mYQZQw3kkvuJwdD+nVhr2 381Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=Xc7sVy9d; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y32si5024774ede.209.2019.11.14.09.42.39; Thu, 14 Nov 2019 09:42:39 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=Xc7sVy9d; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726977AbfKNRmg (ORCPT + 26 others); Thu, 14 Nov 2019 12:42:36 -0500 Received: from conuserg-09.nifty.com ([210.131.2.76]:64705 "EHLO conuserg-09.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726263AbfKNRme (ORCPT ); Thu, 14 Nov 2019 12:42:34 -0500 Received: from grover.flets-west.jp (softbank126021098169.bbtec.net [126.21.98.169]) (authenticated) by conuserg-09.nifty.com with ESMTP id xAEHgSo4028428; Fri, 15 Nov 2019 02:42:30 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-09.nifty.com xAEHgSo4028428 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1573753350; bh=rmpRFmxNZ/Mz3ML460iOsaBVMxNlFRyIh/Y5zJuSSiI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Xc7sVy9dshezER+j91adxqP9RRE1WwfyarA600bZ8t2aXXFCoRhP0zGXPFRhpiCP/ G0kqU+UaVGBXf3+78g/81f53DdGHT030OKS35vyW8LyFINRGmv4f48aPWPKeUoLAUl kec2dPH9dFM9s/gxiEQWZUgHUvB+1fufxiLtQOqf9F6kxIMdzKfN+amak4vW9ozdf7 HS0tZuR/6wnMjub8sqAYZBKwDBKnQmtZqLyTQDuQvpe6ImQDfIQz7nrdpX3W1Rczo2 otMv0nLO7rxRqVzkcZ2XZW2LB1BU4BPWXxBKf3/QDFrxmg85ZPnwPnONhOBoMe2ykI XUrON9xfkU33Q== X-Nifty-SrcIP: [126.21.98.169] From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: Masahiro Yamada , Michal Marek , linux-kernel@vger.kernel.org Subject: [PATCH 4/6] modpost: stop symbol preloading for modversion CRC Date: Fri, 15 Nov 2019 02:42:24 +0900 Message-Id: <20191114174226.7201-4-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191114174226.7201-1-yamada.masahiro@socionext.com> References: <20191114174226.7201-1-yamada.masahiro@socionext.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org It is complicated to add mocked-up symbols to pre-handle CRC. Handle CRC after all the export symbols in the relevant module are registered. Signed-off-by: Masahiro Yamada --- scripts/mod/modpost.c | 64 +++++++++++++++++++++++-------------------- 1 file changed, 35 insertions(+), 29 deletions(-) -- 2.17.1 diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c index 6735ae3da4c2..73bdf27c41fe 100644 --- a/scripts/mod/modpost.c +++ b/scripts/mod/modpost.c @@ -169,7 +169,7 @@ struct symbol { unsigned int vmlinux:1; /* 1 if symbol is defined in vmlinux */ unsigned int kernel:1; /* 1 if symbol is from kernel * (only for external modules) **/ - unsigned int preloaded:1; /* 1 if symbol from Module.symvers, or crc */ + unsigned int preloaded:1; /* 1 if symbol from Module.symvers */ unsigned int is_static:1; /* 1 if symbol is not global */ enum export export; /* Type of export */ char name[0]; @@ -410,15 +410,15 @@ static struct symbol *sym_add_exported(const char *name, struct module *mod, return s; } -static void sym_update_crc(const char *name, struct module *mod, - unsigned int crc, enum export export) +static void sym_set_crc(const char *name, const struct module *mod, + unsigned int crc) { struct symbol *s = find_symbol(name); if (!s) { - s = new_symbol(name, mod, export); - /* Don't complain when we find it later. */ - s->preloaded = 1; + warn("%s: '__crc_%s' is invalid use. __crc_* is reserved for modversion\n", + mod->name, name); + return; } s->crc = crc; s->crc_valid = 1; @@ -683,12 +683,34 @@ static int ignore_undef_symbol(struct elf_info *info, const char *symname) return 0; } +static void handle_modversion(const struct module *mod, + const struct elf_info *info, + const Elf_Sym *sym, const char *symname) +{ + unsigned int crc; + + if (sym->st_shndx == SHN_UNDEF) { + warn("EXPORT symbol \"%s\" [%s%s] version generation failed, symbol will not be versioned.\n", + symname, mod->name, is_vmlinux(mod->name) ? "":".ko"); + return; + } + + if (sym->st_shndx == SHN_ABS) { + crc = sym->st_value; + } else { + unsigned int *crcp; + + /* symbol points to the CRC in the ELF object */ + crcp = sym_get_data(info, sym); + crc = TO_NATIVE(*crcp); + } + sym_set_crc(symname, mod, crc); +} + static void handle_symbol(struct module *mod, struct elf_info *info, const Elf_Sym *sym, const char *symname) { - unsigned int crc; enum export export; - bool is_crc = false; const char *name; if ((!is_vmlinux(mod->name) || mod->is_dot_o) && @@ -697,21 +719,6 @@ static void handle_symbol(struct module *mod, struct elf_info *info, else export = export_from_sec(info, get_secindex(info, sym)); - /* CRC'd symbol */ - if (strstarts(symname, "__crc_")) { - is_crc = true; - crc = (unsigned int) sym->st_value; - if (sym->st_shndx != SHN_UNDEF && sym->st_shndx != SHN_ABS) { - unsigned int *crcp; - - /* symbol points to the CRC in the ELF object */ - crcp = sym_get_data(info, sym); - crc = TO_NATIVE(*crcp); - } - sym_update_crc(symname + strlen("__crc_"), mod, crc, - export); - } - switch (sym->st_shndx) { case SHN_COMMON: if (strstarts(symname, "__gnu_lto_")) { @@ -746,11 +753,6 @@ static void handle_symbol(struct module *mod, struct elf_info *info, } #endif - if (is_crc) { - const char *e = is_vmlinux(mod->name) ?"":".ko"; - warn("EXPORT symbol \"%s\" [%s%s] version generation failed, symbol will not be versioned.\n", - symname + strlen("__crc_"), mod->name, e); - } mod->unres = alloc_symbol(symname, ELF_ST_BIND(sym->st_info) == STB_WEAK, mod->unres); @@ -2063,6 +2065,10 @@ static void read_symbols(const char *modname) sym_update_namespace(symname + strlen("__kstrtabns_"), namespace_from_kstrtabns(&info, sym)); + + if (strstarts(symname, "__crc_")) + handle_modversion(mod, &info, sym, + symname + strlen("__crc_")); } // check for static EXPORT_SYMBOL_* functions && global vars @@ -2476,7 +2482,7 @@ static void read_dump(const char *fname, unsigned int kernel) s->kernel = kernel; s->preloaded = 1; s->is_static = 0; - sym_update_crc(symname, mod, crc, export_no(export)); + sym_set_crc(symname, mod, crc); sym_update_namespace(symname, namespace); } release_file(file, size); From patchwork Thu Nov 14 17:42: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: 179459 Delivered-To: patch@linaro.org Received: by 2002:ac9:3c86:0:0:0:0:0 with SMTP id w6csp10954287ocf; Thu, 14 Nov 2019 09:42:47 -0800 (PST) X-Google-Smtp-Source: APXvYqx7O86eCCZm2S556f0wktJS07B/24SoaQky2TGcR+UNKvsiAMmkSf2n3XrwfVysfPfLqXOX X-Received: by 2002:a50:8dc9:: with SMTP id s9mr2667390edh.155.1573753367549; Thu, 14 Nov 2019 09:42:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1573753367; cv=none; d=google.com; s=arc-20160816; b=OStMV0IbiH9GwhyJQXMjnbUcGrxTVswsw1Sal5isI2SoffohMRjv53/G+KcrHW23Nl d9NGucoovvF4Cm9dBNBba0YCFjwcskuRcTkDuI8XQ6CV4g6/uuGqhoy4rc5DX9AcKMcO LzMMZeBaoXcBM3zH+iunnUvEZMsMQfHPgueJ9qtv6iNif0LcMs0uHUuBDiffmT6uWcql S3gaOjYgbQRAkL5VHDLpKifITd95G27+slxtQptsVzxeYakRY5uCcME+tvQSyLu08ece jJ0iJrVXG3GHHzK3Ua9oSkLg8J0DR3mrgbE29lh32Tqa0FyUgzvBVZl31zidksHH0V2u YCww== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:dkim-filter; bh=7sWrVrerKjQiDhUBDmeGbSq4bDTJ+Bje+3qlC+uY3K4=; b=K55DQrgI68a+IHmp8baa5mO00Rqgo1F74zom9Ek7My2O3v+8ptUgFtee+DntCiWPbi BYeQ09dDpO4uM8S7+njoOK6XErlsgMJ2PJ6iBahKJsDoD5fdBbZmj49V+b413gGlVRyi E5cc2RtaWqYSTbcYlg66rIqRIMC8XmxbISIa0q+ukW7hl11I/wN7MT8b0fz0RS5jdYFi UNVtuPDVZFXHmtsLUnHeQ2/fMCUDeOucuxE0HG6RxFpWizCl09Bh/JrVwL0v8q/1Yc8S MR7CGSeerbp6PjxOFMOMDa0ABHoxXqpF2TWKH36m71KhKsXEgQlXg0aFzxUypghvn+Ao Jd1A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=RYV8mXWk; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id re9si3955681ejb.332.2019.11.14.09.42.47; Thu, 14 Nov 2019 09:42:47 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=RYV8mXWk; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727015AbfKNRmj (ORCPT + 26 others); Thu, 14 Nov 2019 12:42:39 -0500 Received: from conuserg-09.nifty.com ([210.131.2.76]:64769 "EHLO conuserg-09.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726960AbfKNRmh (ORCPT ); Thu, 14 Nov 2019 12:42:37 -0500 Received: from grover.flets-west.jp (softbank126021098169.bbtec.net [126.21.98.169]) (authenticated) by conuserg-09.nifty.com with ESMTP id xAEHgSo5028428; Fri, 15 Nov 2019 02:42:30 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-09.nifty.com xAEHgSo5028428 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1573753351; bh=7sWrVrerKjQiDhUBDmeGbSq4bDTJ+Bje+3qlC+uY3K4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RYV8mXWkF+Wk3CX/SWhnM2IhCdR6GZvStWrJh6VBrX0EfGhlE1FoRjAKhHssIr9me jScCY2jt0fbs7avzxNTAGhrCjLmpH7Fg1co6JRFFioq9kSDViLywlAfjve3SqjARN1 ovZx2lB1PKCwOlAmg2PnOHMH4kobjMVs0CZHxRskKIMOBZRf1S0bUbK1WdrVGlRCiM 8lioqRlyNSQcRxdkrTXdgvtAWe2cOG+JnY8IePBcwZBCp8+PVjaEdTLzLUSaBVOpM3 P3aWR3PVDfbAZaX08pVViNJ7J9iRwgumhOJL2o9ldZnMgApOsXMLHQUAbdQaV1Q7VY uY/dt0gFUCoPw== X-Nifty-SrcIP: [126.21.98.169] From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: Masahiro Yamada , Michal Marek , linux-kernel@vger.kernel.org Subject: [PATCH 5/6] modpost: do not set ->preloaded for symbols from Module.symvers Date: Fri, 15 Nov 2019 02:42:25 +0900 Message-Id: <20191114174226.7201-5-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191114174226.7201-1-yamada.masahiro@socionext.com> References: <20191114174226.7201-1-yamada.masahiro@socionext.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Now that there is no overwrap between symbols from ELF files and ones from Module.symvers. So, the 'exported twice' warning should be reported irrespective of where the symbol in question came from. The exceptional case is external module; in some cases, we build an external module to provide a different version/variant of the corresponding in-kernel module, overriding the same set of exported symbols. You can see this use-case in upstream; tools/testing/nvdimm/libnvdimm.ko replaces drivers/nvdimm/libnvdimm.ko in order to link it against mocked version of core kernel symbols. So, let's relax the 'exported twice' warning when building external modules. The multiple export from external modules is warned only when the previous one is from vmlinux or itself. With this refactoring, the ugly preloading goes away. Signed-off-by: Masahiro Yamada --- scripts/mod/modpost.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) -- 2.17.1 diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c index 73bdf27c41fe..06086105011f 100644 --- a/scripts/mod/modpost.c +++ b/scripts/mod/modpost.c @@ -169,7 +169,6 @@ struct symbol { unsigned int vmlinux:1; /* 1 if symbol is defined in vmlinux */ unsigned int kernel:1; /* 1 if symbol is from kernel * (only for external modules) **/ - unsigned int preloaded:1; /* 1 if symbol from Module.symvers */ unsigned int is_static:1; /* 1 if symbol is not global */ enum export export; /* Type of export */ char name[0]; @@ -394,7 +393,8 @@ static struct symbol *sym_add_exported(const char *name, struct module *mod, if (!s) { s = new_symbol(name, mod, export); } else { - if (!s->preloaded) { + if (!external_module || is_vmlinux(s->module->name) || + s->module == mod) { warn("%s: '%s' exported twice. Previous export was in %s%s\n", mod->name, name, s->module->name, is_vmlinux(s->module->name) ? "" : ".ko"); @@ -403,7 +403,6 @@ static struct symbol *sym_add_exported(const char *name, struct module *mod, s->module = mod; } } - s->preloaded = 0; s->vmlinux = is_vmlinux(mod->name); s->kernel = 0; s->export = export; @@ -2480,7 +2479,6 @@ static void read_dump(const char *fname, unsigned int kernel) } s = sym_add_exported(symname, mod, export_no(export)); s->kernel = kernel; - s->preloaded = 1; s->is_static = 0; sym_set_crc(symname, mod, crc); sym_update_namespace(symname, namespace); From patchwork Thu Nov 14 17:42: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: 179458 Delivered-To: patch@linaro.org Received: by 2002:ac9:3c86:0:0:0:0:0 with SMTP id w6csp10954277ocf; Thu, 14 Nov 2019 09:42:47 -0800 (PST) X-Google-Smtp-Source: APXvYqw1mcP8LOBt4siYt+dvs+QK7f6VcED2OHbreyFRU6Ro3wdD/ygM+2Y6PZhFpUaNkZBEUh7B X-Received: by 2002:a05:6402:168b:: with SMTP id a11mr2649745edv.107.1573753366941; Thu, 14 Nov 2019 09:42:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1573753366; cv=none; d=google.com; s=arc-20160816; b=UDRMMJfeRbz3SycXtzgOCACsiFryI/iM1BZI+VtmCcF0RsvBRr+G6k7jOKT2POMVNi s2oxgI97xSQYGhUthVPfr5y2uicFZ6kUuoNNNQDqWOuGiETlwpDm+fpxvXE18CrNyU4n lLYAhlnM2DMLiFJ0Il3ekh36lqGy5j+fSf3/6lwvR/Ol3RAt9m5hClo4A3lFao7NiNwu 2qIhTMDQt1JFB+CEUe4hmXVI7/IKJjOBfC7/18I8HfadendThGcxqwMEcEZuCuZUlPax IHdgFKCVtF9T/WURMXr54fVi1CSueNOLMEIDjBbnoeSY28+JIxadl+/EtNWdfCEnzf32 jAMw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:dkim-filter; bh=fUBxXICdayMSot+TU06/7Ds+CnTO5ybIlw5ICaeyTpM=; b=vk1UTho1EQc3Bu+ErYcs/MMRYFytKNP4iDah6MOwGqxEdw3EGf2WlIyjFCmbvRCIYd rhWPrqOVmkTjEaNA+4cT+c8+7WviNICmtGfIVz3lRPj4y6sszDG9pFZOaq+aOHyl03N4 j+kTsbQ7zQ2pBElnLvKBo2267pS7okvca04VnAEEqY1lHuWfFMsiiqvsx8l/1VPVLfQ1 pNYGkwmkumVd6h/TJK2HKrDmUwpEjiTWwA3Y+OmOn0z9MGXbQIbchsZmE8XOhPt6BM9K Jhca7i2nAd8mTv4funymE5VYNu8UTkXCB8opjoAk5H+CrjgTiAUx6ydbhDd+mtt57GNz WquA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=CjDBNJoQ; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id re9si3955681ejb.332.2019.11.14.09.42.46; Thu, 14 Nov 2019 09:42:46 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=CjDBNJoQ; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727048AbfKNRml (ORCPT + 26 others); Thu, 14 Nov 2019 12:42:41 -0500 Received: from conuserg-09.nifty.com ([210.131.2.76]:64767 "EHLO conuserg-09.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726957AbfKNRmh (ORCPT ); Thu, 14 Nov 2019 12:42:37 -0500 Received: from grover.flets-west.jp (softbank126021098169.bbtec.net [126.21.98.169]) (authenticated) by conuserg-09.nifty.com with ESMTP id xAEHgSo6028428; Fri, 15 Nov 2019 02:42:31 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-09.nifty.com xAEHgSo6028428 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1573753351; bh=fUBxXICdayMSot+TU06/7Ds+CnTO5ybIlw5ICaeyTpM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=CjDBNJoQ1nFHK4r4CLKmPL1Jn0sCTmTUQp802gD4dmqGZ0GxE/pGDuq2sx3/33pY6 K7t9nxIiS2w/keZd7gwq/hJbzESVtEBRwiQBSQCsjLx1jPARHdYyq+4B+93QyjK3BB Dwx3FkGg3jOx3vbJuvPHSwUuac9bTx0S/CVfSey1gIpIopP15PT9Ni1TK9Y356WvhA 9aRFtC0Ja8r4QPid+ztjELX4X8/AtJozLZJQBzNA6XoODUaKjqXp9g1BWEWhmiukjp SPUI+8c92LCaDx6a8RpPHrh/Svk1BCk8SPXg/Bp7FTZUrk9X54GP/S6wRNUkevZGMk qreEmMHLVJHvw== X-Nifty-SrcIP: [126.21.98.169] From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: Masahiro Yamada , Michal Marek , linux-kernel@vger.kernel.org Subject: [PATCH 6/6] modpost: respect the previous export when 'exported twice' is warned Date: Fri, 15 Nov 2019 02:42:26 +0900 Message-Id: <20191114174226.7201-6-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191114174226.7201-1-yamada.masahiro@socionext.com> References: <20191114174226.7201-1-yamada.masahiro@socionext.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org When 'exported twice' is warned, let sym_add_exported() return without updating the symbol info. This respects the previous export, which is ordered first in modules.order This simplifies the code too. Signed-off-by: Masahiro Yamada --- scripts/mod/modpost.c | 26 +++++++++++--------------- 1 file changed, 11 insertions(+), 15 deletions(-) -- 2.17.1 diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c index 06086105011f..d9a92fbe1146 100644 --- a/scripts/mod/modpost.c +++ b/scripts/mod/modpost.c @@ -211,13 +211,11 @@ static struct symbol *new_symbol(const char *name, struct module *module, enum export export) { unsigned int hash; - struct symbol *new; hash = tdb_hash(name) % SYMBOL_HASH_SIZE; - new = symbolhash[hash] = alloc_symbol(name, 0, symbolhash[hash]); - new->module = module; - new->export = export; - return new; + symbolhash[hash] = alloc_symbol(name, 0, symbolhash[hash]); + + return symbolhash[hash]; } static struct symbol *find_symbol(const char *name) @@ -392,17 +390,15 @@ static struct symbol *sym_add_exported(const char *name, struct module *mod, if (!s) { s = new_symbol(name, mod, export); - } else { - if (!external_module || is_vmlinux(s->module->name) || - s->module == mod) { - warn("%s: '%s' exported twice. Previous export was in %s%s\n", - mod->name, name, s->module->name, - is_vmlinux(s->module->name) ? "" : ".ko"); - } else { - /* In case Module.symvers was out of date */ - s->module = mod; - } + } else if (!external_module || is_vmlinux(s->module->name) || + s->module == mod) { + warn("%s: '%s' exported twice. Previous export was in %s%s\n", + mod->name, name, s->module->name, + is_vmlinux(s->module->name) ? "" : ".ko"); + return s; } + + s->module = mod; s->vmlinux = is_vmlinux(mod->name); s->kernel = 0; s->export = export;