Can you solve my problem about linking ?

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
behzad24b
Posts: 5
Joined: Sun Aug 24, 2008 3:33 am

Can you solve my problem about linking ?

Post by behzad24b »

how can i compile and link my os parts in windows environment and with GCC & NASM ?
pleas help me and say with wich commandline options i can compile my kernel truly in windows?
the commandlins that i use are :

for NASM:
nasm -f aout loader.asm -o loader.o

for gcc :
gcc -Wall -O -fstrength-reduce -fomit-frame-pointer -finline-funct
ions -nostdinc -fno-builtin -I./include -c -o kernel.o kernel.c

for linking :
ld -r -i -e _start -Ttext 0x1000 -o os.o kernel.o graphic.o

for create binary file :
C:\cygwin\bin>objcopy -R .note -R .comment -S -O binary os.o os.bin

for example my problem is in linking , when i want to call an external function that i write in other file for example an OBJ file that compiled with nasm or an OBJ file that compiled with GCC same as graphic.o , after linking these parts , I disassemble the output obj file and i see that when a function called , the call function in assembly code , called an incorrect address that there not exist a valid function .
my NASM version is 2.02
my GCC version is 3.4.4

pleeeeeeas help to me , i work on this problem about 3 month but still i can't solve that . [-o<

im sorry for my bad english writing. :oops:
albeva
Member
Member
Posts: 42
Joined: Thu Aug 21, 2008 8:31 pm

Re: Can you solve my problem about linking ?

Post by albeva »

I take it you are using mingw? mingw is bad for OS deving.

Check out this: http://wiki.osdev.org/GCC_Cross-Compiler
Laksen
Member
Member
Posts: 140
Joined: Fri Nov 09, 2007 3:30 am
Location: Aalborg, Denmark

Re: Can you solve my problem about linking ?

Post by Laksen »

You use the -r flag for ld. That means that the linked object will be a relocatable executable, thus no function calls will be pointing to the correct locations yet
http://j-software.dk | JPasKernel - My Object Pascal kernel
behzad24b
Posts: 5
Joined: Sun Aug 24, 2008 3:33 am

Re: Can you solve my problem about linking ?

Post by behzad24b »

thanks .
I use Cygwin .
now i tray it without -r but still have that problem :(
ru2aqare
Member
Member
Posts: 342
Joined: Fri Jul 11, 2008 5:15 am
Location: Hungary

Re: Can you solve my problem about linking ?

Post by ru2aqare »

behzad24b wrote:thanks .
I use Cygwin .
now i tray it without -r but still have that problem :(
If you want, you could try my linker. It accepts COFF files only, and produces PE or flat binary output. Read more here.
behzad24b
Posts: 5
Joined: Sun Aug 24, 2008 3:33 am

Re: Can you solve my problem about linking ?

Post by behzad24b »

i download your linker . please help me how it work and how i can use that ?
please say an example about commandline options.
Post Reply