.ld
-
- Member
- Posts: 118
- Joined: Mon May 05, 2008 5:51 pm
.ld
Is there a tutorial around for making these files? The barebones for Grub doesnt explain what everthing is in the ld file and I'm avoiding writing my kernel in C++ so I need to know ever detail about the ld.
Re: .ld
Here's the manual on making linker scripts for GNU ld: http://sourceware.org/binutils/docs/ld/ ... ml#Scripts
"Sufficiently advanced stupidity is indistinguishable from malice."
-
- Member
- Posts: 118
- Joined: Mon May 05, 2008 5:51 pm
Re: .ld
Thank you both of you. I have been studying Bran's Kernel but I cant get the darn thing to link correctly.
The batch:
Produces the output:
start.o: file not recognized: File format not recognized
When the ld command is run. I just moved the ld.exe and the stuff it calls for to my build folder. Can I do that? If so what is wrong here?
The batch:
Code: Select all
echo Now assembling, compiling, and linking your kernel:
nasm -f aout -o start.o start.asm
tcc -Wall -O -fstrength-reduce -fomit-frame-pointer -finline-functions -nostdinc -fno-builtin -I./include -c -o main.o main.c
tcc -Wall -O -fstrength-reduce -fomit-frame-pointer -finline-functions -nostdinc -fno-builtin -I./include -c -o scrn.o scrn.c
tcc -Wall -O -fstrength-reduce -fomit-frame-pointer -finline-functions -nostdinc -fno-builtin -I./include -c -o gdt.o gdt.c
tcc -Wall -O -fstrength-reduce -fomit-frame-pointer -finline-functions -nostdinc -fno-builtin -I./include -c -o idt.o idt.c
tcc -Wall -O -fstrength-reduce -fomit-frame-pointer -finline-functions -nostdinc -fno-builtin -I./include -c -o isrs.o isrs.c
tcc -Wall -O -fstrength-reduce -fomit-frame-pointer -finline-functions -nostdinc -fno-builtin -I./include -c -o irq.o irq.c
tcc -Wall -O -fstrength-reduce -fomit-frame-pointer -finline-functions -nostdinc -fno-builtin -I./include -c -o timer.o timer.c
tcc -Wall -O -fstrength-reduce -fomit-frame-pointer -finline-functions -nostdinc -fno-builtin -I./include -c -o kb.o kb.c
ld -T link.ld -o kernel.bin start.o main.o scrn.o gdt.o idt.o isrs.o irq.o timer.o kb.o
echo Cleaning up object files...
del *.o
echo Done!
pause
start.o: file not recognized: File format not recognized
When the ld command is run. I just moved the ld.exe and the stuff it calls for to my build folder. Can I do that? If so what is wrong here?
-
- Member
- Posts: 118
- Joined: Mon May 05, 2008 5:51 pm
Re: .ld
Im using windows
Code: Select all
OUTPUT_FORMAT("binary")
ENTRY(start)
phys = 0x00100000;
SECTIONS
{
.text phys : AT(phys) {
code = .;
*(.text)
*(.rodata)
. = ALIGN(4096);
}
.data : AT(phys + (data - code))
{
data = .;
*(.data)
. = ALIGN(4096);
}
.bss : AT(phys + (bss - code))
{
bss = .;
*(.bss)
. = ALIGN(4096);
}
end = .;
}
Re: .ld
Ahh, I think your problem is actually in the batch file. The linker script looks correct, however, you're using a 16-bit compiler with your .c files, and if you're using '[BITS 32]' in start.asm you are mixing 16-bit and 32 bit which isn't good. Use gcc as a compiler. I use Windows too, and a great port is DJGPP.
Oh and I think the c compiler flags are for gcc, not tcc. (Is it turbo c?)
Oh and I think the c compiler flags are for gcc, not tcc. (Is it turbo c?)
- thepowersgang
- Member
- Posts: 734
- Joined: Tue Dec 25, 2007 6:03 am
- Libera.chat IRC: thePowersGang
- Location: Perth, Western Australia
- Contact:
Re: .ld
It's most probably an incompatibility between versions of LD. The cross compiler that comes with bran's tutorial can understand a.out as an input but the standard linker on Linux/mingw cannot.
Try changing -f aout to -f elf when calling nasm and testing it.
Try changing -f aout to -f elf when calling nasm and testing it.
Kernel Development, It's the brain surgery of programming.
Acess2 OS (c) | Tifflin OS (rust) | mrustc - Rust compiler
Currently Working on: mrustc
Acess2 OS (c) | Tifflin OS (rust) | mrustc - Rust compiler
Currently Working on: mrustc
-
- Member
- Posts: 118
- Joined: Mon May 05, 2008 5:51 pm
Re: .ld
@souradipm
I've looked at DJGPP but I thought I would try Tiny C Compiler because of its size.
When I've tried DJGPP all I've gotten is:
gcc.exe: enviroment variable DJGPP not defined
@thepowersgang
When I do that it gives me:
ld: cannot perform PE operations on non PE output file 'kernel.bin'.
I've looked at DJGPP but I thought I would try Tiny C Compiler because of its size.
When I've tried DJGPP all I've gotten is:
gcc.exe: enviroment variable DJGPP not defined
@thepowersgang
When I do that it gives me:
ld: cannot perform PE operations on non PE output file 'kernel.bin'.
- Combuster
- Member
- Posts: 9301
- Joined: Wed Oct 18, 2006 3:45 am
- Libera.chat IRC: [com]buster
- Location: On the balcony, where I can actually keep 1½m distance
- Contact:
Re: .ld
sigh.
GCC Cross-Compiler
GCC Cross-Compiler