From patchwork Sun May 14 15:27:37 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 13240505 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id CB958C77B7F for ; Sun, 14 May 2023 15:29:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238157AbjENP3Z (ORCPT ); Sun, 14 May 2023 11:29:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47676 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237545AbjENP2u (ORCPT ); Sun, 14 May 2023 11:28:50 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B6CEA46AC; Sun, 14 May 2023 08:28:30 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 0162A61807; Sun, 14 May 2023 15:28:29 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 96EA5C433EF; Sun, 14 May 2023 15:28:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1684078108; bh=aGJ3xn0BmrJvcxnKs1H9H5MNeC4hGTO1aqiwfmy3iA8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BC3/eot32EV0/C480CQ+NBpcKoO+WDRGw8vl7T71vF7GUSR75yHfG9o08ee/PPn3I xTyLVeSMk0NFMNYkjB2sXGYpWbSY62ZX3s07gQ/M2o20QCVShoaTBhLkr6bEWdE1rr 4hhM9K/paAcogY2JIh+0e6CyNvHOHRajiPk3UdCv8JjvI1rqYXNgtCxkr7NHCWlLaR nwxNGka4y3VM0t7oKD7QWZaxb2n5WeXpnF5yru736tDFKTELLlCMtvUMYI5nAM9HAR TMgQkvuyAxIonRaU+4cEwpCiCm373xQA9I50GAp2Oj/SBGktKo4zK8SI6RYOYTHhzQ vIamycxhVj01Q== From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Nathan Chancellor , Nick Desaulniers , Nicolas Pitre , Nicolas Schier , Masahiro Yamada Subject: [PATCH v5 19/21] modpost: squash sym_update_namespace() into sym_add_exported() Date: Mon, 15 May 2023 00:27:37 +0900 Message-Id: <20230514152739.962109-20-masahiroy@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230514152739.962109-1-masahiroy@kernel.org> References: <20230514152739.962109-1-masahiroy@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-kbuild@vger.kernel.org Pass a set of the name, license, and namespace to sym_add_exported(). sym_update_namespace() is unneeded. Signed-off-by: Masahiro Yamada Reviewed-by: Nick Desaulniers --- scripts/mod/modpost.c | 27 ++++----------------------- 1 file changed, 4 insertions(+), 23 deletions(-) diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c index 5db6a6f76971..7edb9a843ead 100644 --- a/scripts/mod/modpost.c +++ b/scripts/mod/modpost.c @@ -353,26 +353,8 @@ static const char *sec_name(const struct elf_info *info, unsigned int secindex) #define strstarts(str, prefix) (strncmp(str, prefix, strlen(prefix)) == 0) -static void sym_update_namespace(const char *symname, const char *namespace) -{ - struct symbol *s = find_symbol(symname); - - /* - * That symbol should have been created earlier and thus this is - * actually an assertion. - */ - if (!s) { - error("Could not update namespace(%s) for symbol %s\n", - namespace, symname); - return; - } - - free(s->namespace); - s->namespace = namespace[0] ? NOFAIL(strdup(namespace)) : NULL; -} - static struct symbol *sym_add_exported(const char *name, struct module *mod, - bool gpl_only) + bool gpl_only, const char *namespace) { struct symbol *s = find_symbol(name); @@ -385,6 +367,7 @@ static struct symbol *sym_add_exported(const char *name, struct module *mod, s = alloc_symbol(name); s->module = mod; s->is_gpl_only = gpl_only; + s->namespace = namespace[0] ? NOFAIL(strdup(namespace)) : NULL; list_add_tail(&s->list, &mod->exported_symbols); hash_add_symbol(s); @@ -1265,8 +1248,7 @@ static void check_export_symbol(struct module *mod, struct elf_info *elf, return; } - s = sym_add_exported(name, mod, is_gpl); - sym_update_namespace(name, sym_get_data(elf, label)); + s = sym_add_exported(name, mod, is_gpl, sym_get_data(elf, label)); /* * We need to be aware whether we are exporting a function or @@ -2135,9 +2117,8 @@ static void read_dump(const char *fname) mod = new_module(modname, strlen(modname)); mod->from_dump = true; } - s = sym_add_exported(symname, mod, gpl_only); + s = sym_add_exported(symname, mod, gpl_only, namespace); sym_set_crc(s, crc); - sym_update_namespace(symname, namespace); } free(buf); return;