Architecture of i386 input file is incompatible with i386:x86-64

旧城冷巷雨未停 提交于 2019-12-03 02:44:40

问题


I'm trying to create a simple kernel using Ubuntu. In the terminal I typed

    ld -Ttext 0x1000 -o kernel.bin loader.o main.o Video.o

But I got the following error message in return:

    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

回答1:


If want compile the file as 32 bits, you can use:

ld -m elf_i386 -s -o file file.o



回答2:


Use 64 bits instead of 32 for your loader and compile it with the following command:

nasm -f elf64 loader.asm -o loader.o

This should solve your error




回答3:


When compiling/linking 32-bit apps on x86_64, setting emulation to elf_i386 provides the correct elf format. So, for example, if you compile an assembler app with nasm -f elf file.asm -o file.o, the link command is ld -m elf_i386 -o exename file.o Courtesy: David



来源:https://stackoverflow.com/questions/19200333/architecture-of-i386-input-file-is-incompatible-with-i386x86-64

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!