Page 1 of 1

".rodata.str1.4" linux linker error

Posted: Mon Mar 17, 2008 8:31 am
by GLneo
Hello all, I have started to try to get my kernel compiling on Linux ( previously working on windows ), and all goes well untill i get the following linker error:

Code: Select all

ld: section .kernel [0000000000100400 -> 0000000000105e5b] overlaps section .rodata.str1.1 [0000000000100400 -> 0000000000100af1]
ld: section .rodata.str1.4 [0000000000100af4 -> 0000000000101497] overlaps section .kernel [0000000000100400 -> 0000000000105e5b]
this is my linker script:

Code: Select all

OUTPUT_FORMAT("binary")
ENTRY(start)
phys = 0x00100000;
virt = 0xC0000400;
SECTIONS
{
  .setup phys : AT( phys )
  {
    setup = .; _setup = .; __setup = .;
    *(.setup)
    setupend = .;
    . = ALIGN(1024);
  }
  .kernel virt : AT( ADDR(.setup) + SIZEOF(.setup) )
  {
    code = .; _code = .; __code = .;
    *(.text)
    codend = .;
    . = ALIGN(0);
  }
  .data : AT( ADDR(.setup) + SIZEOF(.setup) + SIZEOF(.kernel) )
  {
    data = .; _data = .; __data = .;
    *(.data)
    dataend = .;
    . = ALIGN(0);
  }
  .bss : AT( ADDR(.setup) + SIZEOF(.setup) + SIZEOF(.kernel) + SIZEOF(.data) )
  {
    bss = .; _bss = .; __bss = .;
    *(.bss)
    bssend = .;
    . = ALIGN(0);
  }
  setuplength = SIZEOF(.setup);
  bsslength = (bssend - bss) / 4;
  kend = .; _kend = .; __kend = .;
}
and I do not know what the .rodata.str1 section even is? does anyone know what I could add to my linker script to correct this error?

Thank you.

Posted: Mon Mar 17, 2008 9:00 am
by JamesM
Your .kernel section isn't actually mentioned in your linker script. Change this:

Code: Select all

.kernel virt : AT( ADDR(.setup) + SIZEOF(.setup) )
  {
    code = .; _code = .; __code = .;
    *(.text)
    *(.kernel) <---- ADD THIS LINE
    codend = .;
    . = ALIGN(0);
  } 
And hopefully it should link.

Posted: Mon Mar 17, 2008 9:26 am
by AJ
Hi,

Also, I don't know about .rodata.str, but I can't see a .rodata section listed either (you may like to list this along with your .data section).

Cheers,
Adam

Posted: Mon Mar 17, 2008 10:12 am
by GLneo
thank you for reply, I have tried both suggestions but the error remains.

Code: Select all

gcc --version
gcc (GCC) 4.1.3 20070929 (prerelease) (Ubuntu 4.1.2-16ubuntu2)
just in case it matters

Posted: Tue Mar 18, 2008 6:03 pm
by GLneo
ok i added a .rodata section after my .kernel section and .rodata started over lapping my .data section, so i moved it down past .data and it started overwriting my .bss section, so i moved it to the bottom of my linker script and it compiled, but my kernel doesn't run, this could be one of a million problems compiling it on Linux would of made , so i but a text printer in my boot sector to see if i even got their, but nothing showed up, how do i step though my code in bochs or something?

Posted: Wed Mar 19, 2008 1:15 am
by Solar
I'd try a different approach at this point.

You said you worked under Windows previously. Was that, by any chance, a Cygwin / Cross-Compiler setup?

If yes, simply build a cross-compiler under Linux, following the exact same instructions, to get an exact same build environment.

(Still you should try to find out what's actually happening there, but at least you'd be able to compile the status quo again.)

Posted: Wed Mar 19, 2008 8:54 am
by GLneo
I was using DJGPP. My kernel compiles fine now, but I had to modified the linker so I don't know if I broke something because when I test the OS I don't think it even gets past the boot sector

also with Linux how can I make an image file? how would I add my boot sector and kernel using dd or somthing?

thx

Posted: Wed Mar 19, 2008 9:14 am
by JamesM
You modified the linker?! :shock:

There are prebuilt image files all over the place, see http://www.jamesmolloy.co.uk/tutorial_html, chapter 1 for one and an example loopback mount script.