Linking Confuson

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Mini
Posts: 18
Joined: Mon Apr 30, 2007 6:29 pm
Contact:

Linking Confuson

Post by Mini »

Hello I've bean following this tutorial for making an OS kernel in C++ and its all working except when I get to this part:
ld -T Link.ld -o Kernel.bin Loader.o Kernel.o Video.o
I made the 'Link.ld' file but were do I put that code?


And you'll have to explain it in newb for me because im only 13 so ya.
===RygnorkOS Progress===
Version:ALPHA BETA, 0.0.1
Currently working on: getting bootloader to actually work >:(
pcmattman
Member
Member
Posts: 2566
Joined: Sun Jan 14, 2007 9:15 pm
Libera.chat IRC: miselin
Location: Sydney, Australia (I come from a land down under!)
Contact:

Post by pcmattman »

OK, first some questions. Do you know C++? How well do you know it? Don't use OS development as a way to learn a language, it just makes it harder than it already is.

Link.ld is a linker script that tells ld where it needs to put each of the segments (.text, .data, .rodata, .bss) in the final file. Would you mind showing us what you have in link.ld?
Mini
Posts: 18
Joined: Mon Apr 30, 2007 6:29 pm
Contact:

Post by Mini »

Code: Select all

/* Link.ld */
OUTPUT_FORMAT("binary")
ENTRY(start)
SECTIONS
{
    .text 0x100000 :
    {
        code = .; _code = .; __code = .;
        *(.text)
        . = ALIGN(4096);
    }

    .data :
    {
        data = .; _data = .; __data = .;
        *(.data)
        . = ALIGN(4096);
    }

    .bss :
    {
        bss = .; _bss = .; __bss = .;
        *(.bss)
        . = ALIGN(4096);
    }

    end = .; _end = .; __end = .;
} 


And I've been using C++ for about 1 year now.


Oh and if you need to know im using: flat assembler
===RygnorkOS Progress===
Version:ALPHA BETA, 0.0.1
Currently working on: getting bootloader to actually work >:(
pcmattman
Member
Member
Posts: 2566
Joined: Sun Jan 14, 2007 9:15 pm
Libera.chat IRC: miselin
Location: Sydney, Australia (I come from a land down under!)
Contact:

Post by pcmattman »

That all looks right.
except when I get to this part
What happens?
Mini
Posts: 18
Joined: Mon Apr 30, 2007 6:29 pm
Contact:

Post by Mini »

Were do I put it?
===RygnorkOS Progress===
Version:ALPHA BETA, 0.0.1
Currently working on: getting bootloader to actually work >:(
Pyrofan1
Member
Member
Posts: 234
Joined: Sun Apr 29, 2007 1:13 am

Post by Pyrofan1 »

Put what?
pcmattman
Member
Member
Posts: 2566
Joined: Sun Jan 14, 2007 9:15 pm
Libera.chat IRC: miselin
Location: Sydney, Australia (I come from a land down under!)
Contact:

Post by pcmattman »

Put what?
Mini
Posts: 18
Joined: Mon Apr 30, 2007 6:29 pm
Contact:

Post by Mini »

Were do I put:

ld -T Link.ld -o Kernel.bin Loader.o Kernel.o Video.o

? Do I put it in the command promt or do I put it in a .cpp or a .h file were do I put it?
===RygnorkOS Progress===
Version:ALPHA BETA, 0.0.1
Currently working on: getting bootloader to actually work >:(
Pyrofan1
Member
Member
Posts: 234
Joined: Sun Apr 29, 2007 1:13 am

Post by Pyrofan1 »

yes you enter it into a prompt or you put it in a make file
pcmattman
Member
Member
Posts: 2566
Joined: Sun Jan 14, 2007 9:15 pm
Libera.chat IRC: miselin
Location: Sydney, Australia (I come from a land down under!)
Contact:

Post by pcmattman »

OK, that's a command line to run the executable 'ld'. Do you have GCC?

Also, make sure that loader.o, kernel.o and video.o exist (assembled, compiled etc...).

Command lines are second nature to the operating system developer. You'll have to get used to them.
Mini
Posts: 18
Joined: Mon Apr 30, 2007 6:29 pm
Contact:

Post by Mini »

how do I put it into a makefile?
===RygnorkOS Progress===
Version:ALPHA BETA, 0.0.1
Currently working on: getting bootloader to actually work >:(
Mini
Posts: 18
Joined: Mon Apr 30, 2007 6:29 pm
Contact:

Post by Mini »

No I dont have GCC I have DevC++
===RygnorkOS Progress===
Version:ALPHA BETA, 0.0.1
Currently working on: getting bootloader to actually work >:(
User avatar
Brynet-Inc
Member
Member
Posts: 2426
Joined: Tue Oct 17, 2006 9:29 pm
Libera.chat IRC: brynet
Location: Canada
Contact:

Post by Brynet-Inc »

Mini wrote:No I dont have GCC I have DevC++
Wow, This is rather... funny, DevC++ is a Windows frontend to GCC "Mini"..

Is anyone else buying this kids 1 year programming claim?

I'll say this "Mini", For someone who has been using GCC for a year.. you sure haven't learnt much if you don't even know the name of compiler you're using..

And not having the ability to determine what is and what isn't a command line? How is that possible?
Image
Twitter: @canadianbryan. Award by smcerm, I stole it. Original was larger.
User avatar
Alboin
Member
Member
Posts: 1466
Joined: Thu Jan 04, 2007 3:29 pm
Location: Noricum and Pannonia

Post by Alboin »

Brynet-Inc wrote:
Mini wrote:No I dont have GCC I have DevC++
Wow, This is rather... funny, DevC++ is a Windows frontend to GCC "Mini"..

Is anyone else buying this kids 1 year programming claim?
Do you know 'kid' is from the Norse word 'kidh'? I was looking up if 'kids' is possessive or just plural. Is it "kid's", or "kids' "? I can't find a straight answer.
Brynet-Inc wrote: I'll say this "Mini", For someone who has been using GCC for a year.. you sure haven't learnt much if you don't even know the name of compiler you're using..

And not having the ability to determine what is and what isn't a command line? How is that possible?
Is there a book that actually explains what a compiler is, what a linker is, or even what an IDE really is? It seems that every introduction book omits these. It just says "type this", "type that". This is greatly annoying and is the root for problems like this. Maybe I'll write a tutorial or something....
C8H10N4O2 | #446691 | Trust the nodes.
User avatar
Combuster
Member
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:

Post by Combuster »

Alboin wrote:Is there a book that actually explains what a compiler is, what a linker is, or even what an IDE really is? It seems that every introduction book omits these. It just says "type this", "type that". This is greatly annoying and is the root for problems like this. Maybe I'll write a tutorial or something....
There is wikipedia, and there's no reason to not use it instead :roll:
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
Post Reply