我試圖用Ubuntu創建一個簡單的內核。在終端我鍵入i386輸入文件的體系結構與i386不兼容:x86-64
ld -Ttext 0x1000 -o kernel.bin loader.o main.o Video.o
但我得到的回報以下錯誤信息:
ld: i386 architecture of input file `loader.o' is incompatible with i386:x86-64 output
ld: warning: cannot find entry symbol _start; defaulting to 0000000000001000
這是解決方案。在x86_64上編譯/鏈接32位應用程序時,將仿真設置爲'elf_i386'提供了正確的elf格式。因此,例如,如果使用'nasm -f elf file.asm -o file.o'編譯彙編程序,鏈接命令是'ld -m elf_i386 -o exename file.o'。 –
只要不忘記用'-o file file.o'替換'-o file.o文件'。 – Ruslan