我将在x86_64系统中编译linux内核2.4.32。
make dep 是正常的,但使bzImage 在显示如下链接错误后停止:
ld -m elf_x86_64 -e stext -r -o kernel.o sched.o dma.o fork.o exec_domain.o panic.o printk.o module.o exit.o itimer.o info.o time.o softirq.o resource.o sysctl.o acct.o capability.o ptrace.o timer.o user.o signal.o sys.o kmod.o context.o ksyms.o pm.o
dma.o: In function `set_64bit':
dma.c:(.text+0x0): multiple definition of `set_64bit'
sched.o:sched.c:(.text+0x1b): first defined here
dma.o: In function `get_order':
dma.c:(.text+0x4): multiple definition of `get_order'
sched.o:sched.c:(.text+0x0): first defined here
dma.o: In function `read_lock':
dma.c:(.text+0x1a): multiple definition of `read_lock'
sched.o:sched.c:(.text+0x9c): first defined here
dma.o: In function `cpuid':
dma.c:(.text+0xc9): multiple definition of `cpuid'
sched.o:sched.c:(.text+0x24): first defined here
dma.o: In function `cpuid_eax':
dma.c:(.text+0xe1): multiple definition of `cpuid_eax'
sched.o:sched.c:(.text+0x41): first defined here
dma.o: In function `cpuid_ebx':
dma.c:(.text+0xe8): multiple definition of `cpuid_ebx'
sched.o:sched.c:(.text+0x4d): first defined here
dma.o: In function `cpuid_ecx':
dma.c:(.text+0xf1): multiple definition of `cpuid_ecx'
sched.o:sched.c:(.text+0x5b): first defined here
dma.o: In function `cpuid_edx':
dma.c:(.text+0xfa): multiple definition of `cpuid_edx'
sched.o:sched.c:(.text+0x69): first defined here
dma.o: In function `thread_saved_pc':
dma.c:(.text+0x103): multiple definition of `thread_saved_pc'
sched.o:sched.c:(.text+0x77): first defined here
dma.o: In function `rep_nop':
dma.c:(.text+0x10c): multiple definition of `rep_nop'
sched.o:sched.c:(.text+0x85): first defined here
dma.o: In function `sync_core':
dma.c:(.text+0x10f): multiple definition of `sync_core'
sched.o:sched.c:(.text+0x8d): first defined here
kernel2.4.32 / include 目录中有很多 asm 目录,每个目录都属于一个特定的体系结构(例如asm-i386,asm-x86_64,asm-a64 )
并且有一个 asm 目录链接到 asm-x86_64 目录(因为我的系统架构)
当我从这两个目录中的一个 asm 和 asm-x86_64 中删除具有多个定义的函数(如错误列表中的set_64bit)时,错误将消失。
makefile或配置文件有问题吗?为什么这些函数编译多次??!
请求帮助我......答案 0 :(得分:0)
问题来自错误印刷功能'在头文件中定义为@Tsyvarev已被正确提及。
这些有问题的功能定义必须从extern inline
更改为static inline
。
还必须在inb, inw, inl, outb, outw, outl....
文件中更改有关I / O的函数的定义,例如linux2.4.32/include/asm/io.h
,其中这些函数被定义为带有extern
关键字的宏!