2016-07-31 34 views
0

我將在x86_64系統中編譯linux內核2.4.32。Linux內核2.4.32編譯中多種函數的多重定義

化妝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 /包括目錄下有很多 ASM的目錄

每個屬於一個特定的體系結構(如asm-i386,asm-x86_64,asm-a64)

並且有一個單獨的asm鏈接到ASM-x86_64的目錄(因爲我的系統架構)目錄

當我從這兩個目錄之一ASMASM刪除與多個定義(如在錯誤列表set_64bit)功能-x86_64該錯誤將消失。

makefile或配置文件有問題嗎?爲什麼這些函數編譯多次?

懇求幫我...

+0

這個內核大約有十年曆史,可能與現代編譯器不兼容。您是否有需要構建該版本的特定原因? – duskwuff

+0

看起來這是[函數的定義]中的錯字(http://lxr.free-electrons.com/source/include/asm-x86_64/system.h?v=2.4.37#L137):它們使用'extern內聯「而不是標頭中常見的」靜態內聯「定義。 – Tsyvarev

+0

@duskwuff我想添加一個軟件的內核模塊(點擊模塊化路由器),這個軟件只支持一些有限的linux版本。我也測試2.6,但也不起作用。 –

回答

0

的問題是從一個錯字功能在頭文件中定義@Tsyvarev已正確地提到。

這些有問題的功能定義必須從extern inline更改爲static inline

此外,關於I/O的函數的定義,如inb, inw, inl, outb, outw, outl....必須在linux2.4.32/include/asm/io.h文件中更改,其中這些函數被定義爲具有extern關鍵字的宏!