[mingo-tip:master 583/2382] kernel/kallsyms.c:895:81: error: invalid application of 'sizeof' to an incomplete type 'struct kallsyms_entry'

From: kernel test robot
Date: Thu Jan 13 2022 - 13:25:22 EST


tree: git://git.kernel.org/pub/scm/linux/kernel/git/mingo/tip.git master
head: 1a880941a087613ed42f77001229edfcf75ea8a5
commit: 4357bf918816f743b593665e792f78913f0da47b [583/2382] kallsyms/objtool: Process entries
config: x86_64-randconfig-a015-20220109 (https://download.01.org/0day-ci/archive/20220114/202201140216.czBUwf1E-lkp@xxxxxxxxx/config)
compiler: clang version 14.0.0 (https://github.com/llvm/llvm-project 244dd2913a43a200f5a6544d424cdc37b771028b)
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
# https://git.kernel.org/pub/scm/linux/kernel/git/mingo/tip.git/commit/?id=4357bf918816f743b593665e792f78913f0da47b
git remote add mingo-tip git://git.kernel.org/pub/scm/linux/kernel/git/mingo/tip.git
git fetch --no-tags mingo-tip master
git checkout 4357bf918816f743b593665e792f78913f0da47b
# save the config file to linux build tree
mkdir build_dir
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=x86_64 SHELL=/bin/bash

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@xxxxxxxxx>

Note: the mingo-tip/master HEAD 1a880941a087613ed42f77001229edfcf75ea8a5 builds fine.
It only hurts bisectability.

All errors (new ones prefixed by >>):

kernel/kallsyms.c:586:12: warning: no previous prototype for function 'arch_get_kallsym' [-Wmissing-prototypes]
int __weak arch_get_kallsym(unsigned int symnum, unsigned long *value,
^
kernel/kallsyms.c:586:1: note: declare 'static' if the function is not intended to be used outside of this translation unit
int __weak arch_get_kallsym(unsigned int symnum, unsigned long *value,
^
static
>> kernel/kallsyms.c:895:81: error: invalid application of 'sizeof' to an incomplete type 'struct kallsyms_entry'
nr_entries = ((long)&__kallsyms_offsets_end - (long)&__kallsyms_offsets_begin)/sizeof(struct kallsyms_entry);
^ ~~~~~~~~~~~~~~~~~~~~~~~
kernel/kallsyms.c:889:9: note: forward declaration of 'struct kallsyms_entry'
struct kallsyms_entry *entries;
^
kernel/kallsyms.c:905:85: error: subscript of pointer to incomplete type 'struct kallsyms_entry'
printk("# kallsyms entry %6ld/%6ld: [%016Lx]: {%s}\n", i, nr_entries, (u64)entries[i].offset, str);
~~~~~~~^
include/linux/printk.h:450:60: note: expanded from macro 'printk'
#define printk(fmt, ...) printk_index_wrap(_printk, fmt, ##__VA_ARGS__)
^~~~~~~~~~~
include/linux/printk.h:422:19: note: expanded from macro 'printk_index_wrap'
_p_func(_fmt, ##__VA_ARGS__); \
^~~~~~~~~~~
kernel/kallsyms.c:889:9: note: forward declaration of 'struct kallsyms_entry'
struct kallsyms_entry *entries;
^
1 warning and 2 errors generated.


vim +895 kernel/kallsyms.c

886
887 static void __init kallsyms_objtool_init(void)
888 {
889 struct kallsyms_entry *entries;
890 long nr_entries, i;
891 char *str;
892
893 printk("# kallsyms_objtool_init()\n");
894
> 895 nr_entries = ((long)&__kallsyms_offsets_end - (long)&__kallsyms_offsets_begin)/sizeof(struct kallsyms_entry);
896
897 printk("# kallsyms: %ld entries.\n", nr_entries);
898
899 BUG_ON(nr_entries <= 0);
900
901 str = &__kallsyms_strs_begin;
902 entries = (void *) &__kallsyms_offsets_begin;
903
904 for (i = 0; i < nr_entries; i++) {
905 printk("# kallsyms entry %6ld/%6ld: [%016Lx]: {%s}\n", i, nr_entries, (u64)entries[i].offset, str);
906
907 str += strlen(str) + 1;
908
909 }
910 printk("# kallsyms, last str: %p\n", str);
911 printk("# kallsyms, &__kallsyms_strs_end: %p\n", &__kallsyms_strs_end);
912
913 BUG_ON(str != &__kallsyms_strs_end);
914 }
915

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@xxxxxxxxxxxx