gpt4 book ai didi

c - linux kernel 2.4.32编译中大量函数的多重定义

转载 作者:太空宇宙 更新时间:2023-11-04 12:46:05 25 4
gpt4 key购买 nike

我打算在我的 x86_64 系统中编译 linux 内核 2.4.32。

ma​​ke dep 没问题,但是 ma​​ke 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目录(因为我的系统架构)

当我从 asmasm-x86_64 这两个目录之一中删除具有多个定义的函数(如错误列表中的 set_64bit)时,错误将消失。

makefile或config文件有问题吗?为什么这些函数会编译多次??!

请帮助我...

最佳答案

问题是由于@Tsyvarev 已被正确提及而导致头文件中的函数定义打印错误。

必须将这些有问题的函数定义从 extern inline 更改为 static inline

关于 I/O 的函数定义,如 inb, inw, inl, outb, outw, outl.... 必须在 linux2.4.32/include/asm 中更改/io.h 文件,其中这些函数被定义为带有 extern 关键字的宏!

关于c - linux kernel 2.4.32编译中大量函数的多重定义,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38682170/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com