Use ld on 64-bit platform to generate 32-bit executable

拈花ヽ惹草 提交于 2019-12-17 19:46:40

问题


I wrote an assembly that is assemble with:

$as --32 -o hello.o hello.s

Then I tried to generate an executable with:

$ld -o hello hello.o

It gives me an error:

ld: i386 architecture of input file `ConditionalBranching.o' is incompatible with i386:x86-64 output

I tried using flag -m32 or --32, but ld dont take them. I cannot find a solution by reading the man page of ld. How can I generate a 32-bit binary from my 32-bit shared object?


回答1:


Your linker is attempting to create a 64-bit binary, but your assembly code was assembled for a 32-bit architecture. This creates a mismatch.

Fix this by passing the -m elf_i386 flag to your linker, explicitly instructing it to create a 32-bit binary.



来源:https://stackoverflow.com/questions/30184929/use-ld-on-64-bit-platform-to-generate-32-bit-executable

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