Bran's Kernel Development Tutorial Known Bugs: Difference between revisions

From OSDev.wiki
Jump to navigation Jump to search
[unchecked revision][unchecked revision]
Content added Content deleted
(There were more, but this one I could remember ad-hoc.)
 
Line 3: Line 3:
===As soon as I add strings, things go wrong.===
===As soon as I add strings, things go wrong.===


The linker script from Bran's tutorial does not add the <tt>rodata</tt> sections to the binary, which is where the compiler does put static strings. Use this one instead:
The linker script from Bran's tutorial does not add the <tt>rodata</tt> sections to the binary, which is where the compiler puts static strings. Use this one instead:


OUTPUT_FORMAT("binary")
OUTPUT_FORMAT("binary")

Revision as of 09:11, 3 April 2007

Several sources - including this Wiki - point to Bran's Kernel Development Tutorial as a starting point. This is all well, but there are some issues with that tutorial that usually make people appear on the forum and asking all the same questions again. This article is meant to preempt those questions, like a "Bran's FAQ" if you like.

As soon as I add strings, things go wrong.

The linker script from Bran's tutorial does not add the rodata sections to the binary, which is where the compiler puts static strings. Use this one instead:

OUTPUT_FORMAT("binary")
ENTRY(start)
phys = 0x00100000;
SECTIONS
{
  .text phys : AT(phys) {
    code = .;
    *(.text)
    *(.rodata)
    . = ALIGN(4096);
  }
  .data : AT(phys + (data - code))
  {
    data = .;
    *(.data)
    . = ALIGN(4096);
  }
  .bss : AT(phys + (bss - code))
  {
    bss = .;
    *(.bss)
    . = ALIGN(4096);
  }
  end = .;
}