From 98ba56ad890366d38568a83b3ed95ee510d7f4c1 Mon Sep 17 00:00:00 2001 From: Alexander Kuleshov Date: Sun, 1 Apr 2018 00:44:19 +0600 Subject: [PATCH] add description for alignment check of loadable segments https://github.com/torvalds/linux/commit/c55b8550fa57ba4f5e507be406ff9fc2845713e8 --- Booting/linux-bootstrap-5.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Booting/linux-bootstrap-5.md b/Booting/linux-bootstrap-5.md index f10100f..5a35a24 100644 --- a/Booting/linux-bootstrap-5.md +++ b/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);