Commit 69b54314 authored by Linus Torvalds's avatar Linus Torvalds
Browse files

Merge tag 'kbuild-fixes-v6.14' of...

Merge tag 'kbuild-fixes-v6.14' of git://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild

Pull Kbuild fixes from Masahiro Yamada:

 - Suppress false-positive -Wformat-{overflow,truncation}-non-kprintf
   warnings regardless of the W= option

 - Avoid CONFIG_TRIM_UNUSED_KSYMS dropping symbols passed to symbol_get()

 - Fix a build regression of the Debian linux-headers package

* tag 'kbuild-fixes-v6.14' of git://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild:
  kbuild: install-extmod-build: add missing quotation marks for CC variable
  kbuild: fix misspelling in scripts/Makefile.lib
  kbuild: keep symbols for symbol_get() even with CONFIG_TRIM_UNUSED_KSYMS
  scripts/Makefile.extrawarn: Do not show clang's non-kprintf warnings at W=1
parents 146339dd f354fc88
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -1038,6 +1038,7 @@ defined(CONFIG_AUTOFDO_CLANG) || defined(CONFIG_PROPELLER_CLANG)
	*(.discard)							\
	*(.discard.*)							\
	*(.export_symbol)						\
	*(.no_trim_symbol)						\
	*(.modinfo)							\
	/* ld.bfd warns about .gnu.version* even when not emitted */	\
	*(.gnu.version*)						\
+4 −1
Original line number Diff line number Diff line
@@ -306,7 +306,10 @@ extern int modules_disabled; /* for sysctl */
/* Get/put a kernel symbol (calls must be symmetric) */
void *__symbol_get(const char *symbol);
void *__symbol_get_gpl(const char *symbol);
#define symbol_get(x) ((typeof(&x))(__symbol_get(__stringify(x))))
#define symbol_get(x)	({ \
	static const char __notrim[] \
		__used __section(".no_trim_symbol") = __stringify(x); \
	(typeof(&x))(__symbol_get(__stringify(x))); })

/* modules using other modules: kdb wants to see this. */
struct module_use {
+5 −5
Original line number Diff line number Diff line
@@ -31,6 +31,11 @@ KBUILD_CFLAGS-$(CONFIG_CC_NO_ARRAY_BOUNDS) += -Wno-array-bounds
ifdef CONFIG_CC_IS_CLANG
# The kernel builds with '-std=gnu11' so use of GNU extensions is acceptable.
KBUILD_CFLAGS += -Wno-gnu

# Clang checks for overflow/truncation with '%p', while GCC does not:
# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111219
KBUILD_CFLAGS += $(call cc-disable-warning, format-overflow-non-kprintf)
KBUILD_CFLAGS += $(call cc-disable-warning, format-truncation-non-kprintf)
else

# gcc inanely warns about local variables called 'main'
@@ -105,11 +110,6 @@ KBUILD_CFLAGS += $(call cc-disable-warning, packed-not-aligned)
KBUILD_CFLAGS += $(call cc-disable-warning, format-overflow)
ifdef CONFIG_CC_IS_GCC
KBUILD_CFLAGS += $(call cc-disable-warning, format-truncation)
else
# Clang checks for overflow/truncation with '%p', while GCC does not:
# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111219
KBUILD_CFLAGS += $(call cc-disable-warning, format-overflow-non-kprintf)
KBUILD_CFLAGS += $(call cc-disable-warning, format-truncation-non-kprintf)
endif
KBUILD_CFLAGS += $(call cc-disable-warning, stringop-truncation)

+1 −1
Original line number Diff line number Diff line
@@ -305,7 +305,7 @@ endef
# These are shared by some Makefile.* files.

ifdef CONFIG_LTO_CLANG
# Run $(LD) here to covert LLVM IR to ELF in the following cases:
# Run $(LD) here to convert LLVM IR to ELF in the following cases:
#  - when this object needs objtool processing, as objtool cannot process LLVM IR
#  - when this is a single-object module, as modpost cannot process LLVM IR
cmd_ld_single = $(if $(objtool-enabled)$(is-single-obj-m), ; $(LD) $(ld_flags) -r -o $(tmp-target) $@; mv $(tmp-target) $@)
+35 −0
Original line number Diff line number Diff line
@@ -507,6 +507,9 @@ static int parse_elf(struct elf_info *info, const char *filename)
			info->modinfo_len = sechdrs[i].sh_size;
		} else if (!strcmp(secname, ".export_symbol")) {
			info->export_symbol_secndx = i;
		} else if (!strcmp(secname, ".no_trim_symbol")) {
			info->no_trim_symbol = (void *)hdr + sechdrs[i].sh_offset;
			info->no_trim_symbol_len = sechdrs[i].sh_size;
		}

		if (sechdrs[i].sh_type == SHT_SYMTAB) {
@@ -1566,6 +1569,14 @@ static void read_symbols(const char *modname)
	/* strip trailing .o */
	mod = new_module(modname, strlen(modname) - strlen(".o"));

	/* save .no_trim_symbol section for later use */
	if (info.no_trim_symbol_len) {
		mod->no_trim_symbol = xmalloc(info.no_trim_symbol_len);
		memcpy(mod->no_trim_symbol, info.no_trim_symbol,
		       info.no_trim_symbol_len);
		mod->no_trim_symbol_len = info.no_trim_symbol_len;
	}

	if (!mod->is_vmlinux) {
		license = get_modinfo(&info, "license");
		if (!license)
@@ -1728,6 +1739,28 @@ static void handle_white_list_exports(const char *white_list)
	free(buf);
}

/*
 * Keep symbols recorded in the .no_trim_symbol section. This is necessary to
 * prevent CONFIG_TRIM_UNUSED_KSYMS from dropping EXPORT_SYMBOL because
 * symbol_get() relies on the symbol being present in the ksymtab for lookups.
 */
static void keep_no_trim_symbols(struct module *mod)
{
	unsigned long size = mod->no_trim_symbol_len;

	for (char *s = mod->no_trim_symbol; s; s = next_string(s , &size)) {
		struct symbol *sym;

		/*
		 * If find_symbol() returns NULL, this symbol is not provided
		 * by any module, and symbol_get() will fail.
		 */
		sym = find_symbol(s);
		if (sym)
			sym->used = true;
	}
}

static void check_modname_len(struct module *mod)
{
	const char *mod_name;
@@ -2254,6 +2287,8 @@ int main(int argc, char **argv)
		read_symbols_from_files(files_source);

	list_for_each_entry(mod, &modules, list) {
		keep_no_trim_symbols(mod);

		if (mod->dump_file || mod->is_vmlinux)
			continue;

Loading