On Sat, Jun 11, 2022 at 3:34 AM Masahiro Yamada <masahiroy@xxxxxxxxxx> 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