Linux源代码中的错误?

时间:2016-08-01 21:02:18

标签: kernel-module kbuild

我正在尝试为外部系统编写内核模块。为此,我使用该内核的.config文件并在我的开发计算机上重建了源代码。然后我写了一个使用以下行的makefile:

CC=arm-xilinx-linux-gnueabi-gcc
make -C /home/osboxes/Documents/linux-xcomm_zynq/ M=$(PWD) modules

为目标构建模块。我的内核源代码除了包含到module.h和kernel.h之外什么都没有,还有一个init_module和cleanup_module,每个都有一个printk。我成功地为我的开发计算机构建了它,所以我知道没有错误。

当我尝试为目标构建时,我遇到了一些错误。生成Linux源代码时可能会出错吗?运行make后,我没有对Linux源目录进行任何修改。

以下是我尝试构建内核的输出:

CC=arm-xilinx-linux-gnueabi-gcc
make -C /home/osboxes/Documents/linux-xcomm_zynq/ M=/home/osboxes/Documents/kernel_modules/DRFM modules
make[1]: Entering directory '/home/osboxes/Documents/linux-xcomm_zynq'
  CC [M]  /home/osboxes/Documents/kernel_modules/DRFM/testmod.o
In file included from ./arch/x86/include/asm/bitops.h:16:0,
                 from include/linux/bitops.h:36,
                 from include/linux/kernel.h:10,
                 from include/linux/list.h:8,
                 from include/linux/module.h:9,
                 from /home/osboxes/Documents/kernel_modules/DRFM/testmod.c:1:
./arch/x86/include/asm/arch_hweight.h: In function ‘__arch_hweight64’:
./arch/x86/include/asm/arch_hweight.h:56:42: error: expected ‘:’ or ‘)’ before ‘POPCNT64’
  asm (ALTERNATIVE("call __sw_hweight64", POPCNT64, X86_FEATURE_POPCNT)
                                          ^
./arch/x86/include/asm/alternative.h:131:28: note: in definition of macro ‘ALTINSTR_REPLACEMENT’
  b_replacement(num)":\n\t" newinstr "\n" e_replacement(num) ":\n\t"
                            ^
./arch/x86/include/asm/arch_hweight.h:56:7: note: in expansion of macro ‘ALTERNATIVE’
  asm (ALTERNATIVE("call __sw_hweight64", POPCNT64, X86_FEATURE_POPCNT)
       ^
In file included from ./arch/x86/include/asm/pgtable_types.h:250:0,
                 from ./arch/x86/include/asm/processor.h:18,
                 from ./arch/x86/include/asm/thread_info.h:52,
                 from include/linux/thread_info.h:54,
                 from ./arch/x86/include/asm/preempt.h:6,
                 from include/linux/preempt.h:59,
                 from include/linux/spinlock.h:50,
                 from include/linux/seqlock.h:35,
                 from include/linux/time.h:5,
                 from include/linux/stat.h:18,
                 from include/linux/module.h:10,
                 from /home/osboxes/Documents/kernel_modules/DRFM/testmod.c:1:
include/asm-generic/pgtable-nopud.h: At top level:
include/asm-generic/pgtable-nopud.h:15:0: warning: "PUD_SHIFT" redefined
 #define PUD_SHIFT PGDIR_SHIFT
 ^
In file included from ./arch/x86/include/asm/pgtable_types.h:205:0,
                 from ./arch/x86/include/asm/processor.h:18,
                 from ./arch/x86/include/asm/thread_info.h:52,
                 from include/linux/thread_info.h:54,
                 from ./arch/x86/include/asm/preempt.h:6,
                 from include/linux/preempt.h:59,
                 from include/linux/spinlock.h:50,
                 from include/linux/seqlock.h:35,
                 from include/linux/time.h:5,
                 from include/linux/stat.h:18,
                 from include/linux/module.h:10,
                 from /home/osboxes/Documents/kernel_modules/DRFM/testmod.c:1:
./arch/x86/include/asm/pgtable_64_types.h:33:0: note: this is the location of the previous definition
 #define PUD_SHIFT 30
 ^
In file included from ./arch/x86/include/asm/pgtable_types.h:250:0,
                 from ./arch/x86/include/asm/processor.h:18,
                 from ./arch/x86/include/asm/thread_info.h:52,
                 from include/linux/thread_info.h:54,
                 from ./arch/x86/include/asm/preempt.h:6,
                 from include/linux/preempt.h:59,
                 from include/linux/spinlock.h:50,
                 from include/linux/seqlock.h:35,
                 from include/linux/time.h:5,
                 from include/linux/stat.h:18,
                 from include/linux/module.h:10,
                 from /home/osboxes/Documents/kernel_modules/DRFM/testmod.c:1:
include/asm-generic/pgtable-nopud.h:16:0: warning: "PTRS_PER_PUD" redefined
 #define PTRS_PER_PUD 1
 ^
In file included from ./arch/x86/include/asm/pgtable_types.h:205:0,
                 from ./arch/x86/include/asm/processor.h:18,
                 from ./arch/x86/include/asm/thread_info.h:52,
                 from include/linux/thread_info.h:54,
                 from ./arch/x86/include/asm/preempt.h:6,
                 from include/linux/preempt.h:59,
                 from include/linux/spinlock.h:50,
                 from include/linux/seqlock.h:35,
                 from include/linux/time.h:5,
                 from include/linux/stat.h:18,
                 from include/linux/module.h:10,
         from /home/osboxes/Documents/kernel_modules/DRFM/testmod.c:1:
./arch/x86/include/asm/processor.h:172:0: warning: "cache_line_size" redefined
 #define cache_line_size() (boot_cpu_data.x86_cache_alignment)
 ^
In file included from include/linux/printk.h:8:0,
                 from include/linux/kernel.h:13,
                 from include/linux/list.h:8,
                 from include/linux/module.h:9,
                 from /home/osboxes/Documents/kernel_modules/DRFM/testmod.c:1:
include/linux/cache.h:64:0: note: this is the location of the previous definition
 #define cache_line_size() L1_CACHE_BYTES
 ^
In file included from ./arch/x86/include/asm/segment.h:155:0,
                 from ./arch/x86/include/asm/ptrace.h:4,
                 from ./arch/x86/include/asm/alternative.h:8,
                 from ./arch/x86/include/asm/bitops.h:16,
                 from include/linux/bitops.h:36,
                 from include/linux/kernel.h:10,
                 from include/linux/list.h:8,
                 from include/linux/module.h:9,
                 from /home/osboxes/Documents/kernel_modules/DRFM/testmod.c:1:
./arch/x86/include/asm/cache.h:7:25: error: ‘CONFIG_X86_L1_CACHE_SHIFT’ undeclared here (not in a function)
 #define L1_CACHE_SHIFT (CONFIG_X86_L1_CACHE_SHIFT)
                         ^
./arch/x86/include/asm/cache.h:8:30: note: in expansion of macro ‘L1_CACHE_SHIFT’
 #define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
                              ^
include/linux/cache.h:12:25: note: in expansion of macro ‘L1_CACHE_BYTES’
 #define SMP_CACHE_BYTES L1_CACHE_BYTES
                         ^
include/linux/cache.h:20:58: note: in expansion of macro ‘SMP_CACHE_BYTES’
 #define ____cacheline_aligned __attribute__((__aligned__(SMP_CACHE_BYTES)))
                                                          ^
./arch/x86/include/asm/processor.h:275:27: note: in expansion of macro ‘____cacheline_aligned’
 } __attribute__((packed)) ____cacheline_aligned;
                           ^
In file included from ./arch/x86/include/asm/thread_info.h:52:0,
                 from include/linux/thread_info.h:54,
                 from ./arch/x86/include/asm/preempt.h:6,
                 from include/linux/preempt.h:59,
                 from include/linux/spinlock.h:50,
                 from include/linux/seqlock.h:35,
                 from include/linux/time.h:5,
                 from include/linux/stat.h:18,
                 from include/linux/module.h:10,
                 from /home/osboxes/Documents/kernel_modules/DRFM/testmod.c:1:
./arch/x86/include/asm/processor.h:275:1: error: requested alignment is not an integer constant
 } __attribute__((packed)) ____cacheline_aligned;
 ^
./arch/x86/include/asm/processor.h:306:1: error: requested alignment is not an integer constant
 } ____cacheline_aligned;
 ^
In file included from include/asm-generic/percpu.h:6:0,
                 from ./arch/x86/include/asm/percpu.h:551,
                 from ./arch/x86/include/asm/preempt.h:5,
                 from include/linux/preempt.h:59,
                 from include/linux/spinlock.h:50,
                 from include/linux/seqlock.h:35,
                 from include/linux/time.h:5,
                 from include/linux/stat.h:18,
                 from include/linux/module.h:10,
                 from /home/osboxes/Documents/kernel_modules/DRFM/testmod.c:1:
./arch/x86/include/asm/processor.h:308:39: error: requested alignment is not an integer constant
 DECLARE_PER_CPU_SHARED_ALIGNED(struct tss_struct, cpu_tss);
                                       ^
include/linux/percpu-defs.h:101:38: note: in definition of macro ‘DECLARE_PER_CPU_SECTION’
  extern __PCPU_ATTRS(sec) __typeof__(type) name
                                      ^
./arch/x86/include/asm/processor.h:308:1: note: in expansion of macro ‘DECLARE_PER_CPU_SHARED_ALIGNED’
 DECLARE_PER_CPU_SHARED_ALIGNED(struct tss_struct, cpu_tss);
 ^
In file included from ./arch/x86/include/asm/preempt.h:5:0,
                 from include/linux/preempt.h:59,
                 from include/linux/spinlock.h:50,
                 from include/linux/seqlock.h:35,
                 from include/linux/time.h:5,
                 from include/linux/stat.h:18,
                 from include/linux/module.h:10,
                 from /home/osboxes/Documents/kernel_modules/DRFM/testmod.c:1:
./arch/x86/include/asm/processor.h: In function ‘current_top_of_stack’:
./arch/x86/include/asm/processor.h:466:30: error: ‘cpu_current_top_of_stack’ undeclared (first use in this function)
  return this_cpu_read_stable(cpu_current_top_of_stack);
                              ^
./arch/x86/include/asm/percpu.h:213:9: note: in definition of macro ‘percpu_stable_op’
  typeof(var) pfo_ret__;    \
         ^
./arch/x86/include/asm/processor.h:466:9: note: in expansion of macro ‘this_cpu_read_stable’
  return this_cpu_read_stable(cpu_current_top_of_stack);
         ^
./arch/x86/include/asm/processor.h:466:30: note: each undeclared identifier is reported only once for each function it appears in
  return this_cpu_read_stable(cpu_current_top_of_stack);
                              ^
./arch/x86/include/asm/percpu.h:213:9: note: in definition of macro ‘percpu_stable_op’
  typeof(var) pfo_ret__;    \
         ^
./arch/x86/include/asm/processor.h:466:9: note: in expansion of macro ‘this_cpu_read_stable’
  return this_cpu_read_stable(cpu_current_top_of_stack);
         ^
In file included from ./arch/x86/include/asm/atomic.h:240:0,
                 from include/linux/atomic.h:4,
                 from ./arch/x86/include/asm/thread_info.h:53,
                 from include/linux/thread_info.h:54,
                 from ./arch/x86/include/asm/preempt.h:6,
                 from include/linux/preempt.h:59,
                 from include/linux/spinlock.h:50,
                 from include/linux/seqlock.h:35,
                 from include/linux/time.h:5,
                 from include/linux/stat.h:18,
                 from include/linux/module.h:10,
                 from /home/osboxes/Documents/kernel_modules/DRFM/testmod.c:1:
./arch/x86/include/asm/atomic64_64.h: At top level:
./arch/x86/include/asm/atomic64_64.h:19:40: error: unknown type name ‘atomic64_t’
 static inline long atomic64_read(const atomic64_t *v)
                                        ^
In file included from include/uapi/linux/stddef.h:1:0,
                 from include/linux/stddef.h:4,
                 from ./include/uapi/linux/posix_types.h:4,
                 from include/uapi/linux/types.h:13,
                 from include/linux/types.h:5,
                 from include/linux/list.h:4,
                 from include/linux/module.h:9,
                 from /home/osboxes/Documents/kernel_modules/DRFM/testmod.c:1:
./arch/x86/include/asm/atomic64_64.h: In function ‘atomic64_read’:
./arch/x86/include/asm/atomic64_64.h:21:22: error: request for member ‘counter’ in something not a structure or union
  return READ_ONCE((v)->counter);
                      ^
include/linux/compiler.h:279:17: note: in definition of macro ‘__READ_ONCE’
  union { typeof(x) __val; char __c[1]; } __u;   \
                 ^
./arch/x86/include/asm/atomic64_64.h:21:9: note: in expansion of macro ‘READ_ONCE’
  return READ_ONCE((v)->counter);
         ^
./arch/x86/include/asm/atomic64_64.h:21:22: error: request for member ‘counter’ in something not a structure or union
  return READ_ONCE((v)->counter);
                      ^
include/linux/compiler.h:281:22: note: in definition of macro ‘__READ_ONCE’
   __read_once_size(&(x), __u.__c, sizeof(x));  \
                      ^
./arch/x86/include/asm/atomic64_64.h:21:9: note: in expansion of macro ‘READ_ONCE’
  return READ_ONCE((v)->counter);
         ^
./arch/x86/include/asm/atomic64_64.h:21:22: error: request for member ‘counter’ in something not a structure or union
  return READ_ONCE((v)->counter);
                      ^
include/linux/compiler.h:281:42: note: in definition of macro ‘__READ_ONCE’
   __read_once_size(&(x), __u.__c, sizeof(x));  \
                                          ^
./arch/x86/include/asm/atomic64_64.h:21:9: note: in expansion of macro ‘READ_ONCE’
  return READ_ONCE((v)->counter);
         ^
./arch/x86/include/asm/atomic64_64.h:21:22: error: request for member ‘counter’ in something not a structure or union
  return READ_ONCE((v)->counter);
                      ^
include/linux/compiler.h:283:30: note: in definition of macro ‘__READ_ONCE’
   __read_once_size_nocheck(&(x), __u.__c, sizeof(x)); \
                              ^
./arch/x86/include/asm/atomic64_64.h:21:9: note: in expansion of macro ‘READ_ONCE’
  return READ_ONCE((v)->counter);
         ^
./arch/x86/include/asm/atomic64_64.h:21:22: error: request for member ‘counter’ in something not a structure or union
  return READ_ONCE((v)->counter);
                      ^
include/linux/compiler.h:283:50: note: in definition of macro ‘__READ_ONCE’
   __read_once_size_nocheck(&(x), __u.__c, sizeof(x)); \
                                                  ^
./arch/x86/include/asm/atomic64_64.h:21:9: note: in expansion of macro ‘READ_ONCE’
  return READ_ONCE((v)->counter);
         ^
In file included from ./arch/x86/include/asm/atomic.h:240:0,
                 from include/linux/atomic.h:4,
                 from ./arch/x86/include/asm/thread_info.h:53,
                 from include/linux/thread_info.h:54,
                 from ./arch/x86/include/asm/preempt.h:6,
                 from include/linux/preempt.h:59,
                 from include/linux/spinlock.h:50,
                 from include/linux/seqlock.h:35,
                 from include/linux/time.h:5,
                 from include/linux/stat.h:18,
                 from include/linux/module.h:10,
                 from /home/osboxes/Documents/kernel_modules/DRFM/testmod.c:1:
./arch/x86/include/asm/atomic64_64.h: At top level:
./arch/x86/include/asm/atomic64_64.h:31:33: error: unknown type name ‘atomic64_t’
 static inline void atomic64_set(atomic64_t *v, long i)
                                 ^
./arch/x86/include/asm/atomic64_64.h:43:50: error: unknown type name ‘atomic64_t’
 static __always_inline void atomic64_add(long i, atomic64_t *v)
                                                  ^
./arch/x86/include/asm/atomic64_64.h:57:41: error: unknown type name ‘atomic64_t’
 static inline void atomic64_sub(long i, atomic64_t *v)
                                         ^
./arch/x86/include/asm/atomic64_64.h:73:49: error: unknown type name ‘atomic64_t’
 static inline int atomic64_sub_and_test(long i, atomic64_t *v)
                                                 ^
./arch/x86/include/asm/atomic64_64.h:84:42: error: unknown type name ‘atomic64_t’
 static __always_inline void atomic64_inc(atomic64_t *v)
                                          ^
./arch/x86/include/asm/atomic64_64.h:97:42: error: unknown type name ‘atomic64_t’
 static __always_inline void atomic64_dec(atomic64_t *v)
                                          ^
./arch/x86/include/asm/atomic64_64.h:112:41: error: unknown type name ‘atomic64_t’
 static inline int atomic64_dec_and_test(atomic64_t *v)
                                         ^
./arch/x86/include/asm/atomic64_64.h:125:41: error: unknown type name ‘atomic64_t’
 static inline int atomic64_inc_and_test(atomic64_t *v)
                                         ^
./arch/x86/include/asm/atomic64_64.h:139:49: error: unknown type name ‘atomic64_t’
 static inline int atomic64_add_negative(long i, atomic64_t *v)
                                                 ^
./arch/x86/include/asm/atomic64_64.h:151:57: error: unknown type name ‘atomic64_t’
 static __always_inline long atomic64_add_return(long i, atomic64_t *v)

我达到了角色限制,因此我无法发布整个内容,但这是大部分内容。

我应该提一下:我的目标系统是一个ARM处理器,我正在使用Debian构建一个x86 64位虚拟机。我已经设置了CROSS_COMPILER和PATH来引用我试图使用的arm-xilinx-linux-gnueabi-gcc编译器。

在指出上面是从我的源目录中的x86源中提取之后,我尝试将ARCH = arm添加到make命令中,这会产生以下错误:

CC=arm-xilinx-linux-gnueabi-gcc
make ARCH=arm -C /home/osboxes/Documents/linux-xcomm_zynq/ M=/home/osboxes/Documents/kernel_modules/DRFM modules
make[1]: Entering directory '/home/osboxes/Documents/linux-xcomm_zynq'
  CC [M]  /home/osboxes/Documents/kernel_modules/DRFM/testmod.o
gcc: error: unrecognized argument in option ‘-mabi=aapcs-linux’
gcc: note: valid arguments to ‘-mabi=’ are: ms sysv
gcc: error: unrecognized command line option ‘-mlittle-endian’
gcc: error: unrecognized command line option ‘-mno-thumb-interwork’
gcc: error: unrecognized command line option ‘-mfpu=vfp’
scripts/Makefile.build:264: recipe for target '/home/osboxes/Documents/kernel_modules/DRFM/testmod.o' failed
make[2]: *** [/home/osboxes/Documents/kernel_modules/DRFM/testmod.o] Error 1
Makefile:1384: recipe for target '_module_/home/osboxes/Documents/kernel_modules/DRFM' failed
make[1]: *** [_module_/home/osboxes/Documents/kernel_modules/DRFM] Error 2
make[1]: Leaving directory '/home/osboxes/Documents/linux-xcomm_zynq'
Makefile:7: recipe for target 'cross' failed
make: *** [cross] Error 2

在我搜索的其他一些问题中,我看到答案说出了一个&#34;错误:无法识别的命令&#34;可能意味着我使用了错误的编译器,但我指定应该使用arm-xilinx-linux-gnueabi-gcc,据我所知应该是一个合适的ARM编译器。

0 个答案:

没有答案