Linking help

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.
Post Reply
hazardoxide
Member
Member
Posts: 26
Joined: Thu Dec 13, 2007 12:31 pm

Linking help

Post 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
If bill gates had a dollar for everytime windows crashed...oh wait... he does.
Craze Frog
Member
Member
Posts: 368
Joined: Sun Sep 23, 2007 4:52 am

Post 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.)
hazardoxide
Member
Member
Posts: 26
Joined: Thu Dec 13, 2007 12:31 pm

Post by hazardoxide »

i have cygwin with gcc and binutils
If bill gates had a dollar for everytime windows crashed...oh wait... he does.
hazardoxide
Member
Member
Posts: 26
Joined: Thu Dec 13, 2007 12:31 pm

Post 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
If bill gates had a dollar for everytime windows crashed...oh wait... he does.
User avatar
t0xic
Member
Member
Posts: 216
Joined: Sat May 05, 2007 3:16 pm
Location: VA
Contact:

Post by t0xic »

Well, in one example you typed "\Link.ld", and the other one you typed "/Limk.ld". I think you meant Link

--Michael
hazardoxide
Member
Member
Posts: 26
Joined: Thu Dec 13, 2007 12:31 pm

Post by hazardoxide »

I did infact mean Link, but in cygwin, my problem still stands
If bill gates had a dollar for everytime windows crashed...oh wait... he does.
User avatar
t0xic
Member
Member
Posts: 216
Joined: Sat May 05, 2007 3:16 pm
Location: VA
Contact:

Post by t0xic »

iirc, you need /cygdrive/c/link.ld if you reference windows drives
hazardoxide
Member
Member
Posts: 26
Joined: Thu Dec 13, 2007 12:31 pm

Post by hazardoxide »

WTF. It still doesnt work. no such file or directory...grr...
If bill gates had a dollar for everytime windows crashed...oh wait... he does.
User avatar
t0xic
Member
Member
Posts: 216
Joined: Sat May 05, 2007 3:16 pm
Location: VA
Contact:

Post by t0xic »

Are you sure that the file is there?
hazardoxide
Member
Member
Posts: 26
Joined: Thu Dec 13, 2007 12:31 pm

Post by hazardoxide »

yea, im positive.
If bill gates had a dollar for everytime windows crashed...oh wait... he does.
hazardoxide
Member
Member
Posts: 26
Joined: Thu Dec 13, 2007 12:31 pm

Post by hazardoxide »

Image
If bill gates had a dollar for everytime windows crashed...oh wait... he does.
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 »

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:
Image
Twitter: @canadianbryan. Award by smcerm, I stole it. Original was larger.
hazardoxide
Member
Member
Posts: 26
Joined: Thu Dec 13, 2007 12:31 pm

Post 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.
If bill gates had a dollar for everytime windows crashed...oh wait... he does.
User avatar
t0xic
Member
Member
Posts: 216
Joined: Sat May 05, 2007 3:16 pm
Location: VA
Contact:

Post 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
Post Reply