[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 3/7] mkimage: account for space for trampolines earlier
From: |
Ian Campbell |
Subject: |
[PATCH 3/7] mkimage: account for space for trampolines earlier |
Date: |
Sun, 29 Dec 2013 18:47:32 +0000 |
In particular we will want to do this before assigning space for .bss,
otherwise the trampoline will potentially overlap the start of .bss and might
be cleared before it is used.
I'm in two minds about whether this is fixing and actual (perhaps latent) bug
or not. AFAICT none of the existing targets which need trampolines require a
.bss assignment here (e.g. they generate PE images which means the .bss gets
taken care of at load time).
Apart from duplicating the surrounding if statement this is pure code motion.
Signed-off-by: Ian Campbell <address@hidden>
---
util/grub-mkimagexx.c | 77 ++++++++++++++++++++++++++-------------------------
1 file changed, 40 insertions(+), 37 deletions(-)
diff --git a/util/grub-mkimagexx.c b/util/grub-mkimagexx.c
index f5e514f..399ff6a 100644
--- a/util/grub-mkimagexx.c
+++ b/util/grub-mkimagexx.c
@@ -1481,6 +1481,46 @@ SUFFIX (load_image) (const char *kernel_path, size_t
*exec_size,
exec_size, kernel_sz, align,
image_target);
+ if (grub_image_needs_reloc(image_target))
+ {
+#ifdef MKIMAGE_ELF32
+ if (image_target->elf_target == EM_ARM)
+ {
+ grub_size_t tramp;
+
+ *kernel_sz = ALIGN_UP (*kernel_sz, 16);
+
+ tramp = arm_get_trampoline_size (e, sections, section_entsize,
+ num_sections, image_target);
+
+ tramp_off = *kernel_sz;
+ *kernel_sz += ALIGN_UP (tramp, 16);
+ }
+#endif
+
+#ifdef MKIMAGE_ELF64
+ if (image_target->elf_target == EM_IA_64)
+ {
+ grub_size_t tramp;
+
+ *kernel_sz = ALIGN_UP (*kernel_sz, 16);
+
+ grub_ia64_dl_get_tramp_got_size (e, &tramp, &got);
+
+ tramp_off = *kernel_sz;
+ *kernel_sz += ALIGN_UP (tramp, 16);
+
+ ia64jmp_off = *kernel_sz;
+ ia64jmpnum = SUFFIX (count_funcs) (e, symtab_section,
+ image_target);
+ *kernel_sz += 16 * ia64jmpnum;
+
+ ia64_got_off = *kernel_sz;
+ *kernel_sz += ALIGN_UP (got, 16);
+ }
+#endif
+ }
+
section_vaddresses = xmalloc (sizeof (*section_addresses) * num_sections);
for (i = 0; i < num_sections; i++)
@@ -1540,43 +1580,6 @@ SUFFIX (load_image) (const char *kernel_path, size_t
*exec_size,
break;
}
-#ifdef MKIMAGE_ELF32
- if (image_target->elf_target == EM_ARM)
- {
- grub_size_t tramp;
-
- *kernel_sz = ALIGN_UP (*kernel_sz, 16);
-
- tramp = arm_get_trampoline_size (e, sections, section_entsize,
- num_sections, image_target);
-
- tramp_off = *kernel_sz;
- *kernel_sz += ALIGN_UP (tramp, 16);
- }
-#endif
-
-#ifdef MKIMAGE_ELF64
- if (image_target->elf_target == EM_IA_64)
- {
- grub_size_t tramp;
-
- *kernel_sz = ALIGN_UP (*kernel_sz, 16);
-
- grub_ia64_dl_get_tramp_got_size (e, &tramp, &got);
-
- tramp_off = *kernel_sz;
- *kernel_sz += ALIGN_UP (tramp, 16);
-
- ia64jmp_off = *kernel_sz;
- ia64jmpnum = SUFFIX (count_funcs) (e, symtab_section,
- image_target);
- *kernel_sz += 16 * ia64jmpnum;
-
- ia64_got_off = *kernel_sz;
- *kernel_sz += ALIGN_UP (got, 16);
- }
-#endif
-
if (! symtab_section)
grub_util_error ("%s", _("no symbol table"));
}
--
1.8.4.rc3
- [PATCH 0/7] arm-uboot: support for different RAM bases, Ian Campbell, 2013/12/29
- [PATCH 2/7] mkimage: Replace hardcoded 0x400 in R_ARM_ABS32 relocation, Ian Campbell, 2013/12/29
- [PATCH 1/7] mkimage: Refactor IMAGE_EFI checks into a function grub_image_needs_reloc., Ian Campbell, 2013/12/29
- [PATCH 3/7] mkimage: account for space for trampolines earlier,
Ian Campbell <=
- [PATCH 4/7] mkimage: make R_ARM_ABS32 debug output more consistent, Ian Campbell, 2013/12/29
- [PATCH 5/7] mkimage: allow linking at address 0, Ian Campbell, 2013/12/29
- [PATCH 6/7] mkimage: support images which require full relocation at mkimage time., Ian Campbell, 2013/12/29
- [PATCH 7/7] arm-uboot: support relocation at installation time, Ian Campbell, 2013/12/29