Page 2 of 2

Posted: Sun Sep 23, 2007 6:32 pm
by deathkillspt
I really don't know what to do, i've tried .rdata and it doesn't seem to be doing anything could you put an example of where to put that in please?

Code: Select all

OUTPUT_FORMAT("binary")
ENTRY(start)
SECTIONS
{
  .text  0x100000 : {
    *(.text)
  }
  .data  : {
    *(.data)
  }
  .bss  :
  { 					
    *(.bss)
  }
}
should i put it in it's own section or should i add it to one of the other one's? I am really sorry if i am being a pest, it's just that i have been trying so hard to figure out why it just won't work

Posted: Sun Sep 23, 2007 6:53 pm
by frank
Your not a pest. I know how irritating something is when it doesn't work.

Code: Select all

OUTPUT_FORMAT("binary")
ENTRY(start)
SECTIONS
{
  .text  0x100000 : {
    *(.text)
    *(.r*)
  }
  .data  : {
    *(.data)
  }
  .bss  :
  {                
    *(.bss)
  }
} 
try that one

Posted: Sun Sep 23, 2007 6:56 pm
by deathkillspt
grr...It still just boots up and prints "S"

Posted: Mon Sep 24, 2007 11:48 am
by vhg119
deathkillspt wrote:grr...It still just boots up and prints "S"
The only problem I see is that your terminating condition is checking for the character '0' rather than '\0'.

I remember I had really strange printing problems also. It turned out that GCC's optimizations were messing everything up for whatever reason. Let us have a look at your cflags.

Vince

Posted: Mon Sep 24, 2007 8:34 pm
by deathkillspt
How exactley would i get my "cflags"?

Posted: Tue Sep 25, 2007 2:03 pm
by frank
deathkillspt wrote:How exactley would i get my "cflags"?
Just tell us what you are passing to GCC and LD. cflags is the the makefile name for what options you pass to gcc.

Posted: Tue Sep 25, 2007 2:52 pm
by deathkillspt

Code: Select all

gcc -c kernel.c -o kernel.o -fwritable-strings
ld -T link.ld -o kernel.bin stub.o kernel.o

Posted: Wed Sep 26, 2007 7:13 pm
by iammisc
did you use -fwritable-strings with your gcc command?

Posted: Wed Sep 26, 2007 7:35 pm
by deathkillspt
iammisc wrote:did you use -fwritable-strings with your gcc command?
Yes I did.

Posted: Thu Sep 27, 2007 6:44 pm
by vhg119
deathkillspt wrote:

Code: Select all

gcc -c kernel.c -o kernel.o -fwritable-strings
ld -T link.ld -o kernel.bin stub.o kernel.o
This is mine... For some reason, the optimizations were screwing around with the loop that prints the strings.

Code: Select all

-Wall -O -floop-optimize2 -fno-builtin -nostdinc -I include -ffreestanding -c
I wish I knew exactly why I get the errors I get. But I don't. I do know that when I did an '-S' to see the assembly listing for gcc, things didn't look right.

Maybe that would be a good advice for you too. Add '-S' to your cflags and check out the assembly code it produces.

Posted: Fri Sep 28, 2007 1:39 am
by JamesM

Code: Select all

gcc -c kernel.c -o kernel.o -fwritable-strings 
ld -T link.ld -o kernel.bin stub.o kernel.o
You must tell the compiler not to use it's standard library. If you don't, you'll end up with all sorts of crap in your executable and stuff that probably will make it die!

Add

Code: Select all

-nostdlib -nostdinc -fno-builtin -fno-stack-protector
To your gcc command. The last one is optional and doesn't work on some newer versions of gcc.

The loop

Posted: Fri Sep 28, 2007 2:29 am
by Mark139
It does look like constant data is missing. Like the previous post I suspect the .rdata section.

Another point is the while is broken

Code: Select all

while(*string!='0')
Will loop until it sees the character zero, which has a value of 48 (if memory serves me correctly). You should have

Code: Select all

while(*string!= 0 )
or even

Code: Select all

while(*string)