".rodata.str1.4" linux linker error

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
GLneo
Member
Member
Posts: 237
Joined: Wed Dec 20, 2006 7:56 pm

".rodata.str1.4" linux linker error

Post 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.
User avatar
JamesM
Member
Member
Posts: 2935
Joined: Tue Jul 10, 2007 5:27 am
Location: York, United Kingdom
Contact:

Post 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.
User avatar
AJ
Member
Member
Posts: 2646
Joined: Sun Oct 22, 2006 7:01 am
Location: Devon, UK
Contact:

Post 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
GLneo
Member
Member
Posts: 237
Joined: Wed Dec 20, 2006 7:56 pm

Post 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
GLneo
Member
Member
Posts: 237
Joined: Wed Dec 20, 2006 7:56 pm

Post 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?
User avatar
Solar
Member
Member
Posts: 7615
Joined: Thu Nov 16, 2006 12:01 pm
Location: Germany
Contact:

Post 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.)
Every good solution is obvious once you've found it.
GLneo
Member
Member
Posts: 237
Joined: Wed Dec 20, 2006 7:56 pm

Post 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
User avatar
JamesM
Member
Member
Posts: 2935
Joined: Tue Jul 10, 2007 5:27 am
Location: York, United Kingdom
Contact:

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