Page 1 of 1

Linking help

Posted: Wed Dec 26, 2007 3:02 pm
by hazardoxide
Apologies for the many questions. Yes, I've tried google, couldn't seen to find what i'm looking for. I'm following JamesM's Tut. Using windows with Cyg. I Have boot.o and main.o, how do i link them, i have the link.ld linker script file, but i don't understand how to link them. I looked to ld --help, but couldnt figure out how to use link.ld to link the two into "kernel".

thanks

Posted: Wed Dec 26, 2007 4:12 pm
by Craze Frog
Have you tried something like this?

Code: Select all

ld -T link.ld -o kernel.prg main.o
where link.ld is your linker script, kernel.prg is the output file and the rest is a list of input files?

(By the way, unless you know what you're doing without it, you should build a cross compiler and linker, see the wiki for instructions.)

Posted: Wed Dec 26, 2007 4:26 pm
by hazardoxide
i have cygwin with gcc and binutils

Posted: Wed Dec 26, 2007 4:30 pm
by hazardoxide
hmm. i try:

Code: Select all

 ld -T C:\Link.ld 
and

Code: Select all

 ld -T C:/Limk.ld
and for both it says:

"cannot open linker script file - No such file or directoy

Posted: Wed Dec 26, 2007 4:48 pm
by t0xic
Well, in one example you typed "\Link.ld", and the other one you typed "/Limk.ld". I think you meant Link

--Michael

Posted: Wed Dec 26, 2007 4:57 pm
by hazardoxide
I did infact mean Link, but in cygwin, my problem still stands

Posted: Wed Dec 26, 2007 5:11 pm
by t0xic
iirc, you need /cygdrive/c/link.ld if you reference windows drives

Posted: Wed Dec 26, 2007 5:17 pm
by hazardoxide
WTF. It still doesnt work. no such file or directory...grr...

Posted: Wed Dec 26, 2007 5:24 pm
by t0xic
Are you sure that the file is there?

Posted: Wed Dec 26, 2007 9:34 pm
by hazardoxide
yea, im positive.

Posted: Wed Dec 26, 2007 9:45 pm
by hazardoxide
Image

Posted: Wed Dec 26, 2007 10:05 pm
by Brynet-Inc
I'm no Windows guru, but the solution seems rather obvious... you accidentally named the file "Link.ld.txt" instead of "Link.ld".

Perhaps OSDev is a little bit out of your league... :wink:

Posted: Wed Dec 26, 2007 10:12 pm
by hazardoxide
no, its not saved as txt. its link.ld, cuz where it says "file type: .txt" i changed to *all files* so it has no set file type.

Posted: Wed Dec 26, 2007 10:36 pm
by t0xic
Brynet-Inc wrote:I'm no Windows guru, but the solution seems rather obvious... you accidentally named the file "Link.ld.txt" instead of "Link.ld".

Perhaps OSDev is a little bit out of your league... :wink:
Nah, windows is just like that lol...

I don't know what to say... I have my linker script in my kernel's directory, no problem there. Just move the linker script to where the rest of your files are :P