Explorar o código

Fix boot-sector jump into the pack_lba field

_start jumped with a hardcoded EB 40, which lands four bytes before
loader_start, inside pack_lba.  That only booted while the field's low
byte decoded as a harmless push cs (0x0E); a pack_lba of 527 (0x0F)
executes larw with an invalid selector and the BIOS never reaches the
loader.  Any kernel large enough to need 526 sectors would have made the
floppy and final.bin images unbootable.

Compute the displacement from loader_start so the fixed header slots can
no longer move the entry point, and verify a 526-sector kernel boots.
Johannes Zellner hai 2 semanas
pai
achega
97ea952756
Modificáronse 1 ficheiros con 8 adicións e 1 borrados
  1. 8 1
      boot.S

+ 8 - 1
boot.S

@@ -6,7 +6,14 @@
 
 .globl _start
 _start:
-	.byte 0xEB, 0x40, 0x90
+	/* Short jump over the BPB and the fixed header slots to loader_start.
+	 * The displacement is computed so the header layout below can change
+	 * without leaving the jump inside a header field (a hardcoded 0x40
+	 * landed in pack_lba, where 0x0E decoded as a harmless push cs and
+	 * 0x0F as a faulting larw). */
+	.byte 0xEB
+	.byte loader_start - _start - 2
+	.byte 0x90
 	/* ---- BPB (BIOS Parameter Block) ---- */
 	.ascii "NEBOS   "        /* OEM name */
 	.word 512                /* bytes per sector */