grub-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH 5/7] mkimage: allow linking at address 0


From: Ian Campbell
Subject: [PATCH 5/7] mkimage: allow linking at address 0
Date: Sun, 29 Dec 2013 18:47:34 +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 <address@hidden>
---
 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




reply via email to

[Prev in Thread] Current Thread [Next in Thread]