GNU链接器(MingW版)错误ld.exe文件格式无法识别 [英] Error with GNU Linker (MingW Version) ld.exe File Format Not Recognized

查看:107
本文介绍了GNU链接器(MingW版)错误ld.exe文件格式无法识别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在C中制作一个简单的操作系统(从头开始)

我使用Loader.asm和bootload.asm文件来加载我的操作系统。

kmain.c包含基本的内核函数

和print.c包含int main(void)函数,它在屏幕上打印一些文本



我使用这个批处理脚本编译所有文件:

I am making a simple operating System in C, (from scratch)
I use a Loader.asm and a bootload.asm file for Loading my OS.
kmain.c contains the basic kernel functions
and print.c contains the int main(void) function that prints some text
on screen.
I compile ALL the files together using this batch script :

REM buildall.bat
REM By Sids123 (ALLDESP) on CodePlex.com
REM Builds everything and copies it to an OS.img file
@echo off
@echo Building Main Files
gcc -ffreestanding -fno-builtin -nostdlib -c *.c
nasm -f aout Loader.asm -o Loader.o
ld -Ttext 0x1000 -o kernel.bin Loader.o kmain.o print.o
nasm -f bin bootload.asm -o bootload.bin
@echo Copying Files to OS.img
copy /b bootload.bin + kernel.bin os.img
echo Done!!!
pause



但是ld无法复制.o文件来生成kernel.bin

我收到以下消息Ld.exe


But ld is not able to copy .o files to generate a kernel.bin
I get the following Message by Ld.exe

Loader.o File not recognized : File Format no recognized



任何解决方案,



帮助将不胜感激,



~Sids123


Any Solutions to this,

Help would be appreciated,

~Sids123

推荐答案

nasm -f aout Loader.asm -o Loader.o



看起来不对劲。为什么你不使用aout而不是elf?
nasm -f aout Loader.asm -o Loader.o

looks wrong. Why arent you using aout instead of elf?


这篇关于GNU链接器(MingW版)错误ld.exe文件格式无法识别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆