From: Masahiro Yamada <masahiroy@kernel.org>
To: Linux Kbuild mailing list <linux-kbuild@vger.kernel.org>
Cc: Al Viro <viro@zeniv.linux.org.uk>,
Nicolas Pitre <npitre@baylibre.com>,
Luis Chamberlain <mcgrof@kernel.org>,
linux-modules <linux-modules@vger.kernel.org>,
Ard Biesheuvel <ardb@kernel.org>, Arnd Bergmann <arnd@arndb.de>,
Michal Marek <michal.lkml@markovi.net>,
Nick Desaulniers <ndesaulniers@google.com>,
linux-arch <linux-arch@vger.kernel.org>,
linux-ia64@vger.kernel.org,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 3/7] kbuild: generate struct kernel_symbol by modpost
Date: Sun, 12 Jun 2022 03:47:27 +0900 [thread overview]
Message-ID: <CAK7LNAS-VYZ3G3-TmmTQSNuanGsufkoWTv32HNKdDkE+7-6mcg@mail.gmail.com> (raw)
In-Reply-To: <20220610183236.1272216-4-masahiroy@kernel.org>
On Sat, Jun 11, 2022 at 3:34 AM Masahiro Yamada <masahiroy@kernel.org> wrote:
>
> Commit 7b4537199a4a ("kbuild: link symbol CRCs at final link, removing
> CONFIG_MODULE_REL_CRCS") made the module versioning implementation
> arch-agnostic; now all the version CRCs are generated by modpost as C
> code whether the EXPORT_SYMBOL() is placed in *.c or *.S.
>
> Doing similar for the entire data structure of EXPORT_SYMBOL() makes
> further cleanups possible.
>
> This commit splits EXPORT_SYMBOL() compilation into two stages.
>
> When a source file is compiled, EXPORT_SYMBOL() is converted into a
> dummy symbol in the .discard.export_symbol section.
>
> For example,
>
> EXPORT_SYMBOL(foo);
> EXPORT_SYMBOL_NS_GPL(bar, BAR_NAMESPACE);
>
> will be expanded into the following assembly code:
>
> .section .discard.export_symbol
> __export_symbol.foo:
> .asciz ""
> .previous
>
> .section .discard.export_symbol
> __export_symbol_gpl.bar:
> .asciz "BAR_NAMESPACE"
> .previous
>
> They are just markers to tell modpost the name, license, and namespace
> of the symbols. They will be dropped from the final vmlinux and modules
> because the section name starts with ".discard.".
>
> Then, modpost extracts all the information of EXPORT_SYMBOL() from the
> .discard.export_symbol section, then generates C code:
>
> KSYMTAB_ENTRY(foo, "", "");
> KSYMTAB_ENTRY(bar, "_gpl", "BAR_NAMESPACE");
>
> KSYMTAB_ENTRY() is expanded to struct kernel_symbol that will be linked
> to the vmlinux or a module.
>
> With this change, EXPORT_SYMBOL() works in the same way for *.c and *.S
> files, providing the following benefits.
>
> [1] Deprecate EXPORT_DATA_SYMBOL()
Sorry, please let me take back this.
I completely missed how linkage for ia64 works.
I used inline assembly in C, so it would break ia64.
Please ignore this patch.
--
Best Regards
Masahiro Yamada
WARNING: multiple messages have this Message-ID (diff)
From: Masahiro Yamada <masahiroy@kernel.org>
To: Linux Kbuild mailing list <linux-kbuild@vger.kernel.org>
Cc: Al Viro <viro@zeniv.linux.org.uk>,
Nicolas Pitre <npitre@baylibre.com>,
Luis Chamberlain <mcgrof@kernel.org>,
linux-modules <linux-modules@vger.kernel.org>,
Ard Biesheuvel <ardb@kernel.org>, Arnd Bergmann <arnd@arndb.de>,
Michal Marek <michal.lkml@markovi.net>,
Nick Desaulniers <ndesaulniers@google.com>,
linux-arch <linux-arch@vger.kernel.org>,
linux-ia64@vger.kernel.org,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 3/7] kbuild: generate struct kernel_symbol by modpost
Date: Sat, 11 Jun 2022 18:47:27 +0000 [thread overview]
Message-ID: <CAK7LNAS-VYZ3G3-TmmTQSNuanGsufkoWTv32HNKdDkE+7-6mcg@mail.gmail.com> (raw)
In-Reply-To: <20220610183236.1272216-4-masahiroy@kernel.org>
On Sat, Jun 11, 2022 at 3:34 AM Masahiro Yamada <masahiroy@kernel.org> wrote:
>
> Commit 7b4537199a4a ("kbuild: link symbol CRCs at final link, removing
> CONFIG_MODULE_REL_CRCS") made the module versioning implementation
> arch-agnostic; now all the version CRCs are generated by modpost as C
> code whether the EXPORT_SYMBOL() is placed in *.c or *.S.
>
> Doing similar for the entire data structure of EXPORT_SYMBOL() makes
> further cleanups possible.
>
> This commit splits EXPORT_SYMBOL() compilation into two stages.
>
> When a source file is compiled, EXPORT_SYMBOL() is converted into a
> dummy symbol in the .discard.export_symbol section.
>
> For example,
>
> EXPORT_SYMBOL(foo);
> EXPORT_SYMBOL_NS_GPL(bar, BAR_NAMESPACE);
>
> will be expanded into the following assembly code:
>
> .section .discard.export_symbol
> __export_symbol.foo:
> .asciz ""
> .previous
>
> .section .discard.export_symbol
> __export_symbol_gpl.bar:
> .asciz "BAR_NAMESPACE"
> .previous
>
> They are just markers to tell modpost the name, license, and namespace
> of the symbols. They will be dropped from the final vmlinux and modules
> because the section name starts with ".discard.".
>
> Then, modpost extracts all the information of EXPORT_SYMBOL() from the
> .discard.export_symbol section, then generates C code:
>
> KSYMTAB_ENTRY(foo, "", "");
> KSYMTAB_ENTRY(bar, "_gpl", "BAR_NAMESPACE");
>
> KSYMTAB_ENTRY() is expanded to struct kernel_symbol that will be linked
> to the vmlinux or a module.
>
> With this change, EXPORT_SYMBOL() works in the same way for *.c and *.S
> files, providing the following benefits.
>
> [1] Deprecate EXPORT_DATA_SYMBOL()
Sorry, please let me take back this.
I completely missed how linkage for ia64 works.
I used inline assembly in C, so it would break ia64.
Please ignore this patch.
--
Best Regards
Masahiro Yamada
next prev parent reply other threads:[~2022-06-11 18:48 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-06-10 18:32 [PATCH 0/7] Unify <linux/export.h> and <asm/export.h>, remove EXPORT_DATA_SYMBOL() Masahiro Yamada
2022-06-10 18:32 ` Masahiro Yamada
2022-06-10 18:32 ` [PATCH 1/7] modpost: fix section mismatch check for exported init/exit sections Masahiro Yamada
2022-06-10 18:32 ` [PATCH 2/7] modpost: put get_secindex() call inside sec_name() Masahiro Yamada
2022-06-10 21:41 ` Nick Desaulniers
2022-06-10 18:32 ` [PATCH 3/7] kbuild: generate struct kernel_symbol by modpost Masahiro Yamada
2022-06-10 18:32 ` Masahiro Yamada
2022-06-11 18:47 ` Masahiro Yamada [this message]
2022-06-11 18:47 ` Masahiro Yamada
2022-06-10 18:32 ` [PATCH 4/7] ia64,export.h: replace EXPORT_DATA_SYMBOL* with EXPORT_SYMBOL* Masahiro Yamada
2022-06-10 18:32 ` Masahiro Yamada
2022-06-11 18:49 ` Masahiro Yamada
2022-06-11 18:49 ` Masahiro Yamada
2022-06-10 18:32 ` [PATCH 5/7] checkpatch: warn if <asm/export.h> is included Masahiro Yamada
2022-06-11 1:33 ` Joe Perches
2022-06-11 18:56 ` Masahiro Yamada
2022-06-10 18:32 ` [PATCH 6/7] modpost: merge sym_update_namespace() into sym_add_exported() Masahiro Yamada
2022-06-10 22:26 ` Nick Desaulniers
2022-06-10 18:32 ` [PATCH 7/7] modpost: use null string instead of NULL pointer for default namespace Masahiro Yamada
2022-07-25 16:42 ` Nick Desaulniers
2022-06-11 18:51 ` [PATCH 0/7] Unify <linux/export.h> and <asm/export.h>, remove EXPORT_DATA_SYMBOL() Masahiro Yamada
2022-06-11 18:51 ` Masahiro Yamada
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CAK7LNAS-VYZ3G3-TmmTQSNuanGsufkoWTv32HNKdDkE+7-6mcg@mail.gmail.com \
--to=masahiroy@kernel.org \
--cc=ardb@kernel.org \
--cc=arnd@arndb.de \
--cc=linux-arch@vger.kernel.org \
--cc=linux-ia64@vger.kernel.org \
--cc=linux-kbuild@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-modules@vger.kernel.org \
--cc=mcgrof@kernel.org \
--cc=michal.lkml@markovi.net \
--cc=ndesaulniers@google.com \
--cc=npitre@baylibre.com \
--cc=viro@zeniv.linux.org.uk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.