I ran into some confusion in the following situation:
* custom bootloader loads stage 2 at 0x600
* stage 2 loads "kernel" from defined sectors to 0x7C00
* kernel is compiled/linked to elf then objcopied to flat binary
* kernel is written i c, compiled with a gcc cross-compiler
Originally, I was using the bare bones linker script. Global variables, const and otherwise, did not appear to be initialized correctly. I could move the variables to a function body and they would work fine. (In this particular case the variables were used as text attributes for printing to the screen.) The elf file listed the symbols in .rodata and .data sections.
As soon as I switched to Bran's linker script it worked correctly. Can somebody explain the difference between including .rodata within the ".text" section of a linker script à la Bran's kernel tutorial vs. keeping the .rodata in it's own section (bare bones)? Is there some other difference in the scripts that fixed the problem I was experiencing? Does it have something to do with the conversion to flat binary?
Thanks!
c global variables and linker scripts
Re: c global variables and linker scripts
Think about how the global variables in your program are initialised. I'd be suspicious about how the objcopy step is handling your rodata section.
If a trainstation is where trains stop, what is a workstation ?