From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1VxLP5-0001GQ-72 for mharc-grub-devel@gnu.org; Sun, 29 Dec 2013 13:47:59 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41722) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VxLOx-000139-NU for grub-devel@gnu.org; Sun, 29 Dec 2013 13:47:57 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VxLOr-0008Jf-Ms for grub-devel@gnu.org; Sun, 29 Dec 2013 13:47:51 -0500 Received: from benson.vm.bytemark.co.uk ([212.110.190.137]:37730) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VxLOr-0008JU-Fc for grub-devel@gnu.org; Sun, 29 Dec 2013 13:47:45 -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 1VxLOp-0000Kj-Uf; Sun, 29 Dec 2013 18:47:44 +0000 Received: by hastur.hellion.org.uk (sSMTP sendmail emulation); Sun, 29 Dec 2013 18:47:43 +0000 From: Ian Campbell To: grub-devel@gnu.org Subject: [PATCH 5/7] mkimage: allow linking at address 0 Date: Sun, 29 Dec 2013 18:47:34 +0000 Message-Id: <1388342856-18317-5-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:58 -0000 Running from address 0 is plausible at least in principal. Use the maximum possible address as a sentinal instead. Signed-off-by: Ian Campbell --- util/grub-mkimagexx.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/util/grub-mkimagexx.c b/util/grub-mkimagexx.c index 759e838..b4216ff 100644 --- a/util/grub-mkimagexx.c +++ b/util/grub-mkimagexx.c @@ -64,6 +64,8 @@ static Elf_Addr SUFFIX (entry_point); +#define INVALID_START_ADDR (~((Elf_Addr)0)) + static void SUFFIX (generate_elf) (const struct grub_install_image_target_desc *image_target, int note, char **core_img, size_t *core_size, @@ -380,7 +382,7 @@ SUFFIX (relocate_symbols) (Elf_Ehdr *e, Elf_Shdr *sections, { Elf_Word symtab_size, sym_size, num_syms; Elf_Off symtab_offset; - Elf_Addr start_address = 0; + Elf_Addr start_address = INVALID_START_ADDR; Elf_Sym *sym; Elf_Word i; Elf_Shdr *strtab_section; @@ -439,7 +441,7 @@ SUFFIX (relocate_symbols) (Elf_Ehdr *e, Elf_Shdr *sections, (unsigned long long) sym->st_value, (unsigned long long) section_addresses[cur_index]); - if (! start_address) + if (start_address == INVALID_START_ADDR) if (strcmp (name, "_start") == 0 || strcmp (name, "start") == 0) start_address = sym->st_value; } @@ -1602,7 +1604,7 @@ SUFFIX (load_image) (const char *kernel_path, size_t *exec_size, ia64jmp_off + image_target->vaddr_offset, image_target); - if (*start == 0) + if (*start == INVALID_START_ADDR) grub_util_error ("start symbol is not defined"); SUFFIX (entry_point) = (Elf_Addr) *start; @@ -1664,3 +1666,4 @@ SUFFIX (load_image) (const char *kernel_path, size_t *exec_size, #undef Elf_Section #undef ELF_ST_TYPE #undef XEN_NOTE_SIZE +#undef INVALID_START_ADDR -- 1.8.4.rc3