Contiki 2.6

elf32.h

00001 /*
00002  * Copyright (c) 2006, Swedish Institute of Computer Science
00003  * All rights reserved. 
00004  *
00005  * Redistribution and use in source and binary forms, with or without 
00006  * modification, are permitted provided that the following conditions 
00007  * are met: 
00008  * 1. Redistributions of source code must retain the above copyright 
00009  *    notice, this list of conditions and the following disclaimer. 
00010  * 2. Redistributions in binary form must reproduce the above copyright 
00011  *    notice, this list of conditions and the following disclaimer in the 
00012  *    documentation and/or other materials provided with the distribution. 
00013  * 3. Neither the name of the Institute nor the names of its contributors 
00014  *    may be used to endorse or promote products derived from this software 
00015  *    without specific prior written permission. 
00016  *
00017  * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND 
00018  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
00019  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
00020  * ARE DISCLAIMED.  IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE 
00021  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 
00022  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 
00023  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 
00024  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 
00025  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 
00026  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 
00027  * SUCH DAMAGE. 
00028  *
00029  * @(#)$Id: elf32.h,v 1.1 2006/12/01 15:12:27 bg- Exp $
00030  */
00031 
00032 /* @(#)$Id: elf32.h,v 1.1 2006/12/01 15:12:27 bg- Exp $ */
00033 
00034 #ifndef ELF32_H
00035 #define ELF32_H
00036 
00037 /*
00038  * ELF definitions common to all 32-bit architectures.
00039  */
00040 
00041 #define EI_NIDENT 16
00042 
00043 typedef unsigned long  elf32_word;
00044 typedef   signed long  elf32_sword;
00045 typedef unsigned short elf32_half;
00046 typedef unsigned long  elf32_off;
00047 typedef unsigned long  elf32_addr;
00048 
00049 struct elf32_ehdr {
00050   unsigned char e_ident[EI_NIDENT];    /* ident bytes */
00051   elf32_half e_type;                   /* file type */ 
00052   elf32_half e_machine;                /* target machine */
00053   elf32_word e_version;                /* file version */
00054   elf32_addr e_entry;                  /* start address */
00055   elf32_off e_phoff;                   /* phdr file offset */
00056   elf32_off e_shoff;                   /* shdr file offset */
00057   elf32_word e_flags;                  /* file flags */
00058   elf32_half e_ehsize;                 /* sizeof ehdr */
00059   elf32_half e_phentsize;              /* sizeof phdr */
00060   elf32_half e_phnum;                  /* number phdrs */
00061   elf32_half e_shentsize;              /* sizeof shdr */
00062   elf32_half e_shnum;                  /* number shdrs */
00063   elf32_half e_shstrndx;               /* shdr string index */
00064 };
00065 
00066 /* Values for e_type. */
00067 #define ET_NONE         0       /* Unknown type. */
00068 #define ET_REL          1       /* Relocatable. */
00069 #define ET_EXEC         2       /* Executable. */
00070 #define ET_DYN          3       /* Shared object. */
00071 #define ET_CORE         4       /* Core file. */
00072 
00073 struct elf32_shdr {
00074   elf32_word sh_name;           /* section name */
00075   elf32_word sh_type;           /* SHT_... */
00076   elf32_word sh_flags;          /* SHF_... */
00077   elf32_addr sh_addr;           /* virtual address */
00078   elf32_off sh_offset;          /* file offset */
00079   elf32_word sh_size;           /* section size */
00080   elf32_word sh_link;           /* misc info */
00081   elf32_word sh_info;           /* misc info */
00082   elf32_word sh_addralign;      /* memory alignment */
00083   elf32_word sh_entsize;        /* entry size if table */
00084 };
00085 
00086 /* sh_type */
00087 #define SHT_NULL        0               /* inactive */
00088 #define SHT_PROGBITS    1               /* program defined information */
00089 #define SHT_SYMTAB      2               /* symbol table section */
00090 #define SHT_STRTAB      3               /* string table section */
00091 #define SHT_RELA        4               /* relocation section with addends*/
00092 #define SHT_HASH        5               /* symbol hash table section */
00093 #define SHT_DYNAMIC     6               /* dynamic section */
00094 #define SHT_NOTE        7               /* note section */
00095 #define SHT_NOBITS      8               /* no space section */
00096 #define SHT_REL         9               /* relation section without addends */
00097 #define SHT_SHLIB       10              /* reserved - purpose unknown */
00098 #define SHT_DYNSYM      11              /* dynamic symbol table section */
00099 #define SHT_LOPROC      0x70000000      /* reserved range for processor */
00100 #define SHT_HIPROC      0x7fffffff      /* specific section header types */
00101 #define SHT_LOUSER      0x80000000      /* reserved range for application */
00102 #define SHT_HIUSER      0xffffffff      /* specific indexes */
00103 
00104 struct elf32_rel {
00105   elf32_addr      r_offset;       /* Location to be relocated. */
00106   elf32_word      r_info;         /* Relocation type and symbol index. */
00107 };
00108 
00109 struct elf32_rela {
00110   elf32_addr      r_offset;       /* Location to be relocated. */
00111   elf32_word      r_info;         /* Relocation type and symbol index. */
00112   elf32_sword     r_addend;       /* Addend. */
00113 };
00114 
00115 struct elf32_sym {
00116   elf32_word      st_name;        /* String table index of name. */
00117   elf32_addr      st_value;       /* Symbol value. */
00118   elf32_word      st_size;        /* Size of associated object. */
00119   unsigned char   st_info;        /* Type and binding information. */
00120   unsigned char   st_other;       /* Reserved (not used). */
00121   elf32_half      st_shndx;       /* Section index of symbol. */
00122 };
00123 
00124 #define ELF32_R_SYM(info)       ((info) >> 8)
00125 #define ELF32_R_TYPE(info)      ((unsigned char)(info))
00126 
00127 #define ELF_MAGIC_HEADER         "\177ELF\001\001\001"
00128 #define ELF_MAGIC_HEADER_SIZE    7
00129 
00130 #endif /* ELF32_H */