Re: ld.lld: error: undefined symbol: firmware_upload_register
From: Randy Dunlap
Date: Fri Nov 11 2022 - 17:01:25 EST
Hi--
On 11/9/22 04:30, kernel test robot wrote:
> tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
> head: f141df371335645ce29a87d9683a3f79fba7fd67
> commit: 5cd339b370e29b04b85fbb83f40496991465318e fpga: m10bmc-sec: add max10 secure update functions
> date: 5 months ago
> config: mips-buildonly-randconfig-r004-20221109
> compiler: clang version 16.0.0 (https://github.com/llvm/llvm-project 463da45892e2d2a262277b91b96f5f8c05dc25d0)
> reproduce (this is a W=1 build):
> wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
> chmod +x ~/bin/make.cross
> # install mips cross compiling tool for clang build
> # apt-get install binutils-mips-linux-gnu
> # https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=5cd339b370e29b04b85fbb83f40496991465318e
> git remote add linus https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
> git fetch --no-tags linus master
> git checkout 5cd339b370e29b04b85fbb83f40496991465318e
> # save the config file
> mkdir build_dir && cp config build_dir/.config
> COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=mips SHELL=/bin/bash
>
> If you fix the issue, kindly add following tag where applicable
> | Reported-by: kernel test robot <lkp@xxxxxxxxx>
>
> All errors (new ones prefixed by >>):
>
>>> ld.lld: error: undefined symbol: firmware_upload_register
> >>> referenced by intel-m10-bmc-sec-update.c
> >>> fpga/intel-m10-bmc-sec-update.o:(m10bmc_sec_probe) in archive drivers/built-in.a
> --
>>> ld.lld: error: undefined symbol: firmware_upload_unregister
> >>> referenced by intel-m10-bmc-sec-update.c
> >>> fpga/intel-m10-bmc-sec-update.o:(m10bmc_sec_remove) in archive drivers/built-in.a
This happens when (bool) CONFIG_FW_UPLOAD=y and CONFIG_FW_LOADER=m.
Ah, it's the old "bool depending on a tristate" problem.
There may be some Makefile fix for this - I don't know.
Or the Kconfig fix works AFAICT (below). Change FW_UPLOAD to a tristate
and modify 2 header files for exports/inlines.
Luis -- how was FW_LOADER=m and FW_UPLOAD=y supposed to work?
Thanks.
--
---
drivers/base/firmware_loader/Kconfig | 2 +-
drivers/base/firmware_loader/sysfs.h | 2 +-
include/linux/firmware.h | 2 +-
3 files changed, 3 insertions(+), 3 deletions(-)
diff -- a/drivers/base/firmware_loader/Kconfig b/drivers/base/firmware_loader/Kconfig
--- a/drivers/base/firmware_loader/Kconfig
+++ b/drivers/base/firmware_loader/Kconfig
@@ -204,7 +204,7 @@ config FW_CACHE
If unsure, say Y.
config FW_UPLOAD
- bool "Enable users to initiate firmware updates using sysfs"
+ tristate "Enable users to initiate firmware updates using sysfs"
select FW_LOADER_SYSFS
select FW_LOADER_PAGED_BUF
help
diff -- a/drivers/base/firmware_loader/sysfs.h b/drivers/base/firmware_loader/sysfs.h
--- a/drivers/base/firmware_loader/sysfs.h
+++ b/drivers/base/firmware_loader/sysfs.h
@@ -99,7 +99,7 @@ struct fw_sysfs *
fw_create_instance(struct firmware *firmware, const char *fw_name,
struct device *device, u32 opt_flags);
-#ifdef CONFIG_FW_UPLOAD
+#if IS_ENABLED(CONFIG_FW_UPLOAD)
extern struct device_attribute dev_attr_status;
extern struct device_attribute dev_attr_error;
extern struct device_attribute dev_attr_cancel;
diff -- a/include/linux/firmware.h b/include/linux/firmware.h
--- a/include/linux/firmware.h
+++ b/include/linux/firmware.h
@@ -170,7 +170,7 @@ static inline int request_partial_firmwa
#endif
-#ifdef CONFIG_FW_UPLOAD
+#if IS_ENABLED(CONFIG_FW_UPLOAD)
struct fw_upload *
firmware_upload_register(struct module *module, struct device *parent,