[英]gnu ld treating assembly output as linker script, how to fix? or am i doing something wrong in my compiling?
i've been working on my kernel project and to simulate it (that is to run it on QEMU), i need it as a .iso file.我一直在研究我的内核项目并对其进行模拟(即在 QEMU 上运行它),我需要它作为 .iso 文件。
I have an assembly file and to assemble it -
as --32 boot.s -o boot.o<\/code>
我有一个汇编文件并进行汇编---
as --32 boot.s -o boot.o<\/code>
and for the main code (which is in c++), to compile it -
gcc -S kernel.cpp -lstdc++ -o kernel.o<\/code>
对于主要代码(在 c++ 中),编译它 -
gcc -S kernel.cpp -lstdc++ -o kernel.o<\/code>
gives no error.没有错误。 but,
但,
while linking it with this linker script:-在将其与此链接器脚本链接时:-
ENTRY(_start)
SECTIONS
{
/* we need 1MB of space atleast */
. = 1M;
/* text section */
.text BLOCK(4K) : ALIGN(4K)
{
*(.multiboot)
*(.text)
}
/* read only data section */
.rodata BLOCK(4K) : ALIGN(4K)
{
*(.rodata)
}
/* data section */
.data BLOCK(4K) : ALIGN(4K)
{
*(.data)
}
/* bss section */
.bss BLOCK(4K) : ALIGN(4K)
{
*(COMMON)
*(.bss)
}
}
gcc -S<\/code> produces assembly language, but
ld<\/code> expects an object file.
gcc -S<\/code>生成汇编语言,但
ld<\/code>需要一个目标文件。
Somewhere in between you have to run the assembler.
介于两者之间的某个地方,您必须运行汇编程序。
There's no particular need to use the assembler output, so most likely you want to use
-c<\/code> , which does compilation and then assembly to produce an object file, instead of
-S<\/code> :
没有特别需要使用汇编器输出,所以很可能您想使用
-c<\/code> ,它进行编译然后汇编以生成目标文件,而不是
-S<\/code> :
gcc -c kernel.cpp -o kernel.o
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.