mirror of
https://github.com/torvalds/linux.git
synced 2025-04-09 14:45:27 +00:00
Kbuild fixes for v6.14
- 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 -----BEGIN PGP SIGNATURE----- iQJJBAABCgAzFiEEbmPs18K1szRHjPqEPYsBB53g2wYFAmeo5gQVHG1hc2FoaXJv eUBrZXJuZWwub3JnAAoJED2LAQed4NsGi88P/iAqMfFzT5VbnZfoI5HFplDY7Loi OTHR0h7b0FOPBEYDkhz2clZynFVQj+5GxuDoBTDuf5Y6794XHSZgqee9kWI9oPFW V20m1XdnFwlg2eqDJhOr18aWTZs5IBYBq1CO6h5RfrPjkHOq/8XHpYQ2sMP8wD49 GfGE47uNfcQdqZ/Vf0+VJFIACe5d4+MfBbUPMGGZVNlVD7q7jZIqYRR9BydaWLjy gdUtbEfT78Mg9WxMOSpRj/BhlVup6DZmyz9b8t+dxzIpIo50VZxLUt3yafeyotsG OveOmNu5OXt5Oc9m6/etxSkqii3MYEBXW2LCZJvaoA8groAWzh82HD7gJqhzj/X2 gKankeYYr2Ahg3SLW4NdAKMAY3P5iMPi94iRr2SpIDvoFnI+hujFeNA6814UvQOQ mRLta/vHoCPvtwhGSkpFdwEWJWSjSfwXttK/OoHpGLtu9BZIG/olO0MICP/1x4iz u3BcgeblEejFi5fSlqxwU3MLfafaFdDLbqhHuUftigNLm1QqXnGuUGivOWy2B2EI 3S9SdM3l9cPQehydFfiBnp17LcHrGbavxmgTbLRQo+ete7HAdre24ozt1+Ic5OJZ x6x1CGfB7/+v/EXNjYSEr1ETMfJSc0L/yqtbcGPEy5TegYFtdthLvFMizJFNRsap z/ISKxqK8TScKj7g =uAVD -----END PGP SIGNATURE----- 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
This commit is contained in:
commit
69b54314c9
@ -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*) \
|
||||
|
@ -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 {
|
||||
|
@ -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)
|
||||
|
||||
|
@ -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) $@)
|
||||
|
@ -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;
|
||||
|
||||
|
@ -111,6 +111,8 @@ struct module_alias {
|
||||
*
|
||||
* @dump_file: path to the .symvers file if loaded from a file
|
||||
* @aliases: list head for module_aliases
|
||||
* @no_trim_symbol: .no_trim_symbol section data
|
||||
* @no_trim_symbol_len: length of the .no_trim_symbol section
|
||||
*/
|
||||
struct module {
|
||||
struct list_head list;
|
||||
@ -128,6 +130,8 @@ struct module {
|
||||
// Actual imported namespaces
|
||||
struct list_head imported_namespaces;
|
||||
struct list_head aliases;
|
||||
char *no_trim_symbol;
|
||||
unsigned int no_trim_symbol_len;
|
||||
char name[];
|
||||
};
|
||||
|
||||
@ -141,6 +145,8 @@ struct elf_info {
|
||||
char *strtab;
|
||||
char *modinfo;
|
||||
unsigned int modinfo_len;
|
||||
char *no_trim_symbol;
|
||||
unsigned int no_trim_symbol_len;
|
||||
|
||||
/* support for 32bit section numbers */
|
||||
|
||||
|
@ -16,6 +16,7 @@ SECTIONS {
|
||||
*(.discard)
|
||||
*(.discard.*)
|
||||
*(.export_symbol)
|
||||
*(.no_trim_symbol)
|
||||
}
|
||||
|
||||
__ksymtab 0 : ALIGN(8) { *(SORT(___ksymtab+*)) }
|
||||
|
@ -63,7 +63,7 @@ if [ "${CC}" != "${HOSTCC}" ]; then
|
||||
# Clear VPATH and srcroot because the source files reside in the output
|
||||
# directory.
|
||||
# shellcheck disable=SC2016 # $(MAKE), $(CC), and $(build) will be expanded by Make
|
||||
"${MAKE}" run-command KBUILD_RUN_COMMAND='+$(MAKE) HOSTCC=$(CC) VPATH= srcroot=. $(build)='"${destdir}"/scripts
|
||||
"${MAKE}" run-command KBUILD_RUN_COMMAND='+$(MAKE) HOSTCC="$(CC)" VPATH= srcroot=. $(build)='"${destdir}"/scripts
|
||||
|
||||
rm -f "${destdir}/scripts/Kbuild"
|
||||
fi
|
||||
|
Loading…
x
Reference in New Issue
Block a user