From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1VxLOy-00013l-6m for mharc-grub-devel@gnu.org; Sun, 29 Dec 2013 13:47:52 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41651) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VxLOq-0000vv-PP for grub-devel@gnu.org; Sun, 29 Dec 2013 13:47:50 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VxLOk-0008HM-PD for grub-devel@gnu.org; Sun, 29 Dec 2013 13:47:44 -0500 Received: from benson.vm.bytemark.co.uk ([212.110.190.137]:37718) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VxLOk-0008H7-K0 for grub-devel@gnu.org; Sun, 29 Dec 2013 13:47:38 -0500 Received: from cpc22-cmbg14-2-0-cust482.5-4.cable.virginm.net ([86.6.25.227] helo=hastur.hellion.org.uk) by benson.vm.bytemark.co.uk with esmtpsa (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.72) (envelope-from ) id 1VxLOj-0000K8-2B; Sun, 29 Dec 2013 18:47:38 +0000 Received: by hastur.hellion.org.uk (sSMTP sendmail emulation); Sun, 29 Dec 2013 18:47:36 +0000 From: Ian Campbell To: grub-devel@gnu.org Subject: [PATCH 1/7] mkimage: Refactor IMAGE_EFI checks into a function grub_image_needs_reloc. Date: Sun, 29 Dec 2013 18:47:30 +0000 Message-Id: <1388342856-18317-1-git-send-email-ijc@hellion.org.uk> X-Mailer: git-send-email 1.8.4.rc3 In-Reply-To: <1388342839.32105.25.camel@hastur.hellion.org.uk> References: <1388342839.32105.25.camel@hastur.hellion.org.uk> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic] X-Received-From: 212.110.190.137 Cc: Vladimir Serbinenko , Leif Lindholm , Ian Campbell X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list Reply-To: The development of GNU GRUB List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 29 Dec 2013 18:47:50 -0000 Signed-off-by: Ian Campbell --- util/grub-mkimagexx.c | 12 ++++++------ util/mkimage.c | 7 +++++++ 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/util/grub-mkimagexx.c b/util/grub-mkimagexx.c index 0a1ac9e..d059396 100644 --- a/util/grub-mkimagexx.c +++ b/util/grub-mkimagexx.c @@ -1371,7 +1371,7 @@ SUFFIX (locate_sections) (const char *kernel_path, grub_util_info ("locating the section %s at 0x%" GRUB_HOST_PRIxLONG_LONG, name, (unsigned long long) current_address); - if (image_target->id != IMAGE_EFI) + if (!grub_image_needs_reloc(image_target)) { current_address = grub_host_to_target_addr (s->sh_addr) - image_target->link_addr; @@ -1413,7 +1413,7 @@ SUFFIX (locate_sections) (const char *kernel_path, grub_util_info ("locating the section %s at 0x%" GRUB_HOST_PRIxLONG_LONG, name, (unsigned long long) current_address); - if (image_target->id != IMAGE_EFI) + if (!grub_image_needs_reloc(image_target)) current_address = grub_host_to_target_addr (s->sh_addr) - image_target->link_addr; section_addresses[i] = current_address; @@ -1486,7 +1486,7 @@ SUFFIX (load_image) (const char *kernel_path, size_t *exec_size, for (i = 0; i < num_sections; i++) section_vaddresses[i] = section_addresses[i] + image_target->vaddr_offset; - if (image_target->id != IMAGE_EFI) + if (!grub_image_needs_reloc(image_target)) { Elf_Addr current_address = *kernel_sz; @@ -1507,7 +1507,7 @@ SUFFIX (load_image) (const char *kernel_path, size_t *exec_size, grub_util_info ("locating the section %s at 0x%" GRUB_HOST_PRIxLONG_LONG, name, (unsigned long long) current_address); - if (image_target->id != IMAGE_EFI) + if (!grub_image_needs_reloc(image_target)) current_address = grub_host_to_target_addr (s->sh_addr) - image_target->link_addr; @@ -1528,7 +1528,7 @@ SUFFIX (load_image) (const char *kernel_path, size_t *exec_size, || image_target->id == IMAGE_SPARC64_CDCORE) *kernel_sz = ALIGN_UP (*kernel_sz, image_target->mod_align); - if (image_target->id == IMAGE_EFI) + if (grub_image_needs_reloc(image_target)) { symtab_section = NULL; for (i = 0, s = sections; @@ -1588,7 +1588,7 @@ SUFFIX (load_image) (const char *kernel_path, size_t *exec_size, out_img = xmalloc (*kernel_sz + total_module_size); - if (image_target->id == IMAGE_EFI) + if (grub_image_needs_reloc(image_target)) { *start = SUFFIX (relocate_symbols) (e, sections, symtab_section, section_vaddresses, section_entsize, diff --git a/util/mkimage.c b/util/mkimage.c index 26d9816..645e296 100644 --- a/util/mkimage.c +++ b/util/mkimage.c @@ -922,6 +922,13 @@ grub_arm_reloc_jump24 (grub_uint32_t *target, Elf32_Addr sym_addr) return GRUB_ERR_NONE; } +static int grub_image_needs_reloc(const struct grub_install_image_target_desc *target) +{ + if (target->id == IMAGE_EFI) + return 1; + return 0; +} + #pragma GCC diagnostic ignored "-Wcast-align" #define MKIMAGE_ELF32 1 -- 1.8.4.rc3