]> git.ipfire.org Git - thirdparty/grub.git/commitdiff
* grub-core/kern/ia64/dl_helper.c (grub_ia64_dl_get_tramp_got_size):
authorVladimir 'phcoder' Serbinenko <phcoder@gmail.com>
Tue, 17 May 2011 22:21:49 +0000 (00:21 +0200)
committerVladimir 'phcoder' Serbinenko <phcoder@gmail.com>
Tue, 17 May 2011 22:21:49 +0000 (00:21 +0200)
Fix potential usage of Elf32 instead of Elf64 when compiling on
32-bit architecture. Add endianness macros while on it.

ChangeLog
grub-core/kern/ia64/dl_helper.c

index 1d4076a5b41e1de71a6a5872002c2213581dd741..59574202a6560fe412fdd3fe2d89301e6bcb79ff 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2011-05-17  Vladimir Serbinenko  <phcoder@gmail.com>
+
+       * grub-core/kern/ia64/dl_helper.c (grub_ia64_dl_get_tramp_got_size):
+       Fix potential usage of Elf32 instead of Elf64 when compiling on
+       32-bit architecture. Add endianness macros while on it.
+
 2011-05-17  Vladimir Serbinenko  <phcoder@gmail.com>
 
        Use mipsel- rather than mips- in directories involving mipsel ports to
index 9503c49eafd6e2010f927b4451d7015132151b5d..91f28026e2c767eb6dad211bb6c60c2ffa5b9d19 100644 (file)
@@ -27,35 +27,35 @@ void
 grub_ia64_dl_get_tramp_got_size (const void *ehdr, grub_size_t *tramp,
                                 grub_size_t *got)
 {
-  const Elf_Ehdr *e = ehdr;
+  const Elf64_Ehdr *e = ehdr;
   grub_size_t cntt = 0, cntg = 0;;
-  const Elf_Shdr *s;
-  Elf_Word entsize;
+  const Elf64_Shdr *s;
+  Elf64_Word entsize;
   unsigned i;
 
   /* Find a symbol table.  */
-  for (i = 0, s = (Elf_Shdr *) ((char *) e + e->e_shoff);
-       i < e->e_shnum;
-       i++, s = (Elf_Shdr *) ((char *) s + e->e_shentsize))
-    if (s->sh_type == SHT_SYMTAB)
+  for (i = 0, s = (Elf64_Shdr *) ((char *) e + grub_le_to_cpu32 (e->e_shoff));
+       i < grub_le_to_cpu16 (e->e_shnum);
+       i++, s = (Elf64_Shdr *) ((char *) s + grub_le_to_cpu16 (e->e_shentsize)))
+    if (grub_le_to_cpu32 (s->sh_type) == SHT_SYMTAB)
       break;
 
-  if (i == e->e_shnum)
+  if (i == grub_le_to_cpu16 (e->e_shnum))
     return;
 
   entsize = s->sh_entsize;
 
-  for (i = 0, s = (Elf_Shdr *) ((char *) e + e->e_shoff);
-       i < e->e_shnum;
-       i++, s = (Elf_Shdr *) ((char *) s + e->e_shentsize))
-    if (s->sh_type == SHT_RELA)
+  for (i = 0, s = (Elf64_Shdr *) ((char *) e + grub_le_to_cpu32 (e->e_shoff));
+       i < grub_le_to_cpu16 (e->e_shnum);
+       i++, s = (Elf64_Shdr *) ((char *) s + grub_le_to_cpu16 (e->e_shentsize)))
+    if (grub_le_to_cpu32 (s->sh_type) == SHT_RELA)
       {
-       Elf_Rela *rel, *max;
+       Elf64_Rela *rel, *max;
 
-       for (rel = (Elf_Rela *) ((char *) e + s->sh_offset),
-              max = rel + s->sh_size / s->sh_entsize;
+       for (rel = (Elf64_Rela *) ((char *) e + grub_le_to_cpu32 (s->sh_offset)),
+              max = rel + grub_le_to_cpu32 (s->sh_size) / grub_le_to_cpu16 (s->sh_entsize);
             rel < max; rel++)
-         switch (ELF_R_TYPE (rel->r_info))
+         switch (ELF64_R_TYPE (grub_le_to_cpu32 (rel->r_info)))
            {
            case R_IA64_PCREL21B:
              cntt++;