XainFaith wrote:
Problem is any time i do a debug build the debug information is placed after the end of kernel symbol and that then screws up the offset to the initrd.
I'm afraid this is a known GNU/ld issue, which regularly pops up on this forum. I first run into this problem three years ago, and haven't found any solution as of yet.
I'd recommend altering your boot loader to load the kernel and the initrd separately, then pass the address of the initrd to your kernel. Or alternatively you could do what I do, I include the kernel itself in the initrd. Assuming your kernel is the first file in the initrd, you can get the address by using not bss_end, but text_start label minus 512.
Code:
x --- initrd start
512 bytes kernel file meta info
x+512 --- kernel (first file's content in tar)
text_start label, defined by your linker script
...
bss_end label
(some additional debug sections)
x+y ---- second file in tar
... more files ...
This way you don't have to care about how big the debug info section is, because you can jump over your entire kernel using the tar meta info. Downside you'll have to be careful about allocating the bss, so that it won't overlap with the second file (I solve this by mapping the kernel at higher half, and mapping known-to-be-free pages for the bss).
Cheers,
bzt