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

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

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

revision 1.4 by marco_g, Thu Jan 20 17:25:39 2005 UTC revision 1.5 by marco_g, Mon Feb 14 18:41:33 2005 UTC
# Line 1  Line 1 
1  /* dl-386.c - arch-dependent part of loadable module support */  /* dl-386.c - arch-dependent part of loadable module support */
2  /*  /*
3   *  GRUB  --  GRand Unified Bootloader   *  GRUB  --  GRand Unified Bootloader
4   *  Copyright (C) 2002  Free Software Foundation, Inc.   *  Copyright (C) 2002, 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
       || e->e_ident[EI_MAG1] != ELFMAG1  
       || e->e_ident[EI_MAG2] != ELFMAG2  
       || e->e_ident[EI_MAG3] != ELFMAG3  
       || e->e_version != EV_CURRENT  
       || e->e_ident[EI_CLASS] != ELFCLASS32  
34        || e->e_ident[EI_DATA] != ELFDATA2LSB        || e->e_ident[EI_DATA] != ELFDATA2LSB
35        || e->e_machine != EM_386        || e->e_machine != EM_386)
36        || e->e_type != ET_REL)      return grub_error (GRUB_ERR_BAD_OS, "invalid arch specific ELF magic");
     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  /* Relocate symbols.  */  /* Relocate symbols.  */

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

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