Talk:Grub Error 13

From OSDev Wiki
Jump to: navigation, search

Comments

Note: This article places the Multiboot header in a separate section in an attempt of good coding practice. The problem with this technique is that once the kernel becomes big enough, the section may or may not reside in the first 8 KiB of the image. Getting your hands dirty with manually modifying the order of the sections is not a good programming practice. There is nothing wrong with having the header in the .text section; In fact I would strongly recommend it. --Love4boobies 08:59, 18 April 2010 (UTC)

Wrong - putting the multiboot header in .text makes it completely vulnerable to file placement, and is the prime cause for the ton of forum threads "I get error 13 when I expand my kernel". The solution is the exact opposite: place it in a separate section, and force that section up front via the linker script (which you'll already have anyway), so the linker is forced to place it up front in the binary, and not somewhere among the .text objects at the whims of the linker. (Comment removed from original page) - Combuster 08:44, 19 April 2010 (UTC)
Using a linker script and proper alignment is the key, I can't see why a separate section is needed. Another problem with using a separate section is that it doesn't work with all executable formats. - Love4boobies 09:54, 19 April 2010 (UTC)
File placement is the problem, with a linker script you can make the multiboot header reside at the beginning of the file without having to know what file it is in. Just putting it in the .text means that if the file containing is moved past 8KiB or your linker decides to reorder the .text section, it won't be in the correct position (this happened to me when building on windows, I was using *.o in my linker script because the command line was too long and my mboot header moved too far) - Thepowersgang 13:12, 19 April 2010 (UTC)
Personal tools
Namespaces
Variants
Actions
Navigation
About
Toolbox