[PATCH v8 08/11] kbuild: implement CONFIG_TRIM_UNUSED_KSYMS without recursion

2023-06-10 Thread Masahiro Yamada
When CONFIG_TRIM_UNUSED_KSYMS is enabled, Kbuild recursively traverses the directory tree to determine which EXPORT_SYMBOL to trim. If an EXPORT_SYMBOL turns out to be unused by anyone, Kbuild begins the second traverse, where some source files are recompiled with their EXPORT_SYMBOL() tuned into a

[PATCH v8 11/11] linux/export.h: rename 'sec' argument to 'license'

2023-06-10 Thread Masahiro Yamada
Now, EXPORT_SYMBOL() is populated in two stages. In the first stage, all of EXPORT_SYMBOL/EXPORT_SYMBOL_GPL go into the same section, '.export_symbol'. 'sec' does not make sense any more. Rename it to 'license'. Signed-off-by: Masahiro Yamada Reviewed-by: Nick Desaulniers --- (no changes since

[PATCH v8 10/11] modpost: show offset from symbol for section mismatch warnings

2023-06-10 Thread Masahiro Yamada
Currently, modpost only shows the symbol names and section names, so it repeats the same message if there are multiple relocations in the same symbol. It is common the relocation spans across multiple instructions. It is better to show the offset from the symbol. Signed-off-by: Masahiro Yamada R

[PATCH v8 09/11] modpost: merge two similar section mismatch warnings

2023-06-10 Thread Masahiro Yamada
In case of section mismatch, modpost shows slightly different messages. For extable section mismatch: "%s(%s+0x%lx): Section mismatch in reference to the %s:%s\n" For the other cases: "%s: section mismatch in reference: %s (section: %s) -> %s (section: %s)\n" They are similar. Merge them. S

[PATCH v8 07/11] modpost: use null string instead of NULL pointer for default namespace

2023-06-10 Thread Masahiro Yamada
The default namespace is the null string, "". When set, the null string "" is converted to NULL: s->namespace = namespace[0] ? NOFAIL(strdup(namespace)) : NULL; When printed, the NULL pointer is get back to the null string: sym->namespace ?: "" This saves 1 byte memory allocated for "", bu

[PATCH v8 06/11] modpost: squash sym_update_namespace() into sym_add_exported()

2023-06-10 Thread Masahiro Yamada
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/scr

[PATCH v8 05/11] modpost: check static EXPORT_SYMBOL* by modpost again

2023-06-10 Thread Masahiro Yamada
Commit 31cb50b5590f ("kbuild: check static EXPORT_SYMBOL* by script instead of modpost") moved the static EXPORT_SYMBOL* check from the mostpost to a shell script because I thought it must be checked per compilation unit to avoid false negatives. I came up with an idea to do this in modpost, again

[PATCH v8 04/11] ia64,export.h: replace EXPORT_DATA_SYMBOL* with EXPORT_SYMBOL*

2023-06-10 Thread Masahiro Yamada
With the previous refactoring, you can always use EXPORT_SYMBOL*. Replace two instances in ia64, then remove EXPORT_DATA_SYMBOL*. Signed-off-by: Masahiro Yamada Reviewed-by: Nick Desaulniers --- arch/ia64/kernel/head.S | 2 +- arch/ia64/kernel/ivt.S | 2 +- include/asm-generic/expo

[PATCH v8 03/11] kbuild: generate KSYMTAB entries by modpost

2023-06-10 Thread Masahiro Yamada
Commit 7b4537199a4a ("kbuild: link symbol CRCs at final link, removing CONFIG_MODULE_REL_CRCS") made modpost output CRCs in the same way whether the EXPORT_SYMBOL() is placed in *.c or *.S. For further cleanups, this commit applies a similar approach to the entire data structure of EXPORT_SYMBOL()

[PATCH v8 02/11] modpost: pass struct module pointer to check_section_mismatch()

2023-06-10 Thread Masahiro Yamada
The next commit will use it. Signed-off-by: Masahiro Yamada Reviewed-by: Nick Desaulniers --- scripts/mod/modpost.c | 22 +++--- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c index 8decf04633bc..403ba4d923f5 100644

[PATCH v8 00/11] Unify and , remove EXPORT_DATA_SYMBOL(), faster TRIM_UNUSED_KSYMS

2023-06-10 Thread Masahiro Yamada
This patch set refactors modpost first to make it easier to add new code. My goals: - Refactors EXPORT_SYMBOL, and . You can still put EXPORT_SYMBOL() in *.S file, very close to the definition, but you do not need to care about whether it is a function or a data. This removes EXPORT_

[PATCH v8 01/11] Revert "[PATCH] uml: export symbols added by GCC hardened"

2023-06-10 Thread Masahiro Yamada
This reverts commit cead61a6717a9873426b08d73a34a325e3546f5d. It exported __stack_smash_handler and __guard, while they may not be defined by anyone. The code *declares* __stack_smash_handler and __guard. It does not create weak symbols. If no external library is linked, they are left undefined,

Re: [PATCH v7 03/11] kbuild: generate KSYMTAB entries by modpost

2023-06-10 Thread Masahiro Yamada
On Thu, Jun 8, 2023 at 11:24 PM Masahiro Yamada wrote: > > Commit 7b4537199a4a ("kbuild: link symbol CRCs at final link, removing > CONFIG_MODULE_REL_CRCS") made modpost output CRCs in the same way > whether the EXPORT_SYMBOL() is placed in *.c or *.S. > > For further cleanups, this commit applies

Re: [PATCH] x86: Fix build of UML with KASAN

2023-06-10 Thread David Gow
On Fri, 9 Jun 2023 at 19:19, Vincent Whitchurch wrote: > > Building UML with KASAN fails since commit 69d4c0d32186 ("entry, kasan, > x86: Disallow overriding mem*() functions") with the following errors: > > $ tools/testing/kunit/kunit.py run --kconfig_add CONFIG_KASAN=y > ... > ld: mm/kasan/sh