Skip to contentSkip to conversation

Unify <linux/export.h> and <asm/export.h>, remove EXPORT_DATA_SYMBOL(), faster TRIM_UNUSED_KSYMS

PATCH Superseded Masahiro Yamada 4 participants 22 messages Jun 8, 2023 – Jun 22, 2023

Subsystems (8)

v7 of 9 Superseded Latest is v9 →

lore
Share & tools
lore
#0 lore raw

v7 cover Unify <linux/export.h> and <asm/export.h>, remove EXPORT_DATA_SYMBOL(), faster TRIM_UNUSED_KSYMS

This patch set refactors modpost first to make it easier to add new code.

My goals:

- Refactors EXPORT_SYMBOL, <linux/export.h> and <asm/export.h>. 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_DATA_SYMBOL().

- Re-implement TRIM_UNUSED_KSYMS in one-pass.
This makes the building faster.

- Move the static EXPORT_SYMBOL check to modpost. This also makes the building faster.

This patch set is applicable to linux-next 20230608.

Previous version
v6: https://lore.kernel.org/linux-kbuild/CAK7LNARjzGnj+sYX=_5yQ+8qoOQ2KB5N-_Ye53Ru3=XicezTYw@mail.gmail.com/T/#t
v5: https://lore.kernel.org/linux-kbuild/CAK7LNARBiOywrMLbR=9N35sk19U0QM3xcPy7d1WqV-eyb4W23w@mail.gmail.com/T/#t
v4: https://lore.kernel.org/linux-kbuild/CAK7LNASDzy9RERN6+q6WgR4ROYZQue=SBqgbcoYuVePByHtk6Q@mail.gmail.com/T/#t
v3: https://lore.kernel.org/all/[email protected]/

Masahiro Yamada (11):
Revert "[PATCH] uml: export symbols added by GCC hardened"
modpost: pass struct module pointer to check_section_mismatch()
kbuild: generate KSYMTAB entries by modpost
ia64,export.h: replace EXPORT_DATA_SYMBOL* with EXPORT_SYMBOL*
modpost: check static EXPORT_SYMBOL* by modpost again
modpost: squash sym_update_namespace() into sym_add_exported()
modpost: use null string instead of NULL pointer for default namespace
kbuild: implement CONFIG_TRIM_UNUSED_KSYMS without recursion
modpost: merge two similar section mismatch warnings
modpost: show offset from symbol for section mismatch warnings linux/export.h: rename 'sec' argument to 'license'

 .gitignore                        |   2 -
 Makefile                          |  22 +--
 arch/ia64/include/asm/Kbuild      |   1 +
 arch/ia64/include/asm/export.h    |   3 -
 arch/ia64/kernel/head.S           |   2 +-
 arch/ia64/kernel/ivt.S            |   2 +-
 arch/um/os-Linux/user_syms.c      |   7 -
 include/asm-generic/export.h      |  83 +----------
 include/asm-generic/vmlinux.lds.h |   1 +
 include/linux/export-internal.h   |  49 +++++++
 include/linux/export.h            | 127 ++++------------
 include/linux/pm.h                |  14 +-
 kernel/module/internal.h          |  12 ++
 scripts/Makefile.build            |  27 +---
 scripts/Makefile.modpost          |   7 +
 scripts/adjust_autoksyms.sh       |  73 ----------
 scripts/basic/fixdep.c            |   3 +-
 scripts/check-local-export        |  70 ---------
 scripts/gen_autoksyms.sh          |  62 --------
 scripts/gen_ksymdeps.sh           |  30 ----
 scripts/mod/modpost.c             | 233 +++++++++++++++++++-----------
 scripts/mod/modpost.h             |   1 +
 scripts/remove-stale-files        |   4 +
 23 files changed, 266 insertions(+), 569 deletions(-)
 delete mode 100644 arch/ia64/include/asm/export.h
 delete mode 100755 scripts/adjust_autoksyms.sh
 delete mode 100755 scripts/check-local-export
 delete mode 100755 scripts/gen_autoksyms.sh
 delete mode 100755 scripts/gen_ksymdeps.sh
Signature · 7 lines
2.39.2


_______________________________________________
linux-um mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-um
#1 lore raw

PATCH v7 1/11 Revert "[PATCH] uml: export symbols added by GCC hardened"

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. When the stack-protector is disabled, they are left undefined, but yet exported.

If a loadable module tries to access non-existing symbols, bad things (a page fault, NULL pointer dereference, etc.) will happen. So, the current code is wrong.

If the code were written as follows, it would *define* them as weak symbols so modules would be able to get access to them.

  void (*__stack_smash_handler)(void *) __attribute__((weak));
  EXPORT_SYMBOL(__stack_smash_handler);

  long __guard __attribute__((weak));
  EXPORT_SYMBOL(__guard);

In fact, modpost forbids exporting undefined symbols. It shows an error message if it detects such a mistake.

ERROR: modpost: "..." [...] was exported without definition

Unfortunately, it is checked only when the code is built as modular. The problem described above has been unnoticed for a long time because arch/um/os-Linux/user_syms.c is always built-in.

With a planned change in Kbuild, exporting undefined symbols will always result in a build error instead of a run-time error. It is a good thing, but we need to fix the breakage in advance.

One fix is to *define* weak symbols as shown above. An alternative is to export them conditionally as follows:

  #ifdef CONFIG_STACKPROTECTOR
  extern void __stack_smash_handler(void *);
  EXPORT_SYMBOL(__stack_smash_handler);

  external long __guard;
  EXPORT_SYMBOL(__guard);
  #endif

This is what other architectures do; EXPORT_SYMBOL(__stack_chk_guard) is guarded by #ifdef CONFIG_STACKPROTECTOR.

However, adding the #ifdef guard is not sensible because UML cannot enable the stack-protector in the first place! (Please note UML does not select HAVE_STACKPROTECTOR in Kconfig.)

So, the code is already broken (and unused) in multiple ways.

Just remove.

---

Changes in v7:
- New patch

 arch/um/os-Linux/user_syms.c | 7 -------
 1 file changed, 7 deletions(-)
arch/um/os-Linux/user_syms.c +0 -7
index 9b62a9d352b3..a310ae27b479 100644
@@ -37,13 +37,6 @@ EXPORT_SYMBOL(vsyscall_ehdr);
 EXPORT_SYMBOL(vsyscall_end);
 #endif
 
-/* Export symbols used by GCC for the stack protector. */
-extern void __stack_smash_handler(void *) __attribute__((weak));
-EXPORT_SYMBOL(__stack_smash_handler);
-
-extern long __guard __attribute__((weak));
-EXPORT_SYMBOL(__guard);
-
 #ifdef _FORTIFY_SOURCE
 extern int __sprintf_chk(char *str, int flag, size_t len, const char *format);
 EXPORT_SYMBOL(__sprintf_chk);
Signature · 7 lines
2.39.2


_______________________________________________
linux-um mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-um
Reviewed-by on v7 1/11
#2 lore raw

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

Quoted 54 lines · 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. When the stack-protector is disabled, they are left undefined, but yet exported.

If a loadable module tries to access non-existing symbols, bad things (a page fault, NULL pointer dereference, etc.) will happen. So, the current code is wrong.

If the code were written as follows, it would *define* them as weak symbols so modules would be able to get access to them.

  void (*__stack_smash_handler)(void *) __attribute__((weak));
  EXPORT_SYMBOL(__stack_smash_handler);

  long __guard __attribute__((weak));
  EXPORT_SYMBOL(__guard);

In fact, modpost forbids exporting undefined symbols. It shows an error message if it detects such a mistake.

ERROR: modpost: "..." [...] was exported without definition

Unfortunately, it is checked only when the code is built as modular. The problem described above has been unnoticed for a long time because arch/um/os-Linux/user_syms.c is always built-in.

With a planned change in Kbuild, exporting undefined symbols will always result in a build error instead of a run-time error. It is a good thing, but we need to fix the breakage in advance.

One fix is to *define* weak symbols as shown above. An alternative is to export them conditionally as follows:

  #ifdef CONFIG_STACKPROTECTOR
  extern void __stack_smash_handler(void *);
  EXPORT_SYMBOL(__stack_smash_handler);

  external long __guard;
  EXPORT_SYMBOL(__guard);
  #endif

This is what other architectures do; EXPORT_SYMBOL(__stack_chk_guard) is guarded by #ifdef CONFIG_STACKPROTECTOR.

However, adding the #ifdef guard is not sensible because UML cannot enable the stack-protector in the first place! (Please note UML does not select HAVE_STACKPROTECTOR in Kconfig.)

Quoted 5 lines

So, the code is already broken (and unused) in multiple ways.

Just remove.

Thanks for the patch!

Quoted 29 lines

---

Changes in v7:
- New patch

 arch/um/os-Linux/user_syms.c | 7 -------
 1 file changed, 7 deletions(-)
arch/um/os-Linux/user_syms.c +0 -8
index 9b62a9d352b3..a310ae27b479 100644
@@ -37,13 +37,6 @@ EXPORT_SYMBOL(vsyscall_ehdr);
 EXPORT_SYMBOL(vsyscall_end);
 #endif
 
-/* Export symbols used by GCC for the stack protector. */
-extern void __stack_smash_handler(void *) __attribute__((weak));
-EXPORT_SYMBOL(__stack_smash_handler);
-
-extern long __guard __attribute__((weak));
-EXPORT_SYMBOL(__guard);
-
 #ifdef _FORTIFY_SOURCE
 extern int __sprintf_chk(char *str, int flag, size_t len, const char *format);
 EXPORT_SYMBOL(__sprintf_chk);
--

2.39.2

Signature · 2 lines
Thanks,
~Nick Desaulniers
#3 lore raw

PATCH v7 2/11 modpost: pass struct module pointer to check_section_mismatch()

In reply to Masahiro Yamada

The next commit will use it.

---

 scripts/mod/modpost.c | 22 +++++++++++-----------
 1 file changed, 11 insertions(+), 11 deletions(-)
scripts/mod/modpost.c +11 -11
index 8decf04633bc..403ba4d923f5 100644
@@ -1211,7 +1211,7 @@ static void default_mismatch_handler(const char *modname, struct elf_info *elf,
 	}
 }
 
-static void check_section_mismatch(const char *modname, struct elf_info *elf,
+static void check_section_mismatch(struct module *mod, struct elf_info *elf,
 				   Elf_Sym *sym,
 				   unsigned int fsecndx, const char *fromsec,
 				   Elf_Addr faddr, Elf_Addr taddr)
@@ -1222,7 +1222,7 @@ static void check_section_mismatch(const char *modname, struct elf_info *elf,
 	if (!mismatch)
 		return;
 
-	default_mismatch_handler(modname, elf, mismatch, sym,
+	default_mismatch_handler(mod->name, elf, mismatch, sym,
 				 fsecndx, fromsec, faddr,
 				 tosec, taddr);
 }
@@ -1406,7 +1406,7 @@ static int addend_mips_rel(struct elf_info *elf, Elf_Shdr *sechdr, Elf_Rela *r)
 #define R_LARCH_SUB32		55
 #endif
 
-static void section_rela(const char *modname, struct elf_info *elf,
+static void section_rela(struct module *mod, struct elf_info *elf,
 			 Elf_Shdr *sechdr)
 {
 	Elf_Rela *rela;
@@ -1452,12 +1452,12 @@ static void section_rela(const char *modname, struct elf_info *elf,
 			break;
 		}
 
-		check_section_mismatch(modname, elf, elf->symtab_start + r_sym,
+		check_section_mismatch(mod, elf, elf->symtab_start + r_sym,
 				       fsecndx, fromsec, r.r_offset, r.r_addend);
 	}
 }
 
-static void section_rel(const char *modname, struct elf_info *elf,
+static void section_rel(struct module *mod, struct elf_info *elf,
 			Elf_Shdr *sechdr)
 {
 	Elf_Rel *rel;
@@ -1507,7 +1507,7 @@ static void section_rel(const char *modname, struct elf_info *elf,
 			fatal("Please add code to calculate addend for this architecture\n");
 		}
 
-		check_section_mismatch(modname, elf, elf->symtab_start + r_sym,
+		check_section_mismatch(mod, elf, elf->symtab_start + r_sym,
 				       fsecndx, fromsec, r.r_offset, r.r_addend);
 	}
 }
@@ -1524,19 +1524,19 @@ static void section_rel(const char *modname, struct elf_info *elf,
  * to find all references to a section that reference a section that will
  * be discarded and warns about it.
  **/
-static void check_sec_ref(const char *modname, struct elf_info *elf)
+static void check_sec_ref(struct module *mod, struct elf_info *elf)
 {
 	int i;
 	Elf_Shdr *sechdrs = elf->sechdrs;
 
 	/* Walk through all sections */
 	for (i = 0; i < elf->num_sections; i++) {
-		check_section(modname, elf, &elf->sechdrs[i]);
+		check_section(mod->name, elf, &elf->sechdrs[i]);
 		/* We want to process only relocation sections and not .init */
 		if (sechdrs[i].sh_type == SHT_RELA)
-			section_rela(modname, elf, &elf->sechdrs[i]);
+			section_rela(mod, elf, &elf->sechdrs[i]);
 		else if (sechdrs[i].sh_type == SHT_REL)
-			section_rel(modname, elf, &elf->sechdrs[i]);
+			section_rel(mod, elf, &elf->sechdrs[i]);
 	}
 }
 
@@ -1707,7 +1707,7 @@ static void read_symbols(const char *modname)
 					     sym_get_data(&info, sym));
 	}
 
-	check_sec_ref(modname, &info);
+	check_sec_ref(mod, &info);
 
 	if (!mod->is_vmlinux) {
 		version = get_modinfo(&info, "version");
Signature · 7 lines
2.39.2


_______________________________________________
linux-um mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-um
#4 lore raw

PATCH v7 3/11 kbuild: generate KSYMTAB entries by modpost

In reply to 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().

The EXPORT_SYMBOL() compilation is split into two stages.

When a source file is compiled, EXPORT_SYMBOL() is converted into a dummy symbol in the .export_symbol section.

For example,

    EXPORT_SYMBOL(foo);
    EXPORT_SYMBOL_NS_GPL(bar, BAR_NAMESPACE);

will be encoded into the following assembly code:

    .section ".export_symbol","a"
    __export_symbol__foo:
            .asciz ""
            .balign 4
            .long foo - .
    .previous

    .section ".export_symbol","a"
    __export_symbol_gpl_bar:
            .asciz "BAR_NAMESPACE"
            .balign 4
            .long bar - .
    .previous

They are mere markers to tell modpost the name, license, and namespace of the symbols. They will be dropped from the final vmlinux and modules because the *(.export_symbol) will go into /DISCARD/ in the linker script.

Then, modpost extracts all the information about EXPORT_SYMBOL() from the .export_symbol section, and generates the final C code:

    KSYMTAB_FUNC(foo, "", "");
    KSYMTAB_FUNC(bar, "_gpl", "BAR_NAMESPACE");

KSYMTAB_FUNC() (or KSYMTAB_DATA() if it is data) 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()

In the old days, EXPORT_SYMBOL() was only available in C files. To export a symbol in *.S, EXPORT_SYMBOL() was placed in a separate *.c file. arch/arm/kernel/armksyms.c is one example written in the classic manner.

Commit 22823ab419d8 ("EXPORT_SYMBOL() for asm") removed this limitation. Since then, EXPORT_SYMBOL() can be placed close to the symbol definition in *.S files. It was a nice improvement.

However, as that commit mentioned, you need to use EXPORT_DATA_SYMBOL() for data objects on some architectures.

In the new approach, modpost checks symbol's type (STT_FUNC or not), and outputs KSYMTAB_FUNC() or KSYMTAB_DATA() accordingly.

There are only two users of EXPORT_DATA_SYMBOL:

EXPORT_DATA_SYMBOL_GPL(empty_zero_page) (arch/ia64/kernel/head.S)
EXPORT_DATA_SYMBOL(ia64_ivt) (arch/ia64/kernel/ivt.S)

They are transformed as follows and output into .vmlinux.export.c

  KSYMTAB_DATA(empty_zero_page, "_gpl", "");
  KSYMTAB_DATA(ia64_ivt, "", "");

The other EXPORT_SYMBOL users in ia64 assembly are output as KSYMTAB_FUNC().

EXPORT_DATA_SYMBOL() is now deprecated.

[2] merge <linux/export.h> and <asm-generic/export.h>

There are two similar header implementations:

include/linux/export.h for .c files
include/asm-generic/export.h for .S files

Ideally, the functionality should be consistent between them, but they tend to diverge.

Commit 8651ec01daed ("module: add support for symbol namespaces.") did not support the namespace for *.S files.

This commit shifts the essential implementation part to C, which supports EXPORT_SYMBOL_NS() for *.S files.

<asm/export.h> and <asm-generic/export.h> will remain as a wrapper of <linux/export.h> for a while.

They will be removed after #include <asm/export.h> directives are all replaced with #include <linux/export.h>.

[3] Implement CONFIG_TRIM_UNUSED_KSYMS in one-pass algorithm (by a later commit)

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 no-op.

We can do this better now; modpost can selectively emit KSYMTAB entries that are really used by modules.

---

Changes in v7:
- Fix sparse warning reported by 0day bot

    https://lore.kernel.org/linux-kbuild/[email protected]/

Changes in v6:
- Fix build error on UML

Changes in v5:
- Fix build error on ARM

Changes in v4:
- Version 3 did not work if a same name symbol exists in a different compilation unit Fix it.

Changes in v3:
- Move struct kernel_symbol to kernel/module/internal.h

Changes in v2:
- Use KSYMTAB_FUNC and KSYMTAB_DATA for functions and data, respectively This distinction is needed for ia64.

 arch/ia64/include/asm/Kbuild      |   1 +
 arch/ia64/include/asm/export.h    |   3 -
 include/asm-generic/export.h      |  84 ++-----------------------
 include/asm-generic/vmlinux.lds.h |   1 +
 include/linux/export-internal.h   |  49 +++++++++++++++
 include/linux/export.h            |  98 ++++++++++-------------------
 include/linux/pm.h                |   8 +--
 kernel/module/internal.h          |  12 ++++
 scripts/Makefile.build            |   8 +--
 scripts/check-local-export        |   4 +-
 scripts/mod/modpost.c             | 100 ++++++++++++++++++++----------
 scripts/mod/modpost.h             |   1 +
 12 files changed, 179 insertions(+), 190 deletions(-)
 delete mode 100644 arch/ia64/include/asm/export.h
arch/ia64/include/asm/Kbuild +1 -0
index aefae2efde9f..33733245f42b 100644
@@ -1,6 +1,7 @@
 # SPDX-License-Identifier: GPL-2.0
 generated-y += syscall_table.h
 generic-y += agp.h
+generic-y += export.h
 generic-y += kvm_para.h
 generic-y += mcs_spinlock.h
 generic-y += vtime.h
arch/ia64/include/asm/export.h deleted +0 -3
deleted file mode 100644
index ad18c6583252..000000000000
@@ -1,3 +0,0 @@
-/* EXPORT_DATA_SYMBOL != EXPORT_SYMBOL here */
-#define KSYM_FUNC(name) @fptr(name)
-#include <asm-generic/export.h>
include/asm-generic/export.h +5 -79

91 lines not on this page · raw message

include/asm-generic/vmlinux.lds.h +1 -0
index d1f57e4868ed..e65d55e8819c 100644
@@ -1006,6 +1006,7 @@
 	PATCHABLE_DISCARDS						\
 	*(.discard)							\
 	*(.discard.*)							\
+	*(.export_symbol)						\
 	*(.modinfo)							\
 	/* ld.bfd warns about .gnu.version* even when not emitted */	\
 	*(.gnu.version*)						\
include/linux/export-internal.h +49 -0

55 lines not on this page · raw message

include/linux/export.h +34 -64

132 lines not on this page · raw message

include/linux/pm.h +4 -4
index 035d9649eba4..aabb6bd8f89e 100644
@@ -388,10 +388,10 @@ const struct dev_pm_ops name = { \
 #define EXPORT_PM_FN_NS_GPL(name, ns)
 #endif
 
-#define EXPORT_DEV_PM_OPS(name) _EXPORT_DEV_PM_OPS(name, "", "")
-#define EXPORT_GPL_DEV_PM_OPS(name) _EXPORT_DEV_PM_OPS(name, "_gpl", "")
-#define EXPORT_NS_DEV_PM_OPS(name, ns) _EXPORT_DEV_PM_OPS(name, "", #ns)
-#define EXPORT_NS_GPL_DEV_PM_OPS(name, ns) _EXPORT_DEV_PM_OPS(name, "_gpl", #ns)
+#define EXPORT_DEV_PM_OPS(name) _EXPORT_DEV_PM_OPS(name,, "")
+#define EXPORT_GPL_DEV_PM_OPS(name) _EXPORT_DEV_PM_OPS(name,gpl, "")
+#define EXPORT_NS_DEV_PM_OPS(name, ns) _EXPORT_DEV_PM_OPS(name,, #ns)
+#define EXPORT_NS_GPL_DEV_PM_OPS(name, ns) _EXPORT_DEV_PM_OPS(name,gpl, #ns)
 
 /*
  * Use this if you want to use the same suspend and resume callbacks for suspend
kernel/module/internal.h +12 -0
index dc7b0160c480..c8b7b4dcf782 100644
@@ -32,6 +32,18 @@
 /* Maximum number of characters written by module_flags() */
 #define MODULE_FLAGS_BUF_SIZE (TAINT_FLAGS_COUNT + 4)
 
+struct kernel_symbol {
+#ifdef CONFIG_HAVE_ARCH_PREL32_RELOCATIONS
+	int value_offset;
+	int name_offset;
+	int namespace_offset;
+#else
+	unsigned long value;
+	const char *name;
+	const char *namespace;
+#endif
+};
+
 extern struct mutex module_mutex;
 extern struct list_head modules;
 
scripts/Makefile.build +3 -5
index 9f94fc83f086..6bf026a304e4 100644
@@ -161,7 +161,7 @@ quiet_cmd_cc_o_c = CC $(quiet_modtag)  $@
 ifdef CONFIG_MODVERSIONS
 # When module versioning is enabled the following steps are executed:
 # o compile a <file>.o from <file>.c
-# o if <file>.o doesn't contain a __ksymtab version, i.e. does
+# o if <file>.o doesn't contain a __export_symbol*, i.e. does
 #   not export symbols, it's done.
 # o otherwise, we calculate symbol versions using the good old
 #   genksyms on the preprocessed source and dump them into the .cmd file.
@@ -169,7 +169,7 @@ ifdef CONFIG_MODVERSIONS
 #   be compiled and linked to the kernel and/or modules.
 
 gen_symversions =								\
-	if $(NM) $@ 2>/dev/null | grep -q __ksymtab; then			\
+	if $(NM) $@ 2>/dev/null | grep -q '__export_symbol_[^_]*_'; then	\
 		$(call cmd_gensymtypes_$(1),$(KBUILD_SYMTYPES),$(@:.o=.symtypes)) \
 			>> $(dot-target).cmd;					\
 	fi
@@ -340,9 +340,7 @@ $(obj)/%.ll: $(src)/%.rs FORCE
 cmd_gensymtypes_S =                                                         \
    { echo "\#include <linux/kernel.h>" ;                                    \
      echo "\#include <asm/asm-prototypes.h>" ;                              \
-    $(CPP) $(a_flags) $< |                                                  \
-     grep "\<___EXPORT_SYMBOL\>" |                                          \
-     sed 's/.*___EXPORT_SYMBOL[[:space:]]*\([a-zA-Z0-9_]*\)[[:space:]]*,.*/EXPORT_SYMBOL(\1);/' ; } | \
+     $(NM) $@ | sed -n 's/.*__export_symbol_[^_]*_\(.*\)/EXPORT_SYMBOL(\1);/p' ; } | \
     $(CPP) -D__GENKSYMS__ $(c_flags) -xc - | $(genksyms)
 
 quiet_cmd_cc_symtypes_S = SYM $(quiet_modtag) $@
scripts/check-local-export +2 -2
index f90b5a9c67b3..969a313b9299 100755
@@ -46,9 +46,9 @@ BEGIN {
 { symbol_types[$3]=$2 }
 
 # append the exported symbol to the array
-($3 ~ /^__ksymtab_/) {
+($3 ~ /^__export_symbol_(gpl)?_.*/) {
 	export_symbols[i] = $3
-	sub(/^__ksymtab_/, "", export_symbols[i])
+	sub(/^__export_symbol_(gpl)?_/, "", export_symbols[i])
 	i++
 }
 
scripts/mod/modpost.c +67 -33

161 lines not on this page · raw message

scripts/mod/modpost.h +1 -0
index b1e2d95f8047..dfdb9484e325 100644
@@ -137,6 +137,7 @@ struct elf_info {
 	Elf_Shdr     *sechdrs;
 	Elf_Sym      *symtab_start;
 	Elf_Sym      *symtab_stop;
+	unsigned int export_symbol_secndx;	/* .export_symbol section */
 	char         *strtab;
 	char	     *modinfo;
 	unsigned int modinfo_len;
Signature · 7 lines
2.39.2


_______________________________________________
linux-um mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-um
Reviewed-by on v7 3/11
#5 lore raw

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

Quoted 6 lines · 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.

Thanks for the patch!

Signature · 7 lines
Thanks,
~Nick Desaulniers

_______________________________________________
linux-um mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-um
#6 lore raw

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

In reply to Masahiro Yamada
Quoted 18 lines · 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().

The EXPORT_SYMBOL() compilation is split into two stages.

When a source file is compiled, EXPORT_SYMBOL() is converted into a dummy symbol in the .export_symbol section.

For example,

    EXPORT_SYMBOL(foo);
    EXPORT_SYMBOL_NS_GPL(bar, BAR_NAMESPACE);
Quoted 7 lines

will be encoded into the following assembly code:

    .section ".export_symbol","a"
    __export_symbol__foo:
            .asciz ""
            .balign 4
            .long foo - .

I hope this will work for all arches, but
unfortunately, the 0day bot reported breakages
on xtensa.

I will restore the code in v6.

Signature · 2 lines
Best Regards
Masahiro Yamada
#7 lore raw

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

In reply to Masahiro Yamada
Quoted 4 lines · 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.

...

Quoted 3 lines

We can do this better now; modpost can selectively emit KSYMTAB entries that are really used by modules.

This patch results in

Building alpha:defconfig ... failed
--------------
Error log:
<stdin>:1519:2: warning: #warning syscall clone3 not implemented [-Wcpp]
WARNING: modpost: "saved_config" [vmlinux] is COMMON symbol
ERROR: modpost: vmlinux: page_is_ram: EXPORT_SYMBOL used for init symbol. Remove __init or EXPORT_SYMBOL.

I don't know if other architectures are affected - linux-next is so broken that it is difficult to find root causes for all the breakages.

Guenter

---
Bisect log:

# bad: [15e71592dbae49a674429c618a10401d7f992ac3] Add linux-next specific files for 20230621
# good: [45a3e24f65e90a047bef86f927ebdc4c710edaa1] Linux 6.4-rc7
git bisect start 'HEAD' 'v6.4-rc7'
# bad: [e867e67cd55ae460c860ffd896c7fc96add2821c] Merge branch 'master' of git://git.kernel.org/pub/scm/linux/kernel/git/herbert/cryptodev-2.6.git
git bisect bad e867e67cd55ae460c860ffd896c7fc96add2821c
# bad: [57b289d5b1005a9c39d6d6567e0ef6115bd59cea] Merge branch 'for-next' of git://git.kernel.org/pub/scm/linux/kernel/git/riscv/linux.git
git bisect bad 57b289d5b1005a9c39d6d6567e0ef6115bd59cea
# bad: [dc6399fc9ae6d2530fc38fb3ae96bcc8393bd66f] Merge branch 'for-next/perf' of git://git.kernel.org/pub/scm/linux/kernel/git/will/linux.git
git bisect bad dc6399fc9ae6d2530fc38fb3ae96bcc8393bd66f
# good: [6d366ba598334a0457d917a7bf38efd118c5b7be] Merge branch 'mm-stable' of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm
git bisect good 6d366ba598334a0457d917a7bf38efd118c5b7be
# good: [82fe2e45cdb00de4fa648050ae33bdadf9b3294a] perf pmus: Check if we can encode the PMU number in perf_event_attr.type git bisect good 82fe2e45cdb00de4fa648050ae33bdadf9b3294a
# bad: [d2fa756910f88c2f5871775483744407cbf67933] Merge branch 'for-next' of git://git.infradead.org/users/hch/dma-mapping.git
git bisect bad d2fa756910f88c2f5871775483744407cbf67933
# good: [1b990bc8edc396a37a3ff1a43f7c329c361ee07c] Merge branch 'mm-nonmm-unstable' into mm-everything
git bisect good 1b990bc8edc396a37a3ff1a43f7c329c361ee07c
# good: [cff6e7f50bd315e5b39c4e46c704ac587ceb965f] kbuild: Add CLANG_FLAGS to as-instr
git bisect good cff6e7f50bd315e5b39c4e46c704ac587ceb965f
# bad: [8f3847e175a0044e2212fef772e7fa912270cd6d] ia64,export.h: replace EXPORT_DATA_SYMBOL* with EXPORT_SYMBOL*
git bisect bad 8f3847e175a0044e2212fef772e7fa912270cd6d
# good: [3a3f1e573a105328a2cca45a7cfbebabbf5e3192] modpost: fix off by one in is_executable_section()
git bisect good 3a3f1e573a105328a2cca45a7cfbebabbf5e3192
# good: [92e74fb6e6196d642505ae2b74a8e327202afef9] scripts/kallsyms: constify long_options
git bisect good 92e74fb6e6196d642505ae2b74a8e327202afef9
# good: [92e2921eeafdfca9acd9b83f07d2b7ca099bac24] ARC: define ASM_NL and __ALIGN(_STR) outside #ifdef __ASSEMBLY__ guard git bisect good 92e2921eeafdfca9acd9b83f07d2b7ca099bac24
# bad: [bb2aa9a94b41b883037a56709d995c269204ade0] kbuild: generate KSYMTAB entries by modpost
git bisect bad bb2aa9a94b41b883037a56709d995c269204ade0
# good: [94d6cb68124b7a63f24fcc345795ba5f9a27e694] modpost: pass struct module pointer to check_section_mismatch()
git bisect good 94d6cb68124b7a63f24fcc345795ba5f9a27e694

# first bad commit: [bb2aa9a94b41b883037a56709d995c269204ade0] kbuild: generate KSYMTAB entries by modpost

_______________________________________________
linux-um mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-um

#8 lore raw

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

Quoted 21 lines · Guenter Roeck
Quoted 4 lines · 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.

...

Quoted 3 lines

We can do this better now; modpost can selectively emit KSYMTAB entries that are really used by modules.

This patch results in

Building alpha:defconfig ... failed
--------------
Error log:
<stdin>:1519:2: warning: #warning syscall clone3 not implemented [-Wcpp]
WARNING: modpost: "saved_config" [vmlinux] is COMMON symbol
ERROR: modpost: vmlinux: page_is_ram: EXPORT_SYMBOL used for init symbol. Remove __init or EXPORT_SYMBOL.

Quoted 2 lines

I don't know if other architectures are affected - linux-next is so broken that it is difficult to find root causes for all the breakages.

Thanks for the comprehensive build tests.

If you compare the build log, you will see
what has happened.

In Linus' tree (without this patch),

MODPOST Module.symvers
WARNING: modpost: "saved_config" [vmlinux] is COMMON symbol
WARNING: modpost: vmlinux.o: EXPORT_SYMBOL used for init/exit symbol:
page_is_ram (section: .init.text)

In linux-next (with this patch),

MODPOST Module.symvers
WARNING: modpost: "saved_config" [vmlinux] is COMMON symbol
ERROR: modpost: vmlinux: page_is_ram: EXPORT_SYMBOL used for init symbol. Remove __init or EXPORT_SYMBOL.

The change is obvious - I just turned the combination of __init and EXPORT_SYMBOL into an error.

But, it seemed too early to do this.

I will hold it back as a warning for now, as follows:

scripts/mod/modpost.c +0 -0
index bdf4244da993..412115a8202a 100644
@@ -1239,10 +1239,10 @@ static void check_export_symbol(struct module

*mod, struct elf_info *elf,
s->is_func = (ELF_ST_TYPE(sym->st_info) == STT_FUNC);

if (match(secname, PATTERNS(INIT_SECTIONS)))
- error("%s: %s: EXPORT_SYMBOL used for init symbol.
Remove __init or EXPORT_SYMBOL.\n",
+ warn("%s: %s: EXPORT_SYMBOL used for init symbol.
Remove __init or EXPORT_SYMBOL.\n",
mod->name, name);
else if (match(secname, PATTERNS(EXIT_SECTIONS)))
- error("%s: %s: EXPORT_SYMBOL used for exit symbol.
Remove __exit or EXPORT_SYMBOL.\n",
+ warn("%s: %s: EXPORT_SYMBOL used for exit symbol.
Remove __exit or EXPORT_SYMBOL.\n",

                      mod->name, name);

}

Fixing the alpha code is trivial.

arch/alpha/kernel/setup.c +1 -1
index 33bf3a627002..22131e2a9f57 100644
@@ -385,7 +385,7 @@ setup_memory(void *kernel_end)
 #endif /* CONFIG_BLK_DEV_INITRD */
 }
 
-int __init
+int
 page_is_ram(unsigned long pfn)
 {
        struct memclust_struct * cluster;

I do not know much about the warning for "saved_config".

__attribute((common)) was added in the following commit:

https://git.kernel.org/pub/scm/linux/kernel/git/history/history.git/commit/?id=3c7940961fbf9f252e20f9c455f2fe63f273294c

It was more than 20 years ago, and there is no commit description.
I do not know the intention of __attribute((common)).

I hope the maintainers will fix the warnings,
but I do not know if it is likely to happen.

MAINTAINERS says "Odd Fixes"

If you find a build regression, please let me know. So far, I did not get new reports from 0day bot.

Thanks.

Quoted 37 lines

Guenter

---
Bisect log:

# bad: [15e71592dbae49a674429c618a10401d7f992ac3] Add linux-next specific files for 20230621
# good: [45a3e24f65e90a047bef86f927ebdc4c710edaa1] Linux 6.4-rc7
git bisect start 'HEAD' 'v6.4-rc7'
# bad: [e867e67cd55ae460c860ffd896c7fc96add2821c] Merge branch 'master' of git://git.kernel.org/pub/scm/linux/kernel/git/herbert/cryptodev-2.6.git
git bisect bad e867e67cd55ae460c860ffd896c7fc96add2821c
# bad: [57b289d5b1005a9c39d6d6567e0ef6115bd59cea] Merge branch 'for-next' of git://git.kernel.org/pub/scm/linux/kernel/git/riscv/linux.git
git bisect bad 57b289d5b1005a9c39d6d6567e0ef6115bd59cea
# bad: [dc6399fc9ae6d2530fc38fb3ae96bcc8393bd66f] Merge branch 'for-next/perf' of git://git.kernel.org/pub/scm/linux/kernel/git/will/linux.git
git bisect bad dc6399fc9ae6d2530fc38fb3ae96bcc8393bd66f
# good: [6d366ba598334a0457d917a7bf38efd118c5b7be] Merge branch 'mm-stable' of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm
git bisect good 6d366ba598334a0457d917a7bf38efd118c5b7be
# good: [82fe2e45cdb00de4fa648050ae33bdadf9b3294a] perf pmus: Check if we can encode the PMU number in perf_event_attr.type git bisect good 82fe2e45cdb00de4fa648050ae33bdadf9b3294a
# bad: [d2fa756910f88c2f5871775483744407cbf67933] Merge branch 'for-next' of git://git.infradead.org/users/hch/dma-mapping.git
git bisect bad d2fa756910f88c2f5871775483744407cbf67933
# good: [1b990bc8edc396a37a3ff1a43f7c329c361ee07c] Merge branch 'mm-nonmm-unstable' into mm-everything
git bisect good 1b990bc8edc396a37a3ff1a43f7c329c361ee07c
# good: [cff6e7f50bd315e5b39c4e46c704ac587ceb965f] kbuild: Add CLANG_FLAGS to as-instr
git bisect good cff6e7f50bd315e5b39c4e46c704ac587ceb965f
# bad: [8f3847e175a0044e2212fef772e7fa912270cd6d] ia64,export.h: replace EXPORT_DATA_SYMBOL* with EXPORT_SYMBOL*
git bisect bad 8f3847e175a0044e2212fef772e7fa912270cd6d
# good: [3a3f1e573a105328a2cca45a7cfbebabbf5e3192] modpost: fix off by one in is_executable_section()
git bisect good 3a3f1e573a105328a2cca45a7cfbebabbf5e3192
# good: [92e74fb6e6196d642505ae2b74a8e327202afef9] scripts/kallsyms: constify long_options
git bisect good 92e74fb6e6196d642505ae2b74a8e327202afef9
# good: [92e2921eeafdfca9acd9b83f07d2b7ca099bac24] ARC: define ASM_NL and __ALIGN(_STR) outside #ifdef __ASSEMBLY__ guard git bisect good 92e2921eeafdfca9acd9b83f07d2b7ca099bac24
# bad: [bb2aa9a94b41b883037a56709d995c269204ade0] kbuild: generate KSYMTAB entries by modpost
git bisect bad bb2aa9a94b41b883037a56709d995c269204ade0
# good: [94d6cb68124b7a63f24fcc345795ba5f9a27e694] modpost: pass struct module pointer to check_section_mismatch()
git bisect good 94d6cb68124b7a63f24fcc345795ba5f9a27e694

# first bad commit: [bb2aa9a94b41b883037a56709d995c269204ade0] kbuild: generate KSYMTAB entries by modpost
Signature · 2 lines
Best Regards
Masahiro Yamada
#9 lore raw

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

Quoted 25 lines · Masahiro Yamada
Quoted 12 lines · Guenter Roeck
Quoted 4 lines · 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.

...

Quoted 3 lines

We can do this better now; modpost can selectively emit KSYMTAB entries that are really used by modules.

Quoted 7 lines

This patch results in

Building alpha:defconfig ... failed
--------------
Error log:
<stdin>:1519:2: warning: #warning syscall clone3 not implemented [-Wcpp]
WARNING: modpost: "saved_config" [vmlinux] is COMMON symbol

I do not know much about the warning for "saved_config".

Quoted 8 lines

__attribute((common)) was added in the following commit:

https://git.kernel.org/pub/scm/linux/kernel/git/history/history.git/commit/?id=3c7940961fbf9f252e20f9c455f2fe63f273294c

It was more than 20 years ago, and there is no commit description.
I do not know the intention of __attribute((common)).

Adding __attribute__((common)) to a variable declaration, the generated assembler will contain a .comm assembler directive.
https://godbolt.org/z/6jvoaGs8M
https://sourceware.org/binutils/docs/as/Comm.html

Quoted 1 line
Quoted 1 line
Quoted 1 line

.comm declares a common symbol named symbol. When linking, a common symbol in one object file may be merged with a defined or common symbol of the same name in another object file.

When I see this, I think some kind of ODR tricks are afoot. C doesn't have ODR; C++ does, but this attribute allows for ODR-like linker merging where the linker discards duplicates because "they ought to be the same."

IIRC, I think C++ template instantiations are emitted with common linkage. LLVM IR has a linkage type corresponding to this that I initially didn't understand, because without this attribute, I don't think that linkage type is ever emitted for C code.

Indeed, for alpha, we can see the same symbol marked common in arch/alpha/:
arch/alpha/kernel/core_tsunami.c:36:} saved_config[2] __attribute__((common)); arch/alpha/kernel/sys_sio.c:43:} saved_config __attribute((common)); arch/alpha/kernel/core_cia.c:577:} saved_config __attribute((common)); arch/alpha/kernel/core_titan.c:36:} saved_config[4] __attribute__((common));

All of these have different sizes, so according to the GAS manual, this line comes into play:

Quoted 1 line
Quoted 1 line
Quoted 1 line

If ld sees multiple common symbols with the same name, and they do not all have the same size, it will allocate space using the largest size.

This kind of smells like some overcomplicating code to save like 30B of static memory. Fixing this requires careful use of enums. For arch/alpha/ not sure such a rework is worth it, given the imminent demise of the architecture I sense looming on the horizon.

Quoted 58 lines

I hope the maintainers will fix the warnings,
but I do not know if it is likely to happen.

MAINTAINERS says "Odd Fixes"

If you find a build regression, please let me know. So far, I did not get new reports from 0day bot.

Thanks.

Quoted 36 lines

Guenter

---
Bisect log:

# bad: [15e71592dbae49a674429c618a10401d7f992ac3] Add linux-next specific files for 20230621
# good: [45a3e24f65e90a047bef86f927ebdc4c710edaa1] Linux 6.4-rc7
git bisect start 'HEAD' 'v6.4-rc7'
# bad: [e867e67cd55ae460c860ffd896c7fc96add2821c] Merge branch 'master' of git://git.kernel.org/pub/scm/linux/kernel/git/herbert/cryptodev-2.6.git
git bisect bad e867e67cd55ae460c860ffd896c7fc96add2821c
# bad: [57b289d5b1005a9c39d6d6567e0ef6115bd59cea] Merge branch 'for-next' of git://git.kernel.org/pub/scm/linux/kernel/git/riscv/linux.git
git bisect bad 57b289d5b1005a9c39d6d6567e0ef6115bd59cea
# bad: [dc6399fc9ae6d2530fc38fb3ae96bcc8393bd66f] Merge branch 'for-next/perf' of git://git.kernel.org/pub/scm/linux/kernel/git/will/linux.git
git bisect bad dc6399fc9ae6d2530fc38fb3ae96bcc8393bd66f
# good: [6d366ba598334a0457d917a7bf38efd118c5b7be] Merge branch 'mm-stable' of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm
git bisect good 6d366ba598334a0457d917a7bf38efd118c5b7be
# good: [82fe2e45cdb00de4fa648050ae33bdadf9b3294a] perf pmus: Check if we can encode the PMU number in perf_event_attr.type git bisect good 82fe2e45cdb00de4fa648050ae33bdadf9b3294a
# bad: [d2fa756910f88c2f5871775483744407cbf67933] Merge branch 'for-next' of git://git.infradead.org/users/hch/dma-mapping.git
git bisect bad d2fa756910f88c2f5871775483744407cbf67933
# good: [1b990bc8edc396a37a3ff1a43f7c329c361ee07c] Merge branch 'mm-nonmm-unstable' into mm-everything
git bisect good 1b990bc8edc396a37a3ff1a43f7c329c361ee07c
# good: [cff6e7f50bd315e5b39c4e46c704ac587ceb965f] kbuild: Add CLANG_FLAGS to as-instr
git bisect good cff6e7f50bd315e5b39c4e46c704ac587ceb965f
# bad: [8f3847e175a0044e2212fef772e7fa912270cd6d] ia64,export.h: replace EXPORT_DATA_SYMBOL* with EXPORT_SYMBOL*
git bisect bad 8f3847e175a0044e2212fef772e7fa912270cd6d
# good: [3a3f1e573a105328a2cca45a7cfbebabbf5e3192] modpost: fix off by one in is_executable_section()
git bisect good 3a3f1e573a105328a2cca45a7cfbebabbf5e3192
# good: [92e74fb6e6196d642505ae2b74a8e327202afef9] scripts/kallsyms: constify long_options
git bisect good 92e74fb6e6196d642505ae2b74a8e327202afef9
# good: [92e2921eeafdfca9acd9b83f07d2b7ca099bac24] ARC: define ASM_NL and __ALIGN(_STR) outside #ifdef __ASSEMBLY__ guard git bisect good 92e2921eeafdfca9acd9b83f07d2b7ca099bac24
# bad: [bb2aa9a94b41b883037a56709d995c269204ade0] kbuild: generate KSYMTAB entries by modpost
git bisect bad bb2aa9a94b41b883037a56709d995c269204ade0
# good: [94d6cb68124b7a63f24fcc345795ba5f9a27e694] modpost: pass struct module pointer to check_section_mismatch()
git bisect good 94d6cb68124b7a63f24fcc345795ba5f9a27e694

Quoted 1 line
# first bad commit: [bb2aa9a94b41b883037a56709d995c269204ade0] kbuild: generate KSYMTAB entries by modpost

--
Best Regards
Masahiro Yamada

Signature · 2 lines
Thanks,
~Nick Desaulniers
#10 lore raw

PATCH v7 4/11 ia64,export.h: replace EXPORT_DATA_SYMBOL* with EXPORT_SYMBOL*

In reply to Masahiro Yamada

With the previous refactoring, you can always use EXPORT_SYMBOL*.

Replace two instances in ia64, then remove EXPORT_DATA_SYMBOL*.

---

 arch/ia64/kernel/head.S      | 2 +-
 arch/ia64/kernel/ivt.S       | 2 +-
 include/asm-generic/export.h | 3 ---
 3 files changed, 2 insertions(+), 5 deletions(-)
arch/ia64/kernel/head.S +1 -1
index f22469f1c1fc..c096500590e9 100644
@@ -170,7 +170,7 @@ RestRR:											\
 	__PAGE_ALIGNED_DATA
 
 	.global empty_zero_page
-EXPORT_DATA_SYMBOL_GPL(empty_zero_page)
+EXPORT_SYMBOL_GPL(empty_zero_page)
 empty_zero_page:
 	.skip PAGE_SIZE
 
arch/ia64/kernel/ivt.S +1 -1
index d6d4229b28db..7a418e324d30 100644
@@ -87,7 +87,7 @@
 
 	.align 32768	// align on 32KB boundary
 	.global ia64_ivt
-	EXPORT_DATA_SYMBOL(ia64_ivt)
+	EXPORT_SYMBOL(ia64_ivt)
 ia64_ivt:
 /////////////////////////////////////////////////////////////////////////////////////////
 // 0x0000 Entry 0 (size 64 bundles) VHPT Translation (8,20,47)
include/asm-generic/export.h +0 -3
index 0ae9f38a904c..570cd4da7210 100644
@@ -8,7 +8,4 @@
  */
 #include <linux/export.h>
 
-#define EXPORT_DATA_SYMBOL(name)	EXPORT_SYMBOL(name)
-#define EXPORT_DATA_SYMBOL_GPL(name)	EXPORT_SYMBOL_GPL(name)
-
 #endif
Signature · 7 lines
2.39.2


_______________________________________________
linux-um mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-um
#11 lore raw

PATCH v7 5/11 modpost: check static EXPORT_SYMBOL* by modpost again

In reply to 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, against combined ELF files. The relocation entries in ELF will find the correct exported symbol even if there exist symbols with the same name in different compilation units.

Again, the same sample code.

Makefile:

    obj-y += foo1.o foo2.o

foo1.c:

    #include <linux/export.h>
    static void foo(void) {}
    EXPORT_SYMBOL(foo);

foo2.c:

    void foo(void) {}

Then, modpost can catch it correctly.

MODPOST Module.symvers
ERROR: modpost: vmlinux: local symbol 'foo' was exported

---

(no changes since v6)

Changes in v6:
- Make the symbol name in the warning more precise

 scripts/Makefile.build     |  4 ---
 scripts/check-local-export | 70 --------------------------------------
 scripts/mod/modpost.c      |  7 ++++
 3 files changed, 7 insertions(+), 74 deletions(-)
 delete mode 100755 scripts/check-local-export
scripts/Makefile.build +0 -4
index 6bf026a304e4..bd4123795299 100644
@@ -220,8 +220,6 @@ cmd_gen_ksymdeps = \
 	$(CONFIG_SHELL) $(srctree)/scripts/gen_ksymdeps.sh $@ >> $(dot-target).cmd
 endif
 
-cmd_check_local_export = $(srctree)/scripts/check-local-export $@
-
 ifneq ($(findstring 1, $(KBUILD_EXTRA_WARN)),)
 cmd_warn_shared_object = $(if $(word 2, $(modname-multi)),$(warning $(kbuild-file): $*.o is added to multiple modules: $(modname-multi)))
 endif
@@ -229,7 +227,6 @@ endif
 define rule_cc_o_c
 	$(call cmd_and_fixdep,cc_o_c)
 	$(call cmd,gen_ksymdeps)
-	$(call cmd,check_local_export)
 	$(call cmd,checksrc)
 	$(call cmd,checkdoc)
 	$(call cmd,gen_objtooldep)
@@ -241,7 +238,6 @@ endef
 define rule_as_o_S
 	$(call cmd_and_fixdep,as_o_S)
 	$(call cmd,gen_ksymdeps)
-	$(call cmd,check_local_export)
 	$(call cmd,gen_objtooldep)
 	$(call cmd,gen_symversions_S)
 	$(call cmd,warn_shared_object)
scripts/check-local-export deleted +0 -70

70 lines not on this page · raw message

scripts/mod/modpost.c +7 -0
index 0ae6c9c5bdf6..a3185ee6ec1a 100644
@@ -1217,6 +1217,13 @@ static void check_export_symbol(struct module *mod, struct elf_info *elf,
 		return;
 	}
 
+	if (ELF_ST_BIND(sym->st_info) != STB_GLOBAL &&
+	    ELF_ST_BIND(sym->st_info) != STB_WEAK) {
+		error("%s: local symbol '%s' was exported\n", mod->name,
+		      label_name + strlen(prefix));
+		return;
+	}
+
 	if (strcmp(label_name + strlen(prefix), name)) {
 		error("%s: .export_symbol section references '%s', but it does not seem to be an export symbol\n",
 		      mod->name, name);
Signature · 7 lines
2.39.2


_______________________________________________
linux-um mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-um
#12 lore raw

PATCH v7 6/11 modpost: squash sym_update_namespace() into sym_add_exported()

In reply to Masahiro Yamada

Pass a set of the name, license, and namespace to sym_add_exported().

sym_update_namespace() is unneeded.

---

 scripts/mod/modpost.c | 27 ++++-----------------------
 1 file changed, 4 insertions(+), 23 deletions(-)
scripts/mod/modpost.c +4 -23
index a3185ee6ec1a..4b0a009de0fb 100644
@@ -355,26 +355,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);
 
@@ -387,6 +369,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);
 
@@ -1230,8 +1213,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
@@ -2174,9 +2156,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;
Signature · 7 lines
2.39.2


_______________________________________________
linux-um mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-um
#13 lore raw

PATCH v7 7/11 modpost: use null string instead of NULL pointer for default namespace

In reply to 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 "", but loses the readability.

In kernel-space, we strive to save memory, but modpost is a userspace tool used to build the kernel. On modern systems, such small piece of memory is not a big deal.

Handle the namespace string as is.

---

 scripts/mod/modpost.c | 17 +++++++++++------
 1 file changed, 11 insertions(+), 6 deletions(-)
scripts/mod/modpost.c +11 -6
index 4b0a009de0fb..7044b257424a 100644
@@ -300,6 +300,13 @@ static bool contains_namespace(struct list_head *head, const char *namespace)
 {
 	struct namespace_list *list;
 
+	/*
+	 * The default namespace is null string "", which is always implicitly
+	 * contained.
+	 */
+	if (!namespace[0])
+		return true;
+
 	list_for_each_entry(list, head, list) {
 		if (!strcmp(list->namespace, namespace))
 			return true;
@@ -369,7 +376,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;
+	s->namespace = NOFAIL(strdup(namespace));
 	list_add_tail(&s->list, &mod->exported_symbols);
 	hash_add_symbol(s);
 
@@ -1823,8 +1830,7 @@ static void check_exports(struct module *mod)
 		else
 			basename = mod->name;
 
-		if (exp->namespace &&
-		    !contains_namespace(&mod->imported_namespaces, exp->namespace)) {
+		if (!contains_namespace(&mod->imported_namespaces, exp->namespace)) {
 			modpost_log(allow_missing_ns_imports ? LOG_WARN : LOG_ERROR,
 				    "module %s uses symbol %s from namespace %s, but does not import it.\n",
 				    basename, exp->name, exp->namespace);
@@ -1910,8 +1916,7 @@ static void add_exported_symbols(struct buffer *buf, struct module *mod)
 	list_for_each_entry(sym, &mod->exported_symbols, list)
 		buf_printf(buf, "KSYMTAB_%s(%s, \"%s\", \"%s\");\n",
 			   sym->is_func ? "FUNC" : "DATA", sym->name,
-			   sym->is_gpl_only ? "_gpl" : "",
-			   sym->namespace ?: "");
+			   sym->is_gpl_only ? "_gpl" : "", sym->namespace);
 
 	if (!modversions)
 		return;
@@ -2179,7 +2184,7 @@ static void write_dump(const char *fname)
 			buf_printf(&buf, "0x%08x\t%s\t%s\tEXPORT_SYMBOL%s\t%s\n",
 				   sym->crc, sym->name, mod->name,
 				   sym->is_gpl_only ? "_GPL" : "",
-				   sym->namespace ?: "");
+				   sym->namespace);
 		}
 	}
 	write_buf(&buf, fname);
Signature · 7 lines
2.39.2


_______________________________________________
linux-um mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-um
#14 lore raw

PATCH v7 8/11 kbuild: implement CONFIG_TRIM_UNUSED_KSYMS without recursion

In reply to 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 no-op.

Linus stated negative opinions about this slowness in commits:

- 5cf0fd591f2e ("Kbuild: disable TRIM_UNUSED_KSYMS option")
- a555bdd0c58c ("Kbuild: enable TRIM_UNUSED_KSYMS again, with some guarding")

We can do this better now. The final data structures of EXPORT_SYMBOL are generated by the modpost stage, so modpost can selectively emit KSYMTAB entries that are really used by modules.

Commit f73edc8951b2 ("kbuild: unify two modpost invocations") is another ground-work to do this in a one-pass algorithm. With the list of modules, modpost sets sym->used if it is used by a module. modpost emits KSYMTAB only for symbols with sym->used==true.

BTW, Nicolas explained why the trimming was implemented with recursion:

https://lore.kernel.org/all/[email protected]/

Actually, we never achieved that level of optimization where the chain reaction of trimming comes into play because:

- CONFIG_LTO_CLANG cannot remove any unused symbols
- CONFIG_LD_DEAD_CODE_DATA_ELIMINATION is enabled only for vmlinux, but not modules

If deeper trimming is required, we need to revisit this, but I guess that is unlikely to happen.

---

Changes in v7:
- Remove *.usyms

Changes in v5:
- Clean up more

 .gitignore                  |  2 -
 Makefile                    | 22 ++---------
 include/linux/export.h      | 67 +++++-----------------------------
 scripts/Makefile.build      | 15 +-------
 scripts/Makefile.modpost    |  7 ++++
 scripts/adjust_autoksyms.sh | 73 -------------------------------------
 scripts/basic/fixdep.c      |  3 +-
 scripts/gen_autoksyms.sh    | 62 -------------------------------
 scripts/gen_ksymdeps.sh     | 30 ---------------
 scripts/mod/modpost.c       | 54 ++++++++++++++++++++++++---
 scripts/remove-stale-files  |  4 ++
 11 files changed, 75 insertions(+), 264 deletions(-)
 delete mode 100755 scripts/adjust_autoksyms.sh
 delete mode 100755 scripts/gen_autoksyms.sh
 delete mode 100755 scripts/gen_ksymdeps.sh
.gitignore +0 -2
index 7f86e0837909..c3ce78ca20d2 100644
@@ -51,7 +51,6 @@
 *.symversions
 *.tab.[ch]
 *.tar
-*.usyms
 *.xz
 *.zst
 Module.symvers
@@ -112,7 +111,6 @@ modules.order
 #
 /include/config/
 /include/generated/
-/include/ksym/
 /arch/*/include/generated/
 
 # stgit generated dirs
Makefile +3 -19
index f836936fb4d8..cc3fe09c4dec 100644
@@ -1193,28 +1193,12 @@ endif
 export KBUILD_VMLINUX_LIBS
 export KBUILD_LDS          := arch/$(SRCARCH)/kernel/vmlinux.lds
 
-# Recurse until adjust_autoksyms.sh is satisfied
-PHONY += autoksyms_recursive
 ifdef CONFIG_TRIM_UNUSED_KSYMS
 # For the kernel to actually contain only the needed exported symbols,
 # we have to build modules as well to determine what those symbols are.
-# (this can be evaluated only once include/config/auto.conf has been included)
 KBUILD_MODULES := 1
-
-autoksyms_recursive: $(build-dir) modules.order
-	$(Q)$(CONFIG_SHELL) $(srctree)/scripts/adjust_autoksyms.sh \
-	  "$(MAKE) -f $(srctree)/Makefile autoksyms_recursive"
 endif
 
-autoksyms_h := $(if $(CONFIG_TRIM_UNUSED_KSYMS), include/generated/autoksyms.h)
-
-quiet_cmd_autoksyms_h = GEN     $@
-      cmd_autoksyms_h = mkdir -p $(dir $@); \
-			$(CONFIG_SHELL) $(srctree)/scripts/gen_autoksyms.sh $@
-
-$(autoksyms_h):
-	$(call cmd,autoksyms_h)
-
 # '$(AR) mPi' needs 'T' to workaround the bug of llvm-ar <= 14
 quiet_cmd_ar_vmlinux.a = AR      $@
       cmd_ar_vmlinux.a = \
@@ -1223,7 +1207,7 @@ quiet_cmd_ar_vmlinux.a = AR      $@
 	$(AR) mPiT $$($(AR) t $@ | sed -n 1p) $@ $$($(AR) t $@ | grep -F -f $(srctree)/scripts/head-object-list.txt)
 
 targets += vmlinux.a
-vmlinux.a: $(KBUILD_VMLINUX_OBJS) scripts/head-object-list.txt autoksyms_recursive FORCE
+vmlinux.a: $(KBUILD_VMLINUX_OBJS) scripts/head-object-list.txt FORCE
 	$(call if_changed,ar_vmlinux.a)
 
 PHONY += vmlinux_o
@@ -1279,7 +1263,7 @@ scripts: scripts_basic scripts_dtc
 PHONY += prepare archprepare
 
 archprepare: outputmakefile archheaders archscripts scripts include/config/kernel.release \
-	asm-generic $(version_h) $(autoksyms_h) include/generated/utsrelease.h \
+	asm-generic $(version_h) include/generated/utsrelease.h \
 	include/generated/compile.h include/generated/autoconf.h remove-stale-files
 
 prepare0: archprepare
@@ -2039,7 +2023,7 @@ clean: $(clean-dirs)
 		-o -name '*.dtb.S' -o -name '*.dtbo.S' \
 		-o -name '*.dt.yaml' \
 		-o -name '*.dwo' -o -name '*.lst' \
-		-o -name '*.su' -o -name '*.mod' -o -name '*.usyms' \
+		-o -name '*.su' -o -name '*.mod' \
 		-o -name '.*.d' -o -name '.*.tmp' -o -name '*.mod.c' \
 		-o -name '*.lex.c' -o -name '*.tab.[ch]' \
 		-o -name '*.asn1.[ch]' \
include/linux/export.h +10 -57

91 lines not on this page · raw message

scripts/Makefile.build +1 -14
index bd4123795299..7e1b9ed178e8 100644
@@ -82,7 +82,7 @@ ifdef need-builtin
 targets-for-builtin += $(obj)/built-in.a
 endif
 
-targets-for-modules := $(foreach x, o mod $(if $(CONFIG_TRIM_UNUSED_KSYMS), usyms), \
+targets-for-modules := $(foreach x, o mod, \
 				$(patsubst %.o, %.$x, $(filter %.o, $(obj-m))))
 
 ifdef need-modorder
@@ -215,18 +215,12 @@ is-standard-object = $(if $(filter-out y%, $(OBJECT_FILES_NON_STANDARD_$(basetar
 
 $(obj)/%.o: objtool-enabled = $(if $(is-standard-object),$(if $(delay-objtool),$(is-single-obj-m),y))
 
-ifdef CONFIG_TRIM_UNUSED_KSYMS
-cmd_gen_ksymdeps = \
-	$(CONFIG_SHELL) $(srctree)/scripts/gen_ksymdeps.sh $@ >> $(dot-target).cmd
-endif
-
 ifneq ($(findstring 1, $(KBUILD_EXTRA_WARN)),)
 cmd_warn_shared_object = $(if $(word 2, $(modname-multi)),$(warning $(kbuild-file): $*.o is added to multiple modules: $(modname-multi)))
 endif
 
 define rule_cc_o_c
 	$(call cmd_and_fixdep,cc_o_c)
-	$(call cmd,gen_ksymdeps)
 	$(call cmd,checksrc)
 	$(call cmd,checkdoc)
 	$(call cmd,gen_objtooldep)
@@ -237,7 +231,6 @@ endef
 
 define rule_as_o_S
 	$(call cmd_and_fixdep,as_o_S)
-	$(call cmd,gen_ksymdeps)
 	$(call cmd,gen_objtooldep)
 	$(call cmd,gen_symversions_S)
 	$(call cmd,warn_shared_object)
@@ -256,12 +249,6 @@ cmd_mod = printf '%s\n' $(call real-search, $*.o, .o, -objs -y -m) | \
 $(obj)/%.mod: FORCE
 	$(call if_changed,mod)
 
-# List module undefined symbols
-cmd_undefined_syms = $(NM) $< | sed -n 's/^  *U //p' > $@
-
-$(obj)/%.usyms: $(obj)/%.o FORCE
-	$(call if_changed,undefined_syms)
-
 quiet_cmd_cc_lst_c = MKLST   $@
       cmd_cc_lst_c = $(CC) $(c_flags) -g -c -o $*.o $< && \
 		     $(CONFIG_SHELL) $(srctree)/scripts/makelst $*.o \
scripts/Makefile.modpost +7 -0
index 074e27c0c140..65133fcdd5b8 100644
@@ -91,6 +91,13 @@ targets += .vmlinux.objs
 .vmlinux.objs: vmlinux.a $(KBUILD_VMLINUX_LIBS) FORCE
 	$(call if_changed,vmlinux_objs)
 
+ifdef CONFIG_TRIM_UNUSED_KSYMS
+ksym-wl := $(CONFIG_UNUSED_KSYMS_WHITELIST)
+ksym-wl := $(if $(filter-out /%, $(ksym-wl)),$(srctree)/)$(ksym-wl)
+modpost-args += -t $(addprefix -u, $(ksym-wl))
+modpost-deps += $(ksym-wl)
+endif
+
 ifeq ($(wildcard vmlinux.o),)
 missing-input := vmlinux.o
 output-symdump := modules-only.symvers
scripts/adjust_autoksyms.sh deleted +0 -73

73 lines not on this page · raw message

scripts/basic/fixdep.c +1 -2
index fa562806c2be..84b6efa849f4 100644
@@ -246,8 +246,7 @@ static void *read_file(const char *filename)
 /* Ignore certain dependencies */
 static int is_ignored_file(const char *s, int len)
 {
-	return str_ends_with(s, len, "include/generated/autoconf.h") ||
-	       str_ends_with(s, len, "include/generated/autoksyms.h");
+	return str_ends_with(s, len, "include/generated/autoconf.h");
 }
 
 /* Do not parse these files */
scripts/gen_autoksyms.sh deleted +0 -62

62 lines not on this page · raw message

scripts/gen_ksymdeps.sh deleted +0 -30
deleted file mode 100755
index 8ee533f33659..000000000000
@@ -1,30 +0,0 @@
-#!/bin/sh
-# SPDX-License-Identifier: GPL-2.0
-
-set -e
-
-# List of exported symbols
-#
-# If the object has no symbol, $NM warns 'no symbols'.
-# Suppress the stderr.
-# TODO:
-#   Use -q instead of 2>/dev/null when we upgrade the minimum version of
-#   binutils to 2.37, llvm to 13.0.0.
-ksyms=$($NM $1 2>/dev/null | sed -n 's/.*__ksym_marker_\(.*\)/\1/p')
-
-if [ -z "$ksyms" ]; then
-	exit 0
-fi
-
-echo
-echo "ksymdeps_$1 := \\"
-
-for s in $ksyms
-do
-	printf '    $(wildcard include/ksym/%s) \\\n' "$s"
-done
-
-echo
-echo "$1: \$(ksymdeps_$1)"
-echo
-echo "\$(ksymdeps_$1):"
scripts/mod/modpost.c +49 -5

122 lines not on this page · raw message

scripts/remove-stale-files +4 -0
index 7f432900671a..f3659ea0335b 100755
@@ -33,3 +33,7 @@ rm -f rust/target.json
 rm -f scripts/bin2c
 
 rm -f .scmversion
+
+rm -rf include/ksym
+
+find . -name '*.usyms' | xargs rm -f
Signature · 7 lines
2.39.2


_______________________________________________
linux-um mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-um
#15 lore raw

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

kernel test robot noticed the following build errors:

Hi Masahiro,

kernel test robot noticed the following build errors:

[auto build test ERROR on masahiroy-kbuild/for-next]
[also build test ERROR on next-20230608]
[cannot apply to masahiroy-kbuild/fixes arnd-asm-generic/master rafael-pm/linux-next linus/master v6.4-rc5] [If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Masahiro-Yamada/Revert-PATCH-uml-export-symbols-added-by-GCC-hardened/20230608-223125
base:   https://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild.git for-next
patch link:    https://lore.kernel.org/r/20230608142428.256985-9-masahiroy%40kernel.org
patch subject: [PATCH v7 08/11] kbuild: implement CONFIG_TRIM_UNUSED_KSYMS without recursion
config: xtensa-randconfig-r025-20230608 (https://download.01.org/0day-ci/archive/20230609/[email protected]/config)
compiler: xtensa-linux-gcc (GCC) 12.3.0

reproduce (this is a W=1 build):
mkdir -p ~/bin
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
git remote add masahiroy-kbuild https://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild.git
git fetch masahiroy-kbuild for-next
git checkout masahiroy-kbuild/for-next
b4 shazam https://lore.kernel.org/r/[email protected]
# save the config file
mkdir build_dir && cp config build_dir/.config
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.3.0 ~/bin/make.cross W=1 O=build_dir ARCH=xtensa olddefconfig COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.3.0 ~/bin/make.cross W=1 O=build_dir ARCH=xtensa SHELL=/bin/bash kernel/

If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/

All errors (new ones prefixed by >>):

{standard input}: Assembler messages:

>> {standard input}:6: Error: can't resolve prof_on - L0
>> {standard input}:7: Error: can't resolve profile_hits - L0

--
{standard input}: Assembler messages:
{standard input}:6: Error: can't resolve __put_cred - L0 {standard input}:7: Error: can't resolve get_task_cred - L0 {standard input}:8: Error: can't resolve prepare_creds - L0 {standard input}:9: Error: can't resolve commit_creds - L0 {standard input}:10: Error: can't resolve abort_creds - L0 {standard input}:11: Error: can't resolve override_creds - L0 {standard input}:12: Error: can't resolve revert_creds - L0 {standard input}:13: Error: can't resolve cred_fscmp - L0 {standard input}:14: Error: can't resolve prepare_kernel_cred - L0 {standard input}:15: Error: can't resolve set_security_override - L0 {standard input}:16: Error: can't resolve set_security_override_from_ctx - L0 {standard input}:17: Error: can't resolve set_create_files_as - L0

>> {standard input}:18: Error: can't resolve creds_are_invalid - L0
>> {standard input}:19: Error: can't resolve __invalid_creds - L0
>> {standard input}:20: Error: can't resolve __validate_process_creds - L0
--
   {standard input}: Assembler messages:
   {standard input}:6: Error: can't resolve context_tracking - L0
>> {standard input}:7: Error: can't resolve ct_idle_enter - L0
>> {standard input}:8: Error: can't resolve ct_idle_exit - L0

{standard input}:9: Error: can't resolve context_tracking_key - L0 {standard input}:10: Error: can't resolve __ct_user_enter - L0 {standard input}:11: Error: can't resolve ct_user_enter - L0 {standard input}:12: Error: can't resolve __ct_user_exit - L0 {standard input}:13: Error: can't resolve ct_user_exit - L0
--
{standard input}: Assembler messages:

>> {standard input}:6: Error: can't resolve rcu_scheduler_active - L0
>> {standard input}:7: Error: can't resolve rcu_get_gp_kthreads_prio - L0
>> {standard input}:8: Error: can't resolve rcu_momentary_dyntick_idle - L0
>> {standard input}:9: Error: can't resolve rcu_get_gp_seq - L0
>> {standard input}:10: Error: can't resolve rcu_exp_batches_completed - L0
>> {standard input}:11: Error: can't resolve rcutorture_get_gp_data - L0
>> {standard input}:12: Error: can't resolve rcu_is_watching - L0
>> {standard input}:13: Error: can't resolve rcu_gp_slow_register - L0
>> {standard input}:14: Error: can't resolve rcu_gp_slow_unregister - L0
>> {standard input}:15: Error: can't resolve rcu_gp_set_torture_wait - L0
>> {standard input}:16: Error: can't resolve rcu_force_quiescent_state - L0
   {standard input}:17: Error: can't resolve call_rcu - L0
   {standard input}:18: Error: can't resolve kvfree_call_rcu - L0
   {standard input}:19: Error: can't resolve synchronize_rcu - L0
   {standard input}:20: Error: can't resolve get_completed_synchronize_rcu_full - L0
   {standard input}:21: Error: can't resolve get_state_synchronize_rcu - L0
>> {standard input}:22: Error: can't resolve get_state_synchronize_rcu_full - L0
   {standard input}:23: Error: can't resolve start_poll_synchronize_rcu - L0
>> {standard input}:24: Error: can't resolve start_poll_synchronize_rcu_full - L0
   {standard input}:25: Error: can't resolve poll_state_synchronize_rcu - L0
>> {standard input}:26: Error: can't resolve poll_state_synchronize_rcu_full - L0
>> {standard input}:27: Error: can't resolve cond_synchronize_rcu - L0
>> {standard input}:28: Error: can't resolve cond_synchronize_rcu_full - L0
   {standard input}:29: Error: can't resolve rcu_barrier - L0
>> {standard input}:30: Error: can't resolve rcu_exp_jiffies_till_stall_check - L0
>> {standard input}:31: Error: can't resolve rcu_jiffies_till_stall_check - L0
>> {standard input}:32: Error: can't resolve rcu_check_boost_fail - L0
>> {standard input}:33: Error: can't resolve show_rcu_gp_kthreads - L0

{standard input}:34: Error: can't resolve rcu_fwd_progress_check - L0 {standard input}:35: Error: can't resolve synchronize_rcu_expedited - L0 {standard input}:36: Error: can't resolve start_poll_synchronize_rcu_expedited - L0 {standard input}:37: Error: can't resolve start_poll_synchronize_rcu_expedited_full - L0 {standard input}:38: Error: can't resolve cond_synchronize_rcu_expedited - L0 {standard input}:39: Error: can't resolve cond_synchronize_rcu_expedited_full - L0 {standard input}:40: Error: can't resolve rcu_nocb_flush_deferred_wakeup - L0 {standard input}:41: Error: can't resolve rcu_nocb_cpu_deoffload - L0 {standard input}:42: Error: can't resolve rcu_nocb_cpu_offload - L0 {standard input}:43: Error: can't resolve rcu_bind_current_to_nocb - L0 {standard input}:44: Error: can't resolve rcu_note_context_switch - L0 {standard input}:45: Error: can't resolve __rcu_read_lock - L0
{standard input}:46: Error: can't resolve __rcu_read_unlock - L0
--
{standard input}: Assembler messages:

>> {standard input}:6: Error: can't resolve rcu_gp_is_normal - L0
>> {standard input}:7: Error: can't resolve rcu_async_should_hurry - L0
>> {standard input}:8: Error: can't resolve rcu_async_hurry - L0
>> {standard input}:9: Error: can't resolve rcu_async_relax - L0
>> {standard input}:10: Error: can't resolve rcu_gp_is_expedited - L0
>> {standard input}:11: Error: can't resolve rcu_expedite_gp - L0
>> {standard input}:12: Error: can't resolve rcu_unexpedite_gp - L0
>> {standard input}:13: Error: can't resolve rcu_inkernel_boot_has_ended - L0
   {standard input}:14: Error: can't resolve wakeme_after_rcu - L0
   {standard input}:15: Error: can't resolve __wait_rcu_gp - L0
   {standard input}:16: Error: can't resolve finish_rcuwait - L0
>> {standard input}:17: Error: can't resolve init_rcu_head - L0
>> {standard input}:18: Error: can't resolve destroy_rcu_head - L0
>> {standard input}:19: Error: can't resolve init_rcu_head_on_stack - L0
>> {standard input}:20: Error: can't resolve destroy_rcu_head_on_stack - L0
>> {standard input}:21: Error: can't resolve rcuhead_debug_descr - L0
   {standard input}:22: Error: can't resolve do_trace_rcu_torture_read - L0
>> {standard input}:23: Error: can't resolve rcu_cpu_stall_suppress - L0
   {standard input}:24: Error: can't resolve rcu_cpu_stall_suppress_at_boot - L0
   {standard input}:25: Error: can't resolve get_completed_synchronize_rcu - L0
   {standard input}:26: Error: can't resolve call_rcu_tasks - L0
   {standard input}:27: Error: can't resolve synchronize_rcu_tasks - L0
   {standard input}:28: Error: can't resolve rcu_barrier_tasks - L0
>> {standard input}:29: Error: can't resolve show_rcu_tasks_classic_gp_kthread - L0

--
{standard input}: Assembler messages:
{standard input}:6: Error: can't resolve init_srcu_struct - L0 {standard input}:7: Error: can't resolve cleanup_srcu_struct - L0

>> {standard input}:8: Error: can't resolve __srcu_read_lock - L0
   {standard input}:9: Error: can't resolve __srcu_read_unlock - L0
   {standard input}:10: Error: can't resolve call_srcu - L0
>> {standard input}:11: Error: can't resolve synchronize_srcu_expedited - L0
   {standard input}:12: Error: can't resolve synchronize_srcu - L0
   {standard input}:13: Error: can't resolve get_state_synchronize_srcu - L0
   {standard input}:14: Error: can't resolve start_poll_synchronize_srcu - L0
   {standard input}:15: Error: can't resolve poll_state_synchronize_srcu - L0
>> {standard input}:16: Error: can't resolve srcu_barrier - L0
>> {standard input}:17: Error: can't resolve srcu_batches_completed - L0
>> {standard input}:18: Error: can't resolve srcutorture_get_gp_data - L0
>> {standard input}:19: Error: can't resolve srcu_torture_stats_print - L0

--
kernel/sched/core.c:6778:35: warning: no previous prototype for 'schedule_user' [-Wmissing-prototypes]
6778 | asmlinkage __visible void __sched schedule_user(void)
| ^~~~~~~~~~~~~
{standard input}: Assembler messages:
{standard input}:6: Error: can't resolve __tracepoint_ipi_send_cpu - L0
{standard input}:7: Error: can't resolve __traceiter_ipi_send_cpu - L0
{standard input}:8: Error: can't resolve __SCK__tp_func_ipi_send_cpu - L0
{standard input}:9: Error: can't resolve __tracepoint_ipi_send_cpumask - L0 {standard input}:10: Error: can't resolve __traceiter_ipi_send_cpumask - L0 {standard input}:11: Error: can't resolve __SCK__tp_func_ipi_send_cpumask - L0 {standard input}:12: Error: can't resolve __tracepoint_pelt_cfs_tp - L0
{standard input}:13: Error: can't resolve __traceiter_pelt_cfs_tp - L0
{standard input}:14: Error: can't resolve __SCK__tp_func_pelt_cfs_tp - L0
{standard input}:15: Error: can't resolve __tracepoint_pelt_rt_tp - L0
{standard input}:16: Error: can't resolve __traceiter_pelt_rt_tp - L0
{standard input}:17: Error: can't resolve __SCK__tp_func_pelt_rt_tp - L0
{standard input}:18: Error: can't resolve __tracepoint_pelt_dl_tp - L0
{standard input}:19: Error: can't resolve __traceiter_pelt_dl_tp - L0
{standard input}:20: Error: can't resolve __SCK__tp_func_pelt_dl_tp - L0
{standard input}:21: Error: can't resolve __tracepoint_pelt_irq_tp - L0
{standard input}:22: Error: can't resolve __traceiter_pelt_irq_tp - L0
{standard input}:23: Error: can't resolve __SCK__tp_func_pelt_irq_tp - L0
{standard input}:24: Error: can't resolve __tracepoint_pelt_se_tp - L0
{standard input}:25: Error: can't resolve __traceiter_pelt_se_tp - L0
{standard input}:26: Error: can't resolve __SCK__tp_func_pelt_se_tp - L0
{standard input}:27: Error: can't resolve __tracepoint_pelt_thermal_tp - L0 {standard input}:28: Error: can't resolve __traceiter_pelt_thermal_tp - L0
{standard input}:29: Error: can't resolve __SCK__tp_func_pelt_thermal_tp - L0 {standard input}:30: Error: can't resolve __tracepoint_sched_cpu_capacity_tp - L0 {standard input}:31: Error: can't resolve __traceiter_sched_cpu_capacity_tp - L0 {standard input}:32: Error: can't resolve __SCK__tp_func_sched_cpu_capacity_tp - L0 {standard input}:33: Error: can't resolve __tracepoint_sched_overutilized_tp - L0 {standard input}:34: Error: can't resolve __traceiter_sched_overutilized_tp - L0 {standard input}:35: Error: can't resolve __SCK__tp_func_sched_overutilized_tp - L0 {standard input}:36: Error: can't resolve __tracepoint_sched_util_est_cfs_tp - L0 {standard input}:37: Error: can't resolve __traceiter_sched_util_est_cfs_tp - L0 {standard input}:38: Error: can't resolve __SCK__tp_func_sched_util_est_cfs_tp - L0 {standard input}:39: Error: can't resolve __tracepoint_sched_util_est_se_tp - L0 {standard input}:40: Error: can't resolve __traceiter_sched_util_est_se_tp - L0 {standard input}:41: Error: can't resolve __SCK__tp_func_sched_util_est_se_tp - L0 {standard input}:42: Error: can't resolve __tracepoint_sched_update_nr_running_tp - L0 {standard input}:43: Error: can't resolve __traceiter_sched_update_nr_running_tp - L0 {standard input}:44: Error: can't resolve __SCK__tp_func_sched_update_nr_running_tp - L0 {standard input}:45: Error: can't resolve wake_up_process - L0
{standard input}:46: Error: can't resolve single_task_running - L0
{standard input}:47: Error: can't resolve kstat - L0
{standard input}:48: Error: can't resolve kernel_cpustat - L0
{standard input}:49: Error: can't resolve schedule - L0

>> {standard input}:50: Error: can't resolve preempt_schedule - L0
>> {standard input}:51: Error: can't resolve preempt_schedule_notrace - L0

{standard input}:52: Error: can't resolve default_wake_function - L0 {standard input}:53: Error: can't resolve set_user_nice - L0 {standard input}:54: Error: can't resolve sched_setattr_nocheck - L0 {standard input}:55: Error: can't resolve sched_set_fifo - L0 {standard input}:56: Error: can't resolve sched_set_fifo_low - L0 {standard input}:57: Error: can't resolve sched_set_normal - L0 {standard input}:58: Error: can't resolve __cond_resched_lock - L0 {standard input}:59: Error: can't resolve __cond_resched_rwlock_read - L0 {standard input}:60: Error: can't resolve __cond_resched_rwlock_write - L0 {standard input}:61: Error: can't resolve yield - L0 {standard input}:62: Error: can't resolve yield_to - L0 {standard input}:63: Error: can't resolve io_schedule_timeout - L0 {standard input}:64: Error: can't resolve io_schedule - L0 {standard input}:65: Error: can't resolve sched_show_task - L0

Signature · 2 lines
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
#16 lore raw

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

In reply to Masahiro Yamada
kernel test robot noticed the following build errors:

Hi Masahiro,

kernel test robot noticed the following build errors:

[auto build test ERROR on masahiroy-kbuild/for-next]
[also build test ERROR on next-20230608]
[cannot apply to masahiroy-kbuild/fixes arnd-asm-generic/master rafael-pm/linux-next linus/master v6.4-rc5] [If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Masahiro-Yamada/Revert-PATCH-uml-export-symbols-added-by-GCC-hardened/20230608-223125
base:   https://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild.git for-next
patch link:    https://lore.kernel.org/r/20230608142428.256985-9-masahiroy%40kernel.org
patch subject: [PATCH v7 08/11] kbuild: implement CONFIG_TRIM_UNUSED_KSYMS without recursion
config: um-x86_64_defconfig (https://download.01.org/0day-ci/archive/20230609/[email protected]/config)
compiler: clang version 15.0.7 (https://github.com/llvm/llvm-project.git 8dfdcc7b7bf66834a761bd8de445840ef68e4d1a)

reproduce (this is a W=1 build):
mkdir -p ~/bin
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# install um cross compiling tool for clang build
# apt-get install binutils-um-linux-gnu
git remote add masahiroy-kbuild https://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild.git
git fetch masahiroy-kbuild for-next
git checkout masahiroy-kbuild/for-next
b4 shazam https://lore.kernel.org/r/[email protected]
# save the config file
mkdir build_dir && cp config build_dir/.config
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang ~/bin/make.cross W=1 O=build_dir ARCH=um olddefconfig COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang ~/bin/make.cross W=1 O=build_dir ARCH=um SHELL=/bin/bash M=block

If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/

All errors (new ones prefixed by >>):

>> make[2]: *** No rule to make target 'block/bfq.ko', needed by '__modfinal'.
   make[2]: Target '__modfinal' not remade because of errors.
--
>> make[2]: *** No rule to make target 'drivers/net/dummy.ko', needed by '__modfinal'.
>> make[2]: *** No rule to make target 'drivers/net/tun.ko', needed by '__modfinal'.
>> make[2]: *** No rule to make target 'drivers/net/ppp/ppp_generic.ko', needed by '__modfinal'.
>> make[2]: *** No rule to make target 'drivers/net/slip/slip.ko', needed by '__modfinal'.
>> make[2]: *** No rule to make target 'drivers/net/slip/slhc.ko', needed by '__modfinal'.
   make[2]: Target '__modfinal' not remade because of errors.
--
>> make[2]: *** No rule to make target 'fs/isofs/isofs.ko', needed by '__modfinal'.
   make[2]: Target '__modfinal' not remade because of errors.
--
>> make[2]: *** No rule to make target 'sound/soundcore.ko', needed by '__modfinal'.

make[2]: Target '__modfinal' not remade because of errors.

Signature · 2 lines
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
#17 lore raw

PATCH v7 9/11 modpost: merge two similar section mismatch warnings

In reply to 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.

---

 scripts/mod/modpost.c | 18 +++---------------
 1 file changed, 3 insertions(+), 15 deletions(-)
scripts/mod/modpost.c +3 -15
index decb7d23ef9f..85df3f3ba9ee 100644
@@ -1147,21 +1147,10 @@ static void default_mismatch_handler(const char *modname, struct elf_info *elf,
 
 	sec_mismatch_count++;
 
-	switch (mismatch->mismatch) {
-	case TEXT_TO_ANY_INIT:
-	case DATA_TO_ANY_INIT:
-	case TEXTDATA_TO_ANY_EXIT:
-	case XXXINIT_TO_SOME_INIT:
-	case XXXEXIT_TO_SOME_EXIT:
-	case ANY_INIT_TO_ANY_EXIT:
-	case ANY_EXIT_TO_ANY_INIT:
-		warn("%s: section mismatch in reference: %s (section: %s) -> %s (section: %s)\n",
-		     modname, fromsym, fromsec, tosym, tosec);
-		break;
-	case EXTABLE_TO_NON_TEXT:
-		warn("%s(%s+0x%lx): Section mismatch in reference to the %s:%s\n",
-		     modname, fromsec, (long)faddr, tosec, tosym);
+	warn("%s: section mismatch in reference: %s (section: %s) -> %s (section: %s)\n",
+	     modname, fromsym, fromsec, tosym, tosec);
 
+	if (mismatch->mismatch == EXTABLE_TO_NON_TEXT) {
 		if (match(tosec, mismatch->bad_tosec))
 			fatal("The relocation at %s+0x%lx references\n"
 			      "section \"%s\" which is black-listed.\n"
@@ -1181,7 +1170,6 @@ static void default_mismatch_handler(const char *modname, struct elf_info *elf,
 		else
 			error("%s+0x%lx references non-executable section '%s'\n",
 			      fromsec, (long)faddr, tosec);
-		break;
 	}
 }
 
Signature · 7 lines
2.39.2


_______________________________________________
linux-um mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-um
#18 lore raw

PATCH v7 10/11 modpost: show offset from symbol for section mismatch warnings

In reply to 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.

---

 scripts/mod/modpost.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
scripts/mod/modpost.c +2 -2
index 85df3f3ba9ee..40967ed816df 100644
@@ -1147,8 +1147,8 @@ static void default_mismatch_handler(const char *modname, struct elf_info *elf,
 
 	sec_mismatch_count++;
 
-	warn("%s: section mismatch in reference: %s (section: %s) -> %s (section: %s)\n",
-	     modname, fromsym, fromsec, tosym, tosec);
+	warn("%s: section mismatch in reference: %s+0x%x (section: %s) -> %s (section: %s)\n",
+	     modname, fromsym, (unsigned int)(faddr - from->st_value), fromsec, tosym, tosec);
 
 	if (mismatch->mismatch == EXTABLE_TO_NON_TEXT) {
 		if (match(tosec, mismatch->bad_tosec))
Signature · 7 lines
2.39.2


_______________________________________________
linux-um mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-um
Reviewed-by on v7 10/11
#19 lore raw

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

Quoted 8 lines · 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.

Thanks for the patch!

Quoted 23 lines

---

 scripts/mod/modpost.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
scripts/mod/modpost.c +2 -3
index 85df3f3ba9ee..40967ed816df 100644
@@ -1147,8 +1147,8 @@ static void default_mismatch_handler(const char *modname, struct elf_info *elf,
 
        sec_mismatch_count++;
 
-       warn("%s: section mismatch in reference: %s (section: %s) -> %s (section: %s)\n",
-            modname, fromsym, fromsec, tosym, tosec);
+       warn("%s: section mismatch in reference: %s+0x%x (section: %s) -> %s (section: %s)\n",
+            modname, fromsym, (unsigned int)(faddr - from->st_value), fromsec, tosym, tosec);
 
        if (mismatch->mismatch == EXTABLE_TO_NON_TEXT) {
                if (match(tosec, mismatch->bad_tosec))
--

2.39.2

Signature · 2 lines
Thanks,
~Nick Desaulniers
#20 lore raw

PATCH v7 11/11 linux/export.h: rename 'sec' argument to 'license'

In reply to 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'.

---

Changes in v7:
- New patch

 include/linux/export.h | 8 ++++----
 include/linux/pm.h     | 6 +++---
 2 files changed, 7 insertions(+), 7 deletions(-)
include/linux/export.h +4 -4
index fed2e5717461..b411fdb88720 100644
@@ -46,11 +46,11 @@ extern struct module __this_module;
  * be reused in other execution contexts such as the UEFI stub or the
  * decompressor.
  */
-#define __EXPORT_SYMBOL(sym, sec, ns)
+#define __EXPORT_SYMBOL(sym, license, ns)
 
 #elif defined(__GENKSYMS__)
 
-#define __EXPORT_SYMBOL(sym, sec, ns)	__GENKSYMS_EXPORT_SYMBOL(sym)
+#define __EXPORT_SYMBOL(sym, license, ns)	__GENKSYMS_EXPORT_SYMBOL(sym)
 
 #elif defined(__ASSEMBLY__)
 
@@ -67,9 +67,9 @@ extern struct module __this_module;
 #endif /* CONFIG_MODULES */
 
 #ifdef DEFAULT_SYMBOL_NAMESPACE
-#define _EXPORT_SYMBOL(sym, sec)	__EXPORT_SYMBOL(sym, sec, __stringify(DEFAULT_SYMBOL_NAMESPACE))
+#define _EXPORT_SYMBOL(sym, license)	__EXPORT_SYMBOL(sym, license, __stringify(DEFAULT_SYMBOL_NAMESPACE))
 #else
-#define _EXPORT_SYMBOL(sym, sec)	__EXPORT_SYMBOL(sym, sec, "")
+#define _EXPORT_SYMBOL(sym, license)	__EXPORT_SYMBOL(sym, license, "")
 #endif
 
 #define EXPORT_SYMBOL(sym)		_EXPORT_SYMBOL(sym,)
include/linux/pm.h +3 -3
index aabb6bd8f89e..1810d776e84a 100644
@@ -375,14 +375,14 @@ const struct dev_pm_ops name = { \
 }
 
 #ifdef CONFIG_PM
-#define _EXPORT_DEV_PM_OPS(name, sec, ns)				\
+#define _EXPORT_DEV_PM_OPS(name, license, ns)				\
 	const struct dev_pm_ops name;					\
-	__EXPORT_SYMBOL(name, sec, ns);					\
+	__EXPORT_SYMBOL(name, license, ns);				\
 	const struct dev_pm_ops name
 #define EXPORT_PM_FN_GPL(name)		EXPORT_SYMBOL_GPL(name)
 #define EXPORT_PM_FN_NS_GPL(name, ns)	EXPORT_SYMBOL_NS_GPL(name, ns)
 #else
-#define _EXPORT_DEV_PM_OPS(name, sec, ns)				\
+#define _EXPORT_DEV_PM_OPS(name, license, ns)				\
 	static __maybe_unused const struct dev_pm_ops __static_##name
 #define EXPORT_PM_FN_GPL(name)
 #define EXPORT_PM_FN_NS_GPL(name, ns)
Signature · 7 lines
2.39.2


_______________________________________________
linux-um mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-um
Reviewed-by on v7 11/11
#21 lore raw

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

Quoted 8 lines · 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'.

Thanks for the patch!

Quoted 64 lines

---

Changes in v7:
- New patch

 include/linux/export.h | 8 ++++----
 include/linux/pm.h     | 6 +++---
 2 files changed, 7 insertions(+), 7 deletions(-)
include/linux/export.h +4 -4
index fed2e5717461..b411fdb88720 100644
@@ -46,11 +46,11 @@ extern struct module __this_module;
  * be reused in other execution contexts such as the UEFI stub or the
  * decompressor.
  */
-#define __EXPORT_SYMBOL(sym, sec, ns)
+#define __EXPORT_SYMBOL(sym, license, ns)
 
 #elif defined(__GENKSYMS__)
 
-#define __EXPORT_SYMBOL(sym, sec, ns)  __GENKSYMS_EXPORT_SYMBOL(sym)
+#define __EXPORT_SYMBOL(sym, license, ns)      __GENKSYMS_EXPORT_SYMBOL(sym)
 
 #elif defined(__ASSEMBLY__)
 
@@ -67,9 +67,9 @@ extern struct module __this_module;
 #endif /* CONFIG_MODULES */
 
 #ifdef DEFAULT_SYMBOL_NAMESPACE
-#define _EXPORT_SYMBOL(sym, sec)       __EXPORT_SYMBOL(sym, sec, __stringify(DEFAULT_SYMBOL_NAMESPACE))
+#define _EXPORT_SYMBOL(sym, license)   __EXPORT_SYMBOL(sym, license, __stringify(DEFAULT_SYMBOL_NAMESPACE))
 #else
-#define _EXPORT_SYMBOL(sym, sec)       __EXPORT_SYMBOL(sym, sec, "")
+#define _EXPORT_SYMBOL(sym, license)   __EXPORT_SYMBOL(sym, license, "")
 #endif
 
 #define EXPORT_SYMBOL(sym)             _EXPORT_SYMBOL(sym,)
include/linux/pm.h +3 -4
index aabb6bd8f89e..1810d776e84a 100644
@@ -375,14 +375,14 @@ const struct dev_pm_ops name = { \
 }
 
 #ifdef CONFIG_PM
-#define _EXPORT_DEV_PM_OPS(name, sec, ns)                              \
+#define _EXPORT_DEV_PM_OPS(name, license, ns)                          \
        const struct dev_pm_ops name;                                   \
-       __EXPORT_SYMBOL(name, sec, ns);                                 \
+       __EXPORT_SYMBOL(name, license, ns);                             \
        const struct dev_pm_ops name
 #define EXPORT_PM_FN_GPL(name)         EXPORT_SYMBOL_GPL(name)
 #define EXPORT_PM_FN_NS_GPL(name, ns)  EXPORT_SYMBOL_NS_GPL(name, ns)
 #else
-#define _EXPORT_DEV_PM_OPS(name, sec, ns)                              \
+#define _EXPORT_DEV_PM_OPS(name, license, ns)                          \
        static __maybe_unused const struct dev_pm_ops __static_##name
 #define EXPORT_PM_FN_GPL(name)
 #define EXPORT_PM_FN_NS_GPL(name, ns)
--

2.39.2

Signature · 2 lines
Thanks,
~Nick Desaulniers