/[grub]/grub2/kern/powerpc/dl.c
ViewVC logotype

Diff of /grub2/kern/powerpc/dl.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.3 by marco_g, Thu Jan 20 17:25:39 2005 UTC revision 1.4 by marco_g, Mon Feb 14 18:41:33 2005 UTC
# Line 1  Line 1 
1  /* dl.c - arch-dependent part of loadable module support */  /* dl.c - arch-dependent part of loadable module support */
2  /*  /*
3   *  GRUB  --  GRand Unified Bootloader   *  GRUB  --  GRand Unified Bootloader
4   *  Copyright (C) 2002, 2004  Free Software Foundation, Inc.   *  Copyright (C) 2002, 2004, 2005  Free Software Foundation, Inc.
5   *   *
6   *  GRUB is free software; you can redistribute it and/or modify   *  GRUB is free software; you can redistribute it and/or modify
7   *  it under the terms of the GNU General Public License as published by   *  it under the terms of the GNU General Public License as published by
# Line 24  Line 24 
24  #include <grub/err.h>  #include <grub/err.h>
25    
26  /* Check if EHDR is a valid ELF header.  */  /* Check if EHDR is a valid ELF header.  */
27  int  grub_err_t
28  grub_arch_dl_check_header (void *ehdr, grub_size_t size)  grub_arch_dl_check_header (void *ehdr)
29  {  {
30    Elf32_Ehdr *e = ehdr;    Elf32_Ehdr *e = ehdr;
31    
   /* Check the header size.  */  
   if (size < sizeof (Elf32_Ehdr))  
     return 0;  
   
32    /* Check the magic numbers.  */    /* Check the magic numbers.  */
33    if (!((e->e_ident[EI_MAG0] == ELFMAG0)    if (e->e_ident[EI_CLASS] != ELFCLASS32
34          && (e->e_ident[EI_MAG1] == ELFMAG1)        || e->e_ident[EI_DATA] != ELFDATA2MSB
35          && (e->e_ident[EI_MAG2] == ELFMAG2)        || e->e_machine != EM_PPC)
36          && (e->e_ident[EI_MAG3] == ELFMAG3)      return grub_error (GRUB_ERR_BAD_OS, "invalid arch specific ELF magic");
         && (e->e_ident[EI_CLASS] == ELFCLASS32)  
         && (e->e_ident[EI_DATA] == ELFDATA2MSB)  
         && (e->e_ident[EI_VERSION] == EV_CURRENT)  
         && (e->e_type == ET_REL) && (e->e_machine == EM_PPC)  
         && (e->e_version == EV_CURRENT)))  
     return 0;  
     
   /* Make sure that every section is within the core.  */  
   if (size < e->e_shoff + e->e_shentsize * e->e_shnum)  
     return 0;  
37    
38    return 1;    return GRUB_ERR_NONE;
39  }  }
40    
41    

Legend:
Removed from v.1.3  
changed lines
  Added in v.1.4

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26