Parcourir la source

add description for alignment check of loadable segments

https://github.com/torvalds/linux/commit/c55b8550fa57ba4f5e507be406ff9fc2845713e8
Alexander Kuleshov il y a 7 ans
Parent
commit
98ba56ad89
1 fichiers modifiés avec 5 ajouts et 1 suppressions
  1. 5 1
      Booting/linux-bootstrap-5.md

+ 5 - 1
Booting/linux-bootstrap-5.md

@@ -330,7 +330,7 @@ if (ehdr.e_ident[EI_MAG0] != ELFMAG0 ||
 }
 ```
 
-and if it's not valid, it prints an error message and halts. If we got a valid `ELF` file, we go through all program headers from the given `ELF` file and copy all loadable segments with correct address to the output buffer:
+and if it's not valid, it prints an error message and halts. If we got a valid `ELF` file, we go through all program headers from the given `ELF` file and copy all loadable segments with correct 2 megabytes aligned address to the output buffer:
 
 ```C
 	for (i = 0; i < ehdr.e_phnum; i++) {
@@ -338,6 +338,10 @@ and if it's not valid, it prints an error message and halts. If we got a valid `
 
 		switch (phdr->p_type) {
 		case PT_LOAD:
+#ifdef CONFIG_X86_64
+			if ((phdr->p_align % 0x200000) != 0)
+				error("Alignment of LOAD segment isn't multiple of 2MB");
++#endif                
 #ifdef CONFIG_RELOCATABLE
 			dest = output;
 			dest += (phdr->p_paddr - LOAD_PHYSICAL_ADDR);